Search in sources :

Example 6 with UISelectOne

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

use of javax.faces.component.UISelectOne in project acs-community-packaging by Alfresco.

the class DashboardWizard method removeDashlet.

/**
 * Action handler called to Remove a dashlet from the selection for a column
 */
public void removeDashlet(ActionEvent event) {
    UISelectOne dashletColumn = (UISelectOne) event.getComponent().findComponent(COMPONENT_COLUMNDASHLETS);
    // get the ID of the selected Dashlet definition
    String dashletId = (String) dashletColumn.getValue();
    if (dashletId != null) {
        Column column = this.editConfig.getCurrentPage().getColumns().get(this.column);
        // remove the selected dashlet from the column
        for (int i = 0; i < column.getDashlets().size(); i++) {
            if (column.getDashlets().get(i).Id.equals(dashletId)) {
                column.getDashlets().remove(i);
                break;
            }
        }
    }
}
Also used : UISelectOne(javax.faces.component.UISelectOne)

Aggregations

UISelectOne (javax.faces.component.UISelectOne)7 DashletDefinition (org.alfresco.web.config.DashboardsConfigElement.DashletDefinition)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 UIComponent (javax.faces.component.UIComponent)1 UIInput (javax.faces.component.UIInput)1 UIOutput (javax.faces.component.UIOutput)1 UISelectBoolean (javax.faces.component.UISelectBoolean)1 UISelectItems (javax.faces.component.UISelectItems)1 UISelectMany (javax.faces.component.UISelectMany)1 FacesContext (javax.faces.context.FacesContext)1 ValueBinding (javax.faces.el.ValueBinding)1 SelectItem (javax.faces.model.SelectItem)1 ListOfValuesConstraint (org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint)1 DataTypeDefinition (org.alfresco.service.cmr.dictionary.DataTypeDefinition)1 QName (org.alfresco.service.namespace.QName)1 DashboardsConfigElement (org.alfresco.web.config.DashboardsConfigElement)1 LayoutDefinition (org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)1 UIGenericPicker (org.alfresco.web.ui.common.component.UIGenericPicker)1