[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[CASHeW-s-editor-patches] Nodes changes
From: |
Liu Xianfeng |
Subject: |
[CASHeW-s-editor-patches] Nodes changes |
Date: |
Wed, 16 Mar 2005 15:33:28 -0000 |
Index: plugin.xml
===================================================================
RCS file: /share/darwin/darwin4/cvs/java/plugin.xml,v
retrieving revision 1.3
diff -u -r1.3 plugin.xml
--- plugin.xml 2005/03/13 23:16:57 1.3
+++ plugin.xml 2005/03/16 15:20:49
@@ -9,12 +9,20 @@
<library name="composer.jar"/>
</runtime>
<requires>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.gef"/>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- <import plugin="org.eclipse.xsd.editor"/>
+<import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.eclipse.gef"/>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.ui.views"/>
+ <import plugin="org.eclipse.jface"/>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.ui.workbench"/>
+ <import plugin="org.eclipse.ui.cheatsheets"/>
+ <import plugin="org.eclipse.ui.console"/>
+ <import plugin="org.eclipse.ui.editors"/>
+ <import plugin="org.eclipse.ui.externaltools"/>
+ <import plugin="org.eclipse.ui.forms"/>
+ <import plugin="org.eclipse.ui.ide"/>
+ <import plugin="org.eclipse.ui.intro"/>
</requires>
<extension point="org.eclipse.ui.editors">
Index: src/nongnu/cashews/eclipse/composer/commands/DeleteNodeCommand.java
===================================================================
RCS file:
/share/darwin/darwin4/cvs/java/src/nongnu/cashews/eclipse/composer/commands/
DeleteNodeCommand.java,v
retrieving revision 1.3
diff -u -r1.3 DeleteNodeCommand.java
--- src/nongnu/cashews/eclipse/composer/commands/DeleteNodeCommand.java
2005/02/24 20:13:33 1.3
+++ src/nongnu/cashews/eclipse/composer/commands/DeleteNodeCommand.java
2005/03/16 15:20:49
@@ -2,6 +2,7 @@
import nongnu.cashews.eclipse.composer.model.Diagram;
import nongnu.cashews.eclipse.composer.model.Node;
+import nongnu.cashews.eclipse.composer.model.NodeRegistrar;
import org.eclipse.gef.commands.Command;
@@ -34,6 +35,7 @@
public void execute() {
this.index = this.diagram.getNodes().indexOf(this.node);
this.diagram.removeNode(node);
+ NodeRegistrar.removeNode(node.getName());
}
public void undo() {
Index: src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java
===================================================================
RCS file:
/share/darwin/darwin4/cvs/java/src/nongnu/cashews/eclipse/composer/commands/
RenameNodeCommand.java,v
retrieving revision 1.4
diff -u -r1.4 RenameNodeCommand.java
--- src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java
2005/03/14 15:19:47 1.4
+++ src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java
2005/03/16 15:20:49
@@ -36,7 +36,8 @@
{
if (!NodeRegistrar.renameNode(oldName, newName))
{
- Dialogs.displayErrorDialog("This node already exists.");
+ Dialogs.displayErrorDialog("The node, " + newName
+ + ", already exists.");
return;
}
oldName = this.node.getName();
Index: src/nongnu/cashews/eclipse/composer/model/Diagram.java
===================================================================
RCS file:
/share/darwin/darwin4/cvs/java/src/nongnu/cashews/eclipse/composer/model/Dia
gram.java,v
retrieving revision 1.5
diff -u -r1.5 Diagram.java
--- src/nongnu/cashews/eclipse/composer/model/Diagram.java 2005/03/14
15:19:47 1.5
+++ src/nongnu/cashews/eclipse/composer/model/Diagram.java 2005/03/16
15:20:49
@@ -1,5 +1,8 @@
+
+
package nongnu.cashews.eclipse.composer.model;
+import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -7,49 +10,88 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
-public class Diagram extends Element {
+public class Diagram extends Element implements XMLizable
+{
- // serialization version
- static final long serialVersionUID = 1;
+ // serialization version
+ static final long serialVersionUID = 1;
- // properties
- public static String NODES = "nodes";
+ // properties
+ public static String NODES = "nodes";
- // actual fields
- protected List<Node> nodes = new ArrayList<Node>();
-
- public void addNode(Node node) {
- nodes.add(node);
- fireStructureChange(NODES, nodes);
- }
- public void removeNode(Node node) {
- nodes.remove(node);
- fireStructureChange(NODES, nodes);
- }
- public List getNodes() {
- return this.nodes;
- }
-
-
//------------------------------------------------------------------------
- // I/O
-
- public InputStream getAsStream() throws IOException {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(os);
- out.writeObject(this);
- out.close();
- InputStream istream = new ByteArrayInputStream(os.toByteArray());
- os.close();
- return istream;
- }
-
- public static Diagram makeFromStream(InputStream istream) throws
IOException, ClassNotFoundException {
- ObjectInputStream ois = new ObjectInputStream(istream);
- Diagram diagram = (Diagram) ois.readObject();
- ois.close();
- return diagram;
- }
+ // actual fields
+ protected List<Node> nodes = new ArrayList<Node>();
+
+ public void addNode(Node node)
+ {
+ nodes.add(node);
+ fireStructureChange(NODES, nodes);
+ }
+
+ public void removeNode(Node node)
+ {
+ nodes.remove(node);
+ fireStructureChange(NODES, nodes);
+ }
+
+ public List getNodes()
+ {
+ return this.nodes;
+ }
+
+ //
------------------------------------------------------------------------
+ // I/O
+
+ public InputStream getAsStream() throws IOException
+ {
+ /*ByteArrayOutputStream os = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(os);
+ out.writeObject(this);
+ out.close();
+ InputStream istream = new ByteArrayInputStream(os.toByteArray());
+ os.close();
+ return istream;*/
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ BufferedOutputStream o = new BufferedOutputStream(os);
+ o.write(this.toXML().getBytes());
+ o.close();
+ InputStream istream = new ByteArrayInputStream(os.toByteArray());
+ os.close();
+ return istream;
+ }
+
+ public static Diagram makeFromStream(InputStream istream) throws
IOException,
+ ClassNotFoundException
+ {
+ /*ObjectInputStream ois = new ObjectInputStream(istream);
+ Diagram diagram = (Diagram) ois.readObject();
+ ois.close();
+ return diagram;*/
+ return new Diagram();
+ }
+
+ /* (non-Javadoc)
+ * @see nongnu.cashews.eclipse.composer.model.XMLizable#toXML()
+ */
+ public String toXML()
+ {
+ StringBuffer str = new StringBuffer();
+ str.append("<WorkflowDiagram version=");
+ str.append(serialVersionUID + ">");
+
+ Iterator i = nodes.iterator();
+ Node n;
+
+ while(i.hasNext())
+ {
+ n = (Node)i.next();
+ //str.append(n.toXML());
+ }
+ str.append("</WorkflowDiagram>");
+ return str.toString();
+ }
}
Index: src/nongnu/cashews/eclipse/composer/model/EllipseNode.java
===================================================================
RCS file:
/share/darwin/darwin4/cvs/java/src/nongnu/cashews/eclipse/composer/model/Ell
ipseNode.java,v
retrieving revision 1.5
diff -u -r1.5 EllipseNode.java
--- src/nongnu/cashews/eclipse/composer/model/EllipseNode.java 2005/03/14
12:41:13 1.5
+++ src/nongnu/cashews/eclipse/composer/model/EllipseNode.java 2005/03/16
15:20:50
@@ -1,109 +1,160 @@
+
+
package nongnu.cashews.eclipse.composer.model;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-
-public class EllipseNode extends Node implements IPropertySource {
-
- // serialization version
- static final long serialVersionUID = 4;
-
- // properties
-
- // descriptors for property sheet
- protected static IPropertyDescriptor[] descriptors;
- static {
- descriptors = new IPropertyDescriptor[] {
- new TextPropertyDescriptor(NAME, "Name")};
- }
+public class EllipseNode extends Node implements IPropertySource, XMLizable
+{
- // actual fields
+ // serialization version
+ static final long serialVersionUID = 4;
-public EllipseNode(String name)
-{
- setName(name);
-}
+ // properties
- public void setLocation(Point p) {
- if (location.equals(p)) {
- return;
- }
- location = p;
- firePropertyChange(LOCATION, null, p);
- }
-
- public Point getLocation() {
- return location;
- }
-
- public String getName() {
- return name;
- }
-
- public void addInput(Connection connection) {
- inputs.add(connection);
- fireStructureChange(INPUTS, connection);
- }
-
-
- public void addOutput(Connection connection) {
- outputs.add(connection);
- fireStructureChange(OUTPUTS, connection);
- }
-
- public List getIncomingConnections() {
- return inputs;
- }
-
- public List getOutgoingConnections() {
- return outputs;
- }
-
- public void removeInput(Connection connection) {
- inputs.remove(connection);
- fireStructureChange(INPUTS, connection);
- }
-
- public void removeOutput(Connection connection) {
- outputs.remove(connection);
- fireStructureChange(OUTPUTS, connection);
- }
-
//------------------------------------------------------------------------
- // Abstract methods from IPropertySource
-
- public Object getEditableValue() {
- return this;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return descriptors;
- }
-
- public Object getPropertyValue(Object id) {
- if (NAME.equals(id)) {
- return getName();
+ // descriptors for property sheet
+ protected static IPropertyDescriptor[] descriptors;
+ static
+ {
+ descriptors = new IPropertyDescriptor[] { new TextPropertyDescriptor(
+
NAME,
+
"Name") };
+ }
+
+ // actual fields
+
+ public EllipseNode(String name)
+ {
+ setName(name);
+ }
+
+ public void setLocation(Point p)
+ {
+ if (location.equals(p))
+ {
+ return;
}
- else {
- return null;
+ location = p;
+ firePropertyChange(LOCATION, null, p);
+ }
+
+ public Point getLocation()
+ {
+ return location;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void addInput(Connection connection)
+ {
+ inputs.add(connection);
+ fireStructureChange(INPUTS, connection);
+ }
+
+ public void addOutput(Connection connection)
+ {
+ outputs.add(connection);
+ fireStructureChange(OUTPUTS, connection);
+ }
+
+ public List getIncomingConnections()
+ {
+ return inputs;
+ }
+
+ public List getOutgoingConnections()
+ {
+ return outputs;
+ }
+
+ public void removeInput(Connection connection)
+ {
+ inputs.remove(connection);
+ fireStructureChange(INPUTS, connection);
+ }
+
+ public void removeOutput(Connection connection)
+ {
+ outputs.remove(connection);
+ fireStructureChange(OUTPUTS, connection);
+ }
+
+ //
------------------------------------------------------------------------
+ // Abstract methods from IPropertySource
+
+ public Object getEditableValue()
+ {
+ return this;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors()
+ {
+ return descriptors;
+ }
+
+ public Object getPropertyValue(Object id)
+ {
+ if (NAME.equals(id))
+ {
+ return getName();
}
- }
+ else
+ {
+ return null;
+ }
+ }
- public boolean isPropertySet(Object id) {
- return true;
- }
-
- public void resetPropertyValue(Object id) {
- // do nothing
- }
-
- public void setPropertyValue(Object id, Object value) {
- if (id == NAME) {
- setName((String)value);
+ public boolean isPropertySet(Object id)
+ {
+ return true;
+ }
+
+ public void resetPropertyValue(Object id)
+ {
+ // do nothing
+ }
+
+ public void setPropertyValue(Object id, Object value)
+ {
+ if (id == NAME)
+ {
+ setName((String) value);
}
- }
+ }
+
+ /* (non-Javadoc)
+ * @see nongnu.cashews.eclipse.composer.model.XMLizable#toXML()
+ */
+ public String toXML()
+ {
+ StringBuffer str = new StringBuffer();
+ str.append("<EllipseNode ");
+ str.append(" name=");
+ str.append(name);
+ str.append(" location = ");
+ str.append(location);
+ str.append(">");
+ Iterator i = outputs.iterator();
+ Node tempNode = null;
+ Connection tempConnection = null;
+ while(i.hasNext())
+ {
+ tempConnection = (Connection)i.next();
+ tempNode = (Node) tempConnection.getTarget();
+ str.append("<OutgoingEdge destination=");
+ str.append(tempNode.getName());
+ str.append("/>");
+ }
+ str.append("</EllipseNode>");
+ return str.toString();
+ }
}
Index: src/nongnu/cashews/eclipse/composer/model/Node.java
===================================================================
RCS file:
/share/darwin/darwin4/cvs/java/src/nongnu/cashews/eclipse/composer/model/Nod
e.java,v
retrieving revision 1.8
diff -u -r1.8 Node.java
--- src/nongnu/cashews/eclipse/composer/model/Node.java 2005/03/16 11:48:13
1.8
+++ src/nongnu/cashews/eclipse/composer/model/Node.java 2005/03/16 15:20:50
@@ -51,11 +51,11 @@
return location;
}
- public void setName(String name)
+ public void setName(String newName)
{
- if (this.name.equals(name))
+ if (newName.equals(name))
return;
- name = name;
+ name = newName;
firePropertyChange(NAME, null, name);
}
Index: src/nongnu/cashews/eclipse/composer/model/NodeRegistrar.java
===================================================================
RCS file:
/share/darwin/darwin4/cvs/java/src/nongnu/cashews/eclipse/composer/model/Nod
eRegistrar.java,v
retrieving revision 1.2
diff -u -r1.2 NodeRegistrar.java
--- src/nongnu/cashews/eclipse/composer/model/NodeRegistrar.java
2005/03/14 15:19:47 1.2
+++ src/nongnu/cashews/eclipse/composer/model/NodeRegistrar.java
2005/03/16 15:20:50
@@ -38,11 +38,16 @@
{
if (registerNewNode(newName))
{
- names.remove(oldName);
+ removeNode(oldName);
return true;
}
else
return false;
+ }
+
+ public static void removeNode(String name)
+ {
+ names.remove(name);
}
}
Index: src/nongnu/cashews/eclipse/composer/model/RectangleNode.java
===================================================================
RCS file:
/share/darwin/darwin4/cvs/java/src/nongnu/cashews/eclipse/composer/model/Rec
tangleNode.java,v
retrieving revision 1.3
diff -u -r1.3 RectangleNode.java
--- src/nongnu/cashews/eclipse/composer/model/RectangleNode.java
2005/03/14 12:41:13 1.3
+++ src/nongnu/cashews/eclipse/composer/model/RectangleNode.java
2005/03/16 15:20:50
@@ -1,3 +1,5 @@
+
+
package nongnu.cashews.eclipse.composer.model;
import java.util.List;
@@ -6,102 +8,154 @@
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+public class RectangleNode extends Node implements IPropertySource,
XMLizable
+{
+
+ // serialization version
+ static final long serialVersionUID = 5;
+
+ // properties
+
+ // descriptors for property sheet
+ protected static IPropertyDescriptor[] descriptors;
+ static
+ {
+ descriptors = new IPropertyDescriptor[] { new TextPropertyDescriptor(
+
NAME,
+
"Name") };
+ }
+
+ // actual fields
+
+ public RectangleNode(String name)
+ {
+ setName(name);
+ }
+
+ public void setLocation(Point p)
+ {
+ if (location.equals(p))
+ {
+ return;
+ }
+ location = p;
+ firePropertyChange(LOCATION, null, p);
+ }
+
+ public Point getLocation()
+ {
+ return location;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void addInput(Connection connection)
+ {
+ inputs.add(connection);
+ fireStructureChange(INPUTS, connection);
+ }
+
+ public void addOutput(Connection connection)
+ {
+ outputs.add(connection);
+ fireStructureChange(OUTPUTS, connection);
+ }
-public class RectangleNode extends Node implements IPropertySource {
+ public List getIncomingConnections()
+ {
+ return super.inputs;
+ }
+
+ public List getOutgoingConnections()
+ {
+ return super.outputs;
+ }
+
+ public void removeInput(Connection connection)
+ {
+ inputs.remove(connection);
+ fireStructureChange(INPUTS, connection);
+ }
- // serialization version
- static final long serialVersionUID = 5;
+ public void removeOutput(Connection connection)
+ {
+ outputs.remove(connection);
+ fireStructureChange(OUTPUTS, connection);
+ }
+
+ //
------------------------------------------------------------------------
+ // Abstract methods from IPropertySource
+
+ public Object getEditableValue()
+ {
+ return this;
+ }
- // properties
-
+ public IPropertyDescriptor[] getPropertyDescriptors()
+ {
+ return descriptors;
+ }
- // descriptors for property sheet
- protected static IPropertyDescriptor[] descriptors;
- static {
- descriptors = new IPropertyDescriptor[] {
- new TextPropertyDescriptor(NAME, "Name")};
- }
-
- // actual fields
-
- public RectangleNode(String name)
- {
- setName(name);
- }
-
-
- public void setLocation(Point p) {
- if (location.equals(p)) {
- return;
- }
- location = p;
- firePropertyChange(LOCATION, null, p);
- }
-
- public Point getLocation() {
- return location;
- }
-
- public String getName() {
- return name;
- }
-
- public void addInput(Connection connection) {
- inputs.add(connection);
- fireStructureChange(INPUTS, connection);
- }
- public void addOutput(Connection connection) {
- outputs.add(connection);
- fireStructureChange(OUTPUTS, connection);
- }
- public List getIncomingConnections() {
- return super.inputs;
- }
-
- public List getOutgoingConnections() {
- return super.outputs;
- }
-
- public void removeInput(Connection connection) {
- inputs.remove(connection);
- fireStructureChange(INPUTS, connection);
- }
- public void removeOutput(Connection connection) {
- outputs.remove(connection);
- fireStructureChange(OUTPUTS, connection);
- }
-
-
//------------------------------------------------------------------------
- // Abstract methods from IPropertySource
-
- public Object getEditableValue() {
- return this;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return descriptors;
- }
-
- public Object getPropertyValue(Object id) {
- if (NAME.equals(id)) {
- return getName();
+ public Object getPropertyValue(Object id)
+ {
+ if (NAME.equals(id))
+ {
+ return getName();
}
- else {
- return null;
+ else
+ {
+ return null;
}
- }
+ }
- public boolean isPropertySet(Object id) {
- return true;
- }
-
- public void resetPropertyValue(Object id) {
- // do nothing
- }
-
- public void setPropertyValue(Object id, Object value) {
- if (id == NAME) {
- setName((String)value);
+ public boolean isPropertySet(Object id)
+ {
+ return true;
+ }
+
+ public void resetPropertyValue(Object id)
+ {
+ // do nothing
+ }
+
+ public void setPropertyValue(Object id, Object value)
+ {
+ if (id == NAME)
+ {
+ setName((String) value);
}
- }
+ }
+
+ /* (non-Javadoc)
+ * @see nongnu.cashews.eclipse.composer.model.XMLizable#toXML()
+ */
+ public String toXML()
+ {
+ StringBuffer str = new StringBuffer();
+ str.append("<RectangleNode ");
+ str.append("name=");
+ str.append(name);
+ str.append(" location = ");
+ str.append(location);
+ str.append(">");
+ Node tempNode = null;
+ Connection tempConnection = null;
+ if(outputs.size()>0)
+ {
+ for(int i=0; i<outputs.size();i++)
+ {
+ str.append("<OutgoingEdge destination=");
+ tempConnection = (Connection)outputs.get(i);
+ tempNode = tempConnection.getTarget();
+ str.append(tempNode.getName());
+ str.append("/>");
+ }
+ }
+ str.append("</RectangleNode>");
+ return str.toString();
+ }
}
Index: src/nongnu/cashews/eclipse/composer/model/RectangleNodeFactory.java
===================================================================
RCS file:
/share/darwin/darwin4/cvs/java/src/nongnu/cashews/eclipse/composer/model/Rec
tangleNodeFactory.java,v
retrieving revision 1.2
diff -u -r1.2 RectangleNodeFactory.java
--- src/nongnu/cashews/eclipse/composer/model/RectangleNodeFactory.java
2005/03/14 12:41:13 1.2
+++ src/nongnu/cashews/eclipse/composer/model/RectangleNodeFactory.java
2005/03/16 15:20:50
@@ -8,6 +8,7 @@
public RectangleNodeFactory(Class aClass)
{
super(aClass);
+
}
public Node createNode(String name)
Index: src/nongnu/cashews/eclipse/composer/model/XMLizable.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/XMLizable.java
diff -N src/nongnu/cashews/eclipse/composer/model/XMLizable.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/XMLizable.java 1 Jan 1970
00:00:00 -0000
@@ -0,0 +1,18 @@
+/*
+ * Created on 16-Mar-2005
+ *
+ * Interface that defines a method called toXML which returns
+ * XML representation of the class
+ */
+package nongnu.cashews.eclipse.composer.model;
+
+/**
+ * @author Ravish
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+interface XMLizable
+{
+ public String toXML();
+}