From ac3ef0585ad3f4577d9dfa1686852a963eb94f81 Mon Sep 17 00:00:00 2001 From: Gavin Cornwell Date: Fri, 1 Sep 2006 14:07:31 +0000 Subject: [PATCH] - Added dynamic title and description support to dialog and wizard framework - Rationalised debugging through workfllow pages git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3651 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/web-client-config-dialogs.xml | 5 +-- .../web/bean/dialog/BaseDialogBean.java | 10 +++++ .../web/bean/dialog/DialogManager.java | 44 ++++++++++++------ .../alfresco/web/bean/dialog/IDialogBean.java | 18 ++++++++ .../web/bean/repository/TransientNode.java | 3 -- .../web/bean/wizard/WizardManager.java | 45 ++++++++++++------- .../web/bean/workflow/ManageTaskDialog.java | 37 ++++++++++++--- .../bean/workflow/StartWorkflowWizard.java | 3 ++ .../workflow/ViewCompletedTaskDialog.java | 8 ++++ .../web/bean/workflow/WorkflowBean.java | 3 -- 10 files changed, 131 insertions(+), 45 deletions(-) diff --git a/config/alfresco/web-client-config-dialogs.xml b/config/alfresco/web-client-config-dialogs.xml index 9e0b5b47ea..b159613f6f 100644 --- a/config/alfresco/web-client-config-dialogs.xml +++ b/config/alfresco/web-client-config-dialogs.xml @@ -93,12 +93,11 @@ + description-id="manage_task_desc" /> + description-id="view_completed_task_desc" show-ok-button="false" /> If this returns null the DialogManager will + * lookup the title via the dialog configuration

