Search in sources :

Example 6 with UIListItem

use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.

the class CategoriesDialog method getViewItems.

public List<UIListItem> getViewItems() {
    FacesContext context = FacesContext.getCurrentInstance();
    List<UIListItem> items = new ArrayList<UIListItem>(2);
    UIListItem item1 = new UIListItem();
    item1.setValue(VIEW_ICONS);
    item1.setLabel(Application.getMessage(context, LABEL_VIEW_ICONS));
    items.add(item1);
    UIListItem item2 = new UIListItem();
    item2.setValue(VIEW_DETAILS);
    item2.setLabel(Application.getMessage(context, LABEL_VIEW_DETAILS));
    items.add(item2);
    return items;
}
Also used : FacesContext(javax.faces.context.FacesContext) UIListItem(org.alfresco.web.ui.common.component.UIListItem) ArrayList(java.util.ArrayList)

Example 7 with UIListItem

use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.

the class WizardManager method getStepItems.

/**
 * Returns a list of UIListItems representing the steps of the wizard
 *
 * @return List of steps to display in UI
 */
public List<UIListItem> getStepItems() {
    List<UIListItem> items = new ArrayList<UIListItem>(this.currentWizardState.getSteps().size());
    for (int x = 0; x < this.currentWizardState.getSteps().size(); x++) {
        String uiStepNumber = Integer.toString(x + 1);
        StepConfig stepCfg = this.currentWizardState.getSteps().get(x);
        UIListItem item = new UIListItem();
        item.setValue(uiStepNumber);
        // get the title for the step
        String stepTitle = stepCfg.getTitleId();
        if (stepTitle != null) {
            stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), stepTitle);
        } else {
            stepTitle = stepCfg.getTitle();
        }
        // get the tooltip for the step
        String stepTooltip = stepCfg.getDescriptionId();
        if (stepTooltip != null) {
            stepTooltip = Application.getMessage(FacesContext.getCurrentInstance(), stepTooltip);
        } else {
            stepTooltip = stepCfg.getDescription();
        }
        // set the label and tooltip
        item.setLabel(uiStepNumber + ". " + stepTitle);
        item.setTooltip(stepTooltip);
        items.add(item);
    }
    return items;
}
Also used : UIListItem(org.alfresco.web.ui.common.component.UIListItem) ArrayList(java.util.ArrayList) StepConfig(org.alfresco.web.config.WizardsConfigElement.StepConfig)

Example 8 with UIListItem

use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.

the class CreateSpaceWizard method getSummary.

/**
 * @return Returns the summary data for the wizard.
 */
public String getSummary() {
    String summaryCreateType = null;
    ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
    if (this.createFrom.equals(CREATEFROM_SCRATCH)) {
        summaryCreateType = bundle.getString(CREATEFROM_SCRATCH);
    } else if (this.createFrom.equals(CREATEFROM_EXISTING)) {
        summaryCreateType = bundle.getString("an_existing_space");
    } else if (this.createFrom.equals(CREATEFROM_TEMPLATE)) {
        summaryCreateType = bundle.getString("a_template");
    }
    // String summarySaveAsTemplate = this.saveAsTemplate ? bundle.getString("yes") : bundle.getString("no");
    // bundle.getString("save_as_template"), bundle.getString("template_name")},
    // summarySaveAsTemplate, this.templateName
    String spaceTypeLabel = null;
    for (UIListItem item : this.getFolderTypes()) {
        if (item.getValue().equals(this.spaceType)) {
            spaceTypeLabel = item.getLabel();
            break;
        }
    }
    return buildSummary(new String[] { bundle.getString("space_type"), bundle.getString("name"), bundle.getString("description"), bundle.getString("creating_from") }, new String[] { spaceTypeLabel, Utils.encode(this.name), Utils.encode(this.description), summaryCreateType });
}
Also used : UIListItem(org.alfresco.web.ui.common.component.UIListItem) ResourceBundle(java.util.ResourceBundle)

Example 9 with UIListItem

