Search in sources :

Example 1 with LayoutDefinition

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

the class DashboardManager method getDashletDefinitionByIndex.

/**
 * 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<Column> columns = config.getCurrentPage().getColumns();
    int columnCount = columns.size();
    int selectedColumn = index / layoutDef.ColumnLength;
    if (selectedColumn < columnCount) {
        List<DashletDefinition> 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;
}
Also used : DashletDefinition(org.alfresco.web.config.DashboardsConfigElement.DashletDefinition) LayoutDefinition(org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)

Example 2 with LayoutDefinition

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

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

the class DashboardWizard method getColumns.

/**
 * @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 < layoutDef.Columns; i++) {
        String label = Application.getMessage(fc, MSG_COLUMN) + " " + Integer.toString(i + 1);
        columns[i] = new SelectItem(i, label);
    }
    return columns;
}
Also used : FacesContext(javax.faces.context.FacesContext) SelectItem(javax.faces.model.SelectItem) LayoutDefinition(org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)

Example 4 with LayoutDefinition

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

the class DashboardWizard method getColumnDashlets.

/**
 * @return the List of SelectItem objects representing the dashlets displayed in the
 *         currently selected column.
 */
public List<SelectItem> getColumnDashlets() {
    FacesContext fc = FacesContext.getCurrentInstance();
    Column column = this.editConfig.getCurrentPage().getColumns().get(this.column);
    // trim the max number of dashlets for this column
    LayoutDefinition layoutDef = this.editConfig.getCurrentPage().getLayoutDefinition();
    column.trimDashlets(layoutDef.ColumnLength);
    List<SelectItem> dashlets = new ArrayList<SelectItem>(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;
}
Also used : FacesContext(javax.faces.context.FacesContext) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) DashletDefinition(org.alfresco.web.config.DashboardsConfigElement.DashletDefinition) LayoutDefinition(org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)

Example 5 with LayoutDefinition

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

the class DashboardWizard method getSummary.

/**
 * @return Returns the summary data for the wizard.
 */
public String getSummary() {
    LayoutDefinition def = DashboardManager.getDashboardConfig().getLayoutDefinition(this.layout);
    String label = def.Label;
    if (label == null) {
        label = Application.getMessage(FacesContext.getCurrentInstance(), def.LabelId);
    }
    return buildSummary(new String[] { Application.getMessage(FacesContext.getCurrentInstance(), "step_layout") }, new String[] { label });
}
Also used : 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