Author: koen.aers(a)jboss.com
Date: 2009-04-21 14:33:28 -0400 (Tue, 21 Apr 2009)
New Revision: 14839
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/VerticalAutoLayoutAction.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteElementCommand.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ConnectionEditPart.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ContainerEditPart.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ElementEditPart.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/LabelEditPart.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/RootEditPart.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractContainerWrapper.java
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/AbstractLabelWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractNodeWrapper.java
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/ContainerWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultLabelWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/FlowWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelEvent.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java
Log:
richer model event, to allow for adding and removing children to/from elements
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/VerticalAutoLayoutAction.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/VerticalAutoLayoutAction.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/VerticalAutoLayoutAction.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -67,7 +67,7 @@
for (Map.Entry<String, Node> entry: mapping.entrySet()) {
Node node = entry.getValue();
NodeWrapper nodeWrapper =
-
((FlowWrapper)diagramViewer.getContents().getModel()).getElement(entry.getKey());
+
((FlowWrapper)diagramViewer.getContents().getModel()).getNodeWrapper(entry.getKey());
nodeWrapper.setConstraint(new Rectangle(node.x, node.y, node.width,
node.height));
}
}
@@ -76,7 +76,7 @@
protected DirectedGraph createDirectedGraph(Map<String, Node> mapping) {
DirectedGraph graph = new DirectedGraph();
FlowWrapper processWrapper =
(FlowWrapper)diagramViewer.getContents().getModel();
- for (NodeWrapper elementWrapper: processWrapper.getElements()) {
+ for (NodeWrapper elementWrapper: processWrapper.getNodeWrappers()) {
Node node = new Node();
Integer width = (Integer) elementWrapper.getConstraint().width;
Integer height = (Integer) elementWrapper.getConstraint().height;
@@ -90,7 +90,7 @@
graph.nodes.add(node);
mapping.put(elementWrapper.getId(), node);
}
- for (NodeWrapper elementWrapper: processWrapper.getElements()) {
+ for (NodeWrapper elementWrapper: processWrapper.getNodeWrappers()) {
for (ConnectionWrapper connection: elementWrapper.getIncomingConnections())
{
Node source = mapping.get(connection.getSource().getId());
Node target = mapping.get(connection.getTarget().getId());
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteElementCommand.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteElementCommand.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteElementCommand.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -62,7 +62,7 @@
private void initializeEmbeddedCommands() {
embeddedCommands = new ArrayList<DeleteElementCommand>();
ContainerWrapper container = (ContainerWrapper)child;
- List<NodeWrapper> children = container.getElements();
+ List<NodeWrapper> children = container.getNodeWrappers();
for (NodeWrapper w : children) {
DeleteElementCommand c = new DeleteElementCommand();
c.setParent(container);
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ConnectionEditPart.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ConnectionEditPart.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ConnectionEditPart.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -94,7 +94,7 @@
}
public void modelChanged(ModelEvent event) {
- if (event.getChange() == ConnectionWrapper.CHANGE_BENDPOINTS) {
+ if (event.getChangeType() == ConnectionWrapper.CHANGE_BENDPOINTS) {
refreshBendpoints();
}
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ContainerEditPart.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ContainerEditPart.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ContainerEditPart.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -47,7 +47,7 @@
}
public void modelChanged(ModelEvent event) {
- if (event.getChange() == ContainerWrapper.ADD_ELEMENT) {
+ if (event.getChangeType() == ContainerWrapper.ADD_ELEMENT) {
refreshChildren();
Object changedObject = event.getChangedObject();
if (changedObject != null) {
@@ -56,7 +56,7 @@
((ElementEditPart)editPart).performDirectEdit();
}
}
- } else if (event.getChange() == ContainerWrapper.REMOVE_ELEMENT) {
+ } else if (event.getChangeType() == ContainerWrapper.REMOVE_ELEMENT) {
refreshChildren();
} else {
super.modelChanged(event);
@@ -72,7 +72,7 @@
}
protected List<NodeWrapper> getModelChildren() {
- return getElementContainerElementWrapper().getElements();
+ return getElementContainerElementWrapper().getNodeWrappers();
}
public IFigure getContentPane() {
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ElementEditPart.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ElementEditPart.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ElementEditPart.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -99,15 +99,15 @@
}
public void modelChanged(ModelEvent event) {
- if (event.getChange() == NodeWrapper.ADD_INCOMING_CONNECTION) {
+ if (event.getChangeType() == NodeWrapper.ADD_ELEMENT &&
"incomingConnection".equals(event.getChangeDiscriminator())) {
refreshTargetConnections();
- } else if (event.getChange() == NodeWrapper.REMOVE_INCOMING_CONNECTION) {
+ } else if (event.getChangeType() == NodeWrapper.REMOVE_ELEMENT &&
"incomingConnection".equals(event.getChangeDiscriminator())) {
refreshTargetConnections();
- } else if (event.getChange() == NodeWrapper.ADD_OUTGOING_CONNECTION) {
+ } else if (event.getChangeType() == NodeWrapper.ADD_ELEMENT &&
"outgoingConnection".equals(event.getChangeDiscriminator())) {
refreshSourceConnections();
- } else if (event.getChange() == NodeWrapper.REMOVE_OUTGOING_CONNECTION) {
+ } else if (event.getChangeType() == NodeWrapper.REMOVE_ELEMENT &&
"outgoingConnection".equals(event.getChangeDiscriminator())) {
refreshSourceConnections();
- } else if (event.getChange() == NodeWrapper.CHANGE_VISUAL) {
+ } else if (event.getChangeType() == NodeWrapper.CHANGE_VISUAL) {
refreshVisuals();
}
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/LabelEditPart.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/LabelEditPart.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/LabelEditPart.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -106,7 +106,7 @@
}
public void modelChanged(ModelEvent event) {
- if (event.getChange() == Wrapper.CHANGE_PROPERTY || event.getChange() ==
Wrapper.CHANGE_VISUAL) {
+ if (event.getChangeType() == Wrapper.CHANGE_PROPERTY || event.getChangeType() ==
Wrapper.CHANGE_VISUAL) {
refreshVisuals();
}
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/RootEditPart.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/RootEditPart.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/RootEditPart.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -68,7 +68,7 @@
}
protected List<NodeWrapper> getModelChildren() {
- return getWrapper().getElements();
+ return getWrapper().getNodeWrappers();
}
public void activate() {
@@ -82,11 +82,11 @@
}
public void modelChanged(ModelEvent event) {
- if (event.getChange() == ContainerWrapper.ADD_ELEMENT) {
+ if (event.getChangeType() == ContainerWrapper.ADD_ELEMENT) {
refreshChildren();
- } else if (event.getChange() == ContainerWrapper.REMOVE_ELEMENT) {
+ } else if (event.getChangeType() == ContainerWrapper.REMOVE_ELEMENT) {
refreshChildren();
- } else if (event.getChange() == FlowWrapper.CHANGE_VISUAL) {
+ } else if (event.getChangeType() == FlowWrapper.CHANGE_VISUAL) {
refreshVisuals();
}
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -53,10 +53,11 @@
}
}
- public void setPropertyValue(Object id, Object value) {
+ public void setPropertyValue(Object id, Object newValue) {
if (elementPropertySource != null) {
- elementPropertySource.setPropertyValue(id, value);
- wrapper.notifyListeners(Wrapper.CHANGE_PROPERTY, id);
+ Object oldValue = elementPropertySource.getPropertyValue(id);
+ elementPropertySource.setPropertyValue(id, newValue);
+ wrapper.notifyListeners(Wrapper.CHANGE_PROPERTY, id, wrapper, oldValue, newValue);
}
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractContainerWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractContainerWrapper.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractContainerWrapper.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -26,7 +26,7 @@
public void addElement(NodeWrapper element) {
internalAddElement(element);
localAddElement(element);
- notifyListeners(ADD_ELEMENT, element);
+ notifyListeners(ADD_ELEMENT, "node", this, null, element);
}
public void localAddElement(NodeWrapper element) {
@@ -40,12 +40,12 @@
internalRemoveElement(element);
elements.remove(element);
element.setParent(null);
- notifyListeners(REMOVE_ELEMENT, element);
+ notifyListeners(REMOVE_ELEMENT, "node", this, element, null);
}
protected abstract void internalRemoveElement(NodeWrapper element);
- public List<NodeWrapper> getElements() {
+ public List<NodeWrapper> getNodeWrappers() {
return elements;
}
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 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractFlowWrapper.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -29,39 +29,39 @@
*/
public abstract class AbstractFlowWrapper extends AbstractWrapper implements FlowWrapper
{
- private Map<String, NodeWrapper> elementMap = new HashMap<String,
NodeWrapper>();
- private List<NodeWrapper> elementList = new ArrayList<NodeWrapper>();
- private transient List<ModelListener> listeners = new
ArrayList<ModelListener>();
+ private Map<String, NodeWrapper> nodeWrapperMap = new HashMap<String,
NodeWrapper>();
+ private List<NodeWrapper> nodeWrapperList = new
ArrayList<NodeWrapper>();
public abstract Integer getRouterLayout();
- public void setRouterLayout(Integer routerLayout) {
- internalSetRouterLayout(routerLayout);
- notifyListeners(CHANGE_VISUAL, null);
+ public void setRouterLayout(Integer newLayout) {
+ Integer oldLayout = getRouterLayout();
+ internalSetRouterLayout(newLayout);
+ notifyListeners(CHANGE_VISUAL, "routerLayout", this, oldLayout,
newLayout);
}
protected void internalSetRouterLayout(Integer routerLayout) {
}
- public List<NodeWrapper> getElements() {
+ public List<NodeWrapper> getNodeWrappers() {
return Collections.unmodifiableList(
- new ArrayList<NodeWrapper>(elementList));
+ new ArrayList<NodeWrapper>(nodeWrapperList));
}
- public NodeWrapper getElement(String id) {
- return (NodeWrapper) elementMap.get(id);
+ public NodeWrapper getNodeWrapper(String id) {
+ return (NodeWrapper) nodeWrapperMap.get(id);
}
- public void addElement(NodeWrapper element) {
- if (!acceptsElement(element)) return;
- internalAddElement(element);
- localAddElement(element);
- notifyListeners(ADD_ELEMENT, element);
+ public void addElement(NodeWrapper nodeWrapper) {
+ if (!acceptsElement(nodeWrapper)) return;
+ internalAddElement(nodeWrapper);
+ localAddElement(nodeWrapper);
+ notifyListeners(ADD_ELEMENT, "node", this, null, nodeWrapper);
}
public void localAddElement(NodeWrapper element) {
- elementMap.put(element.getId(), element);
- elementList.add(element);
+ nodeWrapperMap.put(element.getId(), element);
+ nodeWrapperList.add(element);
element.setParent(this);
}
@@ -72,14 +72,14 @@
protected abstract void internalAddElement(NodeWrapper element);
public void localRemoveElement(NodeWrapper element) {
- elementMap.remove(element.getId());
- elementList.remove(element);
+ nodeWrapperMap.remove(element.getId());
+ nodeWrapperList.remove(element);
}
public void removeElement(NodeWrapper element) {
localRemoveElement(element);
internalRemoveElement(element);
- notifyListeners(REMOVE_ELEMENT, element);
+ notifyListeners(REMOVE_ELEMENT, "node", this, element, null);
}
protected abstract void internalRemoveElement(NodeWrapper element);
@@ -88,19 +88,4 @@
return this;
}
- public void addListener(ModelListener listener) {
- listeners.add(listener);
- }
-
- public void removeListener(ModelListener listener) {
- listeners.remove(listener);
- }
-
- protected void notifyListeners(int change, NodeWrapper wrapper) {
- ModelEvent event = new ModelEvent(change, wrapper);
- for (ModelListener listener: listeners) {
- listener.modelChanged(event);
- }
- }
-
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractLabelWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractLabelWrapper.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractLabelWrapper.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -16,9 +16,10 @@
return null;
}
- public void setLocation(Point location) {
- this.location = location;
- notifyListeners(CHANGE_VISUAL, this);
+ public void setLocation(Point newLocation) {
+ Point oldLocation = this.location;
+ this.location = newLocation;
+ notifyListeners(CHANGE_VISUAL, "location", this, oldLocation, newLocation);
}
public void setText(String text) {
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractNodeWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractNodeWrapper.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractNodeWrapper.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -47,9 +47,10 @@
private List<ConnectionWrapper> outgoingConnections = new
ArrayList<ConnectionWrapper>();
public void setConstraint(Rectangle constraint) {
+ Rectangle oldConstraint = this.constraint;
this.constraint = constraint;
internalSetConstraint(constraint);
- notifyListeners(CHANGE_VISUAL, this);
+ notifyListeners(CHANGE_VISUAL, "constraint", this, oldConstraint,
constraint);
}
protected abstract void internalSetConstraint(Rectangle constraint);
@@ -90,7 +91,7 @@
public void addIncomingConnection(ConnectionWrapper connection) {
localAddIncomingConnection(connection);
internalAddIncomingConnection(connection);
- notifyListeners(ADD_INCOMING_CONNECTION, connection);
+ notifyListeners(ADD_ELEMENT, "incomingConnection", this, null, connection);
}
public void localAddIncomingConnection(ConnectionWrapper connection) {
@@ -103,7 +104,7 @@
public void removeIncomingConnection(ConnectionWrapper connection) {
incomingConnections.remove(connection);
internalRemoveIncomingConnection(connection);
- notifyListeners(REMOVE_INCOMING_CONNECTION, connection);
+ notifyListeners(REMOVE_ELEMENT, "incomingConnection", this, connection,
null);
}
protected void internalRemoveIncomingConnection(ConnectionWrapper connection) {
@@ -112,7 +113,7 @@
public void addOutgoingConnection(ConnectionWrapper connection) {
localAddOutgoingConnection(connection);
internalAddOutgoingConnection(connection);
- notifyListeners(ADD_OUTGOING_CONNECTION, connection);
+ notifyListeners(ADD_ELEMENT, "outgoingConnection", this, null, connection);
}
public void localAddOutgoingConnection(ConnectionWrapper connection) {
@@ -125,15 +126,16 @@
public void removeOutgoingConnection(ConnectionWrapper connection) {
outgoingConnections.remove(connection);
internalRemoveOutgoingConnection(connection);
- notifyListeners(REMOVE_OUTGOING_CONNECTION, connection);
+ notifyListeners(REMOVE_ELEMENT, "outgoingConnection", this, connection,
null);
}
protected void internalRemoveOutgoingConnection(ConnectionWrapper connection) {
}
- public void setName(String name) {
- internalSetName(name);
- notifyListeners(CHANGE_VISUAL, this);
+ public void setName(String newLocation) {
+ String oldName = getName();
+ internalSetName(newLocation);
+ notifyListeners(CHANGE_VISUAL, "name", this, oldName, newLocation);
}
protected void internalSetName(String name) {
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-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -1,7 +1,9 @@
package org.jboss.tools.flow.common.wrapper;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
@@ -11,6 +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>>();
public void setElement(Element element) {
this.element = element;
@@ -20,6 +23,39 @@
return element;
}
+ public void addChild(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) {
+ 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 void setMetaData(String name, Object value) {
+ if (element != null) {
+ element.setMetaData(name, value);
+ }
+ }
+
+ public Object getMetaData(String name) {
+ if (element != null) {
+ return element.getMetaData(name);
+ }
+ return null;
+ }
+
public void addListener(ModelListener listener) {
listeners.add(listener);
}
@@ -28,15 +64,18 @@
listeners.remove(listener);
}
- public void notifyListeners(int change, Object object) {
- ModelEvent event = new ModelEvent(change, object);
+ public void notifyListeners(int type, Object discriminator, Object object, Object
oldValue, Object newValue) {
+ notifyListeners(new ModelEvent(type, discriminator, object, oldValue, newValue));
+ }
+
+ public void notifyListeners(ModelEvent event) {
for (ModelListener listener: listeners) {
listener.modelChanged(event);
}
}
public void notifyListeners(int change) {
- notifyListeners(change, null);
+ notifyListeners(change, null, null, null, null);
}
public Object getEditableValue() {
@@ -73,10 +112,11 @@
}
}
- public void setPropertyValue(Object id, Object value) {
+ public void setPropertyValue(Object id, Object newValue) {
if (getPropertySource() != null) {
- getPropertySource().setPropertyValue(id, value);
- notifyListeners(CHANGE_PROPERTY, id);
+ Object oldValue = getPropertySource().getPropertyValue(id);
+ getPropertySource().setPropertyValue(id, newValue);
+ notifyListeners(CHANGE_PROPERTY, id, this, oldValue, newValue);
}
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ContainerWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ContainerWrapper.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ContainerWrapper.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -26,7 +26,7 @@
void removeElement(NodeWrapper element);
- List<NodeWrapper> getElements();
+ List<NodeWrapper> getNodeWrappers();
FlowWrapper getFlowWrapper();
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultLabelWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultLabelWrapper.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultLabelWrapper.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -23,7 +23,7 @@
}
public void modelChanged(ModelEvent event) {
- notifyListeners(event.getChange(), event.getChangedObject());
+ notifyListeners(event);
}
protected IPropertySource getPropertySource() {
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/FlowWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/FlowWrapper.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/FlowWrapper.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -7,7 +7,7 @@
Integer ROUTER_LAYOUT_SHORTEST_PATH = new Integer(2);
- NodeWrapper getElement(String id);
+ NodeWrapper getNodeWrapper(String id);
Object getRouterLayout();
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelEvent.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelEvent.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelEvent.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -23,24 +23,47 @@
*/
public class ModelEvent {
- private int change;
+ private int changeType;
+ private Object changeDiscriminator;
private Object changedObject;
+ private Object oldValue;
+ private Object newValue;
- public ModelEvent(int change) {
- this.change = change;
- }
+// public ModelEvent(int changeType) {
+// this.changeType = changeType;
+// }
- public ModelEvent(int change, Object changedObject) {
- this.change = change;
+// public ModelEvent(int changeType, Object changedObject) {
+// this.changeType = changeType;
+// this.changedObject = changedObject;
+// }
+
+ public ModelEvent(int changeType, Object changeDiscriminator, Object changedObject,
Object oldValue, Object newValue) {
+ this.changeType = changeType;
+ this.changeDiscriminator = changeDiscriminator;
this.changedObject = changedObject;
+ this.oldValue = oldValue;
+ this.newValue = newValue;
}
- public int getChange() {
- return change;
+ public int getChangeType() {
+ return changeType;
}
+ public Object getChangeDiscriminator() {
+ return changeDiscriminator;
+ }
+
public Object getChangedObject() {
return changedObject;
}
+ public Object getOldValue() {
+ return oldValue;
+ }
+
+ public Object getNewValue() {
+ return newValue;
+ }
+
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java 2009-04-21
17:49:24 UTC (rev 14838)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java 2009-04-21
18:33:28 UTC (rev 14839)
@@ -5,12 +5,12 @@
import org.jboss.tools.flow.common.model.Element;
-public interface Wrapper extends IAdaptable, IPropertySource {
+public interface Wrapper extends IAdaptable, IPropertySource, Element {
- int ADD_INCOMING_CONNECTION = 1;
- int REMOVE_INCOMING_CONNECTION = 2;
- int ADD_OUTGOING_CONNECTION = 3;
- int REMOVE_OUTGOING_CONNECTION = 4;
+// int ADD_INCOMING_CONNECTION = 1;
+// int REMOVE_INCOMING_CONNECTION = 2;
+// int ADD_OUTGOING_CONNECTION = 3;
+// int REMOVE_OUTGOING_CONNECTION = 4;
int CHANGE_VISUAL = 5;
int ADD_ELEMENT = 6;
int REMOVE_ELEMENT = 7;
@@ -21,8 +21,11 @@
void setElement(Element element);
Element getElement();
+ void addChild(Object type, Element element);
+ void removeChild(Object type, Element element);
+
void addListener(ModelListener listener);
void removeListener(ModelListener listener);
- void notifyListeners(int changeId, Object changedObject);
+ void notifyListeners(int changeId, Object changeDiscriminator, Object changedObject,
Object oldValue, Object newValue);
}