use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.

the class CreateSpaceWizard method getFolderTypes.

/**
 * Returns a list of UIListItem objects representing the folder types
 * and also constructs the list of descriptions for each type
 *
 * @return List of UIListItem components
 */
@SuppressWarnings("unchecked")
public List<UIListItem> getFolderTypes() {
    if ((this.folderTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        FacesContext context = FacesContext.getCurrentInstance();
        this.folderTypes = new ArrayList<UIListItem>(2);
        this.folderTypeDescriptions = new ArrayList<UIDescription>(2);
        // add the well known 'container space' type to start with
        UIListItem defaultItem = new UIListItem();
        String defaultLabel = Application.getMessage(context, "container");
        defaultItem.setValue(ContentModel.TYPE_FOLDER.toString());
        defaultItem.setLabel(defaultLabel);
        defaultItem.setTooltip(defaultLabel);
        defaultItem.setImage(DEFAULT_SPACE_TYPE_ICON_PATH);
        this.folderTypes.add(defaultItem);
        UIDescription defaultDesc = new UIDescription();
        defaultDesc.setControlValue(ContentModel.TYPE_FOLDER.toString());
        defaultDesc.setText(Application.getMessage(context, "container_desc"));
        this.folderTypeDescriptions.add(defaultDesc);
        // add any configured content sub-types to the list
        Config wizardCfg = Application.getConfigService(FacesContext.getCurrentInstance()).getConfig("Space Wizards");
        if (wizardCfg != null) {
            ConfigElement typesCfg = wizardCfg.getConfigElement("folder-types");
            if (typesCfg != null) {
                for (ConfigElement child : typesCfg.getChildren()) {
                    QName idQName = Repository.resolveToQName(child.getAttribute("name"));
                    if (idQName != null) {
                        TypeDefinition typeDef = this.getDictionaryService().getType(idQName);
                        if (typeDef != null) {
                            if (this.getDictionaryService().isSubClass(typeDef.getName(), ContentModel.TYPE_FOLDER)) {
                                // try and get the label from config
                                String label = Utils.getDisplayLabel(context, child);
                                // if there wasn't a client based label try and get it from the dictionary
                                if (label == null) {
                                    label = typeDef.getTitle(this.getDictionaryService());
                                }
                                // finally use the localname if we still haven't found a label
                                if (label == null) {
                                    label = idQName.getLocalName();
                                }
                                // resolve a description string for the type
                                String description = Utils.getDescription(context, child);
                                // if we don't have a local description just use the label
                                if (description == null) {
                                    description = label;
                                }
                                // extract the icon to use from the config
                                String icon = child.getAttribute("icon");
                                if (icon == null || icon.length() == 0) {
                                    icon = DEFAULT_SPACE_TYPE_ICON_PATH;
                                }
                                UIListItem item = new UIListItem();
                                item.setValue(idQName.toString());
                                item.setLabel(label);
                                item.setTooltip(label);
                                item.setImage(icon);
                                this.folderTypes.add(item);
                                UIDescription desc = new UIDescription();
                                desc.setControlValue(idQName.toString());
                                desc.setText(description);
                                this.folderTypeDescriptions.add(desc);
                            } else {
                                logger.warn("Failed to add '" + child.getAttribute("name") + "' to the list of folder types as the type is not a subtype of cm:folder");
                            }
                        } else {
                            logger.warn("Failed to add '" + child.getAttribute("name") + "' to the list of folder types as the type is not recognised");
                        }
                    } else {
                        logger.warn("Failed to add '" + child.getAttribute("name") + "' to the list of folder types as the prefix can not be resolved");
                    }
                }
            } else {
                logger.warn("Could not find 'folder-types' configuration element");
            }
        } else {
            logger.warn("Could not find 'Space Wizards' configuration section");
        }
    }
    return this.folderTypes;
}
Also used : UIDescription(org.alfresco.web.ui.common.component.description.UIDescription) FacesContext(javax.faces.context.FacesContext) UIListItem(org.alfresco.web.ui.common.component.UIListItem) ConfigElement(org.springframework.extensions.config.ConfigElement) Config(org.springframework.extensions.config.Config) QName(org.alfresco.service.namespace.QName) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition)

