Search in sources :

Example 36 with ConfigElement

use of org.springframework.extensions.config.ConfigElement in project acs-community-packaging by Alfresco.

the class DialogsElementReader method parse.

/**
 * @see org.springframework.extensions.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
 */
@SuppressWarnings("unchecked")
public ConfigElement parse(Element element) {
    DialogsConfigElement configElement = null;
    if (element != null) {
        String elementName = element.getName();
        if (elementName.equals(ELEMENT_DIALOGS) == false) {
            throw new ConfigException("DialogsElementReader can only parse " + ELEMENT_DIALOGS + "elements, the element passed was '" + elementName + "'");
        }
        configElement = new DialogsConfigElement();
        // go through the dialogs
        Iterator<Element> items = element.elementIterator(ELEMENT_DIALOG);
        while (items.hasNext()) {
            Element item = items.next();
            String name = item.attributeValue(ATTR_NAME);
            String page = item.attributeValue(ATTR_PAGE);
            String bean = item.attributeValue(ATTR_MANAGED_BEAN);
            String icon = item.attributeValue(ATTR_ICON);
            String title = item.attributeValue(ATTR_TITLE);
            String titleId = item.attributeValue(ATTR_TITLE_ID);
            String subTitle = item.attributeValue(ATTR_SUBTITLE);
            String subTitleId = item.attributeValue(ATTR_SUBTITLE_ID);
            String description = item.attributeValue(ATTR_DESCRIPTION);
            String descriptionId = item.attributeValue(ATTR_DESCRIPTION_ID);
            String errorMsgId = item.attributeValue(ATTR_ERROR_MSG_ID);
            String showOK = item.attributeValue(ATTR_SHOW_OK_BUTTON);
            boolean isOKButtonVisible = true;
            if (showOK != null) {
                isOKButtonVisible = Boolean.parseBoolean(showOK);
            }
            // action related config
            String actionsConfigId = item.attributeValue(ATTR_ACTIONS_CONFIG_ID);
            boolean useMenuForActions = false;
            String asMenu = item.attributeValue(ATTR_ACTIONS_AS_MENU);
            if (asMenu != null) {
                useMenuForActions = Boolean.parseBoolean(asMenu);
            }
            String actionsMenuLabel = item.attributeValue(ATTR_ACTIONS_MENU_LABEL);
            String actionsMenuLabelId = item.attributeValue(ATTR_ACTIONS_MENU_LABEL_ID);
            String moreActionsConfigId = item.attributeValue(ATTR_MORE_ACTIONS_CONFIG_ID);
            String moreActionsMenuLabel = item.attributeValue(ATTR_MORE_ACTIONS_MENU_LABEL);
            String moreActionsMenuLabelId = item.attributeValue(ATTR_MORE_ACTIONS_MENU_LABEL_ID);
            // parse any buttons that may be present
            List<DialogButtonConfig> buttons = parseButtons(item);
            // setup the attrbiutes object
            DialogsConfigElement.DialogAttributes attrs = new DialogsConfigElement.DialogAttributes(name, page, bean);
            attrs.setIcon(icon);
            attrs.setTitle(title);
            attrs.setTitleId(titleId);
            attrs.setSubTitle(subTitle);
            attrs.setSubTitleId(subTitleId);
            attrs.setDescription(description);
            attrs.setDescriptionId(descriptionId);
            attrs.setErrorMessageId(errorMsgId);
            attrs.setOKButtonVisible(isOKButtonVisible);
            attrs.setButtons(buttons);
            attrs.setActionsConfigId(actionsConfigId);
            attrs.setActionsAsMenu(useMenuForActions);
            attrs.setActionsMenuLabel(actionsMenuLabel);
            attrs.setActionsMenuLabelId(actionsMenuLabelId);
            attrs.setMoreActionsConfigId(moreActionsConfigId);
            attrs.setMoreActionsMenuLabel(moreActionsMenuLabel);
            attrs.setMoreActionsMenuLabelId(moreActionsMenuLabelId);
            // create and add the dialog config object
            DialogsConfigElement.DialogConfig cfg = new DialogsConfigElement.DialogConfig(attrs);
            configElement.addDialog(cfg);
        }
    }
    return configElement;
}
Also used : ConfigElement(org.springframework.extensions.config.ConfigElement) Element(org.dom4j.Element) DialogButtonConfig(org.alfresco.web.config.DialogsConfigElement.DialogButtonConfig) ConfigException(org.springframework.extensions.config.ConfigException)

Example 37 with ConfigElement

use of org.springframework.extensions.config.ConfigElement in project acs-community-packaging by Alfresco.

the class SidebarElementReader method parse.

/**
 * @see org.springframework.extensions.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
 */