+ * + * @return The title or null if the title is to be acquired via configuration + */ + public String getTitle(); + + /** + * Returns the description to be used for the dialog + *

If this returns null the DialogManager will + * lookup the description via the dialog configuration

+ * + * @return The title or null if the title is to be acquired via configuration + */ + public String getDescription(); } diff --git a/source/java/org/alfresco/web/bean/repository/TransientNode.java b/source/java/org/alfresco/web/bean/repository/TransientNode.java index 34d0e09a79..9f5332fd8b 100644 --- a/source/java/org/alfresco/web/bean/repository/TransientNode.java +++ b/source/java/org/alfresco/web/bean/repository/TransientNode.java @@ -58,9 +58,6 @@ public class TransientNode extends Node // initialise the node initNode(data); - - if (logger.isDebugEnabled()) - logger.debug("Constructed transient node: " + this); } /** diff --git a/source/java/org/alfresco/web/bean/wizard/WizardManager.java b/source/java/org/alfresco/web/bean/wizard/WizardManager.java index 13362cc6e2..c70115e53b 100644 --- a/source/java/org/alfresco/web/bean/wizard/WizardManager.java +++ b/source/java/org/alfresco/web/bean/wizard/WizardManager.java @@ -12,7 +12,6 @@ import javax.faces.event.ActionEvent; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.web.app.Application; import org.alfresco.web.app.servlet.FacesHelper; -import org.alfresco.web.bean.dialog.DialogState; import org.alfresco.web.config.WizardsConfigElement.ConditionalPageConfig; import org.alfresco.web.config.WizardsConfigElement.PageConfig; import org.alfresco.web.config.WizardsConfigElement.StepConfig; @@ -152,15 +151,23 @@ public final class WizardManager */ public String getTitle() { - String title = this.currentWizardState.getConfig().getTitleId(); + // try and get the title directly from the wizard + String title = this.currentWizardState.getWizard().getTitle(); - if (title != null) + if (title == null) { - title = Application.getMessage(FacesContext.getCurrentInstance(), title); - } - else - { - title = this.currentWizardState.getConfig().getTitle(); + // try and get the title via a message bundle key + title = this.currentWizardState.getConfig().getTitleId(); + + if (title != null) + { + title = Application.getMessage(FacesContext.getCurrentInstance(), title); + } + else + { + // try and get the title from the configuration + title = this.currentWizardState.getConfig().getTitle(); + } } return title; @@ -173,15 +180,23 @@ public final class WizardManager */ public String getDescription() { - String desc = this.currentWizardState.getConfig().getDescriptionId(); + // try and get the description directly from the dialog + String desc = this.currentWizardState.getWizard().getDescription(); - if (desc != null) + if (desc == null) { - desc = Application.getMessage(FacesContext.getCurrentInstance(), desc); - } - else - { - desc = this.currentWizardState.getConfig().getDescription(); + // try and get the description via a message bundle key + desc = this.currentWizardState.getConfig().getDescriptionId(); + + if (desc != null) + { + desc = Application.getMessage(FacesContext.getCurrentInstance(), desc); + } + else + { + // try and get the description from the configuration + desc = this.currentWizardState.getConfig().getDescription(); + } } return desc; diff --git a/source/java/org/alfresco/web/bean/workflow/ManageTaskDialog.java b/source/java/org/alfresco/web/bean/workflow/ManageTaskDialog.java index fc425c1e0d..936199c415 100644 --- a/source/java/org/alfresco/web/bean/workflow/ManageTaskDialog.java +++ b/source/java/org/alfresco/web/bean/workflow/ManageTaskDialog.java @@ -59,11 +59,11 @@ public class ManageTaskDialog extends BaseDialogBean protected List packageItemsToRemove; protected String[] itemsToAdd; protected boolean isItemBeingAdded = false; - + + protected final Log logger = LogFactory.getLog(getClass()); + protected static final String ID_PREFIX = "transition_"; protected static final String CLIENT_ID_PREFIX = AlfrescoNavigationHandler.DIALOG_PREFIX + ID_PREFIX; - - private static final Log logger = LogFactory.getLog(ManageTaskDialog.class); // ------------------------------------------------------------------------------ // Dialog implementation @@ -117,8 +117,11 @@ public class ManageTaskDialog extends BaseDialogBean } if (logger.isDebugEnabled()) - logger.debug("Found workflow package for task '" + - this.task.id + "': " + this.workflowPackage ); + { + logger.debug("Task: " + this.task); + logger.debug("Trasient node: " + this.taskNode); + logger.debug("Workflow package: " + this.workflowPackage ); + } } } @@ -143,6 +146,9 @@ public class ManageTaskDialog extends BaseDialogBean // prepare the edited parameters for saving Map params = WorkflowBean.prepareTaskParams(this.taskNode); + if (logger.isDebugEnabled()) + logger.debug("Saving task with parameters: " + params); + // remove any items the user selected to remove if (this.workflowPackage != null && this.packageItemsToRemove != null && this.packageItemsToRemove.size() > 0) @@ -210,7 +216,21 @@ public class ManageTaskDialog extends BaseDialogBean { return false; } - + + @Override + public String getTitle() + { + String titleStart = Application.getMessage(FacesContext.getCurrentInstance(), "manage_task_title"); + + return titleStart + ": " + this.task.title; + } + + @Override + public String getDescription() + { + return this.task.description; + } + // ------------------------------------------------------------------------------ // Event handlers @@ -220,7 +240,7 @@ public class ManageTaskDialog extends BaseDialogBean String outcome = getDefaultFinishOutcome(); if (logger.isDebugEnabled()) - logger.debug("Transitioning task: " + this.taskNode.getId()); + logger.debug("Transitioning task: " + this.task.id); // to find out which transition button was pressed we need // to look for the button's id in the request parameters, @@ -252,6 +272,9 @@ public class ManageTaskDialog extends BaseDialogBean // prepare the edited parameters for saving Map params = WorkflowBean.prepareTaskParams(this.taskNode); + if (logger.isDebugEnabled()) + logger.debug("Transitioning task with parameters: " + params); + // update the task with the updated parameters this.workflowService.updateTask(this.task.id, params, null, null); diff --git a/source/java/org/alfresco/web/bean/workflow/StartWorkflowWizard.java b/source/java/org/alfresco/web/bean/workflow/StartWorkflowWizard.java index 95ee4ecb77..3e79a173dc 100644 --- a/source/java/org/alfresco/web/bean/workflow/StartWorkflowWizard.java +++ b/source/java/org/alfresco/web/bean/workflow/StartWorkflowWizard.java @@ -129,6 +129,9 @@ public class StartWorkflowWizard extends BaseWizardBean // prepare the parameters from the current state of the property sheet Map params = WorkflowBean.prepareTaskParams(this.startTaskNode); + if (logger.isDebugEnabled()) + logger.debug("Starting workflow with parameters: " + params); + // create a workflow package for the attached items and add them if (this.packageItemsToAdd.size() > 0) { diff --git a/source/java/org/alfresco/web/bean/workflow/ViewCompletedTaskDialog.java b/source/java/org/alfresco/web/bean/workflow/ViewCompletedTaskDialog.java index 9f4136e40b..b037ad74ce 100644 --- a/source/java/org/alfresco/web/bean/workflow/ViewCompletedTaskDialog.java +++ b/source/java/org/alfresco/web/bean/workflow/ViewCompletedTaskDialog.java @@ -37,4 +37,12 @@ public class ViewCompletedTaskDialog extends ManageTaskDialog { return null; } + + @Override + public String getTitle() + { + String titleStart = Application.getMessage(FacesContext.getCurrentInstance(), "view_completed_task_title"); + + return titleStart + ": " + this.task.title; + } } diff --git a/source/java/org/alfresco/web/bean/workflow/WorkflowBean.java b/source/java/org/alfresco/web/bean/workflow/WorkflowBean.java index 7decab43ee..9800da87b5 100644 --- a/source/java/org/alfresco/web/bean/workflow/WorkflowBean.java +++ b/source/java/org/alfresco/web/bean/workflow/WorkflowBean.java @@ -199,9 +199,6 @@ public class WorkflowBean params.put(assocQName, (Serializable)targets); } - if (logger.isDebugEnabled()) - logger.debug("Prepared parameters: " + params); - return params; }