Example 10 with UIListItem

use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.

the class CreateSpaceWizard method getIcons.

/**
 * Returns a list of icons to allow the user to select from.
 * The list can change according to the type of space being created.
 *
 * @return A list of icons
 */
@SuppressWarnings("unchecked")
public List<UIListItem> getIcons() {
    // NOTE: we can't cache this list as it depends on the space type
    // which the user can change during the advanced space wizard
    List<UIListItem> icons = null;
    List<String> iconNames = new ArrayList<String>(8);
    QName type = QName.createQName(this.spaceType);
    String typePrefixForm = type.toPrefixString(this.getNamespaceService());
    Config config = Application.getConfigService(FacesContext.getCurrentInstance()).getConfig(typePrefixForm + " icons");
    if (config != null) {
        ConfigElement iconsCfg = config.getConfigElement("icons");
        if (iconsCfg != null) {
            boolean first = true;
            for (ConfigElement icon : iconsCfg.getChildren()) {
                String iconName = icon.getAttribute("name");
                String iconPath = icon.getAttribute("path");
                if (iconName != null && iconPath != null) {
                    if (first) {
                        // if this is the first icon create the list and make
                        // the first icon in the list the default
                        icons = new ArrayList<UIListItem>(iconsCfg.getChildCount());
                        if (this.icon == null) {
                            // set the default if it is not already
                            this.icon = iconName;
                        }
                        first = false;
                    }
                    UIListItem item = new UIListItem();
                    item.setValue(iconName);
                    item.setImage(iconPath);
                    icons.add(item);
                    iconNames.add(iconName);
                }
            }
        }
    }
    // if we didn't find any icons display one default choice
    if (icons == null) {
        icons = new ArrayList<UIListItem>(1);
        this.icon = DEFAULT_SPACE_ICON_NAME;
        UIListItem item = new UIListItem();
        item.setValue(DEFAULT_SPACE_ICON_NAME);
        item.setImage("/images/icons/space-icon-default.gif");
        icons.add(item);
        iconNames.add(DEFAULT_SPACE_ICON_NAME);
    }
    // current list of icons about to be displayed
    if (iconNames.contains(this.icon) == false) {
        this.icon = iconNames.get(0);
    }
    return icons;
}
Also used : UIListItem(org.alfresco.web.ui.common.component.UIListItem) ConfigElement(org.springframework.extensions.config.ConfigElement) QName(org.alfresco.service.namespace.QName) Config(org.springframework.extensions.config.Config) ArrayList(java.util.ArrayList)

Aggregations

UIListItem (org.alfresco.web.ui.common.component.UIListItem)15 ArrayList (java.util.ArrayList)9 FacesContext (javax.faces.context.FacesContext)9 Collection (java.util.Collection)3 Iterator (java.util.Iterator)3 UIComponent (javax.faces.component.UIComponent)3 ResponseWriter (javax.faces.context.ResponseWriter)3 UIListItems (org.alfresco.web.ui.common.component.UIListItems)3 Config (org.springframework.extensions.config.Config)3 ConfigElement (org.springframework.extensions.config.ConfigElement)3 Map (java.util.Map)2 QName (org.alfresco.service.namespace.QName)2 UIModeList (org.alfresco.web.ui.common.component.UIModeList)2 UIDescription (org.alfresco.web.ui.common.component.description.UIDescription)2 ResourceBundle (java.util.ResourceBundle)1 PropertyNotFoundException (javax.faces.el.PropertyNotFoundException)1 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)1 DashboardsConfigElement (org.alfresco.web.config.DashboardsConfigElement)1 LayoutDefinition (org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition)1 SidebarPluginConfig (org.alfresco.web.config.SidebarConfigElement.SidebarPluginConfig)1