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;
}
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;
}
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;
}
Aggregations