From a6222e94e5b5c6b7a4cd8a50368aac7322843199 Mon Sep 17 00:00:00 2001 From: Gavin Cornwell Date: Sat, 22 Sep 2007 22:08:18 +0000 Subject: [PATCH] Completion of dialog framework enabling all remaining pages in the web client to be converted. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6857 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../web/bean/DocumentDetailsBean.java | 5 + .../alfresco/web/bean/SpaceDetailsBean.java | 5 + .../web/bean/dialog/BaseDialogBean.java | 24 ++++ .../web/bean/dialog/DialogManager.java | 109 ++++++++++++++++-- .../alfresco/web/bean/dialog/IDialogBean.java | 8 ++ source/web/css/main.css | 7 ++ source/web/jsp/dialog/container.jsp | 87 +++++++++++++- 7 files changed, 231 insertions(+), 14 deletions(-) diff --git a/source/java/org/alfresco/web/bean/DocumentDetailsBean.java b/source/java/org/alfresco/web/bean/DocumentDetailsBean.java index e615a38ad9..62948759a5 100644 --- a/source/java/org/alfresco/web/bean/DocumentDetailsBean.java +++ b/source/java/org/alfresco/web/bean/DocumentDetailsBean.java @@ -1156,4 +1156,9 @@ public class DocumentDetailsBean extends BaseDetailsBean implements IDialogBean { baseDialogBean.restored(); } + + public Object getActionsContext() + { + return baseDialogBean.getActionsContext(); + } } diff --git a/source/java/org/alfresco/web/bean/SpaceDetailsBean.java b/source/java/org/alfresco/web/bean/SpaceDetailsBean.java index c5a421223f..58930eb0a7 100644 --- a/source/java/org/alfresco/web/bean/SpaceDetailsBean.java +++ b/source/java/org/alfresco/web/bean/SpaceDetailsBean.java @@ -657,4 +657,9 @@ public class SpaceDetailsBean extends BaseDetailsBean implements IDialogBean { baseDialogBean.restored(); } + + public Object getActionsContext() + { + return baseDialogBean.getActionsContext(); + } } diff --git a/source/java/org/alfresco/web/bean/dialog/BaseDialogBean.java b/source/java/org/alfresco/web/bean/dialog/BaseDialogBean.java index 1fa3f9fa8e..d203781cef 100644 --- a/source/java/org/alfresco/web/bean/dialog/BaseDialogBean.java +++ b/source/java/org/alfresco/web/bean/dialog/BaseDialogBean.java @@ -31,6 +31,7 @@ import java.util.Map; import javax.faces.context.FacesContext; +import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.dictionary.DictionaryService; @@ -146,6 +147,8 @@ public abstract class BaseDialogBean implements IDialogBean public List getAdditionalButtons() { + // none by default, subclasses can override if necessary + return null; } @@ -166,18 +169,39 @@ public abstract class BaseDialogBean implements IDialogBean public String getContainerTitle() { + // nothing by default, subclasses can override if necessary + return null; } public String getContainerSubTitle() { + // nothing by default, subclasses can override if necessary + return null; } public String getContainerDescription() { + // nothing by default, subclasses can override if necessary + return null; } + + public Object getActionsContext() + { + // return the current node as the context for actions be default + // dialog implementations can override this method to return the + // appropriate object for their use case + + if (this.navigator == null) + { + throw new AlfrescoRuntimeException("To use actions in the dialog the 'navigator' " + + "property must be injected with an instance of NavigationBean!"); + } + + return this.navigator.getCurrentNode(); + } /** * @param browseBean The BrowseBean to set. diff --git a/source/java/org/alfresco/web/bean/dialog/DialogManager.java b/source/java/org/alfresco/web/bean/dialog/DialogManager.java index dc20f8c831..a89eedb659 100644 --- a/source/java/org/alfresco/web/bean/dialog/DialogManager.java +++ b/source/java/org/alfresco/web/bean/dialog/DialogManager.java @@ -269,10 +269,20 @@ public final class DialogManager return desc; } + + /** + * Returns the page the dialog will use + * + * @return The page + */ + public String getPage() + { + return this.currentDialogState.getConfig().getPage(); + } /** * Returns the id of a configured action group representing the actions to - * display for the dialog. + * display for the dialog * * @return The action group id */ @@ -282,13 +292,96 @@ public final class DialogManager } /** - * Returns the page the dialog will use + * Returns the id of a configured action group representing the + * 'more actions' to display for the dialog * - * @return The page + * @return The action group id */ - public String getPage() + public String getMoreActions() { - return this.currentDialogState.getConfig().getPage(); + return this.currentDialogState.getConfig().getMoreActionsConfigId(); + } + + /** + * Returns the object to use as the context for the main and more + * actions that may be configured by the dialog + * + * @return Object to use as the context for actions, the current + * node by default + */ + public Object getActionsContext() + { + return this.currentDialogState.getDialog().getActionsContext(); + } + + /** + * Returns the label to use for the main actions when a menu is being used + * + * @return The actions menu label + */ + public String getActionsMenuLabel() + { + // try and get the label via a message bundle key + String label = this.currentDialogState.getConfig().getActionsMenuLabelId(); + + if (label != null) + { + label = Application.getMessage(FacesContext.getCurrentInstance(), label); + } + else + { + // try and get the description from the configuration + label = this.currentDialogState.getConfig().getActionsMenuLabel(); + } + + // if the label is still null use the default of 'Create' + if (label == null) + { + label = Application.getMessage(FacesContext.getCurrentInstance(), "create_options"); + } + + return label; + } + + /** + * Returns the label to use for the more actions menu + * + * @return The more actions menu label + */ + public String getMoreActionsMenuLabel() + { + // try and get the label via a message bundle key + String label = this.currentDialogState.getConfig().getMoreActionsMenuLabelId(); + + if (label != null) + { + label = Application.getMessage(FacesContext.getCurrentInstance(), label); + } + else + { + // try and get the description from the configuration + label = this.currentDialogState.getConfig().getMoreActionsMenuLabel(); + } + + // if the label is still null use the default of 'More Actions' + if (label == null) + { + label = Application.getMessage(FacesContext.getCurrentInstance(), "more_actions"); + } + + return label; + } + + /** + * Determines whether the main actions should be rendered as a + * menu + * + * @return true to render the main set of actions as a menu, false + * to render them as a horizontal list + */ + public boolean getActionsAsMenu() + { + return this.currentDialogState.getConfig().getActionsAsMenu(); } /** @@ -303,7 +396,7 @@ public final class DialogManager /** * Determines whether the current dialog should display the next - * and previous buttons in the header area. + * and previous buttons in the header area * * @return true if navigation support is enabled */ @@ -314,7 +407,7 @@ public final class DialogManager /** * Determines whether the current dialog should display the list - * of views in the header area. + * of views in the header area * * @return true if change view support is enabled */ @@ -325,7 +418,7 @@ public final class DialogManager /** * Determines whether the current dialog should display the list - * of filters in the header area. + * of filters in the header area * * @return true if filter support is enabled */ diff --git a/source/java/org/alfresco/web/bean/dialog/IDialogBean.java b/source/java/org/alfresco/web/bean/dialog/IDialogBean.java index fc9180f1a8..dc12f01344 100644 --- a/source/java/org/alfresco/web/bean/dialog/IDialogBean.java +++ b/source/java/org/alfresco/web/bean/dialog/IDialogBean.java @@ -116,4 +116,12 @@ public interface IDialogBean * @return The title or null if the title is to be acquired via configuration */ public String getContainerDescription(); + + /** + * Returns the object to use as the context for the main and more + * actions that may be configured by the dialog + * + * @return Object to use as the context for actions + */ + public Object getActionsContext(); } diff --git a/source/web/css/main.css b/source/web/css/main.css index 700de0a147..6605597846 100644 --- a/source/web/css/main.css +++ b/source/web/css/main.css @@ -310,6 +310,13 @@ input,textarea,select height: 5px; } +.dialogMainActions +{ + padding-left: 2px; + padding-right: 5px; + vertical-align: -1px; +} + .topToolbar { } diff --git a/source/web/jsp/dialog/container.jsp b/source/web/jsp/dialog/container.jsp index 48a406c2fc..1eb35cf51f 100644 --- a/source/web/jsp/dialog/container.jsp +++ b/source/web/jsp/dialog/container.jsp @@ -75,18 +75,93 @@ - - -
- +
- + + + + <%-- Main actions --%> + + + + + <%-- More actions menu --%> + + + + + <%-- View Filters --%> + + + + + + <%-- View Mode --%> + + + + + + <%-- Navigation --%> + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +