- Added workflow summary component

- Added panel and component above to manage work item dialog

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3616 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2006-08-25 22:21:01 +00:00
parent ff4fa50c65
commit 65eb62715e
7 changed files with 324 additions and 0 deletions

View File

@@ -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

View File

@@ -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<Node> 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
*

View File

@@ -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("<table");
if (this.getAttributes().get("style") != null)
{
out.write(" style=\"");
out.write((String)this.getAttributes().get("style"));
out.write("\"");
}
if (this.getAttributes().get("styleClass") != null)
{
out.write(" class=\"");
out.write((String)this.getAttributes().get("styleClass"));
out.write("\"");
}
out.write(">");
// output the title and description
out.write("<tr><td>");
out.write(bundle.getString("title"));
out.write(":</td><td>");
out.write(wi.definition.title);
out.write("</td></tr><tr><td>");
out.write(bundle.getString("description"));
out.write(":</td><td>");
out.write(wi.definition.description);
out.write("</td></tr><tr><td>");
out.write(bundle.getString("initiated_by"));
out.write(":</td><td>");
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("</td></tr><tr><td>");
out.write(bundle.getString("start_date"));
out.write(":</td><td>");
if (wi.startDate != null)
{
out.write(format.format(wi.startDate));
}
out.write("</td></tr><tr><td>");
out.write(bundle.getString("due_date"));
out.write(":</td><td>");
if (wi.endDate != null)
{
out.write(format.format(wi.endDate));
}
out.write("</td></tr></table>");
}
}
@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;
}
}

View File

@@ -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;
}

View File

@@ -1614,4 +1614,50 @@
</attribute>
</tag>
<tag>
<name>workflowSummary</name>
<tag-class>org.alfresco.web.ui.repo.tag.WorkflowSummaryTag</tag-class>
<body-content>JSP</body-content>
<description>
Shows summary information of a workflow instance.
</description>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>binding</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>rendered</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>style</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>styleClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>

View File

@@ -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;
}

View File

@@ -110,3 +110,12 @@
<%-- Put the package actions here --%>
</a:panel>
<h:outputText styleClass="paddingRow" value="&nbsp;" escape="false" />
<a:panel id="workflow-summary-panel" label="#{msg.part_of_workflow}"
border="white" bgcolor="white" titleBorder="blue" titleBgcolor="#D3E6FE" styleClass="mainSubTitle">
<r:workflowSummary value="#{DialogManager.bean.workflowInstance}" styleClass="workflowSummary" />
</a:panel>