summaryrefslogtreecommitdiff
path: root/eaaf_core/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'eaaf_core/src/main/java')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/AbstractGUIFormBuilderConfiguration.java50
1 files changed, 32 insertions, 18 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/AbstractGUIFormBuilderConfiguration.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/AbstractGUIFormBuilderConfiguration.java
index c9c2ec0b..706c163d 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/AbstractGUIFormBuilderConfiguration.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/AbstractGUIFormBuilderConfiguration.java
@@ -26,13 +26,17 @@
*******************************************************************************/
package at.gv.egiz.eaaf.core.impl.gui;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import at.gv.egiz.eaaf.core.api.gui.GroupDefinition;
+import at.gv.egiz.eaaf.core.api.gui.GroupDefinition.TYPE;
import at.gv.egiz.eaaf.core.api.gui.IGUIBuilderConfiguration;
/**
@@ -42,11 +46,11 @@ import at.gv.egiz.eaaf.core.api.gui.IGUIBuilderConfiguration;
public abstract class AbstractGUIFormBuilderConfiguration implements IGUIBuilderConfiguration {
private static final Logger log = LoggerFactory.getLogger(AbstractGUIFormBuilderConfiguration.class);
- public static final String PARAM_GROUP_FORM = "form";
- public static final String PARAM_GROUP_ACTIONS = "actions";
- public static final String PARAM_GROUP_PARAMS = "params";
- public static final String PARAM_GROUP_UIOPTIONS = "uiOptions";
- public static final String PARAM_GROUP_MSG = "msg";
+ public static final GroupDefinition PARAM_GROUP_FORM = GroupDefinition.getInstance("form", TYPE.MAP);
+ public static final GroupDefinition PARAM_GROUP_ACTIONS = GroupDefinition.getInstance("actions", TYPE.LIST);
+ public static final GroupDefinition PARAM_GROUP_PARAMS = GroupDefinition.getInstance("params", TYPE.MAP);
+ public static final GroupDefinition PARAM_GROUP_UIOPTIONS = GroupDefinition.getInstance("uiOptions", TYPE.MAP);
+ public static final GroupDefinition PARAM_GROUP_MSG = GroupDefinition.getInstance("msg", TYPE.MAP);
public static final String PARAM_VIEWNAME = "viewName";
@@ -130,29 +134,40 @@ public abstract class AbstractGUIFormBuilderConfiguration implements IGUIBuilder
/**
* Get the Group for generic form elements
*
- * @return groupName or <code>null</code> if no groups are used
+ * @return {@link GroupDefinition} or <code>null</code> if no groups are used
*/
- abstract protected String getFromGroup();
+ abstract protected GroupDefinition getFromGroup();
@SuppressWarnings("unchecked")
- protected void setViewParameter(String group, String key, Object value) {
+ protected void setViewParameter(GroupDefinition groupDefinition, String key, Object value) {
- if (StringUtils.isNotEmpty(group)) {
+ if (groupDefinition != null) {
log.trace("Adding group object ... ");
- Object groupMap = params.get(group);
+ Object groupMap = params.get(groupDefinition.getName());
if (groupMap == null) {
- groupMap = new HashMap<String, Object>();;
- log.trace("Build new group element");
+ if (groupDefinition.getType().equals(TYPE.MAP)) {
+ groupMap = new HashMap<String, Object>();;
+ log.trace("Build new MAP based group element");
+
+ } else if (groupDefinition.getType().equals(TYPE.LIST)) {
+ groupMap = new ArrayList<String>();
+ log.trace("Build new List based group element");
+
+ } else
+ log.warn("GroupDefinition contains an unknown type: {}", groupDefinition.getType().name());
}
-
- if (groupMap instanceof Map<?,?>) {
+
+ params.put(groupDefinition.getName(), groupMap);
+ if (groupMap instanceof Map<?,?>)
((Map<String, Object>) groupMap).put(key, value);
- params.put(group, groupMap);
- } else
+ else if (groupMap instanceof List<?>)
+ ((List<String>)groupMap).add(value.toString());
+
+ else
log.warn("Can NOT add element: {} to group: {}, because group is of type: {}",
- key, group, groupMap.getClass().getName());
+ key, groupDefinition.getName(), groupMap.getClass().getName());
} else {
log.trace("Add root object ... ");
@@ -161,5 +176,4 @@ public abstract class AbstractGUIFormBuilderConfiguration implements IGUIBuilder
}
}
-
}