diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 915e1a49f6..bb8b45192f 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -864,7 +864,13 @@ step_columns=Components configure_dashboard_step2_title=Step Two - Select Components configure_dashboard_step2_desc=Select the components for your dashboard and add them to the columns. configure_dashboard_finish_instruction=To save the dashboard configuration click Finish. To review or change your selections click Back. -select_layout=Select the style of layout for your dashboard. +select_layout=Select the style of layout for your dashboard. Changing your existing dashboard layout to another with less columns will result in the additional columns being removed. +select_column=Select the column to configure +dashlet_list=Available Components +dashlet_btn_select=Add +dashlet_btn_remove=Remove +selected_dashlets=Selected Components +dashboard_column=Column # My Alfresco Layouts messages layout_single_label=Single Column @@ -878,7 +884,7 @@ layout_three_column_desc=This layout displays components across three columns of # My Alfresco Dashlet components messages dashlet_gettingstarted_label=Getting Started -dashlet_gettingstarted_desc=This component displays helpful information and links for getting started with the Alfresco web-client application +dashlet_gettingstarted_desc=Displays helpful information for getting started with the Alfresco web-client # User Console and Settings messages title_user_console=User Options diff --git a/source/java/org/alfresco/web/bean/dashboard/DashboardManager.java b/source/java/org/alfresco/web/bean/dashboard/DashboardManager.java index e88f7fc33e..920510b8e0 100644 --- a/source/java/org/alfresco/web/bean/dashboard/DashboardManager.java +++ b/source/java/org/alfresco/web/bean/dashboard/DashboardManager.java @@ -37,7 +37,7 @@ import org.apache.commons.logging.LogFactory; * * @author Kevin Roast */ -public final class DashboardManager +public class DashboardManager { private static Log logger = LogFactory.getLog(DashboardManager.class); @@ -115,41 +115,10 @@ public final class DashboardManager return page; } - /** - * Helper to get the DashDefinition as the zero based index, working from the left most column - * top-bottom then working left-right. - * - * @param index Zero based index from the left most column working top-bottom then left-right - * - * @return DashletDefinition if found or null if no dashlet at the specified index - */ - private static DashletDefinition getDashletDefinitionByIndex(PageConfig config, int index) - { - DashletDefinition def = null; - - LayoutDefinition layoutDef = config.getCurrentPage().getLayoutDefinition(); - List columns = config.getCurrentPage().getColumns(); - int columnCount = columns.size(); - int selectedColumn = index / layoutDef.ColumnLength; - if (selectedColumn < columnCount) - { - List dashlets = columns.get(selectedColumn).getDashlets(); - if (index % layoutDef.ColumnLength < dashlets.size()) - { - def = dashlets.get(index % layoutDef.ColumnLength); - } - } - if (logger.isDebugEnabled()) - logger.debug("Searching for dashlet at index: " + index + - " and found " + (def != null ? def.JSPPage : null)); - - return def; - } - /** * @return the PageConfig for the current My Alfresco dashboard page */ - private PageConfig getPageConfig() + public PageConfig getPageConfig() { if (this.pageConfig == null) { @@ -189,7 +158,7 @@ public final class DashboardManager } } - // persist the config for this user + // persist the initial config for this user //PreferencesService.getPreferences().setValue(PREF_DASHBOARD, pageConfig.toXML()); } @@ -199,6 +168,15 @@ public final class DashboardManager return this.pageConfig; } + /** + * Persist the supplied PageConfig for the current user + */ + public void savePageConfig(PageConfig config) + { + this.pageConfig = config; + PreferencesService.getPreferences().setValue(PREF_DASHBOARD, this.pageConfig.toXML()); + } + /** * @return The externally configured WebClient config element for the Dashboards */ @@ -210,6 +188,37 @@ public final class DashboardManager return config; } + /** + * Helper to get the DashDefinition as the zero based index, working from the left most column + * top-bottom then working left-right. + * + * @param index Zero based index from the left most column working top-bottom then left-right + * + * @return DashletDefinition if found or null if no dashlet at the specified index + */ + private static DashletDefinition getDashletDefinitionByIndex(PageConfig config, int index) + { + DashletDefinition def = null; + + LayoutDefinition layoutDef = config.getCurrentPage().getLayoutDefinition(); + List columns = config.getCurrentPage().getColumns(); + int columnCount = columns.size(); + int selectedColumn = index / layoutDef.ColumnLength; + if (selectedColumn < columnCount) + { + List dashlets = columns.get(selectedColumn).getDashlets(); + if (index % layoutDef.ColumnLength < dashlets.size()) + { + def = dashlets.get(index % layoutDef.ColumnLength); + } + } + if (logger.isDebugEnabled()) + logger.debug("Searching for dashlet at index: " + index + + " and found " + (def != null ? def.JSPPage : null)); + + return def; + } + /** * Dashlet rendering list. diff --git a/source/java/org/alfresco/web/bean/dashboard/DashboardWizard.java b/source/java/org/alfresco/web/bean/dashboard/DashboardWizard.java index 1b1bdf49a7..6f1c0aa433 100644 --- a/source/java/org/alfresco/web/bean/dashboard/DashboardWizard.java +++ b/source/java/org/alfresco/web/bean/dashboard/DashboardWizard.java @@ -17,11 +17,16 @@ package org.alfresco.web.bean.dashboard; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map; +import javax.faces.component.UISelectMany; +import javax.faces.component.UISelectOne; import javax.faces.context.FacesContext; +import javax.faces.event.ActionEvent; +import javax.faces.model.SelectItem; import org.alfresco.web.app.Application; import org.alfresco.web.bean.wizard.BaseWizardBean; @@ -36,14 +41,44 @@ import org.alfresco.web.ui.common.component.description.UIDescription; */ public class DashboardWizard extends BaseWizardBean { + private static final String COMPONENT_COLUMNDASHLETS = "column-dashlets"; + + private static final String COMPONENT_ALLDASHLETS = "all-dashlets"; + + private static final String MSG_COLUMN = "dashboard_column"; + /** List of icons items to display as selectable Layout definitions */ private List layoutIcons = null; /** List of descriptions of the layouts */ - private List layoutDescriptions= null; + private List layoutDescriptions = null; + + /** List of SelectItem objects representing the available dashlets */ + private List dashlets = null; /** Currently selected layout */ - private String layout = DashboardManager.LAYOUT_DEFAULT; + private String layout; + + /** Currently selected column to edit */ + private int column; + + /** The PageConfig holding the columns/dashlets during editing */ + private PageConfig editConfig; + + /** The DashboardManager instance */ + private DashboardManager dashboardManager; + + + // ------------------------------------------------------------------------------ + // Bean setters + + /** + * @param dashboardManager The dashboardManager to set. + */ + public void setDashboardManager(DashboardManager dashboardManager) + { + this.dashboardManager = dashboardManager; + } // ------------------------------------------------------------------------------ @@ -56,14 +91,17 @@ public class DashboardWizard extends BaseWizardBean { super.init(parameters); - + this.editConfig = new PageConfig(this.dashboardManager.getPageConfig()); + this.layout = this.editConfig.getCurrentPage().getLayoutDefinition().Id; + this.column = 0; } - + /** * @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String) */ protected String finishImpl(FacesContext context, String outcome) throws Exception { + this.dashboardManager.savePageConfig(this.editConfig); return outcome; } @@ -74,7 +112,7 @@ public class DashboardWizard extends BaseWizardBean { LayoutDefinition def = DashboardManager.getDashboardConfig().getLayoutDefinition(this.layout); String label = def.Label; - if (label == null || label.length() == 0) + if (label == null) { label = Application.getMessage(FacesContext.getCurrentInstance(), def.LabelId); } @@ -92,7 +130,6 @@ public class DashboardWizard extends BaseWizardBean */ public String getLayout() { - // TODO: implement - need current PageConfig from DashboardManager return this.layout; } @@ -102,6 +139,106 @@ public class DashboardWizard extends BaseWizardBean public void setLayout(String layout) { this.layout = layout; + LayoutDefinition def = DashboardManager.getDashboardConfig().getLayoutDefinition(layout); + this.editConfig.getCurrentPage().setLayoutDefinition(def); + if (this.column >= def.Columns) + { + this.column = def.Columns - 1; + } + } + + /** + * @return the number of columns in the selected page layout + */ + public int getColumnCount() + { + return DashboardManager.getDashboardConfig().getLayoutDefinition(getLayout()).Columns; + } + + /** + * @return the array of UI select items representing the columns that can be configured + */ + public SelectItem[] getColumns() + { + FacesContext fc = FacesContext.getCurrentInstance(); + LayoutDefinition layoutDef = DashboardManager.getDashboardConfig().getLayoutDefinition(getLayout()); + SelectItem[] columns = new SelectItem[layoutDef.Columns]; + for (int i=0; i getAllDashlets() + { + if (this.dashlets == null) + { + FacesContext fc = FacesContext.getCurrentInstance(); + DashboardsConfigElement config = DashboardManager.getDashboardConfig(); + Collection dashletDefs = config.getDashlets(); + List dashlets = new ArrayList(dashletDefs.size()); + for (DashletDefinition dashletDef : dashletDefs) + { + String label = dashletDef.Label; + if (label == null) + { + label = Application.getMessage(fc, dashletDef.LabelId); + } + String description = dashletDef.Description; + if (description == null) + { + description = Application.getMessage(fc, dashletDef.DescriptionId); + } + if (description != null) + { + // append description of the dashlet if set + label = label + " (" + description + ')'; + } + SelectItem item = new SelectItem(dashletDef.Id, label); + dashlets.add(item); + } + this.dashlets = dashlets; + } + return this.dashlets; + } + + /** + * @return the List of SelectItem objects representing the dashlets displayed in the + * currently selected column. + */ + public List getColumnDashlets() + { + FacesContext fc = FacesContext.getCurrentInstance(); + + Column column = this.editConfig.getCurrentPage().getColumns().get(this.column); + List dashlets = new ArrayList(column.getDashlets().size()); + for (DashletDefinition dashletDef : column.getDashlets()) + { + String label = dashletDef.Label; + if (label == null) + { + label = Application.getMessage(fc, dashletDef.LabelId); + } + dashlets.add(new SelectItem(dashletDef.Id, label)); + } + return dashlets; } /** @@ -143,12 +280,12 @@ public class DashboardWizard extends BaseWizardBean // build UIListItem to represent the layout image String label = layoutDef.Label; - if (label == null || label.length() == 0) + if (label == null) { label = Application.getMessage(context, layoutDef.LabelId); } String desc = layoutDef.Description; - if (desc == null || desc.length() == 0) + if (desc == null) { desc = Application.getMessage(context, layoutDef.DescriptionId); } @@ -170,4 +307,48 @@ public class DashboardWizard extends BaseWizardBean this.layoutIcons = icons; this.layoutDescriptions = descriptions; } + + /** + * Action event handler called to Add dashlets to the selection for a column + */ + public void addDashlets(ActionEvent event) + { + UISelectMany dashletPicker = (UISelectMany)event.getComponent().findComponent(COMPONENT_ALLDASHLETS); + UISelectOne dashletColumn = (UISelectOne)event.getComponent().findComponent(COMPONENT_COLUMNDASHLETS); + + // get the IDs of the selected Dashlet definitions + Object[] selected = dashletPicker.getSelectedValues(); + + // get the column to add the dashlets too + DashboardsConfigElement config = DashboardManager.getDashboardConfig(); + LayoutDefinition layoutDef = this.editConfig.getCurrentPage().getLayoutDefinition(); + Column column = this.editConfig.getCurrentPage().getColumns().get(this.column); + // add each selected dashlet to the column + for (int i=0; i pages = new ArrayList(4); private int currentPageIndex = 0; + + /** + * Default constructor + */ + public PageConfig() + { + } + + /** + * Copy constructor + * + * @param copy PageConfig to copy + */ + public PageConfig(PageConfig copy) + { + this.pages = new ArrayList(copy.pages.size()); + for (Page page : copy.pages) + { + // invoke the copy constructor on each Page + // which in turn calls the copy constructor of child classes + this.pages.add(new Page(page)); + } + } + + /** + * @return The current page in the config + */ public Page getCurrentPage() { if (currentPageIndex < pages.size()) @@ -69,11 +96,23 @@ final class PageConfig } } + /** + * Add a new Page to the list + * + * @param page Page to add + */ public void addPage(Page page) { pages.add(page); } + /** + * Get a Page with the specified page Id + * + * @param pageId Of the page to return + * + * @return Page or null if not found + */ public Page getPage(String pageId) { Page foundPage = null; @@ -228,6 +267,12 @@ final class Page private LayoutDefinition layoutDef; private List columns = new ArrayList(4); + /** + * Constructor + * + * @param id + * @param layout + */ public Page(String id, LayoutDefinition layout) { if (id == null || id.length() == 0) @@ -242,6 +287,22 @@ final class Page this.layoutDef = layout; } + /** + * Copy Constructor + * + * @param copy Page to build a copy from + */ + public Page(Page copy) + { + this.id = copy.id; + this.layoutDef = copy.layoutDef; + for (Column column : copy.columns) + { + Column cloneColumn = new Column(column); + addColumn(cloneColumn); + } + } + public String getId() { return this.id; @@ -252,6 +313,26 @@ final class Page return this.layoutDef; } + public void setLayoutDefinition(LayoutDefinition layout) + { + if (layout == null) + { + throw new IllegalArgumentException("Layout for a Dashboard Page is mandatory."); + } + + // correct column collection based on new layout definition + while (this.columns.size() < layout.Columns) + { + addColumn(new Column()); + } + if (this.columns.size() > layout.Columns) + { + this.columns = this.columns.subList(0, layout.Columns); + } + + this.layoutDef = layout; + } + public void addColumn(Column column) { this.columns.add(column); @@ -271,6 +352,23 @@ final class Column { private List dashlets = new ArrayList(4); + /** + * Default constructor + */ + public Column() + { + } + + /** + * Copy constructor + * + * @param copy Column to copy + */ + public Column(Column copy) + { + this.dashlets = (List)((ArrayList)copy.dashlets).clone(); + } + public void addDashlet(DashletDefinition dashlet) { dashlets.add(dashlet); diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index d82e782803..17b5b55b71 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -1456,28 +1456,8 @@ #{NodeService} - fileFolderService - #{FileFolderService} - - - searchService - #{SearchService} - - - navigator - #{NavigationBean} - - - browseBean - #{BrowseBean} - - - dictionaryService - #{DictionaryService} - - - namespaceService - #{NamespaceService} + dashboardManager + #{DashboardManager} diff --git a/source/web/css/main.css b/source/web/css/main.css index 0eb69f1082..7f2e713ba6 100644 --- a/source/web/css/main.css +++ b/source/web/css/main.css @@ -489,6 +489,11 @@ a.topToolbarLinkHighlight, a.topToolbarLinkHighlight:link, a.topToolbarLinkHighl vertical-align: top; } +.alignMiddle +{ + vertical-align: middle; +} + .tableThirdWidth { width: 33%; diff --git a/source/web/jsp/dashboards/wizard/columns.jsp b/source/web/jsp/dashboards/wizard/columns.jsp index f609540f4e..7b0017d07b 100644 --- a/source/web/jsp/dashboards/wizard/columns.jsp +++ b/source/web/jsp/dashboards/wizard/columns.jsp @@ -32,3 +32,41 @@ } + + + + +   + + + + + + + + + <%-- note this component ID is referenced in DashboardWizard --%> + + + + + + + + + + + <%-- note this component ID is referenced in DashboardWizard --%> + + + + + +
+ +
+
+ +
+
+