Author: koen.aers(a)jboss.com
Date: 2008-10-16 14:05:49 -0400 (Thu, 16 Oct 2008)
New Revision: 10899
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractFlowWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java
Log:
container wrapper is properties provider
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractFlowWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractFlowWrapper.java 2008-10-16
17:20:52 UTC (rev 10898)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractFlowWrapper.java 2008-10-16
18:05:49 UTC (rev 10899)
@@ -29,7 +29,8 @@
*/
public abstract class AbstractFlowWrapper extends AbstractWrapper implements FlowWrapper
{
- private Map<String, NodeWrapper> elements = new HashMap<String,
NodeWrapper>();
+ private Map<String, NodeWrapper> elementMap = new HashMap<String,
NodeWrapper>();
+ private List<NodeWrapper> elementList = new ArrayList<NodeWrapper>();
private transient List<ModelListener> listeners = new
ArrayList<ModelListener>();
public abstract Integer getRouterLayout();
@@ -44,11 +45,11 @@
public List<NodeWrapper> getElements() {
return Collections.unmodifiableList(
- new ArrayList<NodeWrapper>(elements.values()));
+ new ArrayList<NodeWrapper>(elementList));
}
public NodeWrapper getElement(String id) {
- return (NodeWrapper) elements.get(id);
+ return (NodeWrapper) elementMap.get(id);
}
public void addElement(NodeWrapper element) {
@@ -59,7 +60,8 @@
}
public void localAddElement(NodeWrapper element) {
- elements.put(element.getId(), element);
+ elementMap.put(element.getId(), element);
+ elementList.add(element);
}
public boolean acceptsElement(NodeWrapper element) {
@@ -68,10 +70,15 @@
protected abstract void internalAddElement(NodeWrapper element);
+ public void localRemoveElement(NodeWrapper element) {
+ elementMap.remove(element.getId());
+ elementList.remove(element);
+ }
+
public void removeElement(NodeWrapper element) {
- elements.remove(element.getId());
+ localRemoveElement(element);
+ internalRemoveElement(element);
notifyListeners(CHANGE_ELEMENTS);
- internalRemoveElement(element);
}
protected abstract void internalRemoveElement(NodeWrapper element);
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.java 2008-10-16
17:20:52 UTC (rev 10898)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.java 2008-10-16
18:05:49 UTC (rev 10899)
@@ -3,6 +3,8 @@
import java.util.List;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.common.properties.DefaultContainerPropertySource;
import org.jboss.tools.flow.common.model.Connection;
import org.jboss.tools.flow.common.model.Container;
import org.jboss.tools.flow.common.model.Flow;
@@ -16,7 +18,12 @@
private AcceptsElementStrategy acceptsElementStrategy;
private AcceptsIncomingConnectionStrategy incomingConnectionStrategy;
private AcceptsOutgoingConnectionStrategy outgoingConnectionStrategy;
+ private DefaultContainerPropertySource propertySource;
+ protected void internalSetName(String name) {
+ getNode().setName(name);
+ }
+
protected void internalAddElement(NodeWrapper element) {
Node node = (Node)element.getElement();
List<Node> nodes = ((Flow)getFlowWrapper().getElement()).getNodes();
@@ -117,4 +124,19 @@
}
}
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPropertySource.class) {
+ return getPropertySource();
+ }
+ return super.getAdapter(adapter);
+ }
+
+ private IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new DefaultContainerPropertySource(this);
+ }
+ return propertySource;
+ }
+
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java 2008-10-16
17:20:52 UTC (rev 10898)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java 2008-10-16
18:05:49 UTC (rev 10899)
@@ -1,6 +1,8 @@
package org.jboss.tools.flow.common.wrapper;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.common.properties.DefaultNodePropertySource;
import org.jboss.tools.flow.common.model.Connection;
import org.jboss.tools.flow.common.model.Node;
import org.jboss.tools.flow.common.strategy.AcceptsIncomingConnectionStrategy;
@@ -10,6 +12,7 @@
private AcceptsIncomingConnectionStrategy incomingConnectionStrategy;
private AcceptsOutgoingConnectionStrategy outgoingConnectionStrategy;
+ private DefaultNodePropertySource propertySource;
public void setNode(Node node) {
setElement(node);
@@ -104,4 +107,19 @@
((DefaultConnectionWrapper) connection).getConnection());
}
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPropertySource.class) {
+ return getPropertySource();
+ }
+ return super.getAdapter(adapter);
+ }
+
+ private IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new DefaultNodePropertySource(this);
+ }
+ return propertySource;
+ }
+
}