Author: koen.aers(a)jboss.com
Date: 2009-04-22 19:30:57 -0400 (Wed, 22 Apr 2009)
New Revision: 14857
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java
Log:
addChild and removeChild are split in internalAddChild and localAddChild and
internalRemoveChild and localRemoveChild respectively
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java 2009-04-22
23:29:44 UTC (rev 14856)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java 2009-04-22
23:30:57 UTC (rev 14857)
@@ -13,7 +13,7 @@
private Element element;
private transient List<ModelListener> listeners = new
ArrayList<ModelListener>();
- private transient Map<Object, List<Element>> children = new
HashMap<Object, List<Element>>();
+ private Map<Object, List<Element>> children = new HashMap<Object,
List<Element>>();
public void setElement(Element element) {
this.element = element;
@@ -24,25 +24,53 @@
}
public void addChild(Object type, Element element) {
+ localAddChild(type, element);
+ internalAddChild(type, element);
+ notifyListeners(ADD_ELEMENT, type, this, null, element);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void internalAddChild(Object type, Element element) {
+ Object childList = getPropertyValue(type);
+ if (childList == null || !(childList instanceof List)) return;
+ ((List)childList).add(element);
+ }
+
+ public void localAddChild(Object type, Element element) {
List<Element> childList = children.get(type);
if (childList == null) {
childList = new ArrayList<Element>();
children.put(type, childList);
}
childList.add(element);
- notifyListeners(ADD_ELEMENT, type, this, null, element);
}
public void removeChild(Object type, Element element) {
+ localRemoveChild(type, element);
+ internalRemoveChild(type, element);
+ notifyListeners(REMOVE_ELEMENT, type, this, element, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void internalRemoveChild(Object type, Element element) {
+ Object childList = getPropertyValue(type);
+ if (childList == null || !(childList instanceof List)) return;
+ ((List)childList).remove(element);
+ }
+
+ public void localRemoveChild(Object type, Element element) {
List<Element> childList = children.get(type);
if (childList == null) return;
childList.remove(element);
if (childList.isEmpty()) {
children.remove(type);
}
- notifyListeners(REMOVE_ELEMENT, type, this, element, null);
}
+ public List<Element> getChildren(Object type) {
+ return children.get(type);
+ }
+
public void setMetaData(String name, Object value) {
if (element != null) {
element.setMetaData(name, value);