mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- Added clean-tomcat target to build
- Added new features to dialog framework - Fixed bug in error message in Add Content Dialog - Fixed typos is sample custom config file git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3413 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -16,11 +16,14 @@
|
||||
*/
|
||||
package org.alfresco.web.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.config.ConfigElement;
|
||||
import org.alfresco.config.ConfigException;
|
||||
import org.alfresco.config.xml.elementreader.ConfigElementReader;
|
||||
import org.alfresco.web.config.DialogsConfigElement.DialogButtonConfig;
|
||||
import org.dom4j.Element;
|
||||
|
||||
/**
|
||||
@@ -32,6 +35,8 @@ public class DialogsElementReader implements ConfigElementReader
|
||||
{
|
||||
public static final String ELEMENT_DIALOGS = "dialogs";
|
||||
public static final String ELEMENT_DIALOG = "dialog";
|
||||
public static final String ELEMENT_BUTTONS = "buttons";
|
||||
public static final String ELEMENT_BUTTON = "button";
|
||||
public static final String ATTR_NAME = "name";
|
||||
public static final String ATTR_PAGE = "page";
|
||||
public static final String ATTR_MANAGED_BEAN = "managed-bean";
|
||||
@@ -42,10 +47,18 @@ public class DialogsElementReader implements ConfigElementReader
|
||||
public static final String ATTR_DESCRIPTION = "description";
|
||||
public static final String ATTR_DESCRIPTION_ID = "description-id";
|
||||
public static final String ATTR_ERROR_MSG_ID = "error-message-id";
|
||||
public static final String ATTR_SHOW_OK_BUTTON = "show-ok-button";
|
||||
public static final String ATTR_ID = "id";
|
||||
public static final String ATTR_LABEL = "label";
|
||||
public static final String ATTR_LABEL_ID = "label-id";
|
||||
public static final String ATTR_ACTION = "action";
|
||||
public static final String ATTR_DISABLED = "disabled";
|
||||
public static final String ATTR_ONCLICK = "onclick";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ConfigElement parse(Element element)
|
||||
{
|
||||
DialogsConfigElement configElement = null;
|
||||
@@ -62,7 +75,7 @@ public class DialogsElementReader implements ConfigElementReader
|
||||
|
||||
configElement = new DialogsConfigElement();
|
||||
|
||||
// go through the items to show
|
||||
// go through the dialogs
|
||||
Iterator<Element> items = element.elementIterator(ELEMENT_DIALOG);
|
||||
while (items.hasNext())
|
||||
{
|
||||
@@ -78,10 +91,20 @@ public class DialogsElementReader implements ConfigElementReader
|
||||
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);
|
||||
}
|
||||
|
||||
// parse any buttons that may be present
|
||||
List<DialogButtonConfig> buttons = parseButtons(item);
|
||||
|
||||
DialogsConfigElement.DialogConfig cfg = new DialogsConfigElement.DialogConfig(
|
||||
name, page, bean, actions, icon, title, titleId, description,
|
||||
descriptionId, errorMsgId);
|
||||
descriptionId, errorMsgId, isOKButtonVisible, buttons);
|
||||
|
||||
configElement.addDialog(cfg);
|
||||
}
|
||||
@@ -90,4 +113,44 @@ public class DialogsElementReader implements ConfigElementReader
|
||||
return configElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the configuration for additional buttons.
|
||||
*
|
||||
* @param dialog The dialog XML element
|
||||
* @return List of configured buttons
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected List<DialogButtonConfig> parseButtons(Element dialog)
|
||||
{
|
||||
List<DialogButtonConfig> buttons = null;
|
||||
|
||||
// iterate over any configured buttons
|
||||
Element buttonsConfig = dialog.element(ELEMENT_BUTTONS);
|
||||
if (buttonsConfig != null)
|
||||
{
|
||||
buttons = new ArrayList<DialogButtonConfig>(4);
|
||||
|
||||
Iterator<Element> children = buttonsConfig.elementIterator(ELEMENT_BUTTON);
|
||||
while (children.hasNext())
|
||||
{
|
||||
Element button = children.next();
|
||||
|
||||
String id = button.attributeValue(ATTR_ID);
|
||||
String label = button.attributeValue(ATTR_LABEL);
|
||||
String labelId = button.attributeValue(ATTR_LABEL_ID);
|
||||
String action = button.attributeValue(ATTR_ACTION);
|
||||
String disabled = button.attributeValue(ATTR_DISABLED);
|
||||
String onclick = button.attributeValue(ATTR_ONCLICK);
|
||||
|
||||
// create the button config object
|
||||
DialogButtonConfig btnCfg = new DialogButtonConfig(id, label,
|
||||
labelId, action, disabled, onclick);
|
||||
|
||||
// add the button to the list
|
||||
buttons.add(btnCfg);
|
||||
}
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user