Search in sources :

Example 6 with LayoutDefinition

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

the class DashboardWizard method setLayout.

/**
 * Set the currently selected layout ID
 */
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;
    }
}
Also used : LayoutDefinition(org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)

Example 7 with LayoutDefinition

use of org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition 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 8 with LayoutDefinition

use of org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition 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)

Example 9 with LayoutDefinition

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

the class Column method fromXML.

/**
 * Deserialise this PageConfig instance from the specified XML stream.
 *
 * @param xml
 */
public void fromXML(DashboardsConfigElement config, String xml) {
    try {
        SAXReader reader = new SAXReader();
        Document document = reader.read(new StringReader(xml));
        Element rootElement = document.getRootElement();
        // walk the pages found in xml
        Iterator itrPages = rootElement.elementIterator(ELEMENT_PAGE);
        while (itrPages.hasNext()) {
            Element pageElement = (Element) itrPages.next();
            String layoutId = pageElement.attributeValue(ATTR_LAYOUTID);
            LayoutDefinition layoutDef = config.getLayoutDefinition(layoutId);
            if (layoutDef != null) {
                // found the layout now build the page and read the columns
                Page page = new Page(pageElement.attributeValue(ATTR_ID), layoutDef);
                Iterator itrColumns = pageElement.elementIterator(ELEMENT_COLUMN);
                while (itrColumns.hasNext()) {
                    Column column = new Column();
                    // read and resolve the dashlet definitions for this column
                    Element columnElement = (Element) itrColumns.next();
                    Iterator itrDashlets = columnElement.elementIterator(ELEMENT_DASHLET);
                    while (itrDashlets.hasNext()) {
                        String dashletId = ((Element) itrDashlets.next()).attributeValue(ATTR_REFID);
                        DashletDefinition dashletDef = config.getDashletDefinition(dashletId);
                        if (dashletDef != null) {
                            column.addDashlet(dashletDef);
                        } else if (logger.isWarnEnabled()) {
                            logger.warn("Failed to resolve Dashboard Dashlet Definition ID: " + dashletId);
                        }
                    }
                    // add the column of dashlets to the page
                    page.addColumn(column);
                }
                // add the page to this config instance
                this.addPage(page);
            } else if (logger.isWarnEnabled()) {
                logger.warn("Failed to resolve Dashboard Layout Definition ID: " + layoutId);
            }
        }
    } catch (DocumentException docErr) {
    // if we cannot parse, then we simply revert to default
    }
}
Also used : SAXReader(org.dom4j.io.SAXReader) Element(org.dom4j.Element) DashboardsConfigElement(org.alfresco.web.config.DashboardsConfigElement) DocumentException(org.dom4j.DocumentException) StringReader(java.io.StringReader) Iterator(java.util.Iterator) DashletDefinition(org.alfresco.web.config.DashboardsConfigElement.DashletDefinition) Document(org.dom4j.Document) LayoutDefinition(org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)

Example 10 with LayoutDefinition

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

the class DashboardsElementReader method parseLayoutDefinition.

/**
 * Parse a single Layout definition from config.
 *
 * @param config Element
 *
 * @return LayoutDefinition for the specified config element.
 */
private static LayoutDefinition parseLayoutDefinition(Element config) {
    String id = getMandatoryLayoutAttributeValue(config, ATTR_ID);
    LayoutDefinition def = new LayoutDefinition(id);
    String columns = getMandatoryLayoutAttributeValue(config, ATTR_COLUMNS);
    def.Columns = Integer.parseInt(columns);
    String columnLength = getMandatoryLayoutAttributeValue(config, ATTR_COLUMNLENGTH);
    def.ColumnLength = Integer.parseInt(columnLength);
    def.Image = getMandatoryLayoutAttributeValue(config, ATTR_IMAGE);
    def.JSPPage = getMandatoryLayoutAttributeValue(config, ATTR_JSP);
    String label = config.attributeValue(ATTR_LABEL);
    String labelId = config.attributeValue(ATTR_LABELID);
    if ((label == null || label.length() == 0) && (labelId == null || labelId.length() == 0)) {
        throw new ConfigException("Either 'label' or 'label-id' attribute must be specified for Dashboard 'layout' configuration element.");
    }
    def.Label = label;
    def.LabelId = labelId;
    String description = config.attributeValue(ATTR_DESCRIPTION);
    String descriptionId = config.attributeValue(ATTR_DESCRIPTIONID);
    if ((description == null || description.length() == 0) && (descriptionId == null || descriptionId.length() == 0)) {
        throw new ConfigException("Either 'description' or 'description-id' attribute must be specified for Dashboard 'layout' configuration element.");
    }
    def.Description = description;
    def.DescriptionId = descriptionId;
    return def;
}
Also used : ConfigException(org.springframework.extensions.config.ConfigException) LayoutDefinition(org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)

Aggregations

LayoutDefinition (org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)11 DashletDefinition (org.alfresco.web.config.DashboardsConfigElement.DashletDefinition)5 DashboardsConfigElement (org.alfresco.web.config.DashboardsConfigElement)4 FacesContext (javax.faces.context.FacesContext)3 ArrayList (java.util.ArrayList)2 SelectItem (javax.faces.model.SelectItem)2 Element (org.dom4j.Element)2 ConfigException (org.springframework.extensions.config.ConfigException)2 StringReader (java.io.StringReader)1 Iterator (java.util.Iterator)1 UISelectMany (javax.faces.component.UISelectMany)1 UISelectOne (javax.faces.component.UISelectOne)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 SAXReader (org.dom4j.io.SAXReader)1 ConfigElement (org.springframework.extensions.config.ConfigElement)1