@SuppressWarnings("unchecked")
public ConfigElement parse(Element element) {
    SidebarConfigElement configElement = null;
    if (element != null) {
        String elementName = element.getName();
        if (elementName.equals(ELEMENT_SIDEBAR) == false) {
            throw new ConfigException("SidebarElementReader can only parse " + ELEMENT_SIDEBAR + "elements, the element passed was '" + elementName + "'");
        }
        configElement = new SidebarConfigElement();
        // go through the plugins that make up the sidebar
        Element pluginsElem = element.element(ELEMENT_PLUGINS);
        if (pluginsElem != null) {
            Iterator<Element> plugins = pluginsElem.elementIterator(ELEMENT_PLUGIN);
            while (plugins.hasNext()) {
                Element plugin = plugins.next();
                String id = plugin.attributeValue(ATTR_ID);
                String page = plugin.attributeValue(ATTR_PAGE);
                String label = plugin.attributeValue(ATTR_LABEL);
                String labelId = plugin.attributeValue(ATTR_LABEL_ID);
                String description = plugin.attributeValue(ATTR_DESCRIPTION);
                String descriptionId = plugin.attributeValue(ATTR_DESCRIPTION_ID);
                String actionsConfigId = plugin.attributeValue(ATTR_ACTIONS_CONFIG_ID);
                String icon = plugin.attributeValue(ATTR_ICON);
                SidebarConfigElement.SidebarPluginConfig cfg = new SidebarConfigElement.SidebarPluginConfig(id, page, label, labelId, description, descriptionId, actionsConfigId, icon);
                configElement.addPlugin(cfg);
            }
        }
        // see if a default plugin is specified
        Element defaultPlugin = element.element(ELEMENT_DEFAULT_PLUGIN);
        if (defaultPlugin != null) {
            configElement.setDefaultPlugin(defaultPlugin.getTextTrim());
        }
    }
    return configElement;
}
Also used : ConfigElement(org.springframework.extensions.config.ConfigElement) Element(org.dom4j.Element) ConfigException(org.springframework.extensions.config.ConfigException)

Example 38 with ConfigElement

use of org.springframework.extensions.config.ConfigElement in project acs-community-packaging by Alfresco.

the class ViewsElementReader method parse.

/**
 * @see org.springframework.extensions.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
 */
@SuppressWarnings("unchecked")
public ConfigElement parse(Element element) {
    ViewsConfigElement configElement = null;
    if (element != null) {
        String name = element.getName();
        if (name.equals(ViewsConfigElement.CONFIG_ELEMENT_ID) == false) {
            throw new ConfigException("ViewsElementReader can only parse " + ViewsConfigElement.CONFIG_ELEMENT_ID + " elements, the element passed was '" + name + "'");
        }
        configElement = new ViewsConfigElement();
        // get the configured views
        Iterator<Element> renderers = element.elementIterator(ELEMENT_VIEWIMPL);
        while (renderers.hasNext()) {
            Element renderer = renderers.next();
            configElement.addView(renderer.getTextTrim());
        }
        // get all the view related default settings
        Element viewDefaults = element.element(ELEMENT_VIEWDEFAULTS);
        if (viewDefaults != null) {
            Iterator<Element> pages = viewDefaults.elementIterator();
            while (pages.hasNext()) {
                Element page = pages.next();
                String pageName = page.getName();
                // get the default view mode for the page
                Element defaultView = page.element(ELEMENT_VIEW);
                if (defaultView != null) {
                    String viewName = defaultView.getTextTrim();
                    configElement.addDefaultView(pageName, viewName);
                }
                // get the initial sort column
                Element sortColumn = page.element(ELEMENT_SORTCOLUMN);
                if (sortColumn != null) {
                    String column = sortColumn.getTextTrim();
                    configElement.addDefaultSortColumn(pageName, column);
                }
                // get the sort direction option
                Element sortDir = page.element(ELEMENT_SORTDIRECTION);
                if (sortDir != null) {
                    configElement.addSortDirection(pageName, sortDir.getTextTrim());
                }
                // process the page-size element
                processPageSizeElement(page.element(ELEMENT_PAGESIZE), pageName, configElement);
            }
        }
    }
    return configElement;
}
Also used : ConfigElement(org.springframework.extensions.config.ConfigElement) Element(org.dom4j.Element) ConfigException(org.springframework.extensions.config.ConfigException)

Aggregations

ConfigElement (org.springframework.extensions.config.ConfigElement)38 Config (org.springframework.extensions.config.Config)21 ConfigService (org.springframework.extensions.config.ConfigService)18 Element (org.dom4j.Element)14 ConfigException (org.springframework.extensions.config.ConfigException)13 SelectItem (javax.faces.model.SelectItem)11 FacesContext (javax.faces.context.FacesContext)10 QuickSort (org.alfresco.web.data.QuickSort)9 QName (org.alfresco.service.namespace.QName)7 ArrayList (java.util.ArrayList)4 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)4 UIListItem (org.alfresco.web.ui.common.component.UIListItem)3 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 StringTokenizer (java.util.StringTokenizer)1 UIComponent (javax.faces.component.UIComponent)1