Search in sources :

Example 1 with UISelectMany

use of javax.faces.component.UISelectMany 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

UISelectMany (javax.faces.component.UISelectMany)1 UISelectOne (javax.faces.component.UISelectOne)1 DashboardsConfigElement (org.alfresco.web.config.DashboardsConfigElement)1 LayoutDefinition (org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)1