Search in sources :

Example 1 with DashboardsConfigElement

use of org.alfresco.web.config.DashboardsConfigElement in project acs-community-packaging by Alfresco.

the class DashboardManager method getDashboardConfig.

/**
 * @return The externally configured WebClient config element for the Dashboards
 */
public static DashboardsConfigElement getDashboardConfig() {
    ConfigService service = Application.getConfigService(FacesContext.getCurrentInstance());
    DashboardsConfigElement config = (DashboardsConfigElement) service.getConfig("Dashboards").getConfigElement(DashboardsConfigElement.CONFIG_ELEMENT_ID);
    return config;
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) DashboardsConfigElement(org.alfresco.web.config.DashboardsConfigElement)

Example 2 with DashboardsConfigElement

use of org.alfresco.web.config.DashboardsConfigElement in project acs-community-packaging by Alfresco.

the class DashboardManager method getPageConfig.

/**
 * @return the PageConfig for the current My Alfresco dashboard page
 */
public PageConfig getPageConfig() {
    if (this.pageConfig == null) {
        PageConfig pageConfig;
        DashboardsConfigElement config = getDashboardConfig();
        // read the config for this user from the Preferences
        String xml = (String) PreferencesService.getPreferences().getValue(PREF_DASHBOARD);
        if (xml != null && xml.length() != 0) {
            if (logger.isDebugEnabled())
                logger.debug("PageConfig found: " + xml);
            // process the XML config and convert into a PageConfig object
            pageConfig = new PageConfig();
            pageConfig.fromXML(config, xml);
        } else {
            if (logger.isDebugEnabled())
                logger.debug("No PageConfig found, creating default instance.");
            // create default config for the first access for a user
            pageConfig = new PageConfig();
            LayoutDefinition layout = config.getLayoutDefinition(LAYOUT_DEFAULT);
            if (layout != null) {
                Page page = new Page("default", layout);
                Column defaultColumn = new Column();
                // add the default dashlet(s) to the column as specified in the config
                if (config.getDefaultDashlets() != null) {
                    for (String id : config.getDefaultDashlets()) {
                        DashletDefinition dashlet = config.getDashletDefinition(id);
                        if (dashlet != null) {
                            defaultColumn.addDashlet(dashlet);
                        }
                    }
                }
                // add the column to the page and we are done
                page.addColumn(defaultColumn);
                pageConfig.addPage(page);
            }
        }
        this.pageConfig = pageConfig;
    }
    return this.pageConfig;
}
Also used : DashboardsConfigElement(org.alfresco.web.config.DashboardsConfigElement) DashletDefinition(org.alfresco.web.config.DashboardsConfigElement.DashletDefinition) LayoutDefinition(org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)

Example 3 with DashboardsConfigElement

use of org.alfresco.web.config.DashboardsConfigElement in project acs-community-packaging by Alfresco.

the class DashboardWizard method getAllDashlets.

/**
 * @return The SelectItem List of all available dashlets
 */
public List<SelectItem> getAllDashlets() {
    if ((this.dashlets == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        FacesContext fc = FacesContext.getCurrentInstance();
        DashboardsConfigElement config = DashboardManager.getDashboardConfig();
        Collection<DashletDefinition> dashletDefs = config.getDashlets();
        List<SelectItem> dashlets = new ArrayList<SelectItem>(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;
}
Also used : FacesContext(javax.faces.context.FacesContext) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) DashboardsConfigElement(org.alfresco.web.config.DashboardsConfigElement) DashletDefinition(org.alfresco.web.config.DashboardsConfigElement.DashletDefinition)

Example 4 with DashboardsConfigElement

use of org.alfresco.web.config.DashboardsConfigElement in project acs-community-packaging by Alfresco.

the class DashboardWizard method buildLayoutValueLists.

/**
 * Build the cached list of values for the layout page. The lists are used by the
 * image radio picker and dynamic description components.
 */
private void buildLayoutValueLists() {
    List<UIListItem> icons = new ArrayList<UIListItem>(4);
    List<UIDescription> descriptions = new ArrayList<UIDescription>(4);
    FacesContext context = FacesContext.getCurrentInstance();
    DashboardsConfigElement config = DashboardManager.getDashboardConfig();
    Iterator<LayoutDefinition> layoutItr = config.getLayouts().iterator();
    while (layoutItr.hasNext()) {
        LayoutDefinition layoutDef = layoutItr.next();
        // build UIListItem to represent the layout image
        String label = layoutDef.Label;
        if (label == null) {
            label = Application.getMessage(context, layoutDef.LabelId);
        }
        String desc = layoutDef.Description;
        if (desc == null) {
            desc = Application.getMessage(context, layoutDef.DescriptionId);
        }
        UIListItem item = new UIListItem();
        item.setLabel(label);
        item.setTooltip(desc);
        item.setValue(layoutDef.Id);
        item.setImage(layoutDef.Image);
        icons.add(item);
        // build UIDescription to represent the layout description text
        UIDescription description = new UIDescription();
        description.setControlValue(layoutDef.Id);
        description.setText(desc);
        descriptions.add(description);
    }
    this.layoutIcons = icons;
    this.layoutDescriptions = descriptions;
}
Also used : UIDescription(org.alfresco.web.ui.common.component.description.UIDescription) FacesContext(javax.faces.context.FacesContext) UIListItem(org.alfresco.web.ui.common.component.UIListItem) ArrayList(java.util.ArrayList) DashboardsConfigElement(org.alfresco.web.config.DashboardsConfigElement) LayoutDefinition(org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)

Example 5 with DashboardsConfigElement

use of org.alfresco.web.config.DashboardsConfigElement in project acs-community-packaging by Alfresco.

the class DashboardWizard method addDashlets.

/**
 * 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();
    if (selected.length != 0) {
        // 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 < selected.length && column.getDashlets().size() < layoutDef.ColumnLength; i++) {
            String dashletId = (String) selected[i];
            // don't add if already present in the list
            boolean found = false;
            for (int x = 0; x < column.getDashlets().size(); x++) {
                if (column.getDashlets().get(x).Id.equals(dashletId)) {
                    found = true;
                    break;
                }
            }
            if (found == false) {
                column.addDashlet(config.getDashletDefinition(dashletId));
            }
        }
    }
}
Also used : UISelectMany(javax.faces.component.UISelectMany) DashboardsConfigElement(org.alfresco.web.config.DashboardsConfigElement) UISelectOne(javax.faces.component.UISelectOne) LayoutDefinition(org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)

Aggregations

DashboardsConfigElement (org.alfresco.web.config.DashboardsConfigElement)6 LayoutDefinition (org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)4 DashletDefinition (org.alfresco.web.config.DashboardsConfigElement.DashletDefinition)3 ArrayList (java.util.ArrayList)2 FacesContext (javax.faces.context.FacesContext)2 StringReader (java.io.StringReader)1 Iterator (java.util.Iterator)1 UISelectMany (javax.faces.component.UISelectMany)1 UISelectOne (javax.faces.component.UISelectOne)1 SelectItem (javax.faces.model.SelectItem)1 UIListItem (org.alfresco.web.ui.common.component.UIListItem)1 UIDescription (org.alfresco.web.ui.common.component.description.UIDescription)1 Document (org.dom4j.Document)1 DocumentException (org.dom4j.DocumentException)1 Element (org.dom4j.Element)1 SAXReader (org.dom4j.io.SAXReader)1 ConfigService (org.springframework.extensions.config.ConfigService)1