diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index fa92b5fa81..b610f14511 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -968,6 +968,9 @@ reassign_workitem_title=Reassign Work Item reassign_workitem_desc=This dialog allows you to reassign a work item. reassign_select_user=Select the user to assign the work item to, then press OK. error_reassign_workitem=Unable to reassign the work item due to system error: +part_of_workflow=Part of Workflow +initiated_by=Initiated by +start_date=Start date # Admin Console messages title_admin_console=Administration Console diff --git a/source/java/org/alfresco/web/bean/workflow/ManageWorkItemDialog.java b/source/java/org/alfresco/web/bean/workflow/ManageWorkItemDialog.java index 05842b6c22..13ca8898e9 100644 --- a/source/java/org/alfresco/web/bean/workflow/ManageWorkItemDialog.java +++ b/source/java/org/alfresco/web/bean/workflow/ManageWorkItemDialog.java @@ -16,6 +16,7 @@ import org.alfresco.repo.workflow.WorkflowModel; import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.workflow.WorkflowInstance; import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.cmr.workflow.WorkflowTask; import org.alfresco.service.cmr.workflow.WorkflowTaskDefinition; @@ -46,6 +47,7 @@ public class ManageWorkItemDialog extends BaseDialogBean protected WorkflowService workflowService; protected Node workItemNode; protected WorkflowTask workItem; + protected WorkflowInstance workflowInstance; protected WorkflowTransition[] transitions; protected List resources; protected WorkItemCompleteResolver completeResolver = new WorkItemCompleteResolver(); @@ -73,6 +75,9 @@ public class ManageWorkItemDialog extends BaseDialogBean WorkflowTaskDefinition taskDef = this.workItem.definition; this.workItemNode = new TransientNode(taskDef.metadata.getName(), "task_" + System.currentTimeMillis(), this.workItem.properties); + + // get access to the workflow instance for the work item + this.workflowInstance = this.workItem.path.instance; } } @@ -313,6 +318,16 @@ public class ManageWorkItemDialog extends BaseDialogBean return this.workItemNode; } + /** + * Returns the WorkflowInstance that the current task belongs to + * + * @return The workflow instance + */ + public WorkflowInstance getWorkflowInstance() + { + return this.workflowInstance; + } + /** * Returns the action group the current task uses for the workflow package * diff --git a/source/java/org/alfresco/web/ui/repo/component/UIWorkflowSummary.java b/source/java/org/alfresco/web/ui/repo/component/UIWorkflowSummary.java new file mode 100644 index 0000000000..304bcfaec3 --- /dev/null +++ b/source/java/org/alfresco/web/ui/repo/component/UIWorkflowSummary.java @@ -0,0 +1,163 @@ +package org.alfresco.web.ui.repo.component; + +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ResourceBundle; + +import javax.faces.context.FacesContext; +import javax.faces.context.ResponseWriter; +import javax.faces.el.ValueBinding; + +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.workflow.WorkflowInstance; +import org.alfresco.web.app.Application; +import org.alfresco.web.bean.repository.Repository; +import org.alfresco.web.ui.common.component.SelfRenderingComponent; + +/** + * JSF component that displays summary information about a workflow. + * + * @author gavinc + */ +public class UIWorkflowSummary extends SelfRenderingComponent +{ + protected WorkflowInstance value = null; + + // ------------------------------------------------------------------------------ + // Component Impl + + @Override + public String getFamily() + { + return "org.alfresco.faces.Workflow"; + } + + @Override + public void restoreState(FacesContext context, Object state) + { + Object values[] = (Object[])state; + // standard component attributes are restored by the super class + super.restoreState(context, values[0]); + this.value = (WorkflowInstance)values[1]; + } + + @Override + public Object saveState(FacesContext context) + { + Object values[] = new Object[8]; + // standard component attributes are saved by the super class + values[0] = super.saveState(context); + values[1] = this.value; + return values; + } + + @Override + @SuppressWarnings("unchecked") + public void encodeBegin(FacesContext context) throws IOException + { + if (!isRendered()) return; + + WorkflowInstance wi = getValue(); + + if (wi != null) + { + ResponseWriter out = context.getResponseWriter(); + ResourceBundle bundle = Application.getBundle(context); + SimpleDateFormat format = new SimpleDateFormat(bundle.getString("date_pattern")); + + // output surrounding table and style if necessary + out.write(""); + + // output the title and description + out.write(""); + out.write(bundle.getString("title")); + out.write(":"); + out.write(wi.definition.title); + out.write(""); + out.write(bundle.getString("description")); + out.write(":"); + out.write(wi.definition.description); + out.write(""); + out.write(bundle.getString("initiated_by")); + out.write(":"); + if (wi.initiator != null) + { + NodeService nodeService = Repository.getServiceRegistry( + context).getNodeService(); + String userName = (String)nodeService.getProperty( + wi.initiator, ContentModel.PROP_USERNAME); + out.write(userName); + } + out.write(""); + out.write(bundle.getString("start_date")); + out.write(":"); + if (wi.startDate != null) + { + out.write(format.format(wi.startDate)); + } + out.write(""); + out.write(bundle.getString("due_date")); + out.write(":"); + if (wi.endDate != null) + { + out.write(format.format(wi.endDate)); + } + out.write(""); + } + } + + @Override + public void encodeEnd(FacesContext context) throws IOException + { + if (!isRendered()) return; + } + + @Override + public boolean getRendersChildren() + { + return false; + } + + // ------------------------------------------------------------------------------ + // Strongly typed component property accessors + + /** + * Returns the workflow instance this component is showing information on + * + * @return The workflow instance + */ + public WorkflowInstance getValue() + { + ValueBinding vb = getValueBinding("value"); + if (vb != null) + { + this.value = (WorkflowInstance)vb.getValue(getFacesContext()); + } + + return this.value; + } + + /** + * Sets the workflow instance to show the summary for + * + * @param value The workflow instance + */ + public void setValue(WorkflowInstance value) + { + this.value = value; + } +} diff --git a/source/java/org/alfresco/web/ui/repo/tag/WorkflowSummaryTag.java b/source/java/org/alfresco/web/ui/repo/tag/WorkflowSummaryTag.java new file mode 100644 index 0000000000..b12ef2411f --- /dev/null +++ b/source/java/org/alfresco/web/ui/repo/tag/WorkflowSummaryTag.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2005 Alfresco, Inc. + * + * Licensed under the Mozilla Public License version 1.1 + * with a permitted attribution clause. You may obtain a + * copy of the License at + * + * http://www.alfresco.org/legal/license.txt + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + */ +package org.alfresco.web.ui.repo.tag; + +import javax.faces.component.UIComponent; + +import org.alfresco.web.ui.common.tag.HtmlComponentTag; + +/** + * Tag that allows the workflow summary component to be placed on a JSP page + * + * @author gavinc + */ +public class WorkflowSummaryTag extends HtmlComponentTag +{ + /** + * @see javax.faces.webapp.UIComponentTag#getComponentType() + */ + public String getComponentType() + { + return "org.alfresco.faces.Workflow"; + } + + /** + * @see javax.faces.webapp.UIComponentTag#getRendererType() + */ + public String getRendererType() + { + return null; + } + + /** + * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent) + */ + protected void setProperties(UIComponent component) + { + super.setProperties(component); + + setStringProperty(component, "value", this.value); + } + + /** + * @see org.alfresco.web.ui.common.tag.HtmlComponentTag#release() + */ + public void release() + { + super.release(); + this.value = null; + } + + /** + * Set the value (binding to the list of user/group data) + * + * @param value the value + */ + public void setValue(String value) + { + this.value = value; + } + + /** the value (binding to the workflow instance) */ + private String value; +} diff --git a/source/web/WEB-INF/repo.tld b/source/web/WEB-INF/repo.tld index 55b9930f2e..9cbb8bfa2b 100644 --- a/source/web/WEB-INF/repo.tld +++ b/source/web/WEB-INF/repo.tld @@ -1614,4 +1614,50 @@ + + workflowSummary + org.alfresco.web.ui.repo.tag.WorkflowSummaryTag + JSP + + + Shows summary information of a workflow instance. + + + + id + false + true + + + + value + true + true + + + + binding + false + true + + + + rendered + false + true + + + + style + false + true + + + + styleClass + false + true + + + diff --git a/source/web/css/main.css b/source/web/css/main.css index dc8bd137bd..9e3053357c 100644 --- a/source/web/css/main.css +++ b/source/web/css/main.css @@ -528,3 +528,14 @@ a.topToolbarLinkHighlight, a.topToolbarLinkHighlight:link, a.topToolbarLinkHighl border-style: solid; border-color: #AAAAAA; } + +.workflowSummary +{ + margin-left: 6px; +} + +.workflowSummary td +{ + padding-right: 9px; + padding-top: 4px; +} diff --git a/source/web/jsp/workflow/manage-workitem-dialog.jsp b/source/web/jsp/workflow/manage-workitem-dialog.jsp index 048aa785e4..dc9bb63f80 100644 --- a/source/web/jsp/workflow/manage-workitem-dialog.jsp +++ b/source/web/jsp/workflow/manage-workitem-dialog.jsp @@ -110,3 +110,12 @@ <%-- Put the package actions here --%> + + + + + + + + \ No newline at end of file