Index: src/nongnu/cashews/eclipse/composer/Plugin.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/Plugin.java
diff -N src/nongnu/cashews/eclipse/composer/Plugin.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/Plugin.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,53 @@
+/* Plugin.java -- Wrapper for the plug-in.
+ 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;
+
+import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+// this plugin does nothing beyond the default
+
+public class Plugin
+ extends AbstractUIPlugin
+{
+
+ public Plugin(IPluginDescriptor descriptor)
+ {
+ super(descriptor);
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/actions/DiagramActionBarContributor.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/actions/DiagramActionBarContributor.java
diff -N src/nongnu/cashews/eclipse/composer/actions/DiagramActionBarContributor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/actions/DiagramActionBarContributor.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,75 @@
+/* DiagramActionBarContributor.java -- Toolbar additions for the diagram.
+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.actions;
+
+import org.eclipse.gef.ui.actions.ActionBarContributor;
+import org.eclipse.gef.ui.actions.DeleteRetargetAction;
+import org.eclipse.gef.ui.actions.RedoRetargetAction;
+import org.eclipse.gef.ui.actions.UndoRetargetAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.ui.actions.ActionFactory;
+
+public class DiagramActionBarContributor
+extends ActionBarContributor
+{
+
+// ------------------------------------------------------------------------
+// Abstract methods from GEF ActionBarContributor
+
+protected void buildActions()
+{
+ addRetargetAction(new UndoRetargetAction());
+ addRetargetAction(new RedoRetargetAction());
+ addRetargetAction(new DeleteRetargetAction());
+}
+
+protected void declareGlobalActionKeys()
+{
+ // do nothing
+}
+
+// ------------------------------------------------------------------------
+// Abstract methods from Eclipse EditorActionBarContributor
+
+public void contributeToToolBar(IToolBarManager toolBarManager)
+{
+ toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
+ toolBarManager.add(getAction(ActionFactory.REDO.getId()));
+}
+
+}
Index: src/nongnu/cashews/eclipse/composer/commands/ConnectionCreateCommand.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/commands/ConnectionCreateCommand.java
diff -N src/nongnu/cashews/eclipse/composer/commands/ConnectionCreateCommand.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/commands/ConnectionCreateCommand.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,113 @@
+/* ConnectionCreateCommand.java -- Command for creating connections.
+ 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 java.util.List;
+
+import nongnu.cashews.eclipse.composer.model.Connection;
+import nongnu.cashews.eclipse.composer.model.Node;
+
+import org.eclipse.gef.commands.Command;
+
+public class ConnectionCreateCommand
+ extends Command
+{
+
+ protected Connection connection;
+
+ protected Node source;
+
+ protected Node target;
+
+ // setters
+
+ public void setSource(Node source)
+ {
+ this.source = source;
+ }
+
+ public void setConnection(Connection connection)
+ {
+ this.connection = connection;
+ }
+
+ public void setTarget(Node target)
+ {
+ this.target = target;
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from Command
+
+ public String getLabel()
+ {
+ return "Create Connection";
+ }
+
+ public boolean canExecute()
+ {
+ if (source.equals(target))
+ return false;
+
+ // Check for existence of connection already
+ List connections = this.source.getOutgoingConnections();
+ for (int i = 0; i < connections.size(); i++)
+ {
+ if (((Connection) connections.get(i)).getTarget().equals(target))
+ return false;
+ }
+ return true;
+ }
+
+ public void execute()
+ {
+ this.connection = new Connection(source, target);
+ }
+
+ public void undo()
+ {
+ this.source.removeOutput(this.connection);
+ this.target.removeInput(this.connection);
+ }
+
+ public void redo()
+ {
+ this.source.addOutput(this.connection);
+ this.target.addInput(this.connection);
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/commands/CreateNodeCommand.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/commands/CreateNodeCommand.java
diff -N src/nongnu/cashews/eclipse/composer/commands/CreateNodeCommand.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/commands/CreateNodeCommand.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,105 @@
+/* CreateNodeCommand.java -- Command for creating 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.commands;
+
+import nongnu.cashews.eclipse.composer.model.Diagram;
+import nongnu.cashews.eclipse.composer.model.Node;
+import nongnu.cashews.eclipse.composer.model.RectangleNode;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+
+public class CreateNodeCommand
+ extends Command
+{
+
+ private Diagram diagram;
+
+ private Node node;
+
+ private Point location;
+
+ public CreateNodeCommand()
+ {
+ node = new RectangleNode("Fred");
+ }
+
+ // setters
+
+ public void setDiagram(Diagram diagram)
+ {
+ this.diagram = diagram;
+ }
+
+ public void setNode(Node node)
+ {
+ this.node = node;
+ }
+
+ public void setLocation(Point location)
+ {
+ this.location = location;
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from Command
+
+ public String getLabel()
+ {
+ return "Create Node";
+ }
+
+ public void execute()
+ {
+ if (location != null)
+ {
+ node.setLocation(location);
+ }
+ diagram.addNode(node);
+ }
+
+ public void undo()
+ {
+ diagram.removeNode(node);
+ }
+
+ public void redo()
+ {
+ execute();
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/commands/DeleteNodeCommand.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/commands/DeleteNodeCommand.java
diff -N src/nongnu/cashews/eclipse/composer/commands/DeleteNodeCommand.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/commands/DeleteNodeCommand.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,89 @@
+/* DeleteNodeCommand.java -- Command for deleting 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.commands;
+
+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
+{
+
+ private Diagram diagram;
+
+ private Node node;
+
+ // setters
+
+ public void setDiagram(Diagram diagram)
+ {
+ this.diagram = diagram;
+ }
+
+ public void setNode(Node node)
+ {
+ this.node = node;
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from Command
+
+ public String getLabel()
+ {
+ return "Delete Node";
+ }
+
+ public void execute()
+ {
+ diagram.removeNode(node);
+ NodeRegistrar.removeNode(node.getName());
+ }
+
+ public void undo()
+ {
+ diagram.addNode(node);
+ }
+
+ public void redo()
+ {
+ execute();
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/commands/MoveNodeCommand.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/commands/MoveNodeCommand.java
diff -N src/nongnu/cashews/eclipse/composer/commands/MoveNodeCommand.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/commands/MoveNodeCommand.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,90 @@
+/* MoveNodeCommand.java -- Command for moving 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.commands;
+
+import nongnu.cashews.eclipse.composer.model.Node;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+
+public class MoveNodeCommand
+ extends Command
+{
+
+ private Node node;
+
+ private Point newPos;
+
+ private Point oldPos;
+
+ // setters
+
+ public void setLocation(Point p)
+ {
+ this.newPos = p;
+ }
+
+ public void setNode(Node node)
+ {
+ this.node = node;
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from Command
+
+ public String getLabel()
+ {
+ return "Move Node";
+ }
+
+ public void execute()
+ {
+ oldPos = this.node.getLocation();
+ this.node.setLocation(newPos);
+ }
+
+ public void undo()
+ {
+ this.node.setLocation(oldPos);
+ }
+
+ public void redo()
+ {
+ this.node.setLocation(newPos);
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java
diff -N src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,96 @@
+/* RenameNodeCommand.java -- Command for renaming 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.commands;
+
+import nongnu.cashews.eclipse.composer.model.Node;
+import nongnu.cashews.eclipse.composer.model.NodeRegistrar;
+import nongnu.cashews.eclipse.composer.util.Dialogs;
+
+import org.eclipse.gef.commands.Command;
+
+public class RenameNodeCommand
+ extends Command
+{
+
+ private Node node;
+
+ private String newName;
+
+ private String oldName;
+
+ // setters
+
+ public void setName(String name)
+ {
+ this.newName = name;
+ }
+
+ public void setNode(Node node)
+ {
+ this.node = node;
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from Command
+
+ public String getLabel()
+ {
+ return "Rename Node";
+ }
+
+ public void execute()
+ {
+ if (!NodeRegistrar.renameNode(oldName, newName))
+ {
+ Dialogs.displayErrorDialog("The node, " + newName + ", already exists.");
+ return;
+ }
+ oldName = this.node.getName();
+ this.node.setName(newName);
+ }
+
+ public void undo()
+ {
+ this.node.setName(oldName);
+ }
+
+ public void redo()
+ {
+ this.node.setName(newName);
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/dnd/DiagramTemplateTransferDropTargetListener.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/dnd/DiagramTemplateTransferDropTargetListener.java
diff -N src/nongnu/cashews/eclipse/composer/dnd/DiagramTemplateTransferDropTargetListener.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/dnd/DiagramTemplateTransferDropTargetListener.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,62 @@
+/* DiagramTemplateTransferDropTargetListener.java -- Event handler.
+ 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.dnd;
+
+import nongnu.cashews.eclipse.composer.model.ElementFactory;
+
+import org.eclipse.gef.EditPartViewer;
+import org.eclipse.gef.dnd.TemplateTransferDropTargetListener;
+import org.eclipse.gef.requests.CreationFactory;
+
+public class DiagramTemplateTransferDropTargetListener extends
+ TemplateTransferDropTargetListener
+{
+
+ public DiagramTemplateTransferDropTargetListener(EditPartViewer viewer)
+ {
+ super(viewer);
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from TemplateTransferDropTargetListener
+
+ protected CreationFactory getFactory(Object template)
+ {
+ return new ElementFactory(template);
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/figures/EllipseNodeFigure.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/figures/EllipseNodeFigure.java
diff -N src/nongnu/cashews/eclipse/composer/figures/EllipseNodeFigure.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/figures/EllipseNodeFigure.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,89 @@
+/* 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.Ellipse;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+public class EllipseNodeFigure
+ extends Figure
+{
+
+ private String name;
+
+ private Ellipse ellipseFigure;
+
+ private Label label;
+
+ public EllipseNodeFigure()
+ {
+ this.ellipseFigure = new Ellipse();
+ 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: src/nongnu/cashews/eclipse/composer/figures/RectangleNodeFigure.java
diff -N src/nongnu/cashews/eclipse/composer/figures/RectangleNodeFigure.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/figures/RectangleNodeFigure.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,89 @@
+/* RectangleNodeFigure.java -- Figure for rectangular 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.figures;
+
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+public class RectangleNodeFigure
+ extends Figure
+{
+
+ private String name;
+
+ private RectangleFigure rectangleFigure;
+
+ private Label label;
+
+ public RectangleNodeFigure()
+ {
+ this.rectangleFigure = new RectangleFigure();
+ this.label = new Label();
+ this.add(rectangleFigure);
+ 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.rectangleFigure.setBounds(rect);
+ this.label.setBounds(rect);
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/model/Connection.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/Connection.java
diff -N src/nongnu/cashews/eclipse/composer/model/Connection.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/Connection.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,71 @@
+/* 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;
+
+public class Connection
+ extends Element
+{
+
+ /**
+ * Comment for serialVersionUID
+ */
+ private static final long serialVersionUID = 1L;
+
+ private Node target;
+
+ private Node source;
+
+ public Connection(Node source, Node target)
+ {
+ this.source = source;
+ this.target = target;
+
+ source.addOutput(this);
+ target.addInput(this);
+ }
+
+ public Node getTarget()
+ {
+ return this.target;
+ }
+
+ public Node getSource()
+ {
+ return this.source;
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/model/Diagram.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/Diagram.java
diff -N src/nongnu/cashews/eclipse/composer/model/Diagram.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/Diagram.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,156 @@
+/* Diagram.java -- Representation of the diagram as a whole.
+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.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.io.InputStreamReader;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+public class Diagram
+extends Element
+implements XMLizable
+{
+
+// serialization version
+static final long serialVersionUID = 1;
+
+// properties
+public static final String NODES = "nodes";
+
+// actual fields
+protected List nodes = new ArrayList();
+
+public void addNode(Node node)
+{
+ nodes.add(node);
+ fireStructureChange(NODES, nodes);
+}
+
+public void removeNode(Node node)
+{
+ nodes.remove(node);
+ fireStructureChange(NODES, nodes);
+}
+
+public List getNodes()
+{
+ return this.nodes;
+}
+
+// ------------------------------------------------------------------------
+// I/O
+
+public InputStream getAsStream() throws IOException
+{
+ /*
+ * ByteArrayOutputStream os = new ByteArrayOutputStream();
+ * ObjectOutputStream out = new ObjectOutputStream(os);
+ * out.writeObject(this); out.close(); InputStream istream = new
+ * ByteArrayInputStream(os.toByteArray()); os.close(); return istream;
+ */
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ BufferedOutputStream o = new BufferedOutputStream(os);
+ o.write(this.toXML().getBytes());
+ o.close();
+ InputStream istream = new ByteArrayInputStream(os.toByteArray());
+ os.close();
+ return istream;
+}
+
+public static Diagram makeFromStream(InputStream istream) throws IOException,
+ ClassNotFoundException, Exception
+{
+ /*
+ * ObjectInputStream ois = new ObjectInputStream(istream); Diagram diagram =
+ * (Diagram) ois.readObject(); ois.close(); return diagram;
+ */
+
+ ByteArrayInputStream is = new ByteArrayInputStream(
+ istream.toString().getBytes());
+ BufferedInputStream i = new BufferedInputStream(is);
+
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ DiagramParser handler = new DiagramParser();
+ reader.setContentHandler(handler);
+ reader.setErrorHandler(handler);
+
+ InputStreamReader r = new InputStreamReader(istream);
+
+ reader.parse(new InputSource(r));
+
+ return handler.getDiagram();
+}
+
+/*
+* (non-Javadoc)
+*
+* @see nongnu.cashews.eclipse.composer.model.XMLizable#toXML()
+*/
+public String toXML()
+{
+ StringBuffer str = new StringBuffer();
+ str.append("");
+
+ Iterator i = nodes.iterator();
+ Node n;
+
+ while (i.hasNext())
+ {
+ n = (Node) i.next();
+ str.append(n.toXML());
+ }
+ str.append("");
+ return str.toString();
+}
+
+}
Index: src/nongnu/cashews/eclipse/composer/model/DiagramParser.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/DiagramParser.java
diff -N src/nongnu/cashews/eclipse/composer/model/DiagramParser.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/DiagramParser.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,180 @@
+/* DiagramParser.java -- Deserializer for diagrams.
+ 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 java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.draw2d.geometry.Point;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * @author Ravish
+ *
+ *
+ */
+public class DiagramParser extends DefaultHandler
+{
+ private Diagram d;
+
+ private List sourceList;
+
+ private List targetList;
+
+ // protected List nodes = new ArrayList();
+ public DiagramParser()
+ {
+ super();
+ }
+
+ public void startDocument()
+ {
+ d = new Diagram();
+ sourceList = new ArrayList();
+ targetList = new ArrayList();
+ }
+
+ public void endDocument()
+ {
+ if (d.nodes.size() <= 1)
+ {
+ return;
+ }
+ Iterator targetNames = targetList.iterator();
+
+ int diagramNodeCount = 0;
+ 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())
+ {
+ targetNode = (Node) j.next();
+ if (targetNode.getName().equals(targetNodeName))
+ {
+ // if (sourceNode.outputs == null)
+
+ sourceNode.outputs = null;
+
+ sourceNode.outputs = new ArrayList();
+
+ new Connection(sourceNode, targetNode);
+ }
+ }
+ diagramNodeCount++;
+ }
+ int max = 0;
+ for (int k = 0; k < d.nodes.size(); k++)
+ {
+ Node cur = (Node) d.nodes.get(k);
+ int tmp = Integer.parseInt(cur.getName().substring(8));
+ if (cur.getName().startsWith("Untitled") && tmp > max)
+ {
+ max = tmp;
+ }
+ }
+ NodeRegistrar.setMax(max);
+
+ }
+
+ public void startElement(String uri, String name, String qName,
+ Attributes atts)
+ {
+ if (name.equals("WorkflowDiagram"))
+ {
+ return;
+ }
+ Node n;
+ Point p;
+ p = new Point();
+
+ if (name.equals("RectangleNode"))
+ {
+ p.setLocation(Integer.parseInt(atts.getValue(1)),
+ Integer.parseInt(atts.getValue(2)));
+ n = new RectangleNode(atts.getValue(0));
+ n.setLocation(p);
+ n.outputs = null;
+ d.addNode(n);
+ }
+ else if (name.equals("EllipseNode"))
+ {
+ p.setLocation(Integer.parseInt(atts.getValue(1)),
+ Integer.parseInt(atts.getValue(2)));
+ n = new EllipseNode(atts.getValue(0));
+ n.setLocation(p);
+ n.outputs = null;
+ d.addNode(n);
+ }
+ else if (name.equals("OutgoingEdge"))
+ {
+ List temp = d.getNodes();
+
+ Node s = (Node) temp.get(temp.size() - 1);
+ String source = s.getName();
+ String target = (String) atts.getValue(0);
+ sourceList.add(source);
+ targetList.add(target);
+ }
+ }
+
+ public void endElement(String uri, String name, String qName)
+ {
+
+ }
+
+ public Diagram getDiagram()
+ {
+ return d;
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/model/Element.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/Element.java
diff -N src/nongnu/cashews/eclipse/composer/model/Element.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/Element.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,87 @@
+/* Element.java -- Representation of a diagram element.
+ 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.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+
+// abstract base class of elements in the model
+
+public abstract class Element
+ implements Cloneable, Serializable
+{
+
+ // serialization version
+ static final long serialVersionUID = 1;
+
+ // property change listeners
+ transient protected PropertyChangeSupport listeners = new PropertyChangeSupport(
+ this);
+
+ public void addPropertyChangeListener(PropertyChangeListener listener)
+ {
+ listeners.addPropertyChangeListener(listener);
+ }
+
+ protected void firePropertyChange(String prop, Object old, Object newValue)
+ {
+ listeners.firePropertyChange(prop, old, newValue);
+ }
+
+ protected void fireStructureChange(String prop, Object child)
+ {
+ listeners.firePropertyChange(prop, null, child);
+ }
+
+ // implemented in order to create listeners field
+ private void readObject(ObjectInputStream in) throws IOException,
+ ClassNotFoundException
+ {
+ in.defaultReadObject();
+ listeners = new PropertyChangeSupport(this);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener l)
+ {
+ listeners.removePropertyChangeListener(l);
+ }
+
+}
Index: src/nongnu/cashews/eclipse/composer/model/ElementFactory.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/ElementFactory.java
diff -N src/nongnu/cashews/eclipse/composer/model/ElementFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/ElementFactory.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,75 @@
+/* ElementFactory.java -- Factory for creating diagram elements.
+ 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 org.eclipse.gef.requests.CreationFactory;
+
+public class ElementFactory
+ implements CreationFactory
+{
+
+ private Object template;
+
+ public ElementFactory(Object template)
+ {
+ this.template = template;
+ }
+
+ /**
+ * @see org.eclipse.gef.requests.CreationFactory#getNewObject()
+ */
+ public Object getNewObject()
+ {
+ try
+ {
+ return ((Class) template).newInstance();
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @see org.eclipse.gef.requests.CreationFactory#getObjectType()
+ */
+ public Object getObjectType()
+ {
+ return template;
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/model/EllipseNode.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/EllipseNode.java
diff -N src/nongnu/cashews/eclipse/composer/model/EllipseNode.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/EllipseNode.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,205 @@
+/* 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.
+
+*/
+
+package nongnu.cashews.eclipse.composer.model;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+public class EllipseNode
+ extends Node
+ implements IPropertySource, 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 EllipseNode(String name)
+ {
+ setName(name);
+ }
+
+ public void setLocation(Point p)
+ {
+ if (location.equals(p))
+ {
+ return;
+ }
+ location = p;
+ firePropertyChange(LOCATION, null, p);
+ }
+
+ public Point getLocation()
+ {
+ return location;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void addInput(Connection connection)
+ {
+ inputs.add(connection);
+ fireStructureChange(INPUTS, connection);
+ }
+
+ public void addOutput(Connection connection)
+ {
+ outputs.add(connection);
+ fireStructureChange(OUTPUTS, connection);
+ }
+
+ public List getIncomingConnections()
+ {
+ return inputs;
+ }
+
+ public List getOutgoingConnections()
+ {
+ return outputs;
+ }
+
+ public void removeInput(Connection connection)
+ {
+ inputs.remove(connection);
+ fireStructureChange(INPUTS, connection);
+ }
+
+ public void removeOutput(Connection connection)
+ {
+ outputs.remove(connection);
+ fireStructureChange(OUTPUTS, connection);
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from IPropertySource
+
+ public Object getEditableValue()
+ {
+ return this;
+ }
+
+ public 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("");
+ Iterator i = outputs.iterator();
+ Node tempNode = null;
+ Connection tempConnection = null;
+ while (i.hasNext())
+ {
+ tempConnection = (Connection) i.next();
+ tempNode = (Node) tempConnection.getTarget();
+ str.append("");
+ }
+ str.append("");
+ return str.toString();
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/model/EllipseNodeFactory.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/EllipseNodeFactory.java
diff -N src/nongnu/cashews/eclipse/composer/model/EllipseNodeFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/EllipseNodeFactory.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,53 @@
+/* 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.
+
+*/
+
+package nongnu.cashews.eclipse.composer.model;
+
+public class EllipseNodeFactory extends NodeFactory
+{
+
+ public EllipseNodeFactory(Class aClass)
+ {
+ super(aClass);
+ }
+
+ public Node createNode(String name)
+ {
+ return new EllipseNode(name);
+ }
+
+}
Index: src/nongnu/cashews/eclipse/composer/model/Node.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/Node.java
diff -N src/nongnu/cashews/eclipse/composer/model/Node.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/Node.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,220 @@
+/* Node.java -- Representation of a node in the diagram.
+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 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 abstract class Node
+extends Element
+implements IPropertySource
+{
+
+// serialization version
+static final long serialVersionUID = 4;
+
+// properties
+public static final String LOCATION = "location";
+
+public static final String NAME = "name";
+
+public static final String INPUTS = "inputs";
+
+public static final String OUTPUTS = "outputs";
+
+// descriptors for property sheet
+static final IPropertyDescriptor[] descriptors;
+static
+ {
+ descriptors = new IPropertyDescriptor[] { new TextPropertyDescriptor(
+ NAME,
+ "Name") };
+ }
+
+// actual fields
+protected Point location = new Point(0, 0);
+
+protected String name = "Node";
+
+protected List outputs = new ArrayList(5);
+
+protected List inputs = new ArrayList(5);
+
+public abstract String toXML();
+
+public void setLocation(Point p)
+{
+ if (this.location.equals(p))
+ return;
+ this.location = p;
+ firePropertyChange(LOCATION, null, p);
+}
+
+public Point getLocation()
+{
+ return location;
+}
+
+public void setName(String newName)
+{
+ if (newName.equals(name))
+ return;
+ name = newName;
+ firePropertyChange(NAME, null, name);
+}
+
+public String getName()
+{
+ return name;
+}
+
+public void addInput(Connection connection)
+{
+ inputs.add(connection);
+ fireStructureChange(INPUTS, connection);
+}
+
+public void addOutput(Connection connection)
+{
+ outputs.add(connection);
+ fireStructureChange(OUTPUTS, connection);
+}
+
+public List getIncomingConnections()
+{
+ return this.inputs;
+}
+
+public List getOutgoingConnections()
+{
+ return this.outputs;
+}
+
+public void removeInput(Connection connection)
+{
+ this.inputs.remove(connection);
+ fireStructureChange(INPUTS, connection);
+}
+
+public void removeOutput(Connection connection)
+{
+ this.outputs.remove(connection);
+ fireStructureChange(OUTPUTS, connection);
+}
+
+// ------------------------------------------------------------------------
+// Abstract methods from IPropertySource
+
+public Object getEditableValue()
+{
+ return this;
+}
+
+public IPropertyDescriptor[] getPropertyDescriptors()
+{
+ return descriptors.clone();
+}
+
+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);
+}
+
+/**
+* Provides a unique hashcode for this particular node.
+*
+* @return the hash code for this node.
+*/
+public int hashCode()
+{
+ return 9 * 11 + name.hashCode();
+}
+
+public boolean equals(Object obj)
+{
+ if (obj == this)
+ return true;
+ if (obj instanceof Node)
+ {
+ Node cmpNode = (Node) obj;
+ return getName().equals(cmpNode.getName());
+ }
+ else
+ return false;
+}
+
+/**
+* Returns a String
-based representation of the
+* Node
for debugging purposes.
+*
+* @return a String
-based representation.
+*/
+public String toString()
+{
+ StringBuffer buffer = new StringBuffer(getClass().getName());
+ buffer.append("[name=");
+ buffer.append(name);
+ buffer.append("]");
+ return buffer.toString();
+}
+
+}
Index: src/nongnu/cashews/eclipse/composer/model/NodeFactory.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/NodeFactory.java
diff -N src/nongnu/cashews/eclipse/composer/model/NodeFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/NodeFactory.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,94 @@
+/* NodeFactory.java -- Factory for creating 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.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.gef.requests.SimpleFactory;
+
+public abstract class NodeFactory
+ extends SimpleFactory
+{
+
+ static int autoId;
+
+ private Node node;
+
+ /**
+ * @param aClass
+ */
+ public NodeFactory(Class aClass)
+ {
+ super(aClass);
+ // TODO Auto-generated constructor stub
+ }
+
+ public Node getNewObject()
+ {
+ do
+ {
+ node = createNode("Untitled" + autoId);
+ ++autoId;
+ }
+ while (!NodeRegistrar.registerNewNode(node.getName()));
+ return node;
+ }
+
+ public Node getNewObject(String name)
+ {
+ Pattern untitled = Pattern.compile("Untitled([0-9]*)");
+ Matcher matcher = untitled.matcher(name);
+ if (matcher.matches())
+ {
+ int serializedId = Integer.parseInt(matcher.group());
+ autoId = serializedId + 1;
+ }
+ node = createNode(name);
+ if (!NodeRegistrar.registerNewNode(node.getName()))
+ {
+ throw new IllegalStateException("A node with one of the "
+ + "deserialized names already "
+ + "exists.");
+ }
+ return node;
+ }
+
+ public abstract Node createNode(String name);
+
+}
Index: src/nongnu/cashews/eclipse/composer/model/NodeRegistrar.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/NodeRegistrar.java
diff -N src/nongnu/cashews/eclipse/composer/model/NodeRegistrar.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/NodeRegistrar.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,88 @@
+/* NodeRegistrar.java -- Maintains a register of created 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.HashSet;
+import java.util.Set;
+
+/**
+ * @author Andrew John Hughes (address@hidden)
+ */
+public class NodeRegistrar
+{
+
+ private static Set names;
+ private static int max;
+
+ static
+ {
+ names = new HashSet();
+ }
+
+ public static boolean registerNewNode(String name)
+ {
+ if (names.contains(name) || Integer.parseInt(name.substring(8)) <= max )
+ return false;
+ names.add(name);
+ return true;
+ }
+ public static void setMax(int x)
+ {
+ max = x;
+ }
+ public static int getMax()
+ {
+ return max;
+ }
+ public static boolean renameNode(String oldName, String newName)
+ {
+ if (registerNewNode(newName))
+ {
+ removeNode(oldName);
+ return true;
+ }
+ else
+ return false;
+ }
+
+ public static void removeNode(String name)
+ {
+ names.remove(name);
+ }
+
+}
Index: src/nongnu/cashews/eclipse/composer/model/RectangleNode.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/RectangleNode.java
diff -N src/nongnu/cashews/eclipse/composer/model/RectangleNode.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/RectangleNode.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,207 @@
+/* RectangleNode.java -- Representation of a rectangular 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.model;
+
+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 RectangleNode
+ extends Node
+ implements IPropertySource, XMLizable
+{
+
+ // serialization version
+ static final long serialVersionUID = 5;
+
+ // properties
+
+ // descriptors for property sheet
+ static final IPropertyDescriptor[] descriptors;
+ static
+ {
+ descriptors = new IPropertyDescriptor[] { new TextPropertyDescriptor(
+ NAME,
+ "Name") };
+ }
+
+ // actual fields
+
+ public RectangleNode(String name)
+ {
+ setName(name);
+ }
+
+ public void setLocation(Point p)
+ {
+ if (location.equals(p))
+ {
+ return;
+ }
+ location = p;
+ firePropertyChange(LOCATION, null, p);
+ }
+
+ public Point getLocation()
+ {
+ return location;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void addInput(Connection connection)
+ {
+ inputs.add(connection);
+ fireStructureChange(INPUTS, connection);
+ }
+
+ public void addOutput(Connection connection)
+ {
+ outputs.add(connection);
+ fireStructureChange(OUTPUTS, connection);
+ }
+
+ public List getIncomingConnections()
+ {
+ return super.inputs;
+ }
+
+ public List getOutgoingConnections()
+ {
+ return super.outputs;
+ }
+
+ public void removeInput(Connection connection)
+ {
+ inputs.remove(connection);
+ fireStructureChange(INPUTS, connection);
+ }
+
+ public void removeOutput(Connection connection)
+ {
+ outputs.remove(connection);
+ fireStructureChange(OUTPUTS, connection);
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from IPropertySource
+
+ public Object getEditableValue()
+ {
+ return this;
+ }
+
+ public 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("");
+ Node tempNode = null;
+ Connection tempConnection = null;
+ if (outputs.size() > 0)
+ {
+ for (int i = 0; i < outputs.size(); i++)
+ {
+ str.append("");
+ }
+ }
+ str.append("");
+ return str.toString();
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/model/RectangleNodeFactory.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/RectangleNodeFactory.java
diff -N src/nongnu/cashews/eclipse/composer/model/RectangleNodeFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/RectangleNodeFactory.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,55 @@
+/* RectangleNodeFactory.java -- Factory for creating rectangle 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;
+
+public class RectangleNodeFactory
+ extends NodeFactory
+{
+
+ public RectangleNodeFactory(Class aClass)
+ {
+ super(aClass);
+
+ }
+
+ public Node createNode(String name)
+ {
+ return new RectangleNode(name);
+ }
+
+}
Index: src/nongnu/cashews/eclipse/composer/model/XMLizable.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/model/XMLizable.java
diff -N src/nongnu/cashews/eclipse/composer/model/XMLizable.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/model/XMLizable.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,48 @@
+/* XMLizable.java -- Interface for classes that are serialized as XML.
+ 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;
+
+/**
+ * @author Ravish Bhagdev (address@hidden)
+ */
+interface XMLizable
+{
+
+ public String toXML();
+
+}
Index: src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java
diff -N src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,76 @@
+/* ConnectionPart.java -- Visible part of the connection.
+ 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 nongnu.cashews.eclipse.composer.model.Connection;
+
+import org.eclipse.draw2d.PolygonDecoration;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+
+public class ConnectionPart
+ extends AbstractConnectionEditPart
+{
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from AbstractEditPart
+
+ protected void createEditPolicies()
+ {
+ // none at present
+ }
+
+ protected void refreshVisuals()
+ {
+ PolylineConnection figure = (PolylineConnection) getFigure();
+ Connection connx = (Connection) getModel();
+ // figure.setRoutingConstraint(MagicHelper.getConnectionBendpoints(connx));
+
+ PolygonDecoration decoration = new PolygonDecoration();
+ PointList decorationPointList = new PointList();
+ decorationPointList.addPoint(0, 0);
+ decorationPointList.addPoint(-2, 2);
+ // decorationPointList.addPoint(-4,0);
+ decorationPointList.addPoint(-2, -2);
+ decoration.setFill(true);
+ decoration.setTemplate(decorationPointList);
+ figure.setTargetDecoration(decoration);
+
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/parts/DiagramPart.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/parts/DiagramPart.java
diff -N src/nongnu/cashews/eclipse/composer/parts/DiagramPart.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/parts/DiagramPart.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,126 @@
+/* DiagramPart.java -- Displayable part of a diagram.
+ 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.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import nongnu.cashews.eclipse.composer.model.Diagram;
+import nongnu.cashews.eclipse.composer.policies.DiagramLayoutEditPolicy;
+
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.FreeformLayer;
+import org.eclipse.draw2d.FreeformLayout;
+import org.eclipse.draw2d.IFigure;
+
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+
+public class DiagramPart
+ extends AbstractGraphicalEditPart
+ implements PropertyChangeListener
+{
+
+ // ------------------------------------------------------------------------
+ // Overridden methods from AbstractEditPart
+
+ protected List getModelChildren()
+ {
+ return ((Diagram) this.getModel()).getNodes();
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from AbstractGraphicalEditPart
+
+ // override activate to register with the model for property changes
+ public void activate()
+ {
+ if (isActive())
+ {
+ return;
+ }
+ super.activate();
+ ((Diagram) getModel()).addPropertyChangeListener(this);
+ }
+
+ // override deactivate to deregister with the model
+ public void deactivate()
+ {
+ if (!isActive())
+ {
+ return;
+ }
+ super.deactivate();
+ ((Diagram) getModel()).removePropertyChangeListener(this);
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from AbstractGraphicalEditPart
+
+ // create the figure corresponding to this part
+ protected IFigure createFigure()
+ {
+ Figure figure = new FreeformLayer();
+ figure.setLayoutManager(new FreeformLayout());
+ return figure;
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from AbstractEditPart
+
+ protected void createEditPolicies()
+ {
+ // install a custom layout policy that handles dragging nodes around
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, new DiagramLayoutEditPolicy());
+
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from PropertyChangeListener
+
+ // catch property changes
+ public void propertyChange(PropertyChangeEvent event)
+ {
+ String prop = event.getPropertyName();
+ if (Diagram.NODES.equals(prop))
+ {
+ refreshChildren();
+ }
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/parts/DiagramTreeEditPart.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/parts/DiagramTreeEditPart.java
diff -N src/nongnu/cashews/eclipse/composer/parts/DiagramTreeEditPart.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/parts/DiagramTreeEditPart.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,79 @@
+/* DiagramTreeEditPart.java -- Editable part of the diagram tree.
+ 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.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import nongnu.cashews.eclipse.composer.model.Diagram;
+
+import org.eclipse.gef.editparts.AbstractTreeEditPart;
+
+public class DiagramTreeEditPart
+ extends AbstractTreeEditPart
+ implements PropertyChangeListener
+{
+
+ public DiagramTreeEditPart(Object model)
+ {
+ super(model);
+ }
+
+ public void activate()
+ {
+ super.activate();
+ ((Diagram) getModel()).addPropertyChangeListener(this);
+ }
+
+ public void deactivate()
+ {
+ ((Diagram) getModel()).removePropertyChangeListener(this);
+ super.deactivate();
+ }
+
+ protected List getModelChildren()
+ {
+ return ((Diagram) getModel()).getNodes();
+ }
+
+ public void propertyChange(PropertyChangeEvent change)
+ {
+ refreshChildren();
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/parts/EllipseNodePart.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/parts/EllipseNodePart.java
diff -N src/nongnu/cashews/eclipse/composer/parts/EllipseNodePart.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/parts/EllipseNodePart.java 31 Mar 2005 17:31:23 -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.EllipseNodeFigure;
+import nongnu.cashews.eclipse.composer.model.EllipseNode;
+import nongnu.cashews.eclipse.composer.model.Node;
+import nongnu.cashews.eclipse.composer.tools.EllipseNodeCellEditorLocator;
+import nongnu.cashews.eclipse.composer.tools.EllipseNodeDirectEditManager;
+
+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 EllipseNodePart
+ 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();
+ ((EllipseNode) getModel()).addPropertyChangeListener(this);
+ }
+
+ // override deactivate to deregister with the model
+ public void deactivate()
+ {
+ if (!isActive())
+ {
+ return;
+ }
+ super.deactivate();
+ ((EllipseNode) getModel()).removePropertyChangeListener(this);
+ }
+
+ protected List getModelSourceConnections()
+ {
+ return ((EllipseNode) this.getModel()).getOutgoingConnections();
+ }
+
+ protected List getModelTargetConnections()
+ {
+ return ((EllipseNode) this.getModel()).getIncomingConnections();
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from AbstractEditPart
+
+ protected void refreshVisuals()
+ {
+ EllipseNode node = (EllipseNode) this.getModel();
+ Point loc = node.getLocation();
+ Dimension size = new Dimension(60, 60);
+ Rectangle rectangle = new Rectangle(loc, size);
+
+ ((EllipseNodeFigure) 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)
+ {
+ EllipseNodeFigure nodeFigure = (EllipseNodeFigure) getFigure();
+ manager = new EllipseNodeDirectEditManager(
+ this,
+ TextCellEditor.class,
+ new EllipseNodeCellEditorLocator(
+ nodeFigure),
+ nodeFigure);
+ }
+ manager.show();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from AbstractGraphicalEditPart
+
+ protected IFigure createFigure()
+ {
+ // return new NodeFigure();
+ return new EllipseNodeFigure();
+ }
+
+
+}
Index: src/nongnu/cashews/eclipse/composer/parts/NodePart.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/parts/NodePart.java
diff -N src/nongnu/cashews/eclipse/composer/parts/NodePart.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/parts/NodePart.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,196 @@
+/* NodePart.java -- A node part of the diagram.
+ 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.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import nongnu.cashews.eclipse.composer.model.Node;
+import nongnu.cashews.eclipse.composer.policies.NodeDirectEditPolicy;
+import nongnu.cashews.eclipse.composer.policies.NodeEditPolicy;
+import nongnu.cashews.eclipse.composer.policies.NodeGraphicalNodeEditPolicy;
+
+import org.eclipse.draw2d.ChopboxAnchor;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.NodeEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.gef.tools.DirectEditManager;
+
+public abstract class NodePart
+ extends AbstractGraphicalEditPart
+ implements PropertyChangeListener, NodeEditPart
+{
+
+ protected DirectEditManager manager;
+
+ // ------------------------------------------------------------------------
+ // Overridden from AbstractGraphicalEditPart
+
+ // override activate to register with the model for property changes
+ public void activate()
+ {
+ if (isActive())
+ {
+ return;
+ }
+ super.activate();
+ ((Node) getModel()).addPropertyChangeListener(this);
+ }
+
+ // override deactivate to deregister with the model
+ public void deactivate()
+ {
+ if (!isActive())
+ {
+ return;
+ }
+ super.deactivate();
+ ((Node) getModel()).removePropertyChangeListener(this);
+ }
+
+ protected List getModelSourceConnections()
+ {
+ return ((Node) this.getModel()).getOutgoingConnections();
+ }
+
+ protected List getModelTargetConnections()
+ {
+ return ((Node) this.getModel()).getIncomingConnections();
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from AbstractEditPart
+
+ protected void refreshVisuals()
+ {
+
+ }
+
+ public void performRequest(Request request)
+ {
+
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from AbstractGraphicalEditPart
+
+ protected IFigure createFigure()
+ {
+ // return new NodeFigure();
+ return new Figure();
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from AbstractEditPart
+
+ protected void createEditPolicies()
+ {
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new NodeEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE,
+ new NodeGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new NodeDirectEditPolicy());
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from PropertyChangeListener
+
+ public void propertyChange(PropertyChangeEvent changeEvent)
+ {
+ if (changeEvent.getPropertyName().equals(Node.LOCATION))
+ {
+ refreshVisuals();
+ }
+ else if (changeEvent.getPropertyName().equals(Node.NAME))
+ {
+ refreshVisuals();
+ }
+ else if (changeEvent.getPropertyName().equals(Node.INPUTS))
+ {
+ refreshTargetConnections();
+ }
+ else if (changeEvent.getPropertyName().equals(Node.OUTPUTS))
+ {
+ refreshSourceConnections();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from NodeEditPart
+
+ public ConnectionAnchor getSourceConnectionAnchor(
+ ConnectionEditPart connection)
+ {
+ return new NodeConnectionAnchor(getFigure());
+ }
+
+ public ConnectionAnchor getTargetConnectionAnchor(
+ ConnectionEditPart connection)
+ {
+ return new NodeConnectionAnchor(getFigure());
+ }
+
+ public ConnectionAnchor getSourceConnectionAnchor(Request request)
+ {
+ return new NodeConnectionAnchor(getFigure());
+ }
+
+ public ConnectionAnchor getTargetConnectionAnchor(Request request)
+ {
+ return new NodeConnectionAnchor(getFigure());
+ }
+
+ // ------------------------------------------------------------------------
+ // Inner Classes
+
+ private static class NodeConnectionAnchor
+ extends ChopboxAnchor
+ {
+
+ public NodeConnectionAnchor(IFigure figure)
+ {
+ super(figure);
+ }
+
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/parts/NodeTreeEditPart.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/parts/NodeTreeEditPart.java
diff -N src/nongnu/cashews/eclipse/composer/parts/NodeTreeEditPart.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/parts/NodeTreeEditPart.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,92 @@
+/* NodeTreeEditPart.java -- Editable part of the node tree.
+ 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.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collections;
+import java.util.List;
+
+import nongnu.cashews.eclipse.composer.model.Node;
+import nongnu.cashews.eclipse.composer.policies.NodeEditPolicy;
+
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.editparts.AbstractTreeEditPart;
+
+public class NodeTreeEditPart
+ extends AbstractTreeEditPart
+ implements PropertyChangeListener
+{
+
+ public NodeTreeEditPart(Object model)
+ {
+ super(model);
+ }
+
+ public void activate()
+ {
+ super.activate();
+ ((Node) getModel()).addPropertyChangeListener(this);
+ }
+
+ public void deactivate()
+ {
+ ((Node) getModel()).removePropertyChangeListener(this);
+ super.deactivate();
+ }
+
+ protected List getModelChildren()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ public void propertyChange(PropertyChangeEvent change)
+ {
+ refreshVisuals();
+ }
+
+ protected void createEditPolicies()
+ {
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new NodeEditPolicy());
+ }
+
+ protected void refreshVisuals()
+ {
+ setWidgetText(((Node) getModel()).getName());
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/parts/PartFactory.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/parts/PartFactory.java
diff -N src/nongnu/cashews/eclipse/composer/parts/PartFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/parts/PartFactory.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,87 @@
+/* PartFactory.java -- Factory for creating parts of the diagram.
+ 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 nongnu.cashews.eclipse.composer.model.Connection;
+import nongnu.cashews.eclipse.composer.model.Diagram;
+import nongnu.cashews.eclipse.composer.model.EllipseNode;
+import nongnu.cashews.eclipse.composer.model.RectangleNode;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartFactory;
+
+// an EditPartFactory knows how to make an EditPart from a model object
+// in the context of a parent EditPart
+
+public class PartFactory implements EditPartFactory
+{
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from EditPartFactory
+
+ public EditPart createEditPart(EditPart context, Object model)
+ {
+ EditPart part = null;
+
+ if (model instanceof Diagram)
+ {
+ part = new DiagramPart();
+ }
+ else if (model instanceof RectangleNode)
+ {
+ part = new RectangleNodePart();
+ }
+ else if (model instanceof EllipseNode)
+ {
+ part = new EllipseNodePart();
+ }
+ else if (model instanceof Connection)
+ {
+ part = new ConnectionPart();
+ }
+
+ else
+ {
+ return null;
+ }
+ // tell the newly created part about the model object
+ part.setModel(model);
+
+ return part;
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/parts/RectangleNodePart.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/parts/RectangleNodePart.java
diff -N src/nongnu/cashews/eclipse/composer/parts/RectangleNodePart.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/parts/RectangleNodePart.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,145 @@
+/* RectangleNodePart.java -- Displayable part of the rectangular 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.RectangleNodeFigure;
+import nongnu.cashews.eclipse.composer.model.RectangleNode;
+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;
+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 RectangleNodePart 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();
+ ((RectangleNode) getModel()).addPropertyChangeListener(this);
+ }
+
+ // override deactivate to deregister with the model
+ public void deactivate()
+ {
+ if (!isActive())
+ {
+ return;
+ }
+ super.deactivate();
+ ((RectangleNode) getModel()).removePropertyChangeListener(this);
+ }
+
+ protected List getModelSourceConnections()
+ {
+ return ((RectangleNode) this.getModel()).getOutgoingConnections();
+ }
+
+ protected List getModelTargetConnections()
+ {
+ return ((RectangleNode) this.getModel()).getIncomingConnections();
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from AbstractEditPart
+
+ protected void refreshVisuals()
+ {
+ RectangleNode node = (RectangleNode) this.getModel();
+ Point loc = node.getLocation();
+ Dimension size = new Dimension(150, 40);
+ 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);
+ // //////============================================================
+
+ }
+
+ public void performRequest(Request request)
+ {
+ if (request.getType() == RequestConstants.REQ_DIRECT_EDIT)
+ {
+ if (manager == null)
+ {
+ RectangleNodeFigure nodeFigure = (RectangleNodeFigure) getFigure();
+ manager = new RectangleNodeDirectEditManager(
+ this,
+ TextCellEditor.class,
+ new RectangleNodeCellEditorLocator(
+ nodeFigure),
+ nodeFigure);
+ }
+ manager.show();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from AbstractGraphicalEditPart
+
+ protected IFigure createFigure()
+ {
+ // return new NodeFigure();
+ return new RectangleNodeFigure();
+ }
+
+}
Index: src/nongnu/cashews/eclipse/composer/parts/TreePartFactory.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/parts/TreePartFactory.java
diff -N src/nongnu/cashews/eclipse/composer/parts/TreePartFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/parts/TreePartFactory.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,65 @@
+/* TreePartFactory.java -- Factory for creating displayable tree parts.
+ 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 nongnu.cashews.eclipse.composer.model.Diagram;
+import nongnu.cashews.eclipse.composer.model.Node;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartFactory;
+
+public class TreePartFactory
+ implements EditPartFactory
+{
+
+ public EditPart createEditPart(EditPart context, Object model)
+ {
+ if (model instanceof Diagram)
+ {
+ return new DiagramTreeEditPart(model);
+ }
+ else if (model instanceof Node)
+ {
+ return new NodeTreeEditPart(model);
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/policies/DiagramLayoutEditPolicy.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/policies/DiagramLayoutEditPolicy.java
diff -N src/nongnu/cashews/eclipse/composer/policies/DiagramLayoutEditPolicy.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/policies/DiagramLayoutEditPolicy.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,106 @@
+/* DiagramLayoutEditPolicy.java -- Policy for editing the diagram layout.
+ 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.policies;
+
+import nongnu.cashews.eclipse.composer.commands.CreateNodeCommand;
+
+import nongnu.cashews.eclipse.composer.commands.MoveNodeCommand;
+import nongnu.cashews.eclipse.composer.model.Diagram;
+import nongnu.cashews.eclipse.composer.model.Node;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
+import org.eclipse.gef.requests.CreateRequest;
+
+//XYLayoutEditPolicy is a policy that constrains figures by a location and size
+//This extends it with the capability to change the location
+
+public class DiagramLayoutEditPolicy
+ extends XYLayoutEditPolicy
+{
+
+ // ------------------------------------------------------------------------
+ // Overridden from ConstrainedLayoutEditPolicy
+
+ protected EditPolicy createChildEditPolicy(EditPart child)
+ {
+ // we need to do this because the default is resizable
+ return new NonResizableEditPolicy();
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from ConstrainedLayoutEditPolicy
+
+ protected Command createAddCommand(EditPart child, Object constraint)
+ {
+ return null; // no support for adding
+ }
+
+ protected Command createChangeConstraintCommand(EditPart child,
+ Object constraint)
+ {
+ // return a command to move the part to the location given by the constraint
+ MoveNodeCommand locationCommand = new MoveNodeCommand();
+ locationCommand.setNode((Node) child.getModel());
+ locationCommand.setLocation(((Rectangle) constraint).getLocation());
+ return locationCommand;
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from LayoutEditPolicy
+
+ protected Command getCreateCommand(CreateRequest request)
+ {
+ CreateNodeCommand command = new CreateNodeCommand();
+ command.setDiagram((Diagram) getHost().getModel());
+ command.setNode((Node) request.getNewObject());
+ Rectangle constraint = (Rectangle) getConstraintFor(request);
+ command.setLocation(constraint.getLocation());
+ return command;
+ }
+
+ protected Command getDeleteDependantCommand(Request request)
+ {
+ return null; // no support for deleting a dependant
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/policies/NodeDirectEditPolicy.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/policies/NodeDirectEditPolicy.java
diff -N src/nongnu/cashews/eclipse/composer/policies/NodeDirectEditPolicy.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/policies/NodeDirectEditPolicy.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,81 @@
+/* DirectEditPolicy.java -- Direct editing policy.
+ 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.policies;
+
+import nongnu.cashews.eclipse.composer.commands.RenameNodeCommand;
+import nongnu.cashews.eclipse.composer.figures.EllipseNodeFigure;
+import nongnu.cashews.eclipse.composer.figures.RectangleNodeFigure;
+import nongnu.cashews.eclipse.composer.model.EllipseNode;
+import nongnu.cashews.eclipse.composer.model.Node;
+import nongnu.cashews.eclipse.composer.model.RectangleNode;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.DirectEditPolicy;
+import org.eclipse.gef.requests.DirectEditRequest;
+
+public class NodeDirectEditPolicy
+ extends DirectEditPolicy
+{
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from DirectEditPolicy
+
+ protected Command getDirectEditCommand(DirectEditRequest request)
+ {
+
+ RenameNodeCommand cmd = new RenameNodeCommand();
+ cmd.setNode((Node) getHost().getModel());
+ cmd.setName((String) request.getCellEditor().getValue());
+ return cmd;
+ }
+
+ protected void showCurrentEditValue(DirectEditRequest request)
+ {
+ Object nodeType = getHost().getModel();
+ if (nodeType instanceof RectangleNode)
+ {
+ String value = (String) request.getCellEditor().getValue();
+ ((RectangleNodeFigure) getHostFigure()).setName(value);
+ }
+ else if (nodeType instanceof EllipseNode)
+ {
+ String value = (String) request.getCellEditor().getValue();
+ ((EllipseNodeFigure) getHostFigure()).setName(value);
+ }
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/policies/NodeEditPolicy.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/policies/NodeEditPolicy.java
diff -N src/nongnu/cashews/eclipse/composer/policies/NodeEditPolicy.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/policies/NodeEditPolicy.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,65 @@
+/* NodeEditPolicy.java -- Policy for editing 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.policies;
+
+import nongnu.cashews.eclipse.composer.commands.DeleteNodeCommand;
+import nongnu.cashews.eclipse.composer.model.Diagram;
+import nongnu.cashews.eclipse.composer.model.Node;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.ComponentEditPolicy;
+
+import org.eclipse.gef.requests.GroupRequest;
+
+public class NodeEditPolicy
+ extends ComponentEditPolicy
+{
+
+ // ------------------------------------------------------------------------
+ // Overridden from ComponentEditPolicy
+
+ protected Command createDeleteCommand(GroupRequest request)
+ {
+
+ Object parent = getHost().getParent().getModel();
+ DeleteNodeCommand deleteCommand = new DeleteNodeCommand();
+ deleteCommand.setDiagram((Diagram) parent);
+ deleteCommand.setNode((Node) getHost().getModel());
+ return deleteCommand;
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/policies/NodeGraphicalNodeEditPolicy.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/policies/NodeGraphicalNodeEditPolicy.java
diff -N src/nongnu/cashews/eclipse/composer/policies/NodeGraphicalNodeEditPolicy.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/policies/NodeGraphicalNodeEditPolicy.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,87 @@
+/* NodeGraphicalNodeEditPolicy.java -- Policy for editing graphical 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.policies;
+
+import nongnu.cashews.eclipse.composer.commands.ConnectionCreateCommand;
+
+import nongnu.cashews.eclipse.composer.model.Node;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy;
+import org.eclipse.gef.requests.CreateConnectionRequest;
+import org.eclipse.gef.requests.ReconnectRequest;
+
+public class NodeGraphicalNodeEditPolicy
+ extends GraphicalNodeEditPolicy
+{
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from GraphicalNodeEditPolicy
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getConnectionCompleteCommand(org.eclipse.gef.requests.CreateConnectionRequest)
+ */
+ protected Command getConnectionCompleteCommand(CreateConnectionRequest request)
+ {
+
+ ConnectionCreateCommand command = (ConnectionCreateCommand) request.getStartCommand();
+ command.setTarget((Node) getHost().getModel());
+ return command;
+
+ }
+
+ protected Command getConnectionCreateCommand(CreateConnectionRequest request)
+ {
+ ConnectionCreateCommand command = new ConnectionCreateCommand();
+ command.setSource((Node) getHost().getModel());
+ request.setStartCommand(command);
+ return command;
+ }
+
+ protected Command getReconnectTargetCommand(ReconnectRequest request)
+ {
+ return null;
+ }
+
+ protected Command getReconnectSourceCommand(ReconnectRequest request)
+ {
+ return null;
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/tools/EllipseNodeCellEditorLocator.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/tools/EllipseNodeCellEditorLocator.java
diff -N src/nongnu/cashews/eclipse/composer/tools/EllipseNodeCellEditorLocator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/tools/EllipseNodeCellEditorLocator.java 31 Mar 2005 17:31:23 -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.EllipseNodeFigure;
+
+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 EllipseNodeCellEditorLocator
+ implements CellEditorLocator
+{
+
+ private EllipseNodeFigure nodeFigure;
+
+ public EllipseNodeCellEditorLocator(EllipseNodeFigure 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/EllipseNodeDirectEditManager.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/tools/EllipseNodeDirectEditManager.java
diff -N src/nongnu/cashews/eclipse/composer/tools/EllipseNodeDirectEditManager.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/tools/EllipseNodeDirectEditManager.java 31 Mar 2005 17:31:23 -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.EllipseNodeFigure;
+
+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 EllipseNodeDirectEditManager
+ extends DirectEditManager
+{
+
+ Font scaledFont;
+
+ protected VerifyListener verifyListener;
+
+ protected EllipseNodeFigure ellipseNodeFigure;
+
+ public EllipseNodeDirectEditManager(GraphicalEditPart source,
+ Class editorType,
+ CellEditorLocator locator,
+ EllipseNodeFigure 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/RectangleNodeCellEditorLocator.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/tools/RectangleNodeCellEditorLocator.java
diff -N src/nongnu/cashews/eclipse/composer/tools/RectangleNodeCellEditorLocator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/tools/RectangleNodeCellEditorLocator.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,70 @@
+/* RectangleNodeCellEditorLocator.java -- Locator for rectangle 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.RectangleNodeFigure;
+
+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 RectangleNodeCellEditorLocator
+ implements CellEditorLocator
+{
+
+ private RectangleNodeFigure nodeFigure;
+
+ public RectangleNodeCellEditorLocator(RectangleNodeFigure 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/RectangleNodeDirectEditManager.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/tools/RectangleNodeDirectEditManager.java
diff -N src/nongnu/cashews/eclipse/composer/tools/RectangleNodeDirectEditManager.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/tools/RectangleNodeDirectEditManager.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,138 @@
+/* RectangleNodeDirectEditManager.java -- Manager for direct rectangle 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.RectangleNodeFigure;
+
+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 RectangleNodeDirectEditManager
+ extends DirectEditManager
+{
+
+ Font scaledFont;
+
+ protected VerifyListener verifyListener;
+
+ protected RectangleNodeFigure nodeFigure;
+
+ public RectangleNodeDirectEditManager(GraphicalEditPart source,
+ Class editorType,
+ CellEditorLocator locator,
+ RectangleNodeFigure nodeFigure)
+ {
+ super(source, editorType, locator);
+ this.nodeFigure = nodeFigure;
+ }
+
+ // ------------------------------------------------------------------------
+ // 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.nodeFigure.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/DiagramCreationWizard.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/ui/DiagramCreationWizard.java
diff -N src/nongnu/cashews/eclipse/composer/ui/DiagramCreationWizard.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/ui/DiagramCreationWizard.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,158 @@
+/* DiagramCreationWizard.java -- Wizard for creating the diagram.
+ 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 java.io.InputStream;
+
+import nongnu.cashews.eclipse.composer.model.Diagram;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.ui.part.FileEditorInput;
+
+public class DiagramCreationWizard
+ extends Wizard
+ implements INewWizard
+{
+
+ private WizardPage wizardPage;
+
+ private IStructuredSelection selection;
+
+ private IWorkbench workbench;
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from IWorkbenchWizard
+
+ public void init(IWorkbench workbench, IStructuredSelection currentSelection)
+ {
+ this.workbench = workbench;
+ this.selection = currentSelection;
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from Wizard
+
+ public void addPages()
+ {
+ // by default the superclass doesn't have any pages - here we add one
+ this.wizardPage = new WizardPage(this.workbench, this.selection);
+ addPage(this.wizardPage);
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from Wizard
+
+ public boolean performFinish()
+ {
+ return this.wizardPage.finish();
+ }
+}
+
+class WizardPage extends WizardNewFileCreationPage
+{
+
+ private IWorkbench workbench;
+
+ public WizardPage(IWorkbench aWorkbench, IStructuredSelection selection)
+ {
+ super("riverPage1", selection);
+ this.setTitle("Create River Model");
+ this.setDescription("Create a new River model");
+ this.workbench = aWorkbench;
+ }
+
+ public boolean finish()
+ {
+ IFile newFile = createNewFile();
+ if (newFile == null)
+ return false; // ie.- creation was unsuccessful
+
+ // Since the file resource was created fine, open it for editing
+ // iff requested by the user
+ try
+ {
+ IWorkbenchWindow dwindow = workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = dwindow.getActivePage();
+ if (page != null)
+ page.openEditor(new FileEditorInput(newFile),
+ "nongnu.cashews.eclipse.composer.editor");
+ }
+ catch (org.eclipse.ui.PartInitException e)
+ {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from WizardNewFileCreationPage
+
+ public void createControl(Composite parent)
+ {
+ super.createControl(parent);
+ this.setFileName("model.river");
+ setPageComplete(validatePage());
+ }
+
+ protected InputStream getInitialContents()
+ {
+ // by default the superclass returns null for this
+
+ Diagram diagram = new Diagram();
+
+ InputStream istream = null;
+ try
+ {
+ istream = diagram.getAsStream();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return istream;
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/ui/DiagramEditor.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/ui/DiagramEditor.java
diff -N src/nongnu/cashews/eclipse/composer/ui/DiagramEditor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/ui/DiagramEditor.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,347 @@
+/* DiagramEditor.java -- Representation of the diagram editor.
+ 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 java.io.InputStream;
+import java.util.EventObject;
+
+import nongnu.cashews.eclipse.composer.dnd.DiagramTemplateTransferDropTargetListener;
+import nongnu.cashews.eclipse.composer.model.Diagram;
+import nongnu.cashews.eclipse.composer.parts.PartFactory;
+import nongnu.cashews.eclipse.composer.parts.TreePartFactory;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.gef.DefaultEditDomain;
+import org.eclipse.gef.KeyHandler;
+import org.eclipse.gef.KeyStroke;
+import org.eclipse.gef.dnd.TemplateTransferDragSourceListener;
+import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.gef.ui.parts.ContentOutlinePage;
+import org.eclipse.gef.ui.parts.GraphicalEditorWithPalette;
+import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
+import org.eclipse.gef.ui.parts.TreeViewer;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.dialogs.SaveAsDialog;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+public class DiagramEditor extends GraphicalEditorWithPalette
+{
+
+ private PaletteRoot paletteRoot;
+
+ private KeyHandler sharedKeyHandler;
+
+ private boolean savePreviouslyNeeded;
+
+ private Diagram diagram = new Diagram();
+
+ public DiagramEditor()
+ {
+ // an EditDomain is a "session" of editing which contains things
+ // like the CommandStack
+ setEditDomain(new DefaultEditDomain(this));
+ }
+
+ public Diagram getDiagram()
+ {
+ return this.diagram;
+ }
+
+ protected KeyHandler getCommonKeyHandler()
+ {
+ if (sharedKeyHandler == null)
+ {
+ sharedKeyHandler = new KeyHandler();
+ sharedKeyHandler.put(
+ KeyStroke.getPressed(SWT.DEL, 127, 0),
+ getActionRegistry().getAction(
+ GEFActionConstants.DELETE));
+ }
+ return sharedKeyHandler;
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from GraphicalEditor
+
+ protected void configureGraphicalViewer()
+ {
+ super.configureGraphicalViewer();
+ getGraphicalViewer().setRootEditPart(new ScalableFreeformRootEditPart());
+
+ // set the factory to use for creating EditParts for elements in the model
+ getGraphicalViewer().setEditPartFactory(new PartFactory());
+
+ getGraphicalViewer().setKeyHandler(
+ new GraphicalViewerKeyHandler(
+ getGraphicalViewer()).setParent(getCommonKeyHandler()));
+ }
+
+ public void commandStackChanged(EventObject event)
+ {
+ if (isDirty())
+ {
+ if (!this.savePreviouslyNeeded)
+ {
+ this.savePreviouslyNeeded = true;
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+ }
+ else
+ {
+ savePreviouslyNeeded = false;
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+ super.commandStackChanged(event);
+ }
+
+ public Object getAdapter(Class type)
+ {
+ if (type == IContentOutlinePage.class)
+ return new OutlinePage();
+ return super.getAdapter(type);
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden from EditorPart
+
+ protected void setInput(IEditorInput input)
+ {
+ super.setInput(input);
+
+ IFile file = ((IFileEditorInput) input).getFile();
+ try
+ { // attempt to read from a file
+ InputStream istream = file.getContents(false);
+ diagram = Diagram.makeFromStream(istream);
+ }
+ catch (Exception e)
+ { // but if there's an error, create a new diagram
+ e.printStackTrace();
+ diagram = new Diagram();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from GraphicalEditor
+
+ protected void initializeGraphicalViewer()
+ {
+ // this uses the PartFactory set in configureGraphicalViewer
+ // to create an EditPart for the diagram and sets it as the
+ // content for the viewer
+ getGraphicalViewer().setContents(this.diagram);
+
+ getGraphicalViewer().addDropTargetListener(
+ new DiagramTemplateTransferDropTargetListener(
+ getGraphicalViewer()));
+ }
+
+ // ------------------------------------------------------------------------
+ // Overridden methods from GraphicalEditorWithPalette
+
+ protected void initializePaletteViewer()
+ {
+ super.initializePaletteViewer();
+ getPaletteViewer().addDragSourceListener(
+ new TemplateTransferDragSourceListener(
+ getPaletteViewer()));
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from EditorPart
+
+ public void doSave(IProgressMonitor monitor)
+ {
+ try
+ {
+ IFile file = ((IFileEditorInput) getEditorInput()).getFile();
+ file.setContents(this.diagram.getAsStream(), true, false, monitor);
+ getCommandStack().markSaveLocation();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void doSaveAs()
+ {
+ SaveAsDialog dialog = new SaveAsDialog(
+ getSite().getWorkbenchWindow().getShell());
+ dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile());
+ dialog.open();
+ IPath path = dialog.getResult();
+
+ if (path == null)
+ return;
+
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ final IFile file = workspace.getRoot().getFile(path);
+
+ WorkspaceModifyOperation op = new WorkspaceModifyOperation()
+ {
+ public void execute(final IProgressMonitor monitor) throws CoreException
+ {
+ try
+ {
+ file.create(diagram.getAsStream(), true, monitor);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ try
+ {
+ new ProgressMonitorDialog(getSite().getWorkbenchWindow().getShell()).run(
+ false,
+ true,
+ op);
+ setInput(new FileEditorInput((IFile) file));
+ getCommandStack().markSaveLocation();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void gotoMarker(IMarker marker)
+ {
+ }
+
+ public boolean isDirty()
+ {
+ // rely on the command stack to determine dirty flag
+ return getCommandStack().isDirty();
+ }
+
+ public boolean isSaveAsAllowed()
+ {
+ // allow Save As
+ return true;
+ }
+
+ // ------------------------------------------------------------------------
+ // Abstract methods from GraphicalEditorWithPalette
+
+ protected PaletteRoot getPaletteRoot()
+ {
+ if (this.paletteRoot == null)
+ {
+ this.paletteRoot = PaletteFactory.createPalette();
+ }
+ return this.paletteRoot;
+ }
+
+ // ========================================================================
+ // Inner Classes
+
+ public class OutlinePage extends ContentOutlinePage
+ {
+
+ private PageBook pageBook;
+
+ private Control outline;
+
+ public OutlinePage()
+ {
+ super(new TreeViewer());
+ }
+
+ public void init(IPageSite pageSite)
+ {
+ super.init(pageSite);
+ ActionRegistry registry = getActionRegistry();
+ IActionBars bars = pageSite.getActionBars();
+ String id = IWorkbenchActionConstants.UNDO;
+ bars.setGlobalActionHandler(id, registry.getAction(id));
+ id = IWorkbenchActionConstants.REDO;
+ bars.setGlobalActionHandler(id, registry.getAction(id));
+ id = IWorkbenchActionConstants.DELETE;
+ bars.setGlobalActionHandler(id, registry.getAction(id));
+ bars.updateActionBars();
+ }
+
+ public void createControl(Composite parent)
+ {
+ pageBook = new PageBook(parent, SWT.NONE);
+ outline = getViewer().createControl(pageBook);
+ pageBook.showPage(outline);
+ getSelectionSynchronizer().addViewer(getViewer());
+ getViewer().setEditDomain(getEditDomain());
+ getViewer().setEditPartFactory(new TreePartFactory());
+ getViewer().setKeyHandler(getCommonKeyHandler());
+ getViewer().setContents(getDiagram());
+ }
+
+ public Control getControl()
+ {
+ return this.pageBook;
+ }
+
+ public void dispose()
+ {
+ getSelectionSynchronizer().removeViewer(getViewer());
+ super.dispose();
+ }
+ }
+}
Index: src/nongnu/cashews/eclipse/composer/ui/PaletteFactory.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/ui/PaletteFactory.java
diff -N src/nongnu/cashews/eclipse/composer/ui/PaletteFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/ui/PaletteFactory.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,132 @@
+/* PaletteFactory.java -- Factory for creating palettes.
+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 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.RectangleNode;
+import nongnu.cashews.eclipse.composer.model.RectangleNodeFactory;
+
+import org.eclipse.gef.palette.CombinedTemplateCreationEntry;
+import org.eclipse.gef.palette.ConnectionCreationToolEntry;
+import org.eclipse.gef.palette.PaletteContainer;
+import org.eclipse.gef.palette.PaletteDrawer;
+import org.eclipse.gef.palette.PaletteGroup;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.palette.SelectionToolEntry;
+import org.eclipse.gef.palette.ToolEntry;
+
+public class PaletteFactory
+{
+
+private static PaletteContainer createControlGroup(PaletteRoot root)
+{
+ PaletteGroup controlGroup = new PaletteGroup("Control Group");
+
+ List entries = new ArrayList();
+ ToolEntry tool = new SelectionToolEntry();
+ entries.add(tool);
+ root.setDefaultEntry(tool);
+
+ tool = new ConnectionCreationToolEntry("Connection", "Create a connection",
+ null, null, /* small icon */
+ null /* large icon */
+ );
+ entries.add(tool);
+
+ controlGroup.addAll(entries);
+ return controlGroup;
+}
+
+private static PaletteContainer createComponentsDrawer()
+{
+
+ PaletteDrawer drawer = new PaletteDrawer("Components", null);
+
+ List entries = new ArrayList();
+ ToolEntry tool = new CombinedTemplateCreationEntry(
+ "Rectangle",
+ "Create a new RectangleNode",
+ RectangleNode.class,
+ new RectangleNodeFactory(
+ RectangleNode.class),
+ null, /* small icon */
+ null /* large icon */
+ );
+ ToolEntry ellipseTool = new CombinedTemplateCreationEntry(
+ "EllipseNode",
+ "Create a new Node",
+ EllipseNode.class,
+ new EllipseNodeFactory(
+ EllipseNode.class),
+ null, /*
+ * small
+ * icon
+ */
+ null /*
+ * large
+ * icon
+ */
+ );
+ entries.add(tool);
+ entries.add(ellipseTool);
+ drawer.addAll(entries);
+ return drawer;
+}
+
+private static List createCategories(PaletteRoot root)
+{
+ List categories = new ArrayList();
+
+ categories.add(createControlGroup(root));
+ categories.add(createComponentsDrawer());
+
+ return categories;
+}
+
+public static PaletteRoot createPalette()
+{
+ PaletteRoot paletteRoot = new PaletteRoot();
+ paletteRoot.addAll(createCategories(paletteRoot));
+ return paletteRoot;
+}
+
+}
Index: src/nongnu/cashews/eclipse/composer/util/Dialogs.java
===================================================================
RCS file: src/nongnu/cashews/eclipse/composer/util/Dialogs.java
diff -N src/nongnu/cashews/eclipse/composer/util/Dialogs.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/nongnu/cashews/eclipse/composer/util/Dialogs.java 31 Mar 2005 17:31:23 -0000
@@ -0,0 +1,64 @@
+/* Dialogs.java -- Diagram editor dialogs.
+ 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.util;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Roger Liu
+ *
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class Dialogs
+{
+ public static void displayErrorDialog(String message)
+ {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null)
+ {
+ Shell shell = window.getShell();
+ shell.setMinimized(false);
+ shell.forceActive();
+ MessageDialog.openError(shell, "CASheW-s Composer Error", message);
+ }
+ }
+}