Index: TODO =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/TODO,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 TODO --- TODO 31 Mar 2005 15:25:24 -0000 1.3 +++ TODO 5 May 2005 23:34:44 -0000 @@ -1,24 +1,16 @@ -* RDF - * Parse RDF in XML form -* OWL -* OWL-S -* Eclipse diagram editor - * Serialize/Deserialize - * Extend with all elements for OWL-S +Top priority: +* CASheW-s model +* Instantiate, serialize and send model +* Parse WSDL +* Interface +Nearly completed: * RDF * Parse RDF in XML form -* OWL * OWL-S -* Eclipse diagram editor - * Serialize/Deserialize - * Extend with all elements for OWL-S -* RDF - * Parse RDF in XML form +Postponed: * OWL -* OWL-S * Eclipse diagram editor - * Serialize/Deserialize * Extend with all elements for OWL-S Index: src/nongnu/cashews/eclipse/composer/actions/DiagramActionBarContributor.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/actions/DiagramActionBarContributor.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 DiagramActionBarContributor.java --- src/nongnu/cashews/eclipse/composer/actions/DiagramActionBarContributor.java 31 Mar 2005 17:35:20 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/actions/DiagramActionBarContributor.java 5 May 2005 23:34:44 -0000 @@ -70,6 +70,7 @@ public void contributeToToolBar(IToolBar { toolBarManager.add(getAction(ActionFactory.UNDO.getId())); toolBarManager.add(getAction(ActionFactory.REDO.getId())); + } } Index: src/nongnu/cashews/eclipse/composer/commands/ConnectionCreateCommand.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/commands/ConnectionCreateCommand.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 ConnectionCreateCommand.java --- src/nongnu/cashews/eclipse/composer/commands/ConnectionCreateCommand.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/commands/ConnectionCreateCommand.java 5 May 2005 23:34:44 -0000 @@ -1,54 +1,55 @@ /* ConnectionCreateCommand.java -- Command for creating connections. - Copyright (C) 2005 The University of Sheffield. + Copyright (C) 2005 The University of Sheffield. -This file is part of the CASheW-s editor Eclipse plug-in. + This file is part of the CASheW-s editor Eclipse plug-in. -The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, -and redistribute it under the terms of the GNU General Public License -version 2 (or, at your option, any later version), and/or the Eclipse -Public License version 1.0. + The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, + and redistribute it under the terms of the GNU General Public License + version 2 (or, at your option, any later version), and/or the Eclipse + Public License version 1.0. -The CASheW-s editor is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with The CASheW-s editor; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -The University of Sheffield makes available all content in this plug-in -("Content"). Unless otherwise indicated below, the Content is provided to -you under the terms and conditions of the Eclipse Public License Version -1.0 ("EPL"). A copy of the EPL is available at -http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, -"Program" will mean the Content. - -If you did not receive this Content directly from the University of Sheffield, -the Content is being redistributed by another party ("Redistributor") and -different terms and conditions may apply to your use of any object code in -the Content. Check the Redistributor's license that was provided with the -Content. If no such license exists, contact the Redistributor. Unless -otherwise indicated below, the terms and conditions of the EPL still apply -to any source code in the Content. + The CASheW-s editor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The CASheW-s editor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. + + The University of Sheffield makes available all content in this plug-in + ("Content"). Unless otherwise indicated below, the Content is provided to + you under the terms and conditions of the Eclipse Public License Version + 1.0 ("EPL"). A copy of the EPL is available at + http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, + "Program" will mean the Content. + + If you did not receive this Content directly from the University of Sheffield, + the Content is being redistributed by another party ("Redistributor") and + different terms and conditions may apply to your use of any object code in + the Content. Check the Redistributor's license that was provided with the + Content. If no such license exists, contact the Redistributor. Unless + otherwise indicated below, the terms and conditions of the EPL still apply + to any source code in the Content. + + */ -*/ package nongnu.cashews.eclipse.composer.commands; import java.util.List; -import nongnu.cashews.eclipse.composer.model.Connection; +import nongnu.cashews.eclipse.composer.model.ConnectionElement; import nongnu.cashews.eclipse.composer.model.Node; +import nongnu.cashews.eclipse.composer.ui.ConnectionWindow; import org.eclipse.gef.commands.Command; -public class ConnectionCreateCommand - extends Command +public class ConnectionCreateCommand extends Command { - protected Connection connection; + protected ConnectionElement connection; protected Node source; @@ -61,7 +62,7 @@ public class ConnectionCreateCommand this.source = source; } - public void setConnection(Connection connection) + public void setConnection(ConnectionElement connection) { this.connection = connection; } @@ -82,21 +83,31 @@ public class ConnectionCreateCommand public boolean canExecute() { if (source.equals(target)) - return false; + { + return false; + } // Check for existence of connection already - List connections = this.source.getOutgoingConnections(); - for (int i = 0; i < connections.size(); i++) + if (source.getOutgoingConnections() != null) { - if (((Connection) connections.get(i)).getTarget().equals(target)) - return false; + List connections = this.source.getOutgoingConnections(); + if (connections.size() != 0) + { + for (int i = 0; i < connections.size(); i++) + { + if (((ConnectionElement) connections.get(i)).getTarget().equals(target)) + return false; + } + } } return true; } public void execute() { - this.connection = new Connection(source, target); + this.connection = new ConnectionElement(source, target); + ConnectionWindow cw = new ConnectionWindow(null, connection); + cw.open(); } public void undo() Index: src/nongnu/cashews/eclipse/composer/commands/CreateNodeCommand.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/commands/CreateNodeCommand.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 CreateNodeCommand.java --- src/nongnu/cashews/eclipse/composer/commands/CreateNodeCommand.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/commands/CreateNodeCommand.java 5 May 2005 23:34:44 -0000 @@ -37,12 +37,20 @@ to any source code in the Content. package nongnu.cashews.eclipse.composer.commands; +import java.util.Iterator; +import java.util.Vector; + import nongnu.cashews.eclipse.composer.model.Diagram; import nongnu.cashews.eclipse.composer.model.Node; -import nongnu.cashews.eclipse.composer.model.RectangleNode; +import nongnu.cashews.eclipse.composer.wizards.ProcessData; +import nongnu.cashews.eclipse.composer.wizards.ProcessDefine; import org.eclipse.draw2d.geometry.Point; import org.eclipse.gef.commands.Command; +import org.eclipse.jface.window.ApplicationWindow; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.ui.dialogs.FileSelectionDialog; +import org.eclipse.ui.dialogs.FileSystemElement; public class CreateNodeCommand extends Command @@ -53,10 +61,14 @@ public class CreateNodeCommand private Node node; private Point location; + + public String pName,oName; + + public Vector names; + //ProcessData data = new ProcessData(); public CreateNodeCommand() { - node = new RectangleNode("Fred"); } // setters @@ -64,6 +76,8 @@ public class CreateNodeCommand public void setDiagram(Diagram diagram) { this.diagram = diagram; + DiagramSingleton ds = DiagramSingleton.getInstance(); + ds.setDiagram(diagram); } public void setNode(Node node) @@ -75,7 +89,11 @@ public class CreateNodeCommand { this.location = location; } - + + public void setName(String name){ + this.pName = name; + System.out.println("ccc" + pName); + } // ------------------------------------------------------------------------ // Overridden from Command @@ -85,12 +103,25 @@ public class CreateNodeCommand } public void execute() - { + + { ProcessDefine pd = new ProcessDefine(null); + pd.run(); + pName = pd.getPerformanceName(); + oName = pd.getOperationName(); + //System.out.println("data" + data); + if (pd.status.equals("OK")){ + if (location != null) { + System.out.println(pName); + if (pName != null){ + node.setName(pName + ":" + oName);} node.setLocation(location); } - diagram.addNode(node); + diagram.addNode(node); } + else{ + return; + } } public void undo() Index: src/nongnu/cashews/eclipse/composer/commands/DeleteNodeCommand.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/commands/DeleteNodeCommand.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 DeleteNodeCommand.java --- src/nongnu/cashews/eclipse/composer/commands/DeleteNodeCommand.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/commands/DeleteNodeCommand.java 5 May 2005 23:34:44 -0000 @@ -1,56 +1,59 @@ /* DeleteNodeCommand.java -- Command for deleting nodes. - Copyright (C) 2005 The University of Sheffield. + Copyright (C) 2005 The University of Sheffield. -This file is part of the CASheW-s editor Eclipse plug-in. + This file is part of the CASheW-s editor Eclipse plug-in. -The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, -and redistribute it under the terms of the GNU General Public License -version 2 (or, at your option, any later version), and/or the Eclipse -Public License version 1.0. + The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, + and redistribute it under the terms of the GNU General Public License + version 2 (or, at your option, any later version), and/or the Eclipse + Public License version 1.0. -The CASheW-s editor is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with The CASheW-s editor; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -The University of Sheffield makes available all content in this plug-in -("Content"). Unless otherwise indicated below, the Content is provided to -you under the terms and conditions of the Eclipse Public License Version -1.0 ("EPL"). A copy of the EPL is available at -http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, -"Program" will mean the Content. - -If you did not receive this Content directly from the University of Sheffield, -the Content is being redistributed by another party ("Redistributor") and -different terms and conditions may apply to your use of any object code in -the Content. Check the Redistributor's license that was provided with the -Content. If no such license exists, contact the Redistributor. Unless -otherwise indicated below, the terms and conditions of the EPL still apply -to any source code in the Content. + The CASheW-s editor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The CASheW-s editor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. + + The University of Sheffield makes available all content in this plug-in + ("Content"). Unless otherwise indicated below, the Content is provided to + you under the terms and conditions of the Eclipse Public License Version + 1.0 ("EPL"). A copy of the EPL is available at + http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, + "Program" will mean the Content. + + If you did not receive this Content directly from the University of Sheffield, + the Content is being redistributed by another party ("Redistributor") and + different terms and conditions may apply to your use of any object code in + the Content. Check the Redistributor's license that was provided with the + Content. If no such license exists, contact the Redistributor. Unless + otherwise indicated below, the terms and conditions of the EPL still apply + to any source code in the Content. + + */ -*/ package nongnu.cashews.eclipse.composer.commands; +import nongnu.cashews.eclipse.composer.model.ConnectionElement; 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; -public class DeleteNodeCommand - extends Command +public class DeleteNodeCommand extends Command { private Diagram diagram; private Node node; + private ConnectionElement connection; + + // setters public void setDiagram(Diagram diagram) @@ -63,6 +66,11 @@ public class DeleteNodeCommand this.node = node; } + public void setConnection(ConnectionElement connection) + { + this.connection = connection; + } + // ------------------------------------------------------------------------ // Overridden from Command @@ -73,8 +81,79 @@ public class DeleteNodeCommand public void execute() { + if(diagram.getNodes() == null) + return; + int nodeSize = diagram.getNodes().size(); + for (int i = 0; i < nodeSize; i++) + { + + Node temp = (Node) diagram.getNodes().get(i); + if (temp.getOutgoingConnections() != null) + { + + if (temp.getOutgoingConnections().size() != 0) + { + for (int j = 0; j < temp.getOutgoingConnections().size(); j++) + { + + ConnectionElement outgoing = (ConnectionElement) temp.getOutgoingConnections().get( + j); + if (node.getName().equals(outgoing.getTarget().getName())) + {// temp.removeOutput(cn); + if (temp.getOutgoingConnections().remove(outgoing)) + { + outgoing.getSource().removeOutput(outgoing); + System.out.println("Outgoing Connection Deleted"); + j--; + } + else + { + System.out.println("Outgoing Connection Delete Failed"); + } + + } + + } + } + } + if (temp.getIncomingConnections() != null) + { + if (temp.getIncomingConnections().size() != 0) + { + for (int k = 0; k < temp.getIncomingConnections().size(); k++) + { + + ConnectionElement incoming = (ConnectionElement) temp.getIncomingConnections().get( + k); + + if (node.getName().equals(incoming.getSource().getName())) + { + if (temp.getIncomingConnections().remove(incoming)) + { + incoming.getTarget().removeInput(incoming); + System.out.println("Incoming Connection Deleted"); + k--; + } + else + { + System.out.println("Incoming Delete Failed"); + } + } + + } + } + + } + } + if(node.getOutgoingConnections() != null) + node.getOutgoingConnections().clear(); + if(node.getIncomingConnections()!=null) + node.getIncomingConnections().clear(); + diagram.removeNode(node); NodeRegistrar.removeNode(node.getName()); + + //dp.refreshVisuals(); } public void undo() Index: src/nongnu/cashews/eclipse/composer/commands/DiagramSingleton.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/commands/DiagramSingleton.java diff -N src/nongnu/cashews/eclipse/composer/commands/DiagramSingleton.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/commands/DiagramSingleton.java 5 May 2005 23:34:44 -0000 @@ -0,0 +1,75 @@ +/* DiagramSingleton.java -- For accessing the diagram object. +Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + + +package nongnu.cashews.eclipse.composer.commands; + +import nongnu.cashews.eclipse.composer.model.Diagram; + +/** +* @author Ravish +*/ +public class DiagramSingleton +{ + private Diagram diagram = new Diagram(); + + private static DiagramSingleton ds; + static + { + ds = new DiagramSingleton(); + } + + public static DiagramSingleton getInstance() + { + return ds; + } + + private DiagramSingleton() + { + + } + + public Diagram getDiagram() + { + return diagram; + } + + public void setDiagram(Diagram d) + { + this.diagram = d; + } +} Index: src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 RenameNodeCommand.java --- src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java 5 May 2005 23:34:44 -0000 @@ -37,6 +37,7 @@ to any source code in the Content. package nongnu.cashews.eclipse.composer.commands; +import nongnu.cashews.eclipse.composer.model.Diagram; import nongnu.cashews.eclipse.composer.model.Node; import nongnu.cashews.eclipse.composer.model.NodeRegistrar; import nongnu.cashews.eclipse.composer.util.Dialogs; @@ -46,7 +47,8 @@ import org.eclipse.gef.commands.Command; public class RenameNodeCommand extends Command { - + Diagram diagram; + private Node node; private String newName; @@ -73,15 +75,21 @@ public class RenameNodeCommand return "Rename Node"; } + public boolean canExecute(){ + return false; + } public void execute() - { - if (!NodeRegistrar.renameNode(oldName, newName)) + {/* if (newName.equals("")){ + Dialogs.displayErrorDialog("The name of the node can not be null!"); + return; + } + if (!NodeRegistrar.renameNode(oldName, newName, (Diagram)DiagramSingleton.getInstance().getDiagram())) { Dialogs.displayErrorDialog("The node, " + newName + ", already exists."); return; } oldName = this.node.getName(); - this.node.setName(newName); + this.node.setName(newName);*/ } public void undo() @@ -93,4 +101,9 @@ public class RenameNodeCommand { this.node.setName(newName); } + public void setDiagram(Diagram d) + { + this.diagram = d; + DiagramSingleton.getInstance().setDiagram(d); + } } Index: src/nongnu/cashews/eclipse/composer/figures/EndPointFigure.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/figures/EndPointFigure.java diff -N src/nongnu/cashews/eclipse/composer/figures/EndPointFigure.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/figures/EndPointFigure.java 5 May 2005 23:34:44 -0000 @@ -0,0 +1,113 @@ +/* EllipseNodeFigure.java -- Figure for the elliptical node. +Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.figures; +/** + * @author Xianfeng Liu + */ +import org.eclipse.draw2d.Border; +import org.eclipse.draw2d.Figure; +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.Ellipse; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Insets; +import org.eclipse.draw2d.geometry.Rectangle; + +public class EndPointFigure +extends Figure implements Border +{ + +private String name; + +private Ellipse ellipseFigure; + +private Label label; + +public EndPointFigure() +{ + this.ellipseFigure = new Ellipse(); + this.label = new Label(); + this.add(ellipseFigure); + this.add(label); + this.ellipseFigure.setFillXOR(true); + +} +public String getText() +{ + return this.label.getText(); +} + +public Rectangle getTextBounds() +{ + return this.label.getTextBounds(); +} + +public void setName(String name) +{ + this.name = name; + this.label.setText(name); + this.repaint(); +} + +// ------------------------------------------------------------------------ +// Overridden methods from Figure + +public void setBounds(Rectangle rect) +{ + super.setBounds(rect); + this.ellipseFigure.setBounds(rect); + this.label.setBounds(rect); +} +public Insets getInsets(IFigure figure) +{ + // TODO Auto-generated method stub + return null; +} +public Dimension getPreferredSize(IFigure figure) +{ + // TODO Auto-generated method stub + return null; +} +public void paint(IFigure figure, Graphics graphics, Insets insets) +{ + // TODO Auto-generated method stub + + +} +} Index: src/nongnu/cashews/eclipse/composer/figures/PerformanceNodeFigure.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/figures/PerformanceNodeFigure.java diff -N src/nongnu/cashews/eclipse/composer/figures/PerformanceNodeFigure.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/figures/PerformanceNodeFigure.java 5 May 2005 23:34:44 -0000 @@ -0,0 +1,92 @@ +/* EllipseNodeFigure.java -- Figure for the elliptical node. + Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.figures; + +import org.eclipse.draw2d.Figure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.RoundedRectangle; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Rectangle; + +public class PerformanceNodeFigure + extends Figure +{ + + private String name; + + private RoundedRectangle ellipseFigure; + + private Label label; + + public PerformanceNodeFigure() + { + this.ellipseFigure = new RoundedRectangle(); + Dimension d = new Dimension(40, 40); + this.ellipseFigure.setCornerDimensions(d); + this.label = new Label(); + this.add(ellipseFigure); + this.add(label); + } + + public String getText() + { + return this.label.getText(); + } + + public Rectangle getTextBounds() + { + return this.label.getTextBounds(); + } + + public void setName(String name) + { + this.name = name; + this.label.setText(name); + this.repaint(); + } + + // ------------------------------------------------------------------------ + // Overridden methods from Figure + + public void setBounds(Rectangle rect) + { + super.setBounds(rect); + this.ellipseFigure.setBounds(rect); + this.label.setBounds(rect); + } +} Index: src/nongnu/cashews/eclipse/composer/figures/RectangleNodeFigure.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/figures/RectangleNodeFigure.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 RectangleNodeFigure.java --- src/nongnu/cashews/eclipse/composer/figures/RectangleNodeFigure.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/figures/RectangleNodeFigure.java 5 May 2005 23:34:44 -0000 @@ -55,11 +55,12 @@ public class RectangleNodeFigure public RectangleNodeFigure() { this.rectangleFigure = new RectangleFigure(); + this.rectangleFigure.setFillXOR(true); this.label = new Label(); this.add(rectangleFigure); this.add(label); + } - public String getText() { return this.label.getText(); @@ -76,7 +77,7 @@ public class RectangleNodeFigure this.label.setText(name); this.repaint(); } - + // ------------------------------------------------------------------------ // Overridden methods from Figure Index: src/nongnu/cashews/eclipse/composer/figures/StartPointFigure.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/figures/StartPointFigure.java diff -N src/nongnu/cashews/eclipse/composer/figures/StartPointFigure.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/figures/StartPointFigure.java 5 May 2005 23:34:44 -0000 @@ -0,0 +1,92 @@ +/* EllipseNodeFigure.java -- Figure for the elliptical node. +Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.figures; +/** + * @author Xianfeng Liu + */ +import org.eclipse.draw2d.Figure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.Ellipse; +import org.eclipse.draw2d.geometry.Rectangle; + +public class StartPointFigure +extends Figure +{ + +private String name; + +private Ellipse ellipseFigure; + +private Label label; + +public StartPointFigure() +{ + this.ellipseFigure = new Ellipse(); + this.label = new Label(); + this.add(ellipseFigure); + this.add(label); + this.ellipseFigure.setFillXOR(true); + +} +public String getText() +{ + return this.label.getText(); +} + +public Rectangle getTextBounds() +{ + return this.label.getTextBounds(); +} + +public void setName(String name) +{ + this.name = name; + this.label.setText(name); + this.repaint(); +} + +// ------------------------------------------------------------------------ +// Overridden methods from Figure + +public void setBounds(Rectangle rect) +{ + super.setBounds(rect); + this.ellipseFigure.setBounds(rect); + this.label.setBounds(rect); +} +} Index: src/nongnu/cashews/eclipse/composer/model/ConnectionElement.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/model/ConnectionElement.java diff -N src/nongnu/cashews/eclipse/composer/model/ConnectionElement.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/model/ConnectionElement.java 5 May 2005 23:34:44 -0000 @@ -0,0 +1,99 @@ +/* Connection.java -- A connection between two nodes. + Copyright (C) 2005 The University of Sheffield. + + This file is part of the CASheW-s editor Eclipse plug-in. + + The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, + and redistribute it under the terms of the GNU General Public License + version 2 (or, at your option, any later version), and/or the Eclipse + Public License version 1.0. + + The CASheW-s editor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The CASheW-s editor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. + + The University of Sheffield makes available all content in this plug-in + ("Content"). Unless otherwise indicated below, the Content is provided to + you under the terms and conditions of the Eclipse Public License Version + 1.0 ("EPL"). A copy of the EPL is available at + http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, + "Program" will mean the Content. + + If you did not receive this Content directly from the University of Sheffield, + the Content is being redistributed by another party ("Redistributor") and + different terms and conditions may apply to your use of any object code in + the Content. Check the Redistributor's license that was provided with the + Content. If no such license exists, contact the Redistributor. Unless + otherwise indicated below, the terms and conditions of the EPL still apply + to any source code in the Content. + + */ + + +package nongnu.cashews.eclipse.composer.model; + +import java.util.ArrayList; + +import nongnu.cashews.language.process.Connection; + +public class ConnectionElement extends Element +{ + + /** + * Comment for serialVersionUID + */ + private static final long serialVersionUID = 1L; + + private Node target; + + private Node source; + + private Connection conn; + + public ConnectionElement(Node source, Node target) + { + this.source = source; + this.target = target; + if (target.inputs != null) + { + target.addInput(this); + } + else + { + target.inputs = new ArrayList(); + target.addInput(this); + } + if (source.outputs != null) + { + source.addOutput(this); + } + else + { + source.outputs = new ArrayList(); + source.addOutput(this); + } + + conn = new Connection(); + PerformanceElement sourcePerformNode = (PerformanceElement) source; + conn.setFromPerformance(sourcePerformNode.getPerformance().getName()); + PerformanceElement targetPerformNode = (PerformanceElement) target; + conn.setToPerformance(targetPerformNode.getPerformance().getName()); + + } + + public Node getTarget() + { + return this.target; + } + + public Node getSource() + { + return this.source; + } +} Index: src/nongnu/cashews/eclipse/composer/model/Diagram.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/model/Diagram.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 Diagram.java --- src/nongnu/cashews/eclipse/composer/model/Diagram.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/model/Diagram.java 5 May 2005 23:34:44 -0000 @@ -90,12 +90,6 @@ public List getNodes() 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()); Index: src/nongnu/cashews/eclipse/composer/model/DiagramParser.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/model/DiagramParser.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 DiagramParser.java --- src/nongnu/cashews/eclipse/composer/model/DiagramParser.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/model/DiagramParser.java 5 May 2005 23:34:44 -0000 @@ -39,10 +39,8 @@ package nongnu.cashews.eclipse.composer.model; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map; import org.eclipse.draw2d.geometry.Point; @@ -51,6 +49,7 @@ import org.xml.sax.helpers.DefaultHandle /** * @author Ravish + * @author Xianfeng Liu * * */ @@ -60,9 +59,10 @@ public class DiagramParser extends Defau private List sourceList; + boolean duplicateAtTheEnd = false; + private List targetList; - // protected List nodes = new ArrayList(); public DiagramParser() { super(); @@ -73,6 +73,7 @@ public class DiagramParser extends Defau d = new Diagram(); sourceList = new ArrayList(); targetList = new ArrayList(); + } public void endDocument() @@ -81,39 +82,50 @@ public class DiagramParser extends Defau { return; } - Iterator targetNames = targetList.iterator(); - int diagramNodeCount = 0; + Iterator targetNames = targetList.iterator(); + Iterator sourceNames = sourceList.iterator(); + Node sourceNodes = null; + Node targetNodes = null; List diagramNodes = d.getNodes(); - String targetNodeName; - diagramNodeCount = 0; - - while (targetNames.hasNext()) - { - targetNodeName = (String) targetNames.next(); - - Node sourceNode = (Node) diagramNodes.get(diagramNodeCount); - - Iterator j = d.getNodes().iterator(); - Node targetNode; - - while (j.hasNext()) + Iterator diagramIterator = d.getNodes().iterator(); + int counter = 0; + while (sourceNames.hasNext() && targetNames.hasNext()) + { + String tempSourceName = (String) sourceNames.next(); + diagramIterator = d.getNodes().iterator(); + while (diagramIterator.hasNext()) { - targetNode = (Node) j.next(); - if (targetNode.getName().equals(targetNodeName)) + Node tempNode = (Node) diagramIterator.next(); + if (tempSourceName.equals((String) (tempNode.getName()))) { - // if (sourceNode.outputs == null) - - sourceNode.outputs = null; - - sourceNode.outputs = new ArrayList(); - - new Connection(sourceNode, targetNode); + sourceNodes = tempNode; + + } } - diagramNodeCount++; + diagramIterator = d.getNodes().iterator(); + String tempTargetNode = (String) targetNames.next(); + while (diagramIterator.hasNext()) + { + Node tempNode = (Node) diagramIterator.next(); + if (tempTargetNode.equals((String) (tempNode.getName()))) + { + targetNodes = tempNode; + + } + } + + if (counter!=0 && sourceNodes.getName().equals(sourceList.get(counter-1))){ + sourceNodes.outputs.add(new ConnectionElement(sourceNodes,targetNodes)); + } + else{ + sourceNodes.outputs = new ArrayList(); + new ConnectionElement(sourceNodes, targetNodes);} + counter++; } - int max = 0; + + /*int max = 0; for (int k = 0; k < d.nodes.size(); k++) { Node cur = (Node) d.nodes.get(k); @@ -123,7 +135,7 @@ public class DiagramParser extends Defau max = tmp; } } - NodeRegistrar.setMax(max); + System.out.println("Max autoId node is: " + max);*/ } @@ -142,7 +154,9 @@ public class DiagramParser extends Defau { p.setLocation(Integer.parseInt(atts.getValue(1)), Integer.parseInt(atts.getValue(2))); - n = new RectangleNode(atts.getValue(0)); + RectangleNodeFactory rFactory = new RectangleNodeFactory( + PerformanceElement.class); + n = rFactory.getNewObject(atts.getValue(0)); n.setLocation(p); n.outputs = null; d.addNode(n); @@ -151,7 +165,8 @@ public class DiagramParser extends Defau { p.setLocation(Integer.parseInt(atts.getValue(1)), Integer.parseInt(atts.getValue(2))); - n = new EllipseNode(atts.getValue(0)); + PerformanceElementFactory eFactory = new PerformanceElementFactory(PerformanceElement.class); + n = eFactory.getNewObject(atts.getValue(0)); n.setLocation(p); n.outputs = null; d.addNode(n); @@ -164,13 +179,18 @@ public class DiagramParser extends Defau String source = s.getName(); String target = (String) atts.getValue(0); sourceList.add(source); + System.out.println("Source node is: " + source); + System.out.println("Target node is: " + target); targetList.add(target); + System.out.println("sourcr list are: " + sourceList); + System.out.println("target list are: " + targetList); + } } public void endElement(String uri, String name, String qName) { - + } public Diagram getDiagram() Index: src/nongnu/cashews/eclipse/composer/model/EndPointNode.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/model/EndPointNode.java diff -N src/nongnu/cashews/eclipse/composer/model/EndPointNode.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/model/EndPointNode.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,174 @@ +package nongnu.cashews.eclipse.composer.model; +/** + * @author Xianfeng Liu + */ +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 EndPointNode + extends Node + implements IPropertySource, XMLizable +{ + + // serialization version + static final long serialVersionUID = 4; + + // properties + + // descriptors for property sheet + static final IPropertyDescriptor[] descriptors; + static + { + descriptors = new IPropertyDescriptor[] { new TextPropertyDescriptor( + NAME, + "Name") }; + } + + // actual fields + + public EndPointNode(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(ConnectionElement connection) + { + inputs.add(connection); + fireStructureChange(INPUTS, connection); + } + + public void addOutput(ConnectionElement connection) + { + + outputs.add(connection); + fireStructureChange(OUTPUTS, connection); + } + + public List getIncomingConnections() + { + return inputs; + } + + public List getOutgoingConnections() + { + return outputs; + } + + public void removeInput(ConnectionElement connection) + { + inputs.remove(connection); + fireStructureChange(INPUTS, connection); + } + + public void removeOutput(ConnectionElement connection) + { + outputs.remove(connection); + fireStructureChange(OUTPUTS, connection); + } + + // ------------------------------------------------------------------------ + // Abstract methods from IPropertySource + + public Object getEditableValue() + { + return this; + } + + 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); + } + } + + /* + * (non-Javadoc) + * + * @see nongnu.cashews.eclipse.composer.model.XMLizable#toXML() + */ + public String toXML() + { + StringBuffer str = new StringBuffer(); + str.append(""); + if(outputs != null && outputs.size() > 0) + { + Iterator i = outputs.iterator(); + Node tempNode = null; + ConnectionElement tempConnection = null; + while (i.hasNext()) + { + tempConnection = (ConnectionElement) i.next(); + tempNode = (Node) tempConnection.getTarget(); + str.append(""); + } + } + str.append(""); + return str.toString(); + } +} Index: src/nongnu/cashews/eclipse/composer/model/EndPointNodeFactory.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/model/EndPointNodeFactory.java diff -N src/nongnu/cashews/eclipse/composer/model/EndPointNodeFactory.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/model/EndPointNodeFactory.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,60 @@ +/* EllipseNodeFactory.java -- Factory for creating ellipse nodes. +Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ +/** +* +* @author Xianfeng Liu +* +* +*/ +package nongnu.cashews.eclipse.composer.model; +/** + * @author Xianfeng Liu + */ +public class EndPointNodeFactory extends NodeFactory +{ + +public EndPointNodeFactory(Class aClass) +{ + super(aClass); +} + +public Node createNode(String name) +{ + return new StartPointNode(name); +} + +} Index: src/nongnu/cashews/eclipse/composer/model/Node.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/model/Node.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 Node.java --- src/nongnu/cashews/eclipse/composer/model/Node.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/model/Node.java 5 May 2005 23:34:45 -0000 @@ -34,7 +34,12 @@ otherwise indicated below, the terms and to any source code in the Content. */ - +/** + * + * @author Xianfeng Liu + * + * + */ package nongnu.cashews.eclipse.composer.model; import java.util.ArrayList; @@ -70,15 +75,14 @@ static NAME, "Name") }; } - // actual fields protected Point location = new Point(0, 0); protected String name = "Node"; -protected List outputs = new ArrayList(5); +protected List outputs = new ArrayList(5); -protected List inputs = new ArrayList(5); +protected List inputs = new ArrayList(5); public abstract String toXML(); @@ -108,13 +112,13 @@ public String getName() return name; } -public void addInput(Connection connection) +public void addInput(ConnectionElement connection) { inputs.add(connection); fireStructureChange(INPUTS, connection); } -public void addOutput(Connection connection) +public void addOutput(ConnectionElement connection) { outputs.add(connection); fireStructureChange(OUTPUTS, connection); @@ -130,13 +134,13 @@ public List getOutgoingConnections() return this.outputs; } -public void removeInput(Connection connection) +public void removeInput(ConnectionElement connection) { this.inputs.remove(connection); fireStructureChange(INPUTS, connection); } -public void removeOutput(Connection connection) +public void removeOutput(ConnectionElement connection) { this.outputs.remove(connection); fireStructureChange(OUTPUTS, connection); Index: src/nongnu/cashews/eclipse/composer/model/NodeFactory.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/model/NodeFactory.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 NodeFactory.java --- src/nongnu/cashews/eclipse/composer/model/NodeFactory.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/model/NodeFactory.java 5 May 2005 23:34:45 -0000 @@ -1,54 +1,60 @@ /* NodeFactory.java -- Factory for creating nodes. - Copyright (C) 2005 The University of Sheffield. + Copyright (C) 2005 The University of Sheffield. -This file is part of the CASheW-s editor Eclipse plug-in. + This file is part of the CASheW-s editor Eclipse plug-in. -The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, -and redistribute it under the terms of the GNU General Public License -version 2 (or, at your option, any later version), and/or the Eclipse -Public License version 1.0. + The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, + and redistribute it under the terms of the GNU General Public License + version 2 (or, at your option, any later version), and/or the Eclipse + Public License version 1.0. -The CASheW-s editor is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with The CASheW-s editor; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -The University of Sheffield makes available all content in this plug-in -("Content"). Unless otherwise indicated below, the Content is provided to -you under the terms and conditions of the Eclipse Public License Version -1.0 ("EPL"). A copy of the EPL is available at -http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, -"Program" will mean the Content. - -If you did not receive this Content directly from the University of Sheffield, -the Content is being redistributed by another party ("Redistributor") and -different terms and conditions may apply to your use of any object code in -the Content. Check the Redistributor's license that was provided with the -Content. If no such license exists, contact the Redistributor. Unless -otherwise indicated below, the terms and conditions of the EPL still apply -to any source code in the Content. + The CASheW-s editor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The CASheW-s editor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. + + The University of Sheffield makes available all content in this plug-in + ("Content"). Unless otherwise indicated below, the Content is provided to + you under the terms and conditions of the Eclipse Public License Version + 1.0 ("EPL"). A copy of the EPL is available at + http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, + "Program" will mean the Content. + + If you did not receive this Content directly from the University of Sheffield, + the Content is being redistributed by another party ("Redistributor") and + different terms and conditions may apply to your use of any object code in + the Content. Check the Redistributor's license that was provided with the + Content. If no such license exists, contact the Redistributor. Unless + otherwise indicated below, the terms and conditions of the EPL still apply + to any source code in the Content. + + */ -*/ package nongnu.cashews.eclipse.composer.model; import java.util.regex.Matcher; import java.util.regex.Pattern; +import nongnu.cashews.eclipse.composer.commands.DiagramSingleton; +import nongnu.cashews.eclipse.composer.wizards.ProcessData; +import nongnu.cashews.eclipse.composer.wizards.ProcessDefine; + import org.eclipse.gef.requests.SimpleFactory; -public abstract class NodeFactory - extends SimpleFactory +public abstract class NodeFactory extends SimpleFactory { - static int autoId; + int autoId; private Node node; + + /** * @param aClass @@ -61,12 +67,25 @@ public abstract class NodeFactory public Node getNewObject() { + do { node = createNode("Untitled" + autoId); ++autoId; } - while (!NodeRegistrar.registerNewNode(node.getName())); + while (!NodeRegistrar.registerNewNode( + node.getName(), + (Diagram) DiagramSingleton.getInstance().getDiagram())); + + /*ProcessDefine pd = new ProcessDefine(null); + pd.run(); + + String name = null; + name = pd.getName(); + NodeRegistrar.registerNewNode( + name, + (Diagram) DiagramSingleton.getInstance().getDiagram()); + node = createNode(name);*/ return node; } @@ -76,16 +95,14 @@ public abstract class NodeFactory Matcher matcher = untitled.matcher(name); if (matcher.matches()) { - int serializedId = Integer.parseInt(matcher.group()); + int serializedId = Integer.parseInt(matcher.group(1)); autoId = serializedId + 1; } + + NodeRegistrar.registerNewNode( + name, + (Diagram) DiagramSingleton.getInstance().getDiagram()); node = createNode(name); - if (!NodeRegistrar.registerNewNode(node.getName())) - { - throw new IllegalStateException("A node with one of the " - + "deserialized names already " - + "exists."); - } return node; } Index: src/nongnu/cashews/eclipse/composer/model/NodeRegistrar.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/model/NodeRegistrar.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 NodeRegistrar.java --- src/nongnu/cashews/eclipse/composer/model/NodeRegistrar.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/model/NodeRegistrar.java 5 May 2005 23:34:45 -0000 @@ -1,77 +1,110 @@ /* NodeRegistrar.java -- Maintains a register of created nodes. - Copyright (C) 2005 The University of Sheffield. + Copyright (C) 2005 The University of Sheffield. -This file is part of the CASheW-s editor Eclipse plug-in. + This file is part of the CASheW-s editor Eclipse plug-in. -The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, -and redistribute it under the terms of the GNU General Public License -version 2 (or, at your option, any later version), and/or the Eclipse -Public License version 1.0. + The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, + and redistribute it under the terms of the GNU General Public License + version 2 (or, at your option, any later version), and/or the Eclipse + Public License version 1.0. -The CASheW-s editor is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with The CASheW-s editor; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -The University of Sheffield makes available all content in this plug-in -("Content"). Unless otherwise indicated below, the Content is provided to -you under the terms and conditions of the Eclipse Public License Version -1.0 ("EPL"). A copy of the EPL is available at -http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, -"Program" will mean the Content. - -If you did not receive this Content directly from the University of Sheffield, -the Content is being redistributed by another party ("Redistributor") and -different terms and conditions may apply to your use of any object code in -the Content. Check the Redistributor's license that was provided with the -Content. If no such license exists, contact the Redistributor. Unless -otherwise indicated below, the terms and conditions of the EPL still apply -to any source code in the Content. + The CASheW-s editor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The CASheW-s editor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. + + The University of Sheffield makes available all content in this plug-in + ("Content"). Unless otherwise indicated below, the Content is provided to + you under the terms and conditions of the Eclipse Public License Version + 1.0 ("EPL"). A copy of the EPL is available at + http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, + "Program" will mean the Content. + + If you did not receive this Content directly from the University of Sheffield, + the Content is being redistributed by another party ("Redistributor") and + different terms and conditions may apply to your use of any object code in + the Content. Check the Redistributor's license that was provided with the + Content. If no such license exists, contact the Redistributor. Unless + otherwise indicated below, the terms and conditions of the EPL still apply + to any source code in the Content. + + */ -*/ package nongnu.cashews.eclipse.composer.model; +import java.util.ArrayList; import java.util.HashSet; +import java.util.Iterator; +import java.util.List; import java.util.Set; + + /** * @author Andrew John Hughes (address@hidden) + * @author Xianfeng Liu (address@hidden) */ + public class NodeRegistrar { private static Set names; - private static int max; + + private static List temps; static { names = new HashSet(); + temps = new ArrayList(); } - public static boolean registerNewNode(String name) + public static boolean registerNewNode(String name, Diagram d) { - if (names.contains(name) || Integer.parseInt(name.substring(8)) <= max ) - return false; - names.add(name); + if(d.nodes == null) + { + return true; + } + Iterator i = d.nodes.iterator(); + names.clear(); + while(i.hasNext()) + { + names.add(((Node)i.next()).getName()); + } + + if (names.contains(name)) + { + return false; + } return true; } - public static void setMax(int x) - { - max = x; - } - public static int getMax() + + public int getMax(Diagram d) { - return max; + int m=0; + int temp=0; + Iterator i = d.nodes.iterator(); + names.clear(); + while(i.hasNext()) + { + temp = (Integer.parseInt(((Node)i.next()).getName().substring(8))); + if (m < temp) + { + m = temp; + } + } + return m; + } - public static boolean renameNode(String oldName, String newName) + + public static boolean renameNode(String oldName, String newName, Diagram d) { - if (registerNewNode(newName)) + if (registerNewNode(newName, d)) { removeNode(oldName); return true; @@ -83,6 +116,7 @@ public class NodeRegistrar public static void removeNode(String name) { names.remove(name); + } } Index: src/nongnu/cashews/eclipse/composer/model/PerformanceElement.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/model/PerformanceElement.java diff -N src/nongnu/cashews/eclipse/composer/model/PerformanceElement.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/model/PerformanceElement.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,256 @@ +/* EllipseNode.java -- Representation of an ellipsical node. + Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ +/** + * + * @author Xianfeng Liu + * + * + */ +package nongnu.cashews.eclipse.composer.model; + +import java.net.URISyntaxException; +import java.util.Iterator; +import java.util.List; + +import nongnu.cashews.eclipse.composer.util.Dialogs; +import nongnu.cashews.language.process.Performance; + +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 PerformanceElement + extends Node + + + implements IPropertySource, XMLizable +{ + + // serialization version + static final long serialVersionUID = 4; + Performance performance; + // properties + + // descriptors for property sheet + static final IPropertyDescriptor[] descriptors; + static + { + descriptors = new IPropertyDescriptor[] { new TextPropertyDescriptor( + NAME, + "Name") }; + } + + // actual fields + + public PerformanceElement(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(ConnectionElement connection) + { + inputs.add(connection); + fireStructureChange(INPUTS, connection); + } + + public void addOutput(ConnectionElement connection) + { + + outputs.add(connection); + fireStructureChange(OUTPUTS, connection); + } + + public List getIncomingConnections() + { + return inputs; + } + + public List getOutgoingConnections() + { + return outputs; + } + + public void removeInput(ConnectionElement connection) + { + inputs.remove(connection); + fireStructureChange(INPUTS, connection); + } + + public void removeOutput(ConnectionElement connection) + { + outputs.remove(connection); + fireStructureChange(OUTPUTS, connection); + } + + // ------------------------------------------------------------------------ + // Abstract methods from IPropertySource + + public Object getEditableValue() + { + return this; + } + + 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); + } + } + + /* + * (non-Javadoc) + * + * @see nongnu.cashews.eclipse.composer.model.XMLizable#toXML() + */ + public String toXML() + { + StringBuffer str = new StringBuffer(); + str.append(""); + if(outputs != null && outputs.size() > 0) + { + Iterator i = outputs.iterator(); + Node tempNode = null; + ConnectionElement tempConnection = null; + while (i.hasNext()) + { + tempConnection = (ConnectionElement) i.next(); + tempNode = (Node) tempConnection.getTarget(); + str.append(""); + } + } + str.append(""); + return str.toString(); + } + + /** + * Retrieves the performance associated with this + * node. + * + * @return the performance. + */ + public Performance getPerformance() + { + return performance; + } + + /** + * Sets the name of the node, and its corresponding + * performance. + * + * @param name the new name of the node. + */ + public void setName(String name) + { + try + { + if (performance == null) + performance = new Performance(name); + else + performance.setName(name); + super.setName(name); + } + catch (URISyntaxException e) + { + Dialogs.displayErrorDialog("Invalid name: " + e); + } + } + +} Index: src/nongnu/cashews/eclipse/composer/model/PerformanceElementFactory.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/model/PerformanceElementFactory.java diff -N src/nongnu/cashews/eclipse/composer/model/PerformanceElementFactory.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/model/PerformanceElementFactory.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,58 @@ +/* EllipseNodeFactory.java -- Factory for creating ellipse nodes. + Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ +/** + * + * @author Xianfeng Liu + * + * + */ +package nongnu.cashews.eclipse.composer.model; + +public class PerformanceElementFactory extends NodeFactory +{ + + public PerformanceElementFactory(Class aClass) + { + super(aClass); + } + + public Node createNode(String name) + { + return new PerformanceElement(name); + } + +} Index: src/nongnu/cashews/eclipse/composer/model/RectangleNode.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/model/RectangleNode.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 RectangleNode.java --- src/nongnu/cashews/eclipse/composer/model/RectangleNode.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/model/RectangleNode.java 5 May 2005 23:34:45 -0000 @@ -34,7 +34,12 @@ otherwise indicated below, the terms and to any source code in the Content. */ - +/** + * + * @author Xianfeng Liu + * + * + */ package nongnu.cashews.eclipse.composer.model; import java.util.List; @@ -90,13 +95,13 @@ public class RectangleNode return name; } - public void addInput(Connection connection) + public void addInput(ConnectionElement connection) { inputs.add(connection); fireStructureChange(INPUTS, connection); } - public void addOutput(Connection connection) + public void addOutput(ConnectionElement connection) { outputs.add(connection); fireStructureChange(OUTPUTS, connection); @@ -112,15 +117,15 @@ public class RectangleNode return super.outputs; } - public void removeInput(Connection connection) + public void removeInput(ConnectionElement connection) { - inputs.remove(connection); + super.inputs.remove(connection); fireStructureChange(INPUTS, connection); } - public void removeOutput(Connection connection) + public void removeOutput(ConnectionElement connection) { - outputs.remove(connection); + super.outputs.remove(connection); fireStructureChange(OUTPUTS, connection); } @@ -187,13 +192,13 @@ public class RectangleNode str.append(">"); Node tempNode = null; - Connection tempConnection = null; - if (outputs.size() > 0) + ConnectionElement tempConnection = null; + if (outputs != null && outputs.size() > 0) { for (int i = 0; i < outputs.size(); i++) { - str.append(" + * + * + */ package nongnu.cashews.eclipse.composer.model; public class RectangleNodeFactory Index: src/nongnu/cashews/eclipse/composer/model/StartPointNode.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/model/StartPointNode.java diff -N src/nongnu/cashews/eclipse/composer/model/StartPointNode.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/model/StartPointNode.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,174 @@ +package nongnu.cashews.eclipse.composer.model; +/** + * @author Xianfeng Liu + */ +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 StartPointNode + extends Node + implements IPropertySource, XMLizable +{ + + // serialization version + static final long serialVersionUID = 4; + + // properties + + // descriptors for property sheet + static final IPropertyDescriptor[] descriptors; + static + { + descriptors = new IPropertyDescriptor[] { new TextPropertyDescriptor( + NAME, + "Name") }; + } + + // actual fields + + public StartPointNode(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(ConnectionElement connection) + { + inputs.add(connection); + fireStructureChange(INPUTS, connection); + } + + public void addOutput(ConnectionElement connection) + { + + outputs.add(connection); + fireStructureChange(OUTPUTS, connection); + } + + public List getIncomingConnections() + { + return inputs; + } + + public List getOutgoingConnections() + { + return outputs; + } + + public void removeInput(ConnectionElement connection) + { + inputs.remove(connection); + fireStructureChange(INPUTS, connection); + } + + public void removeOutput(ConnectionElement connection) + { + outputs.remove(connection); + fireStructureChange(OUTPUTS, connection); + } + + // ------------------------------------------------------------------------ + // Abstract methods from IPropertySource + + public Object getEditableValue() + { + return this; + } + + 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); + } + } + + /* + * (non-Javadoc) + * + * @see nongnu.cashews.eclipse.composer.model.XMLizable#toXML() + */ + public String toXML() + { + StringBuffer str = new StringBuffer(); + str.append(""); + if(outputs != null && outputs.size() > 0) + { + Iterator i = outputs.iterator(); + Node tempNode = null; + ConnectionElement tempConnection = null; + while (i.hasNext()) + { + tempConnection = (ConnectionElement) i.next(); + tempNode = (Node) tempConnection.getTarget(); + str.append(""); + } + } + str.append(""); + return str.toString(); + } +} Index: src/nongnu/cashews/eclipse/composer/model/StartPointNodeFactory.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/model/StartPointNodeFactory.java diff -N src/nongnu/cashews/eclipse/composer/model/StartPointNodeFactory.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/model/StartPointNodeFactory.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,60 @@ +/* EllipseNodeFactory.java -- Factory for creating ellipse nodes. +Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ +/** +* +* @author Xianfeng Liu +* +* +*/ +package nongnu.cashews.eclipse.composer.model; +/** + * @author Xianfeng Liu + */ +public class StartPointNodeFactory extends NodeFactory +{ + +public StartPointNodeFactory(Class aClass) +{ + super(aClass); +} + +public Node createNode(String name) +{ + return new StartPointNode(name); +} + +} Index: src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 ConnectionPart.java --- src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java 5 May 2005 23:34:45 -0000 @@ -37,12 +37,25 @@ to any source code in the Content. package nongnu.cashews.eclipse.composer.parts; -import nongnu.cashews.eclipse.composer.model.Connection; - +import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure; +import nongnu.cashews.eclipse.composer.model.ConnectionElement; +import nongnu.cashews.eclipse.composer.model.PerformanceElement; +import nongnu.cashews.eclipse.composer.model.Node; + +import org.eclipse.draw2d.Ellipse; +import org.eclipse.draw2d.FigureListener; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; import org.eclipse.draw2d.PolygonDecoration; import org.eclipse.draw2d.PolylineConnection; +import org.eclipse.draw2d.RoundedRectangle; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gef.editparts.AbstractConnectionEditPart; +import org.eclipse.gef.editparts.AbstractGraphicalEditPart; public class ConnectionPart extends AbstractConnectionEditPart @@ -51,6 +64,12 @@ public class ConnectionPart // ------------------------------------------------------------------------ // Abstract methods from AbstractEditPart + private String name; + + private Ellipse ellipseFigure; + + private Label label; + protected void createEditPolicies() { // none at present @@ -58,8 +77,10 @@ public class ConnectionPart protected void refreshVisuals() { - PolylineConnection figure = (PolylineConnection) getFigure(); - Connection connx = (Connection) getModel(); + try + { + PolylineConnection figure = (PolylineConnection) getFigure(); + ConnectionElement connx = (ConnectionElement) getModel(); // figure.setRoutingConstraint(MagicHelper.getConnectionBendpoints(connx)); PolygonDecoration decoration = new PolygonDecoration(); @@ -71,6 +92,46 @@ public class ConnectionPart decoration.setFill(true); decoration.setTemplate(decorationPointList); figure.setTargetDecoration(decoration); - + + if (figure.getChildren().size() > 1) + { + figure.remove(ellipseFigure); + } + + ellipseFigure = new Ellipse(); + Dimension d = new Dimension(40, 40); + label = new Label(); + + ellipseFigure.setLocation(midPoint(connx.getSource().getLocation(), connx.getTarget().getLocation())); + + + figure.add(ellipseFigure); + + figure.addFigureListener + ( + new FigureListener() + { + + public void figureMoved(IFigure source) + { + ConnectionElement connx = (ConnectionElement) getModel(); + ellipseFigure.setLocation(midPoint(connx.getSource().getLocation(), connx.getTarget().getLocation())); + } + + } + ); + + } + catch(Exception e) + { + e.printStackTrace(); + System.out.println("Refresh Visuals"); + } + + } + public Point midPoint(Point x, Point y) + { + Point p = new Point ( (x.x + y.x)/2, (x.y + y.y) /2 ); + return p; } } Index: src/nongnu/cashews/eclipse/composer/parts/DiagramPart.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/parts/DiagramPart.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 DiagramPart.java --- src/nongnu/cashews/eclipse/composer/parts/DiagramPart.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/parts/DiagramPart.java 5 May 2005 23:34:45 -0000 @@ -90,6 +90,8 @@ public class DiagramPart ((Diagram) getModel()).removePropertyChangeListener(this); } + + // ------------------------------------------------------------------------ // Abstract methods from AbstractGraphicalEditPart Index: src/nongnu/cashews/eclipse/composer/parts/EndPointNodePart.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/parts/EndPointNodePart.java diff -N src/nongnu/cashews/eclipse/composer/parts/EndPointNodePart.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/parts/EndPointNodePart.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,150 @@ +/* EllipseNodePart.java -- Displayable part of the elliptical node. +Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.parts; +/** + * @author Xianfeng Liu + */ +import java.beans.PropertyChangeListener; +import java.util.List; + +import nongnu.cashews.eclipse.composer.figures.EndPointFigure; +import nongnu.cashews.eclipse.composer.model.EndPointNode; +import nongnu.cashews.eclipse.composer.model.Node; +import nongnu.cashews.eclipse.composer.tools.EndPointNodeCellEditorLocator; +import nongnu.cashews.eclipse.composer.tools.EndPointNodeDirectEditManager; +import org.eclipse.draw2d.IFigure; + +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.NodeEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; + +import org.eclipse.jface.viewers.TextCellEditor; + +public class EndPointNodePart +extends NodePart +implements PropertyChangeListener, NodeEditPart +{ + +// ------------------------------------------------------------------------ +// Overridden from AbstractGraphicalEditPart + +// override activate to register with the model for property changes +public void activate() +{ + if (isActive()) + { + return; + } + super.activate(); + ((EndPointNode) getModel()).addPropertyChangeListener(this); +} + +// override deactivate to deregister with the model +public void deactivate() +{ + if (!isActive()) + { + return; + } + super.deactivate(); + ((EndPointNode) getModel()).removePropertyChangeListener(this); +} + +protected List getModelSourceConnections() +{ + return ((EndPointNode) this.getModel()).getOutgoingConnections(); +} + +protected List getModelTargetConnections() +{ + return ((EndPointNode) this.getModel()).getIncomingConnections(); +} + +// ------------------------------------------------------------------------ +// Overridden from AbstractEditPart + +protected void refreshVisuals() +{ + EndPointNode node = (EndPointNode) this.getModel(); + Point loc = node.getLocation(); + Dimension size = new Dimension(20,20); + Rectangle rectangle = new Rectangle(loc, size); + ((EndPointFigure) this.getFigure()).setName(((Node) this.getModel()).getName()); + + // tells the parent part (in this case DiagramPart) that this part + // and its figure are to be constrained to the given rectangle + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), + rectangle); + + // //////============================================================ + +} + +public void performRequest(Request request) +{ + if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) + { + if (manager == null) + { + EndPointFigure nodeFigure = (EndPointFigure) getFigure(); + manager = new EndPointNodeDirectEditManager( + this, + TextCellEditor.class, + new EndPointNodeCellEditorLocator( + nodeFigure), + nodeFigure); + } + manager.show(); + } +} + +// ------------------------------------------------------------------------ +// Abstract methods from AbstractGraphicalEditPart + +protected IFigure createFigure() +{ + // return new NodeFigure(); + return new EndPointFigure(); +} + + +} Index: src/nongnu/cashews/eclipse/composer/parts/PartFactory.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/parts/PartFactory.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 PartFactory.java --- src/nongnu/cashews/eclipse/composer/parts/PartFactory.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/parts/PartFactory.java 5 May 2005 23:34:45 -0000 @@ -37,10 +37,12 @@ to any source code in the Content. package nongnu.cashews.eclipse.composer.parts; -import nongnu.cashews.eclipse.composer.model.Connection; +import nongnu.cashews.eclipse.composer.model.ConnectionElement; import nongnu.cashews.eclipse.composer.model.Diagram; -import nongnu.cashews.eclipse.composer.model.EllipseNode; +import nongnu.cashews.eclipse.composer.model.PerformanceElement; +import nongnu.cashews.eclipse.composer.model.EndPointNode; import nongnu.cashews.eclipse.composer.model.RectangleNode; +import nongnu.cashews.eclipse.composer.model.StartPointNode; import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPartFactory; @@ -66,15 +68,22 @@ public class PartFactory implements Edit { part = new RectangleNodePart(); } - else if (model instanceof EllipseNode) + else if (model instanceof PerformanceElement) { - part = new EllipseNodePart(); + part = new PerformanceNodePart(); } - else if (model instanceof Connection) + else if (model instanceof ConnectionElement) { part = new ConnectionPart(); } - + else if (model instanceof StartPointNode) + { + part = new StartPointNodePart(); + } + else if (model instanceof EndPointNode) + { + part = new EndPointNodePart(); + } else { return null; Index: src/nongnu/cashews/eclipse/composer/parts/PerformanceNodePart.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/parts/PerformanceNodePart.java diff -N src/nongnu/cashews/eclipse/composer/parts/PerformanceNodePart.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/parts/PerformanceNodePart.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,149 @@ +/* EllipseNodePart.java -- Displayable part of the elliptical node. + Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.parts; + +import java.beans.PropertyChangeListener; +import java.util.List; + +import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure; +import nongnu.cashews.eclipse.composer.model.PerformanceElement; +import nongnu.cashews.eclipse.composer.model.Node; +import nongnu.cashews.eclipse.composer.tools.PerformanceNodeCellEditorLocator; +import nongnu.cashews.eclipse.composer.tools.PerformanceNodeDirectEditManager; + +import org.eclipse.draw2d.IFigure; + +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.NodeEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; + +import org.eclipse.jface.viewers.TextCellEditor; + +public class PerformanceNodePart + extends NodePart + implements PropertyChangeListener, NodeEditPart +{ + + // ------------------------------------------------------------------------ + // Overridden from AbstractGraphicalEditPart + + // override activate to register with the model for property changes + public void activate() + { + if (isActive()) + { + return; + } + super.activate(); + ((PerformanceElement) getModel()).addPropertyChangeListener(this); + } + + // override deactivate to deregister with the model + public void deactivate() + { + if (!isActive()) + { + return; + } + super.deactivate(); + ((PerformanceElement) getModel()).removePropertyChangeListener(this); + } + + protected List getModelSourceConnections() + { + return ((PerformanceElement) this.getModel()).getOutgoingConnections(); + } + + protected List getModelTargetConnections() + { + return ((PerformanceElement) this.getModel()).getIncomingConnections(); + } + + // ------------------------------------------------------------------------ + // Overridden from AbstractEditPart + + protected void refreshVisuals() + { + PerformanceElement node = (PerformanceElement) this.getModel(); + Point loc = node.getLocation(); + Dimension size = new Dimension(120, 70); + Rectangle rectangle = new Rectangle(loc, size); + + ((PerformanceNodeFigure) this.getFigure()).setName(((Node) this.getModel()).getName()); + + // tells the parent part (in this case DiagramPart) that this part + // and its figure are to be constrained to the given rectangle + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), + rectangle); + // //////============================================================ + + } + + public void performRequest(Request request) + { + if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) + { + if (manager == null) + { + PerformanceNodeFigure nodeFigure = (PerformanceNodeFigure) getFigure(); + manager = new PerformanceNodeDirectEditManager( + this, + TextCellEditor.class, + new PerformanceNodeCellEditorLocator( + nodeFigure), + nodeFigure); + } + manager.show(); + } + } + + // ------------------------------------------------------------------------ + // Abstract methods from AbstractGraphicalEditPart + + protected IFigure createFigure() + { + // return new NodeFigure(); + return new PerformanceNodeFigure(); + } + + +} Index: src/nongnu/cashews/eclipse/composer/parts/RectangleNodePart.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/parts/RectangleNodePart.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 RectangleNodePart.java --- src/nongnu/cashews/eclipse/composer/parts/RectangleNodePart.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/parts/RectangleNodePart.java 5 May 2005 23:34:45 -0000 @@ -37,6 +37,7 @@ to any source code in the Content. package nongnu.cashews.eclipse.composer.parts; + import java.beans.PropertyChangeListener; import java.util.List; @@ -45,6 +46,7 @@ import nongnu.cashews.eclipse.composer.m import nongnu.cashews.eclipse.composer.tools.RectangleNodeCellEditorLocator; import nongnu.cashews.eclipse.composer.tools.RectangleNodeDirectEditManager; + import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; @@ -58,7 +60,8 @@ import org.eclipse.jface.viewers.TextCel public class RectangleNodePart extends NodePart implements PropertyChangeListener, NodeEditPart -{ +{ + // ------------------------------------------------------------------------ // Overridden from AbstractGraphicalEditPart @@ -94,7 +97,7 @@ public class RectangleNodePart extends N { return ((RectangleNode) this.getModel()).getIncomingConnections(); } - + // ------------------------------------------------------------------------ // Overridden from AbstractEditPart @@ -102,19 +105,17 @@ public class RectangleNodePart extends N { RectangleNode node = (RectangleNode) this.getModel(); Point loc = node.getLocation(); - Dimension size = new Dimension(150, 40); + Dimension size = new Dimension(400, 10); Rectangle rectangle = new Rectangle(loc, size); - ((RectangleNodeFigure) this.getFigure()).setName(((RectangleNode) this.getModel()).getName()); - // tells the parent part (in this case DiagramPart) that this part // and its figure are to be constrained to the given rectangle ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), - rectangle); + rectangle); // //////============================================================ } - + public void performRequest(Request request) { if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) Index: src/nongnu/cashews/eclipse/composer/parts/StartPointNodePart.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/parts/StartPointNodePart.java diff -N src/nongnu/cashews/eclipse/composer/parts/StartPointNodePart.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/parts/StartPointNodePart.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,153 @@ +/* EllipseNodePart.java -- Displayable part of the elliptical node. +Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.parts; +/** + * @author Xianfeng Liu + */ +import java.beans.PropertyChangeListener; +import java.util.List; + +import nongnu.cashews.eclipse.composer.figures.StartPointFigure; +import nongnu.cashews.eclipse.composer.model.Node; +import nongnu.cashews.eclipse.composer.model.StartPointNode; +import nongnu.cashews.eclipse.composer.tools.StartPointNodeCellEditorLocator; +import nongnu.cashews.eclipse.composer.tools.StartPointNodeDirectEditManager; + +import org.eclipse.draw2d.IFigure; + +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.NodeEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; + +import org.eclipse.jface.viewers.TextCellEditor; + +public class StartPointNodePart +extends NodePart +implements PropertyChangeListener, NodeEditPart +{ + +// ------------------------------------------------------------------------ +// Overridden from AbstractGraphicalEditPart + +// override activate to register with the model for property changes +public void activate() +{ + if (isActive()) + { + return; + } + super.activate(); + ((StartPointNode) getModel()).addPropertyChangeListener(this); +} + +// override deactivate to deregister with the model +public void deactivate() +{ + if (!isActive()) + { + return; + } + super.deactivate(); + ((StartPointNode) getModel()).removePropertyChangeListener(this); +} + +protected List getModelSourceConnections() +{ + return ((StartPointNode) this.getModel()).getOutgoingConnections(); +} + +protected List getModelTargetConnections() +{ + return ((StartPointNode) this.getModel()).getIncomingConnections(); +} + +// ------------------------------------------------------------------------ +// Overridden from AbstractEditPart + +protected void refreshVisuals() +{ + StartPointNode node = (StartPointNode) this.getModel(); + Point loc = node.getLocation(); + Dimension size = new Dimension(20,20); + Dimension sizes = new Dimension(30,30); + Rectangle rectangle = new Rectangle(loc, size); + Rectangle rectangle1 = new Rectangle(loc, sizes); + ((StartPointFigure) this.getFigure()).setName(((Node) this.getModel()).getName()); + + // tells the parent part (in this case DiagramPart) that this part + // and its figure are to be constrained to the given rectangle + ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), + rectangle); + + // //////============================================================ + +} + +public void performRequest(Request request) +{ + if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) + { + if (manager == null) + { + StartPointFigure nodeFigure = (StartPointFigure) getFigure(); + manager = new StartPointNodeDirectEditManager( + this, + TextCellEditor.class, + new StartPointNodeCellEditorLocator( + nodeFigure), + nodeFigure); + } + manager.show(); + } +} + +// ------------------------------------------------------------------------ +// Abstract methods from AbstractGraphicalEditPart + +protected IFigure createFigure() +{ + // return new NodeFigure(); + return new StartPointFigure(); +} + + +} Index: src/nongnu/cashews/eclipse/composer/policies/NodeDirectEditPolicy.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/policies/NodeDirectEditPolicy.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 NodeDirectEditPolicy.java --- src/nongnu/cashews/eclipse/composer/policies/NodeDirectEditPolicy.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/policies/NodeDirectEditPolicy.java 5 May 2005 23:34:45 -0000 @@ -38,11 +38,16 @@ to any source code in the Content. package nongnu.cashews.eclipse.composer.policies; import nongnu.cashews.eclipse.composer.commands.RenameNodeCommand; -import nongnu.cashews.eclipse.composer.figures.EllipseNodeFigure; +import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure; +import nongnu.cashews.eclipse.composer.figures.EndPointFigure; import nongnu.cashews.eclipse.composer.figures.RectangleNodeFigure; -import nongnu.cashews.eclipse.composer.model.EllipseNode; +import nongnu.cashews.eclipse.composer.figures.StartPointFigure; +import nongnu.cashews.eclipse.composer.model.Diagram; +import nongnu.cashews.eclipse.composer.model.PerformanceElement; +import nongnu.cashews.eclipse.composer.model.EndPointNode; import nongnu.cashews.eclipse.composer.model.Node; import nongnu.cashews.eclipse.composer.model.RectangleNode; +import nongnu.cashews.eclipse.composer.model.StartPointNode; import org.eclipse.gef.commands.Command; import org.eclipse.gef.editpolicies.DirectEditPolicy; @@ -59,6 +64,7 @@ public class NodeDirectEditPolicy { RenameNodeCommand cmd = new RenameNodeCommand(); + cmd.setDiagram((Diagram) getHost().getParent().getModel()); cmd.setNode((Node) getHost().getModel()); cmd.setName((String) request.getCellEditor().getValue()); return cmd; @@ -72,10 +78,20 @@ public class NodeDirectEditPolicy String value = (String) request.getCellEditor().getValue(); ((RectangleNodeFigure) getHostFigure()).setName(value); } - else if (nodeType instanceof EllipseNode) + else if (nodeType instanceof PerformanceElement) { String value = (String) request.getCellEditor().getValue(); - ((EllipseNodeFigure) getHostFigure()).setName(value); + ((PerformanceNodeFigure) getHostFigure()).setName(value); } + else if (nodeType instanceof StartPointNode) + { + String value = (String) request.getCellEditor().getValue(); + ((StartPointFigure) getHostFigure()).setName(value); + } + else if (nodeType instanceof EndPointNode) + { + String value = (String) request.getCellEditor().getValue(); + ((EndPointFigure) getHostFigure()).setName(value); + } } } Index: src/nongnu/cashews/eclipse/composer/tools/EndPointNodeCellEditorLocator.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/tools/EndPointNodeCellEditorLocator.java diff -N src/nongnu/cashews/eclipse/composer/tools/EndPointNodeCellEditorLocator.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/tools/EndPointNodeCellEditorLocator.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,71 @@ +/* EllipseNodeCellEditorLocator.java -- Locator for elliptical nodes. +Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.tools; +/** + * @author Xianfeng Liu + */ +import nongnu.cashews.eclipse.composer.figures.EndPointFigure; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Text; + +public class EndPointNodeCellEditorLocator +implements CellEditorLocator +{ + +private EndPointFigure nodeFigure; + +public EndPointNodeCellEditorLocator(EndPointFigure nodeFigure) +{ + this.nodeFigure = nodeFigure; +} + +// ------------------------------------------------------------------------ +// Abstract methods from CellEditorLocator + +public void relocate(CellEditor celleditor) +{ + Text text = (Text) celleditor.getControl(); + Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); + Rectangle rect = this.nodeFigure.getTextBounds(); + text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1); +} +} Index: src/nongnu/cashews/eclipse/composer/tools/EndPointNodeDirectEditManager.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/tools/EndPointNodeDirectEditManager.java diff -N src/nongnu/cashews/eclipse/composer/tools/EndPointNodeDirectEditManager.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/tools/EndPointNodeDirectEditManager.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,142 @@ +/* EllipseNodeDirectEditManager.java -- Manager for direct edits. +Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.tools; +/** + * @author Xianfeng Liu + */ +import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure; +import nongnu.cashews.eclipse.composer.figures.EndPointFigure; +import nongnu.cashews.eclipse.composer.figures.StartPointFigure; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Text; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Dimension; + +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.gef.tools.DirectEditManager; + +public class EndPointNodeDirectEditManager +extends DirectEditManager +{ + +Font scaledFont; + +protected VerifyListener verifyListener; + +protected EndPointFigure endPointFigure; + +public EndPointNodeDirectEditManager(GraphicalEditPart source, + Class editorType, + CellEditorLocator locator, + EndPointFigure endPointFigure) +{ + super(source, editorType, locator); + this.endPointFigure = endPointFigure; +} + +// ------------------------------------------------------------------------ +// Overridden methods from DirectEditManager + +protected void bringDown() +{ + Font disposeFont = this.scaledFont; + this.scaledFont = null; + super.bringDown(); + if (disposeFont != null) + { + disposeFont.dispose(); + } +} + +protected void unhookListeners() +{ + super.unhookListeners(); + Text text = (Text) getCellEditor().getControl(); + text.removeVerifyListener(verifyListener); + verifyListener = null; +} + +// ------------------------------------------------------------------------ +// Abstract methods from DirectEditManager + +protected void initCellEditor() +{ + + verifyListener = new VerifyListener() + { + public void verifyText(VerifyEvent event) + { + Text text = (Text) getCellEditor().getControl(); + String oldText = text.getText(); + String leftText = oldText.substring(0, event.start); + String rightText = oldText.substring(event.end, oldText.length()); + GC gc = new GC(text); + Point size = gc.textExtent(leftText + event.text + rightText); + gc.dispose(); + if (size.x != 0) + { + size = text.computeSize(size.x, SWT.DEFAULT); + } + getCellEditor().getControl().setSize(size.x, size.y); + } + }; + + Text text = (Text) getCellEditor().getControl(); + text.addVerifyListener(verifyListener); + + getCellEditor().setValue(this.endPointFigure.getText()); + IFigure figure = ((GraphicalEditPart) getEditPart()).getFigure(); + scaledFont = figure.getFont(); + FontData data = scaledFont.getFontData()[0]; + Dimension fontSize = new Dimension(0, data.getHeight()); + data.setHeight(fontSize.height); + scaledFont = new Font(null, data); + + text.setFont(scaledFont); + text.selectAll(); +} +} Index: src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeCellEditorLocator.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeCellEditorLocator.java diff -N src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeCellEditorLocator.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeCellEditorLocator.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,70 @@ +/* EllipseNodeCellEditorLocator.java -- Locator for elliptical nodes. + Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.tools; + +import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure; + +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Text; + +public class PerformanceNodeCellEditorLocator + implements CellEditorLocator +{ + + private PerformanceNodeFigure nodeFigure; + + public PerformanceNodeCellEditorLocator(PerformanceNodeFigure nodeFigure) + { + this.nodeFigure = nodeFigure; + } + + // ------------------------------------------------------------------------ + // Abstract methods from CellEditorLocator + + public void relocate(CellEditor celleditor) + { + Text text = (Text) celleditor.getControl(); + Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); + Rectangle rect = this.nodeFigure.getTextBounds(); + text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1); + } +} Index: src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeDirectEditManager.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeDirectEditManager.java diff -N src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeDirectEditManager.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/tools/PerformanceNodeDirectEditManager.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,138 @@ +/* EllipseNodeDirectEditManager.java -- Manager for direct edits. + Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.tools; + +import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Text; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Dimension; + +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.gef.tools.DirectEditManager; + +public class PerformanceNodeDirectEditManager + extends DirectEditManager +{ + + Font scaledFont; + + protected VerifyListener verifyListener; + + protected PerformanceNodeFigure ellipseNodeFigure; + + public PerformanceNodeDirectEditManager(GraphicalEditPart source, + Class editorType, + CellEditorLocator locator, + PerformanceNodeFigure ellipseNodeFigure) + { + super(source, editorType, locator); + this.ellipseNodeFigure = ellipseNodeFigure; + } + + // ------------------------------------------------------------------------ + // Overridden methods from DirectEditManager + + protected void bringDown() + { + Font disposeFont = this.scaledFont; + this.scaledFont = null; + super.bringDown(); + if (disposeFont != null) + { + disposeFont.dispose(); + } + } + + protected void unhookListeners() + { + super.unhookListeners(); + Text text = (Text) getCellEditor().getControl(); + text.removeVerifyListener(verifyListener); + verifyListener = null; + } + + // ------------------------------------------------------------------------ + // Abstract methods from DirectEditManager + + protected void initCellEditor() + { + + verifyListener = new VerifyListener() + { + public void verifyText(VerifyEvent event) + { + Text text = (Text) getCellEditor().getControl(); + String oldText = text.getText(); + String leftText = oldText.substring(0, event.start); + String rightText = oldText.substring(event.end, oldText.length()); + GC gc = new GC(text); + Point size = gc.textExtent(leftText + event.text + rightText); + gc.dispose(); + if (size.x != 0) + { + size = text.computeSize(size.x, SWT.DEFAULT); + } + getCellEditor().getControl().setSize(size.x, size.y); + } + }; + + Text text = (Text) getCellEditor().getControl(); + text.addVerifyListener(verifyListener); + + getCellEditor().setValue(this.ellipseNodeFigure.getText()); + IFigure figure = ((GraphicalEditPart) getEditPart()).getFigure(); + scaledFont = figure.getFont(); + FontData data = scaledFont.getFontData()[0]; + Dimension fontSize = new Dimension(0, data.getHeight()); + data.setHeight(fontSize.height); + scaledFont = new Font(null, data); + + text.setFont(scaledFont); + text.selectAll(); + } +} Index: src/nongnu/cashews/eclipse/composer/tools/RectangleNodeDirectEditManager.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/tools/RectangleNodeDirectEditManager.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 RectangleNodeDirectEditManager.java --- src/nongnu/cashews/eclipse/composer/tools/RectangleNodeDirectEditManager.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/tools/RectangleNodeDirectEditManager.java 5 May 2005 23:34:45 -0000 @@ -36,7 +36,9 @@ to any source code in the Content. */ package nongnu.cashews.eclipse.composer.tools; - +/** + * @author Xianfeng Liu + */ import nongnu.cashews.eclipse.composer.figures.RectangleNodeFigure; import org.eclipse.swt.SWT; Index: src/nongnu/cashews/eclipse/composer/tools/StartPointNodeCellEditorLocator.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/tools/StartPointNodeCellEditorLocator.java diff -N src/nongnu/cashews/eclipse/composer/tools/StartPointNodeCellEditorLocator.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/tools/StartPointNodeCellEditorLocator.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,72 @@ +/* EllipseNodeCellEditorLocator.java -- Locator for elliptical nodes. +Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.tools; +/** + * @author Xianfeng Liu + */ +import nongnu.cashews.eclipse.composer.figures.StartPointFigure; + +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Text; + +public class StartPointNodeCellEditorLocator +implements CellEditorLocator +{ + +private StartPointFigure nodeFigure; + +public StartPointNodeCellEditorLocator(StartPointFigure nodeFigure) +{ + this.nodeFigure = nodeFigure; +} + +// ------------------------------------------------------------------------ +// Abstract methods from CellEditorLocator + +public void relocate(CellEditor celleditor) +{ + Text text = (Text) celleditor.getControl(); + Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); + Rectangle rect = this.nodeFigure.getTextBounds(); + text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1); +} +} Index: src/nongnu/cashews/eclipse/composer/tools/StartPointNodeDirectEditManager.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/tools/StartPointNodeDirectEditManager.java diff -N src/nongnu/cashews/eclipse/composer/tools/StartPointNodeDirectEditManager.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/tools/StartPointNodeDirectEditManager.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,137 @@ +/* EllipseNodeDirectEditManager.java -- Manager for direct edits. +Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.tools; +import nongnu.cashews.eclipse.composer.figures.StartPointFigure; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Text; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Dimension; + +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.gef.tools.DirectEditManager; + +public class StartPointNodeDirectEditManager +extends DirectEditManager +{ + +Font scaledFont; + +protected VerifyListener verifyListener; + +protected StartPointFigure startPointFigure; + +public StartPointNodeDirectEditManager(GraphicalEditPart source, + Class editorType, + CellEditorLocator locator, + StartPointFigure startPointFigure) +{ + super(source, editorType, locator); + this.startPointFigure = startPointFigure; +} + +// ------------------------------------------------------------------------ +// Overridden methods from DirectEditManager + +protected void bringDown() +{ + Font disposeFont = this.scaledFont; + this.scaledFont = null; + super.bringDown(); + if (disposeFont != null) + { + disposeFont.dispose(); + } +} + +protected void unhookListeners() +{ + super.unhookListeners(); + Text text = (Text) getCellEditor().getControl(); + text.removeVerifyListener(verifyListener); + verifyListener = null; +} + +// ------------------------------------------------------------------------ +// Abstract methods from DirectEditManager + +protected void initCellEditor() +{ + + verifyListener = new VerifyListener() + { + public void verifyText(VerifyEvent event) + { + Text text = (Text) getCellEditor().getControl(); + String oldText = text.getText(); + String leftText = oldText.substring(0, event.start); + String rightText = oldText.substring(event.end, oldText.length()); + GC gc = new GC(text); + Point size = gc.textExtent(leftText + event.text + rightText); + gc.dispose(); + if (size.x != 0) + { + size = text.computeSize(size.x, SWT.DEFAULT); + } + getCellEditor().getControl().setSize(size.x, size.y); + } + }; + + Text text = (Text) getCellEditor().getControl(); + text.addVerifyListener(verifyListener); + + getCellEditor().setValue(this.startPointFigure.getText()); + IFigure figure = ((GraphicalEditPart) getEditPart()).getFigure(); + scaledFont = figure.getFont(); + FontData data = scaledFont.getFontData()[0]; + Dimension fontSize = new Dimension(0, data.getHeight()); + data.setHeight(fontSize.height); + scaledFont = new Font(null, data); + + text.setFont(scaledFont); + text.selectAll(); +} +} Index: src/nongnu/cashews/eclipse/composer/ui/ConnectionPage1.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/ui/ConnectionPage1.java diff -N src/nongnu/cashews/eclipse/composer/ui/ConnectionPage1.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/ui/ConnectionPage1.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,50 @@ +package nongnu.cashews.eclipse.composer.ui; + +import java.util.Iterator; + +import nongnu.cashews.eclipse.composer.model.ConnectionElement; +import nongnu.cashews.eclipse.composer.model.PerformanceElement; +import nongnu.cashews.language.process.ValueData; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.List; + +public class ConnectionPage1 extends WizardPage +{ + ConnectionElement gc; + List inputs; + + public ConnectionPage1(ConnectionElement gc) + { + super("Get Inputs"); + this.gc = gc; + } + + public void createControl(Composite parent) + { + Composite composite = new Composite(parent, SWT.NULL); + + GridLayout gridLayout = new GridLayout(2, false); + composite.setLayout(gridLayout); + + new Label (composite, SWT.LEFT).setText("Inputs:"); + //inputs = new List(composite,0); + inputs = new List(composite, SWT.SINGLE); + + setControl(composite); + + /*java.util.List pn = ((PerformanceElement)gc.getSource()).getPerformance().getValueData(); + Iterator i = pn.iterator(); + + while(i.hasNext()) + { + inputs.add(((ValueData)i.next()).toString()); + }*/ + + } + +} Index: src/nongnu/cashews/eclipse/composer/ui/ConnectionWindow.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/ui/ConnectionWindow.java diff -N src/nongnu/cashews/eclipse/composer/ui/ConnectionWindow.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/ui/ConnectionWindow.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,46 @@ + + +package nongnu.cashews.eclipse.composer.ui; + +import nongnu.cashews.eclipse.composer.model.ConnectionElement; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.window.ApplicationWindow; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +public class ConnectionWindow extends ApplicationWindow +{ + ConnectionElement gc; + public String status = null; + + protected Control createContents(Composite parent) + { + ConnectionWizard cw = new ConnectionWizard(gc); + WizardDialog dialog = new WizardDialog(getShell(), cw); + dialog.setBlockOnOpen(true); + int returnCode = dialog.open(); + if (returnCode == Dialog.OK) + { + status = "OK"; + System.out.println("OK"); + } + else + { + status = "Cancelled"; + System.out.println("Cancelled"); + } + + return null; + + } + + public ConnectionWindow(Shell parentShell, ConnectionElement gc) + { + super(parentShell); + this.gc = gc; + } + +} Index: src/nongnu/cashews/eclipse/composer/ui/ConnectionWizard.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/ui/ConnectionWizard.java diff -N src/nongnu/cashews/eclipse/composer/ui/ConnectionWizard.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/ui/ConnectionWizard.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,77 @@ +/* ConnectionWizard.java -- Wizard displayed to collect information when connection is created. +Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ + +package nongnu.cashews.eclipse.composer.ui; + +import nongnu.cashews.eclipse.composer.model.ConnectionElement; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.ui.IWorkbench; + +/** + * @author Ravish + */ +public class ConnectionWizard extends Wizard +{ + ConnectionPage1 cp1; + ConnectionElement gc; + + public ConnectionWizard(ConnectionElement gc) + { + setWindowTitle("Process definition wizard"); + this.gc = gc; + } + + public void addPages() + { + cp1 = new ConnectionPage1(gc); + addPage(cp1); + } + + public boolean performFinish() + { + return false; + } + + public void handleEvent(Event e) + { + + } +} Index: src/nongnu/cashews/eclipse/composer/ui/DiagramCreationWizard.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/ui/DiagramCreationWizard.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 DiagramCreationWizard.java --- src/nongnu/cashews/eclipse/composer/ui/DiagramCreationWizard.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/ui/DiagramCreationWizard.java 5 May 2005 23:34:45 -0000 @@ -98,9 +98,9 @@ class WizardPage extends WizardNewFileCr public WizardPage(IWorkbench aWorkbench, IStructuredSelection selection) { - super("riverPage1", selection); - this.setTitle("Create River Model"); - this.setDescription("Create a new River model"); + super("Workflow Page1", selection); + this.setTitle("Create Workflow Model"); + this.setDescription("Create a new workflow"); this.workbench = aWorkbench; } @@ -134,7 +134,7 @@ class WizardPage extends WizardNewFileCr public void createControl(Composite parent) { super.createControl(parent); - this.setFileName("model.river"); + this.setFileName("cashew.cws"); setPageComplete(validatePage()); } Index: src/nongnu/cashews/eclipse/composer/ui/DiagramEditor.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/ui/DiagramEditor.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 DiagramEditor.java --- src/nongnu/cashews/eclipse/composer/ui/DiagramEditor.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/ui/DiagramEditor.java 5 May 2005 23:34:45 -0000 @@ -89,13 +89,15 @@ public class DiagramEditor extends Graph private boolean savePreviouslyNeeded; - private Diagram diagram = new Diagram(); + private Diagram diagram; public DiagramEditor() { + diagram = new Diagram(); // an EditDomain is a "session" of editing which contains things // like the CommandStack setEditDomain(new DefaultEditDomain(this)); + System.out.println("Diagram Editor created"); } public Diagram getDiagram() @@ -211,6 +213,7 @@ public class DiagramEditor extends Graph try { IFile file = ((IFileEditorInput) getEditorInput()).getFile(); + //file.setContents(this.diagram.getAsStream(), true, false, monitor); file.setContents(this.diagram.getAsStream(), true, false, monitor); getCommandStack().markSaveLocation(); } Index: src/nongnu/cashews/eclipse/composer/ui/PaletteFactory.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/ui/PaletteFactory.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 PaletteFactory.java --- src/nongnu/cashews/eclipse/composer/ui/PaletteFactory.java 31 Mar 2005 17:35:21 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/ui/PaletteFactory.java 5 May 2005 23:34:45 -0000 @@ -40,10 +40,14 @@ package nongnu.cashews.eclipse.composer. import java.util.ArrayList; import java.util.List; -import nongnu.cashews.eclipse.composer.model.EllipseNode; -import nongnu.cashews.eclipse.composer.model.EllipseNodeFactory; +import nongnu.cashews.eclipse.composer.model.PerformanceElement; +import nongnu.cashews.eclipse.composer.model.PerformanceElementFactory; +import nongnu.cashews.eclipse.composer.model.EndPointNode; +import nongnu.cashews.eclipse.composer.model.EndPointNodeFactory; import nongnu.cashews.eclipse.composer.model.RectangleNode; import nongnu.cashews.eclipse.composer.model.RectangleNodeFactory; +import nongnu.cashews.eclipse.composer.model.StartPointNode; +import nongnu.cashews.eclipse.composer.model.StartPointNodeFactory; import org.eclipse.gef.palette.CombinedTemplateCreationEntry; import org.eclipse.gef.palette.ConnectionCreationToolEntry; @@ -83,8 +87,8 @@ private static PaletteContainer createCo List entries = new ArrayList(); ToolEntry tool = new CombinedTemplateCreationEntry( - "Rectangle", - "Create a new RectangleNode", + "Synchronization", + "Create a new Synchronization", RectangleNode.class, new RectangleNodeFactory( RectangleNode.class), @@ -92,11 +96,11 @@ private static PaletteContainer createCo null /* large icon */ ); ToolEntry ellipseTool = new CombinedTemplateCreationEntry( - "EllipseNode", - "Create a new Node", - EllipseNode.class, - new EllipseNodeFactory( - EllipseNode.class), + "Performance", + "Create a new Performance", + PerformanceElement.class, + new PerformanceElementFactory( + PerformanceElement.class), null, /* * small * icon @@ -106,8 +110,40 @@ private static PaletteContainer createCo * icon */ ); - entries.add(tool); + ToolEntry endPointTool = new CombinedTemplateCreationEntry( + "EndPoint", + "Create a new EndPoint", + EndPointNode.class, + new EndPointNodeFactory( + EndPointNode.class), + null, /* + * small + * icon + */ + null /* + * large + * icon + */ +); + ToolEntry startPointTool = new CombinedTemplateCreationEntry( + "StartPoint", + "Create a new StartPoint", + StartPointNode.class, + new StartPointNodeFactory( + StartPointNode.class), + null, /* + * small + * icon + */ + null /* + * large + * icon + */ +); + //entries.add(tool); entries.add(ellipseTool); + //entries.add(startPointTool); + //entries.add(endPointTool); drawer.addAll(entries); return drawer; } Index: src/nongnu/cashews/eclipse/composer/wizards/DataEntry.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/wizards/DataEntry.java diff -N src/nongnu/cashews/eclipse/composer/wizards/DataEntry.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/wizards/DataEntry.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,67 @@ +package nongnu.cashews.eclipse.composer.wizards; + +class DataEntry { + private String input; + + private String valueD; + + private String valueC; + + /** + * Gets the e-mail + * + * @return String + */ + public String getInput() { + return input; + } + + /** + * Sets the e-mail + * + * @param email + * The email to set. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * Gets the first name + * + * @return String + */ + public String getValueD() { + return valueD; + } + + /** + * Sets the first name + * + * @param firstName + * The firstName to set. + */ + public void setValueD(String valueD) { + this.valueD = valueD; + } + + /** + * Gets the last name + * + * @return String + */ + public String getValueC() { + return valueC; + } + + /** + * Sets the last name + * + * @param lastName + * The lastName to set. + */ + public void setValueC(String valueC) { + this.valueC = valueC; + } +} + Index: src/nongnu/cashews/eclipse/composer/wizards/DataEvaluatePage.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/wizards/DataEvaluatePage.java diff -N src/nongnu/cashews/eclipse/composer/wizards/DataEvaluatePage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/wizards/DataEvaluatePage.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,73 @@ +package nongnu.cashews.eclipse.composer.wizards; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.window.ApplicationWindow; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +public class DataEvaluatePage { + Display display = new Display(); + Shell shell = new Shell(display); + + + Label dataValue; + Label dataCollector; + Button evaluate; + + Text dataValueText; + Text dataCollectorText; + + public DataEvaluatePage() { + shell.setText("SWT Temperature Converter"); + shell.setLayout(new GridLayout(4, false)); + dataValue = new Label(shell, SWT.NULL); + dataValue.setText("Data Value: "); + + dataValueText = new Text(shell, SWT.SINGLE | SWT.BORDER); + + dataCollector = new Label(shell, SWT.NULL); + dataCollector.setText("Data Collector: "); + + dataCollectorText = new Text(shell, SWT.SINGLE | SWT.BORDER); + evaluate = new Button(shell, SWT.BORDER); + GridData gridData = new GridData(GridData.FILL_BOTH); + gridData.horizontalSpan = 4; + evaluate.setLayoutData(gridData); + + evaluate.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + shell.close(); + } + }); + + shell.pack(); + shell.open(); + + // Set up the event loop. + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) { + // If no more entries in event queue + display.sleep(); + } + } + + display.dispose(); + } + } Index: src/nongnu/cashews/eclipse/composer/wizards/NamePerformancePage.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/wizards/NamePerformancePage.java diff -N src/nongnu/cashews/eclipse/composer/wizards/NamePerformancePage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/wizards/NamePerformancePage.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,58 @@ + + +package nongnu.cashews.eclipse.composer.wizards; + +import nongnu.cashews.eclipse.composer.model.Node; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; + +class NamePerformancePage extends WizardPage +{ + Text perfomanceName; + public NamePerformancePage() + { + super("Name Performance"); + setTitle("Please give a name"); + setDescription("Please name the performance"); + setPageComplete(false); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) + { + Composite composite = new Composite(parent, SWT.NULL); + GridLayout gridLayout = new GridLayout(2, false); + composite.setLayout(gridLayout); + new Label (composite, SWT.LEFT).setText("Please Name the Performance"); + perfomanceName = new Text(composite, SWT.SINGLE | SWT.BORDER); + perfomanceName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + perfomanceName.setSize(500, 20); + perfomanceName.addListener(SWT.Modify, new Listener() { + public void handleEvent(Event event) { + String text = perfomanceName.getText().trim(); + ((ProcessWizard)getWizard()).data.performanceName = text; + String a = perfomanceName.getText(); + System.out.println("Node name" + a); + if (perfomanceName.getText()!=null){ + setPageComplete(true); + } + else{setPageComplete(false);} + } + }); + setControl(composite); + } +} Index: src/nongnu/cashews/eclipse/composer/wizards/OperationSelectPage.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/wizards/OperationSelectPage.java diff -N src/nongnu/cashews/eclipse/composer/wizards/OperationSelectPage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/wizards/OperationSelectPage.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,52 @@ +package nongnu.cashews.eclipse.composer.wizards; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; + +public class OperationSelectPage extends WizardPage { + Combo OperationTypes; + + public OperationSelectPage() { + super("OperationSelectPage"); + setTitle("Operation Select"); + setDescription("Please the operation to use"); + setPageComplete(false); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + Composite composite = new Composite(parent, SWT.NULL); + composite.setLayout(new GridLayout(2, false)); + new Label(composite, SWT.NULL).setText("Operation Types: "); + OperationTypes = new Combo(composite, SWT.READ_ONLY | SWT.BORDER); + OperationTypes.add("aaa"); + OperationTypes.add("sss"); + OperationTypes.add("ddd"); + OperationTypes.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + OperationTypes.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event event) { + String text = OperationTypes.getText(); + ((ProcessWizard)getWizard()).data.operationName = text; + System.out.println(OperationTypes.getText()); + System.out.println("operation" + text); + if (OperationTypes.getText()!=null){ + setPageComplete(true); + } + else{setPageComplete(false);} + } + }); + + setControl(composite); + } + +} \ No newline at end of file Index: src/nongnu/cashews/eclipse/composer/wizards/ProcessData.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/wizards/ProcessData.java diff -N src/nongnu/cashews/eclipse/composer/wizards/ProcessData.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/wizards/ProcessData.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,16 @@ +package nongnu.cashews.eclipse.composer.wizards; + +public class ProcessData { + + public String performanceName; + public String operationName; + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append("Performance Name:\t" + performanceName.toString() + "\n"); + sb.append("Operation Name:\t" + operationName.toString() + "\n"); + return sb.toString(); + } + + +} + Index: src/nongnu/cashews/eclipse/composer/wizards/ProcessDefine.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/wizards/ProcessDefine.java diff -N src/nongnu/cashews/eclipse/composer/wizards/ProcessDefine.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/wizards/ProcessDefine.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,82 @@ +package nongnu.cashews.eclipse.composer.wizards; + +import nongnu.cashews.eclipse.composer.commands.CreateNodeCommand; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.window.ApplicationWindow; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; + +public class ProcessDefine extends ApplicationWindow { + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite) + */ + public String status = null; + public String pName = null; + public String oName = null; + CreateNodeCommand cn = new CreateNodeCommand(); + protected Control createContents(Composite parent) { + ProcessWizard wizard = new ProcessWizard(this); + WizardDialog dialog = new WizardDialog(getShell(), wizard); + dialog.setBlockOnOpen(true); + int returnCode = dialog.open(); + if(returnCode == Dialog.OK){ + status = "OK"; + System.out.println("OK"); + } + else{ + status = "Cancelled"; + System.out.println("Cancelled");} + + return null; + + } + public void run (){ + ProcessWizard wizard = new ProcessWizard(this); + // ProcessData data = new ProcessData(); + WizardDialog dialog = new WizardDialog(getShell(), wizard); + dialog.setBlockOnOpen(true); + int returnCode = dialog.open(); + if(returnCode == Dialog.OK){ + //if (data!=null) + //System.out.println(data); + status = "OK"; + System.out.println("OK"); + //System.out.println(getName()); + } + else{ + status = "Cancelled"; + System.out.println("Cancelled");} + } + /** + * @param parentShell + */ + public void setpName(String name){ + this.pName = name; + //cn.setName(name); + System.out.println("Ptocess Define: " + name); + } + public String getPerformanceName(){ + return this.pName; + } + public void setoName(String name){ + this.oName = name; + } + public String getOperationName(){ + return this.oName; + } + /*public String getName(){ + return this.name; + }*/ + public ProcessDefine(Shell parentShell) { + super(parentShell); + } +} \ No newline at end of file Index: src/nongnu/cashews/eclipse/composer/wizards/ProcessWizard.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/wizards/ProcessWizard.java diff -N src/nongnu/cashews/eclipse/composer/wizards/ProcessWizard.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/wizards/ProcessWizard.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,105 @@ +package nongnu.cashews.eclipse.composer.wizards; + +import nongnu.cashews.eclipse.composer.commands.CreateNodeCommand; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.window.ApplicationWindow; +import org.eclipse.jface.wizard.WizardDialog; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.*; + +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; + +import org.eclipse.jface.wizard.WizardPage; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.DialogSettings; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.wizard.Wizard; + +// The data model. + +class ProcessWizard extends Wizard { +CreateNodeCommand cn = new CreateNodeCommand(); +ProcessData data = new ProcessData(); +ProcessDefine pd ; +static final String KEY_PERFORMANCE_NAME = "Performance Name"; + + public ProcessWizard(ProcessDefine pd) { + setWindowTitle("Process definition wizard"); + setNeedsProgressMonitor(true); + DialogSettings dialogSettings = new DialogSettings("ProcessInfo"); + setDialogSettings(dialogSettings); + this.pd = pd; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.IWizard#addPages() + */ + public void addPages() { + addPage(new WSDLFileLoadPage()); + addPage(new NamePerformancePage()); + addPage(new OperationSelectPage()); + addPage(new ValueDataSelectedPage()); + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.IWizard#performFinish() + */ + public boolean performFinish() { + if(getDialogSettings() != null) { + getDialogSettings().put(KEY_PERFORMANCE_NAME, data.performanceName); + } + try { + // puts the data into a database ... + getContainer().run(true, true, new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) + throws InvocationTargetException, InterruptedException { + monitor.beginTask("Store data", 100); + monitor.worked(40); + // store data here ... + // System.out.println(data); + pd.setpName(data.performanceName); + pd.setoName(data.operationName); + Thread.sleep(2000); + monitor.done(); + } + }); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + return true; + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.IWizard#performCancel() + */ + public boolean performCancel() { + boolean ans = MessageDialog.openConfirm(getShell(), "Confirmation", "Are you sure to cancel the task?"); + if(ans) + return true; + else{ + ProcessDefine pd = new ProcessDefine(null); + pd.close(); + return false;} + } +} Index: src/nongnu/cashews/eclipse/composer/wizards/ValueDataContentProvider.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/wizards/ValueDataContentProvider.java diff -N src/nongnu/cashews/eclipse/composer/wizards/ValueDataContentProvider.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/wizards/ValueDataContentProvider.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,41 @@ +package nongnu.cashews.eclipse.composer.wizards; + +import java.util.List; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; + +class ValueDataContentProvider implements IStructuredContentProvider { + /** + * Gets the elements + * + * @param inputElement + * the List of elements + * @return Object[] + */ + public Object[] getElements(Object inputElement) { + return ((List) inputElement).toArray(); + } + + /** + * Disposes any resources + */ + public void dispose() { + // Do nothing + } + + /** + * Called when the input changes + * + * @param viewer + * the viewer + * @param oldInput + * the old input + * @param newInput + * the new input + */ + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // Do nothing + } +} + Index: src/nongnu/cashews/eclipse/composer/wizards/ValueDataLabelProvider.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/wizards/ValueDataLabelProvider.java diff -N src/nongnu/cashews/eclipse/composer/wizards/ValueDataLabelProvider.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/wizards/ValueDataLabelProvider.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,84 @@ +package nongnu.cashews.eclipse.composer.wizards; + +import java.util.List; + +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.graphics.Image; + +class ValueDataLabelProvider implements ITableLabelProvider { + /** + * Gets the image for the column + * + * @param element + * the element + * @param columnIndex + * the column index + */ + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + /** + * Gets the text for the column + * + * @param element + * the element + * @param columnIndex + * the column index + */ + public String getColumnText(Object element, int columnIndex) { + DataEntry ae = (DataEntry) element; + switch (columnIndex) { + case 0: + return ae.getValueC(); + case 1: + return ae.getValueD(); + case 2: + return ae.getInput(); + } + return ""; + } + + /** + * Adds a listener + * + * @param listener + * the listener + */ + public void addListener(ILabelProviderListener listener) { + // Do nothing + } + + /** + * Disposes any resources + */ + public void dispose() { + // Do nothing + } + + /** + * Returns true if changing the property for the element would change the + * label + * + * @param element + * the element + * @param property + * the property + */ + public boolean isLabelProperty(Object element, String property) { + return false; + } + + /** + * Removes a listener + * + * @param listener + * the listener + */ + public void removeListener(ILabelProviderListener listener) { + // Do nothing + } +} \ No newline at end of file Index: src/nongnu/cashews/eclipse/composer/wizards/ValueDataSelectedPage.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/wizards/ValueDataSelectedPage.java diff -N src/nongnu/cashews/eclipse/composer/wizards/ValueDataSelectedPage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/wizards/ValueDataSelectedPage.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,106 @@ + + +package nongnu.cashews.eclipse.composer.wizards; + +import java.util.LinkedList; + +import org.eclipse.draw2d.Panel; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.window.ApplicationWindow; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; + +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; + +class ValueDataSelectedPage extends WizardPage +{ + /* + * private Button d; + * + * private Button c; + * + * private Button dr; + */ + + private Table input, valueData; + + private Button add, add2; + + private Panel panel; + + private Label dv, dc; + + private Text dvT, dcT; + + /** + * ComplaintsPage constructor + */ + public ValueDataSelectedPage() + { + super("ValuedataSelectPage"); + setTitle("Value data Select"); + setDescription("Please input the data values "); + setPageComplete(true); + } + + /** + * Creates the page controls + */ + public void createControl(Composite parent) + { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout(3,false)); + LinkedList entries = new LinkedList(); + + input = new Table(composite, SWT.NONE); + input.setLayoutData(new GridData(GridData.FILL_VERTICAL + | GridData.FILL_HORIZONTAL)); + new TableColumn(input, SWT.NULL).setText(" Input "); + input.setHeaderVisible(true); + input.setLinesVisible(true); + for (int i = 0, n = input.getColumnCount(); i < n; i++) + input.getColumn(i).pack(); + Composite composite1 = new Composite(composite, SWT.NONE); + composite1.setLayout(new GridLayout(1,false)); + add = new Button(composite1, SWT.RIGHT); + add.setText("Add->"); + + add2 = new Button(composite1,SWT.RIGHT); + add2.setText("<-Add"); + valueData = new Table(composite, SWT.RIGHT); + + // Set up the table + valueData.setLayoutData(new GridData(GridData.FILL_VERTICAL + | GridData.FILL_HORIZONTAL)); + TableColumn vd = new TableColumn(valueData, SWT.CENTER); + vd.setText(" ValueData "); + valueData.showColumn(vd); + valueData.setHeaderVisible(true); + valueData.setLinesVisible(true); + + for (int i = 0, n = valueData.getColumnCount(); i < n; i++) + valueData.getColumn(i).pack(); + + /** + * + * End + * + */ + setControl(composite); + } + +} Index: src/nongnu/cashews/eclipse/composer/wizards/WSDLFileLoadPage.java =================================================================== RCS file: src/nongnu/cashews/eclipse/composer/wizards/WSDLFileLoadPage.java diff -N src/nongnu/cashews/eclipse/composer/wizards/WSDLFileLoadPage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/eclipse/composer/wizards/WSDLFileLoadPage.java 5 May 2005 23:34:45 -0000 @@ -0,0 +1,92 @@ + + +package nongnu.cashews.eclipse.composer.wizards; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.FileSelectionDialog; + +class WSDLFileLoadPage extends WizardPage +{ + + Button browse, load; + + Text filePath; + //Display display = new Display(); + Shell shell = new Shell(); + public WSDLFileLoadPage() + { + super("WSDL Load"); + setTitle("Please load a WSDL file"); + setDescription("Please specify the path of the file"); + setPageComplete(false); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) + { + Composite composite = new Composite(parent, SWT.NULL); + GridLayout gridLayout = new GridLayout(2, false); + composite.setLayout(gridLayout); + new Label(composite, SWT.UP).setText("Please locate the file!"); + Composite compositeText = new Composite(composite, SWT.NULL); + compositeText.setLayout(new RowLayout()); + filePath = new Text(composite, SWT.SINGLE | SWT.BORDER); + filePath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + filePath.setSize(500, 20); + filePath.addListener(SWT.Modify, new Listener() { + public void handleEvent(Event event) { + if (filePath.getText()!=null){ + setPageComplete(true); + } + else{setPageComplete(false);} + } + }); + Composite compositeButton2 = new Composite(composite, SWT.NULL); + compositeButton2.setLayout(new RowLayout()); + browse = new Button(composite, SWT.RIGHT); + browse.setText("Browse"); + + browse.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(shell, SWT.OPEN); + String file = dialog.open(); + if(file != null) { + try { + + filePath.setText(file); + + } catch (Exception ex) { + ex.printStackTrace(); + + } + } + } + }); + setControl(composite); + } + +} Index: src/nongnu/cashews/language/process/Connection.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/Connection.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 Connection.java --- src/nongnu/cashews/language/process/Connection.java 4 May 2005 07:31:55 -0000 1.1 +++ src/nongnu/cashews/language/process/Connection.java 5 May 2005 23:34:45 -0000 @@ -22,6 +22,7 @@ package nongnu.cashews.language.process; import java.net.URI; +import java.net.URISyntaxException; /** * Represents the connection between two performances, which provides @@ -68,6 +69,49 @@ public class Connection * @serial the index of the destination input. */ private int toIndex; + + /** + * Sets the name of the source performance to that specified. + * + * @param name the name of the source performance. + * @throws URISyntaxException if the supplied name is not a valid URI. + */ + public void setFromPerformance(String name) + throws URISyntaxException + { + setFromPerformance(new URI(name)); + } + + /** + * Sets the name of the source performance to that specified. + * + * @param name the name of the source performance. + */ + public void setFromPerformance(URI name) + { + fromPerformance = name; + } + + /** + * Sets the name of the target performance to that specified. + * + * @param name the name of the target performance. + * @throws URISyntaxException if the supplied name is not a valid URI. + */ + public void setToPerformance(String name) + throws URISyntaxException + { + setToPerformance(new URI(name)); + } + + /** + * Sets the name of the target performance to that specified. + * + * @param name the name of the target performance. + */ + public void setToPerformance(URI name) + { + toPerformance = name; + } } - Index: src/nongnu/cashews/language/process/Performance.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/Performance.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 Performance.java --- src/nongnu/cashews/language/process/Performance.java 4 May 2005 07:31:55 -0000 1.1 +++ src/nongnu/cashews/language/process/Performance.java 5 May 2005 23:34:45 -0000 @@ -22,6 +22,7 @@ package nongnu.cashews.language.process; import java.net.URI; +import java.net.URISyntaxException; import java.util.List; /** @@ -72,4 +73,72 @@ public class Performance */ private List valueCollectors; + /** + * Constructs a new Performance with the + * specified name. + * + * @param name the performance name. + */ + public Performance(String name) + { + + } + + /** + * Constructs a new Performance with the specified name. + * + * @param name the name of the process. + */ + public Performance(URI name) + { + setName(name); + } + + /** + * Sets the name of this performance to that specified. + * + * @param name the name of the performance. + * @throws URISyntaxException if the supplied name is not a valid URI. + */ + public void setName(String name) + throws URISyntaxException + { + setName(new URI(name)); + } + + /** + * Sets the name of this performance to that specified. + * + * @param name the name of the performance. + */ + public void setName(URI name) + { + this.name = name; + } + + /** + * Retrieves the name of this performance. + * + * @return the name of the performance. + */ + public URI getName() + { + return name; + } + + /** + * Retrieves the value datas of this performance + */ + public List getValueData() + { + return valueDatas; + } + + /** + * Retrieves the value collectors of this performance + */ + public List getValueCollectors() + { + return valueCollectors; + } }