Author: nickboldt
Date: 2009-06-12 16:58:42 -0400 (Fri, 12 Jun 2009)
New Revision: 15935
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/
trunk/jbpm/plugins/org.jboss.tools.flow.common/.classpath
trunk/jbpm/plugins/org.jboss.tools.flow.common/.project
trunk/jbpm/plugins/org.jboss.tools.flow.common/META-INF/
trunk/jbpm/plugins/org.jboss.tools.flow.common/META-INF/MANIFEST.MF
trunk/jbpm/plugins/org.jboss.tools.flow.common/build.properties
trunk/jbpm/plugins/org.jboss.tools.flow.common/icons/
trunk/jbpm/plugins/org.jboss.tools.flow.common/icons/layoutH.gif
trunk/jbpm/plugins/org.jboss.tools.flow.common/icons/layoutV.gif
trunk/jbpm/plugins/org.jboss.tools.flow.common/plugin.properties
trunk/jbpm/plugins/org.jboss.tools.flow.common/plugin.xml
trunk/jbpm/plugins/org.jboss.tools.flow.common/schema/
trunk/jbpm/plugins/org.jboss.tools.flow.common/schema/elements.exsd
trunk/jbpm/plugins/org.jboss.tools.flow.common/schema/languages.exsd
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/Activator.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/Logger.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/HorizontalAutoLayoutAction.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/VerticalAutoLayoutAction.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddChildCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddNodeCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ChangeConstraintCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/CreateBendpointCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteBendpointCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteChildCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteConnectionCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteNodeCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ElementConnectionCreateCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/LabelMoveCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/MoveBendpointCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ReconnectElementConnectionSourceCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ReconnectElementConnectionTargetCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/RenameElementCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/SplitConnectionCommand.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/DropDownMenuWithDefaultAction.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericActionBarContributor.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericContextMenuProvider.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericModelEditor.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/OverviewOutlinePage.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/PaletteFactory.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/CellEditorLocator.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ConnectionEditPart.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ContainerEditPart.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/EditPartFactory.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ElementEditPart.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/LabelEditPart.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/NodeEditPart.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/RootEditPart.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/AbstractElementFigure.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/CrossHairDecoration.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondAnchor.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondDecoration.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondElementFigure.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/ElementContainerFigure.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/ElementFigure.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/EllipseElementFigure.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/IFigureFactory.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/NodeFigureFactory.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/RectangleElementFigure.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/RoundedRectangleElementFigure.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Connection.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Container.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultConnection.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultContainer.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultElement.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultFlow.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultNode.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Element.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Flow.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Node.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ConnectionBendpointEditPolicy.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ConnectionEditPolicy.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementContainerLayoutEditPolicy.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementDirectEditManager.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementDirectEditPolicy.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementEditPolicy.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementNodeEditPolicy.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/LabelGraphicalNodeEditPolicy.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultContainerWrapperPropertySource.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultFlowWrapperPropertySource.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultNodeWrapperPropertySource.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/IPropertyId.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/LanguageRegistry.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsElementStrategy.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsIncomingConnectionStrategy.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsOutgoingConnectionStrategy.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/SaveElementStrategy.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractConnectionWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractContainerWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractFlowWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractLabelWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractNodeWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ConnectionWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ContainerWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultConnectionWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultFlowWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultLabelWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/FlowWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/LabelWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelEvent.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelListener.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/NodeWrapper.java
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4319
Added: trunk/jbpm/plugins/org.jboss.tools.flow.common/.classpath
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.common/.classpath (rev
0)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.common/.classpath 2009-06-12 20:58:42 UTC (rev
15935)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.common/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jbpm/plugins/org.jboss.tools.flow.common/.project
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.common/.project (rev
0)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.common/.project 2009-06-12 20:58:42 UTC (rev
15935)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.flow.common</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.common/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jbpm/plugins/org.jboss.tools.flow.common/META-INF/MANIFEST.MF
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.common/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.common/META-INF/MANIFEST.MF 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,32 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name.0
+Bundle-SymbolicName: org.jboss.tools.flow.common;singleton:=true
+Bundle-Version: 1.0.0.CR1
+Bundle-Activator: org.jboss.tools.flow.common.Activator
+Bundle-Vendor: %Bundle-Vendor.0
+Require-Bundle:
+ org.eclipse.ui.views,
+ org.eclipse.draw2d,
+ org.eclipse.gef,
+ org.eclipse.jface,
+ org.eclipse.core.runtime,
+ org.eclipse.ui,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide
+Bundle-ActivationPolicy: lazy
+Export-Package:
org.jboss.tools.flow.common;uses:="org.eclipse.core.runtime,org.eclipse.ui.plugin,org.osgi.framework",
+ org.jboss.tools.flow.common.action,
+ org.jboss.tools.flow.common.command,
+ org.jboss.tools.flow.common.editor,
+ org.jboss.tools.flow.common.editpart,
+ org.jboss.tools.flow.common.figure,
+ org.jboss.tools.flow.common.model,
+ org.jboss.tools.flow.common.policy,
+ org.jboss.tools.flow.common.properties,
+ org.jboss.tools.flow.common.registry,
+ org.jboss.tools.flow.common.strategy,
+ org.jboss.tools.flow.common.wrapper
+Bundle-ClassPath: .
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Localization: plugin
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.common/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jbpm/plugins/org.jboss.tools.flow.common/build.properties
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.common/build.properties
(rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.common/build.properties 2009-06-12 20:58:42
UTC (rev 15935)
@@ -0,0 +1,11 @@
+jars.compile.order = .
+source.. = src/
+src.includes = src/,\
+ build.properties,\
+ META-INF/
+bin.includes = .,\
+ META-INF/,\
+ plugin.xml,\
+ icons/,\
+ plugin.properties
+output.. = bin/
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.common/build.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jbpm/plugins/org.jboss.tools.flow.common/icons/layoutH.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.common/icons/layoutH.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jbpm/plugins/org.jboss.tools.flow.common/icons/layoutV.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.common/icons/layoutV.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jbpm/plugins/org.jboss.tools.flow.common/plugin.properties
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.common/plugin.properties
(rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.common/plugin.properties 2009-06-12 20:58:42
UTC (rev 15935)
@@ -0,0 +1,3 @@
+#Properties file for org.jboss.tools.flow.common
+Bundle-Vendor.0 = JBoss
+Bundle-Name.0 = JBoss Tools Process Plug-in
\ No newline at end of file
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.common/plugin.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jbpm/plugins/org.jboss.tools.flow.common/plugin.xml
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.common/plugin.xml (rev
0)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.common/plugin.xml 2009-06-12 20:58:42 UTC (rev
15935)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="languages" name="JBoss Tools Flow Language
Extensions" schema="schema/languages.exsd"/>
+ <extension-point id="elements" name="JBoss Tools Flow Language
Elements" schema="schema/elements.exsd"/>
+
+</plugin>
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.common/plugin.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jbpm/plugins/org.jboss.tools.flow.common/schema/elements.exsd
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.common/schema/elements.exsd
(rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.common/schema/elements.exsd 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,266 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.flow.common"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.tools.flow.common"
id="elements" name="Flow Language Elements"/>
+ </appInfo>
+ <documentation>
+ This extension point provides a way to contribute language elements to a target
flow language.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="element" minOccurs="1"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="element">
+ <complexType>
+ <choice minOccurs="0" maxOccurs="1">
+ <element ref="flow"/>
+ <element ref="container"/>
+ <element ref="node"/>
+ <element ref="connection"/>
+ </choice>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="language" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="label" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="figure" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="resource"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="flow">
+ <complexType>
+ <attribute name="acceptsElementStrategy"
type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.strategy.AcceptsElementStrategy"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="node">
+ <complexType>
+ <sequence>
+ <element ref="figure" minOccurs="0"
maxOccurs="1"/>
+ </sequence>
+ <attribute name="acceptsIncomingConnectionStrategy"
type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.strategy.AcceptsIncomingConnectionStrategy"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="acceptsOutgoingConnectionStrategy"
type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.strategy.AcceptsOutgoingConnectionStrategy"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="container">
+ <complexType>
+ <attribute name="acceptsElementStrategy"
type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.strategy.AcceptsElementStrategy"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="acceptsIncomingConnectionStrategy"
type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.strategy.AcceptsIncomingConnectionStrategy"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="acceptsOutgoingConnectionStrategy"
type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.strategy.AcceptsOutgoingConnectionStrategy"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="connection" type="string">
+ </element>
+
+ <element name="figure">
+ <complexType>
+ <choice minOccurs="0" maxOccurs="1">
+ <element ref="ellipse"/>
+ <element ref="rectangle"/>
+ <element ref="rounded-rectangle"/>
+ </choice>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.flow.common.figure.ElementFigure"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="color" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="icon" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="resource"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="ellipse" type="string">
+ </element>
+
+ <element name="rectangle" type="string">
+ </element>
+
+ <element name="rounded-rectangle" type="string">
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.common/schema/elements.exsd
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jbpm/plugins/org.jboss.tools.flow.common/schema/languages.exsd
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.common/schema/languages.exsd
(rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.common/schema/languages.exsd 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,113 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.flow.common"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.jboss.tools.flow.common"
id="language" name="JBoss Tools Flow Language Extensions"/>
+ </appinfo>
+ <documentation>
+ This extension points enables to register domain specific languages that can be
edited as graphs or flows. The language is associated with an appropriate editor.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="language"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="language">
+ <complexType>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="editor" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.common/schema/languages.exsd
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/Activator.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/Activator.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/Activator.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,64 @@
+package org.jboss.tools.flow.common;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">kris verlaenen
</a>
+ */
+public class Activator extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID = "org.jboss.tools.process";
+
+ private static Activator plugin;
+
+ public Activator() {
+ plugin = this;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ private static String getUniqueIdentifier() {
+ if (getDefault() == null ) {
+ return PLUGIN_ID;
+ }
+ return getDefault().getBundle().getSymbolicName();
+ }
+
+ public static void log(Throwable t) {
+ log(new Status(IStatus.ERROR, getUniqueIdentifier(), 0,
+ "Internal error in JBoss Tools Process Plugin: ", t));
+ }
+
+ public static void log(IStatus status) {
+ getDefault().getLog().log(status);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/Activator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/Logger.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/Logger.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/Logger.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,37 @@
+package org.jboss.tools.flow.common;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+public class Logger {
+
+ public static void logInfo(String message) {
+ log(IStatus.INFO, IStatus.OK, message, null);
+ }
+
+ public static void logError(Throwable exception) {
+ logError("Unexpected Exception", exception);
+ }
+
+ public static void logError(String message, Throwable exception) {
+ log(IStatus.ERROR, IStatus.OK, message, exception);
+ }
+
+ public static void log(int severity, int code, String message, Throwable exception) {
+ log(createStatus(severity, code, message, exception));
+ }
+
+ public static IStatus createStatus(int severity, int code, String message, Throwable
exception) {
+ return new Status(
+ severity,
+ Activator.getDefault().getBundle().getSymbolicName(),
+ code,
+ message,
+ exception);
+ }
+
+ public static void log(IStatus status) {
+ Activator.getDefault().getLog().log(status);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/Logger.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/HorizontalAutoLayoutAction.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/HorizontalAutoLayoutAction.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/HorizontalAutoLayoutAction.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,56 @@
+package org.jboss.tools.flow.common.action;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Map;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.graph.DirectedGraph;
+import org.eclipse.draw2d.graph.Node;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.flow.common.Activator;
+
+/**
+ * Action for auto layouting a process.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class HorizontalAutoLayoutAction extends VerticalAutoLayoutAction {
+
+ public static final String ID =
"org.jboss.tools.process.editor.action.HorizontalAutoLayoutAction";
+
+ public HorizontalAutoLayoutAction(GraphicalViewer diagramViewer) {
+ super(diagramViewer);
+ }
+
+ protected void initialize() {
+ setId(ID);
+ setText("Auto Layout (Horizontal)");
+ setImageDescriptor(
+ ImageDescriptor.createFromURL(
+ Activator.getDefault().getBundle().getEntry("icons/layoutH.gif")));
+ setToolTipText("Auto layout the process (horizontal)");
+ }
+
+ protected DirectedGraph createDirectedGraph(Map<String, Node> mapping) {
+ DirectedGraph graph = super.createDirectedGraph(mapping);
+ graph.setDirection(PositionConstants.HORIZONTAL);
+ return graph;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/HorizontalAutoLayoutAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/VerticalAutoLayoutAction.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/VerticalAutoLayoutAction.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/VerticalAutoLayoutAction.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,103 @@
+package org.jboss.tools.flow.common.action;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.draw2d.graph.DirectedGraph;
+import org.eclipse.draw2d.graph.DirectedGraphLayout;
+import org.eclipse.draw2d.graph.Edge;
+import org.eclipse.draw2d.graph.Node;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.jboss.tools.flow.common.Activator;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.FlowWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * Action for auto layouting a process.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class VerticalAutoLayoutAction extends Action implements IAction {
+
+ public static final String ID =
"org.jboss.tools.process.editor.action.VerticalAutoLayoutAction";
+
+ private GraphicalViewer diagramViewer;
+
+ public VerticalAutoLayoutAction(GraphicalViewer diagramViewer) {
+ this.diagramViewer = diagramViewer;
+ initialize();
+ }
+
+ protected void initialize() {
+ setId(ID);
+ setText("Auto Layout (Vertical)");
+ setImageDescriptor(
+ ImageDescriptor.createFromURL(
+ Activator.getDefault().getBundle().getEntry("icons/layoutV.gif")));
+ setToolTipText("Auto layout the process (vertical)");
+ }
+
+ public void run() {
+ Map<String, Node> mapping = new HashMap<String, Node>();
+ DirectedGraph graph = createDirectedGraph(mapping);
+ DirectedGraphLayout layout = new DirectedGraphLayout();
+ layout.visit(graph);
+ for (Map.Entry<String, Node> entry: mapping.entrySet()) {
+ Node node = entry.getValue();
+ NodeWrapper nodeWrapper =
+
((FlowWrapper)diagramViewer.getContents().getModel()).getNodeWrapper(entry.getKey());
+ nodeWrapper.setConstraint(new Rectangle(node.x, node.y, node.width,
node.height));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected DirectedGraph createDirectedGraph(Map<String, Node> mapping) {
+ DirectedGraph graph = new DirectedGraph();
+ FlowWrapper processWrapper =
(FlowWrapper)diagramViewer.getContents().getModel();
+ for (NodeWrapper elementWrapper: processWrapper.getNodeWrappers()) {
+ Node node = new Node();
+ Integer width = (Integer) elementWrapper.getConstraint().width;
+ Integer height = (Integer) elementWrapper.getConstraint().height;
+ if (width == null || width <= 0) {
+ width = 80;
+ }
+ if (height == null || height <= 0) {
+ height = 40;
+ }
+ node.setSize(new Dimension(width, height));
+ graph.nodes.add(node);
+ mapping.put(elementWrapper.getId(), node);
+ }
+ for (NodeWrapper elementWrapper: processWrapper.getNodeWrappers()) {
+ for (ConnectionWrapper connection: elementWrapper.getIncomingConnections())
{
+ Node source = mapping.get(connection.getSource().getId());
+ Node target = mapping.get(connection.getTarget().getId());
+ graph.edges.add(new Edge(source, target));
+ }
+ }
+ return graph;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/action/VerticalAutoLayoutAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddChildCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddChildCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddChildCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,32 @@
+package org.jboss.tools.flow.common.command;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.Wrapper;
+
+public class AddChildCommand extends Command {
+
+ private Wrapper child;
+ private Wrapper parent;
+ private Object type;
+
+ public void execute() {
+ parent.addChild(type, child);
+ }
+
+ public void setChild(Wrapper newChild) {
+ child = newChild;
+ }
+
+ public void setType(Object newType) {
+ type = newType;
+ }
+
+ public void setParent(Wrapper newParent) {
+ parent = newParent;
+ }
+
+ public void undo() {
+ parent.removeChild(type, child);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddChildCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddNodeCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddNodeCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddNodeCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,63 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * A command for adding an element.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class AddNodeCommand extends Command {
+
+ private NodeWrapper child;
+ private ContainerWrapper parent;
+
+ public void execute() {
+ parent.addElement(child);
+ child.setParent(parent);
+ }
+
+ protected ContainerWrapper getParent() {
+ return parent;
+ }
+
+ protected NodeWrapper getChild() {
+ return child;
+ }
+
+ public void setChild(NodeWrapper newChild) {
+ child = newChild;
+ }
+
+ public void setParent(ContainerWrapper newParent) {
+ parent = newParent;
+ }
+
+ public void undo() {
+ parent.removeElement(child);
+ child.setParent(null);
+ }
+
+ public boolean canExecute() {
+ return parent.acceptsElement(child);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/AddNodeCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ChangeConstraintCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ChangeConstraintCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ChangeConstraintCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,50 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * A command for changing a constraint.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ChangeConstraintCommand extends Command {
+
+ private NodeWrapper element;
+ private Rectangle constraint;
+ private Rectangle oldConstraint;
+
+ public void execute() {
+ element.setConstraint(constraint);
+ }
+
+ public void setConstraint(Rectangle rect) {
+ constraint = rect;
+ }
+
+ public void setElement(NodeWrapper element) {
+ this.element = element;
+ oldConstraint = element.getConstraint();
+ }
+
+ public void undo() {
+ element.setConstraint(oldConstraint);
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ChangeConstraintCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/CreateBendpointCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/CreateBendpointCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/CreateBendpointCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,53 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+
+/**
+ * A command for creating a bendpoint.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class CreateBendpointCommand extends Command {
+
+ private ConnectionWrapper connection;
+ private Point location;
+ private int index;
+
+ public void execute() {
+ connection.addBendpoint(index, location);
+ }
+
+ public void setConnection(Object model) {
+ connection = (ConnectionWrapper) model;
+ }
+
+ public void setIndex(int i) {
+ index = i;
+ }
+
+ public void setLocation(Point point) {
+ location = point;
+ }
+
+ public void undo() {
+ connection.removeBendpoint(index);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/CreateBendpointCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteBendpointCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteBendpointCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteBendpointCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,51 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+
+
+/**
+ * A command for deleting a bendpoint.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class DeleteBendpointCommand extends Command {
+
+ private ConnectionWrapper connection;
+ private Point oldLocation;
+ private int index;
+
+ public void execute() {
+ oldLocation = (Point) connection.getBendpoints().get(index);
+ connection.removeBendpoint(index);
+ }
+
+ public void setConnectionModel(Object model) {
+ connection = (ConnectionWrapper) model;
+ }
+
+ public void setIndex(int i) {
+ index = i;
+ }
+
+ public void undo() {
+ connection.addBendpoint(index, oldLocation);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteBendpointCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteChildCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteChildCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteChildCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,36 @@
+package org.jboss.tools.flow.common.command;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.Wrapper;
+
+public class DeleteChildCommand extends Command {
+
+ private Wrapper child;
+ private Wrapper parent;
+ private Object type;
+
+ public void execute() {
+ parent.removeChild(type, child);
+ }
+
+ public void setChild(Wrapper newChild) {
+ child = newChild;
+ }
+
+ public void setType(Object newType) {
+ type = newType;
+ }
+
+ public void setParent(Wrapper newParent) {
+ parent = newParent;
+ }
+
+ public void undo() {
+ parent.addChild(type, child);
+ }
+
+ public boolean canExecute() {
+ return child != null && parent != null && type != null;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteChildCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteConnectionCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteConnectionCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteConnectionCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,53 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * A command for deleting a connection.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class DeleteConnectionCommand extends Command {
+
+ private NodeWrapper source;
+ private NodeWrapper target;
+ private ConnectionWrapper connection;
+
+ public void execute() {
+ connection.disconnect();
+ }
+
+ public void setSource(NodeWrapper action) {
+ source = action;
+ }
+
+ public void setTarget(NodeWrapper action) {
+ target = action;
+ }
+
+ public void setAntecedentTaskConnection(ConnectionWrapper connection) {
+ this.connection = connection;
+ }
+
+ public void undo() {
+ connection.connect(source, target);
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteConnectionCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteNodeCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteNodeCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteNodeCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,130 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * A command for deleting an element.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class DeleteNodeCommand extends Command {
+
+ private NodeWrapper child;
+ private ContainerWrapper parent;
+
+ private List<DeleteNodeCommand> embeddedCommands;
+
+ private List<NodeWrapper> incomingElementWrappers = new
ArrayList<NodeWrapper>();
+ private List<NodeWrapper> outgoingElementWrappers = new
ArrayList<NodeWrapper>();
+ private List<ConnectionWrapper> incomingConnections = new
ArrayList<ConnectionWrapper>();
+ private List<ConnectionWrapper> outgoingConnections = new
ArrayList<ConnectionWrapper>();
+
+
+ private void deleteConnections(NodeWrapper element) {
+ for (ConnectionWrapper connection: element.getIncomingConnections()) {
+ incomingElementWrappers.add(connection.getSource());
+ incomingConnections.add(connection);
+ }
+ for (ConnectionWrapper connection: element.getOutgoingConnections()) {
+ outgoingElementWrappers.add(connection.getTarget());
+ outgoingConnections.add(connection);
+ }
+ for (ConnectionWrapper connection: incomingConnections) {
+ connection.disconnect();
+ }
+ for (ConnectionWrapper connection: outgoingConnections) {
+ connection.disconnect();
+ }
+ }
+
+ private void initializeEmbeddedCommands() {
+ embeddedCommands = new ArrayList<DeleteNodeCommand>();
+ ContainerWrapper container = (ContainerWrapper)child;
+ List<NodeWrapper> children = container.getNodeWrappers();
+ for (NodeWrapper w : children) {
+ DeleteNodeCommand c = new DeleteNodeCommand();
+ c.setParent(container);
+ c.setChild(w);
+ embeddedCommands.add(c);
+ }
+ }
+
+ private void executeEmbeddedCommands() {
+ if (embeddedCommands == null) {
+ initializeEmbeddedCommands();
+ }
+ for (DeleteNodeCommand c : embeddedCommands) {
+ c.execute();
+ }
+ }
+
+ public void execute() {
+ if (child instanceof ContainerWrapper) {
+ executeEmbeddedCommands();
+ }
+ deleteConnections(child);
+ parent.removeElement(child);
+ }
+
+ private void restoreConnections() {
+ int i = 0;
+ for (ConnectionWrapper connection: incomingConnections) {
+ connection.connect((NodeWrapper) incomingElementWrappers.get(i), child);
+ i++;
+ }
+ i = 0;
+ for (ConnectionWrapper connection: outgoingConnections) {
+ connection.connect(child, (NodeWrapper) outgoingElementWrappers.get(i));
+ i++;
+ }
+ incomingConnections.clear();
+ incomingElementWrappers.clear();
+ outgoingConnections.clear();
+ outgoingElementWrappers.clear();
+ }
+
+ public void setChild(NodeWrapper child) {
+ this.child = child;
+ }
+
+ public void setParent(ContainerWrapper parent) {
+ this.parent = parent;
+ }
+
+ private void undoEmbeddedCommands() {
+ for (DeleteNodeCommand c : embeddedCommands) {
+ c.undo();
+ }
+ }
+
+ public void undo() {
+ parent.addElement(child);
+ restoreConnections();
+ if (child instanceof ContainerWrapper) {
+ undoEmbeddedCommands();
+ }
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/DeleteNodeCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ElementConnectionCreateCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ElementConnectionCreateCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ElementConnectionCreateCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,80 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * A command for creating an element.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ElementConnectionCreateCommand extends Command {
+
+ private ConnectionWrapper connection;
+ private NodeWrapper source;
+ private NodeWrapper target;
+
+ public boolean canExecute() {
+ if (source.equals(target)) {
+ return false;
+ }
+ // Check for existence of connection already
+ for (ConnectionWrapper connection: source.getOutgoingConnections()) {
+ if (connection.getTarget().equals(target)) {
+ return false;
+ }
+ }
+ return source.acceptsOutgoingConnection(connection, target)
+ && target != null &&
target.acceptsIncomingConnection(connection, source);
+ }
+
+ public void execute() {
+ connection.connect(source, target);
+ }
+
+ public NodeWrapper getSource() {
+ return source;
+ }
+
+ public NodeWrapper getTarget() {
+ return target;
+ }
+
+ public void redo() {
+ connection.connect(source, target);
+ }
+
+ public void setSource(NodeWrapper source) {
+ this.source = source;
+ }
+
+ public void setConnection(ConnectionWrapper connection) {
+ this.connection = connection;
+ }
+
+ public void setTarget(NodeWrapper target) {
+ this.target = target;
+ }
+
+ public void undo() {
+ connection.disconnect();
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ElementConnectionCreateCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/LabelMoveCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/LabelMoveCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/LabelMoveCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,40 @@
+package org.jboss.tools.flow.common.command;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.LabelWrapper;
+
+
+public class LabelMoveCommand extends Command {
+
+ LabelWrapper labelWrapper = null;
+ Point location = null;
+ IFigure parent = null;
+ Point oldOffset = null;
+ Point newOffset = null;
+
+ public LabelMoveCommand(LabelWrapper labelWrapper, IFigure parent, Point location) {
+ this.labelWrapper = labelWrapper;
+ this.parent = parent;
+ this.location = location;
+ }
+
+ public void execute() {
+ if (oldOffset == null) {
+ oldOffset = labelWrapper.getLocation();
+ }
+ if (newOffset == null) {
+ newOffset = labelWrapper.getLocation().getCopy();
+ parent.translateToAbsolute(newOffset);
+ newOffset.translate(location);
+ parent.translateToRelative(newOffset);
+ }
+ labelWrapper.setLocation(newOffset);
+ }
+
+ public void undo() {
+ labelWrapper.setLocation(oldOffset);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/LabelMoveCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/MoveBendpointCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/MoveBendpointCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/MoveBendpointCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,54 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+
+/**
+ * A command for moving a bendpoint.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class MoveBendpointCommand extends Command {
+
+ private ConnectionWrapper connection;
+ private Point oldLocation, newLocation;
+ private int index;
+
+ public void execute() {
+ oldLocation = (Point) connection.getBendpoints().get(index);
+ connection.replaceBendpoint(index, newLocation);
+ }
+
+ public void setConnectionModel(Object model) {
+ connection = (ConnectionWrapper) model;
+ }
+
+ public void setIndex(int i) {
+ index = i;
+ }
+
+ public void setNewLocation(Point point) {
+ newLocation = point;
+ }
+
+ public void undo() {
+ connection.replaceBendpoint(index, oldLocation);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/MoveBendpointCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ReconnectElementConnectionSourceCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ReconnectElementConnectionSourceCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ReconnectElementConnectionSourceCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,73 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * A command for reconnecting the source of a connection.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ReconnectElementConnectionSourceCommand extends Command {
+
+ private ConnectionWrapper connection;
+ private NodeWrapper target;
+ private NodeWrapper oldSource;
+ private NodeWrapper newSource;
+
+ public boolean canExecute() {
+ if (connection.getTarget().equals(newSource)) {
+ return false;
+ }
+ for (ConnectionWrapper connection: newSource.getOutgoingConnections()) {
+ if (connection.getTarget().equals(target) &&
!connection.getSource().equals(oldSource)) {
+ return false;
+ }
+ }
+ return newSource.acceptsOutgoingConnection(connection, target); //XXX
+ }
+
+ public void execute() {
+ if (newSource != null) {
+ connection.disconnect();
+ connection.connect(newSource, target);
+ }
+ }
+
+ public void setSource(NodeWrapper source) {
+ this.newSource = source;
+ }
+
+ public void setConnection(ConnectionWrapper connection) {
+ this.connection = connection;
+ this.target = connection.getTarget();
+ this.oldSource = connection.getSource();
+ }
+
+ public void undo() {
+ connection.disconnect();
+ connection.connect(oldSource, target);
+ }
+
+ public void redo() {
+ connection.disconnect();
+ connection.connect(newSource, target);
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ReconnectElementConnectionSourceCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ReconnectElementConnectionTargetCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ReconnectElementConnectionTargetCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ReconnectElementConnectionTargetCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,74 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * A command for reconnecting the target of a connection.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ReconnectElementConnectionTargetCommand extends Command {
+
+ private ConnectionWrapper connection;
+ private NodeWrapper oldTarget;
+ private NodeWrapper newTarget;
+ private NodeWrapper source;
+
+
+ public boolean canExecute() {
+ if (connection.getSource().equals(newTarget)) {
+ return false;
+ }
+ for (ConnectionWrapper connection: newTarget.getIncomingConnections()) {
+ if (connection.getSource().equals(source) &&
!connection.getTarget().equals(oldTarget)) {
+ return false;
+ }
+ }
+ return newTarget.acceptsIncomingConnection(connection, source);
+ }
+
+ public void execute() {
+ if (newTarget != null) {
+ connection.disconnect();
+ connection.connect(source, newTarget);
+ }
+ }
+
+ public void setTarget(NodeWrapper target) {
+ this.newTarget = target;
+ }
+
+ public void setConnection(ConnectionWrapper connection) {
+ this.connection = connection;
+ this.source = connection.getSource();
+ this.oldTarget = connection.getTarget();
+ }
+
+ public void undo() {
+ connection.disconnect();
+ connection.connect(source, oldTarget);
+ }
+
+ public void redo() {
+ connection.disconnect();
+ connection.connect(source, newTarget);
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/ReconnectElementConnectionTargetCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/RenameElementCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/RenameElementCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/RenameElementCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,58 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.flow.common.properties.IPropertyId;
+
+/**
+ * A command for renaming an element.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class RenameElementCommand extends Command {
+
+ private IPropertySource source;
+ private String name;
+ private String oldName;
+
+
+ public void execute() {
+ if (source != null) {
+ source.setPropertyValue(IPropertyId.NAME, name);
+ }
+ }
+
+ public void setName(String string) {
+ name = string;
+ }
+
+ public void setOldName(String string) {
+ oldName = string;
+ }
+
+ public void setSource(IPropertySource propertySource) {
+ source = propertySource;
+ }
+
+ public void undo() {
+ if (source != null) {
+ source.setPropertyValue(IPropertyId.NAME, oldName);
+ }
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/RenameElementCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/SplitConnectionCommand.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/SplitConnectionCommand.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/SplitConnectionCommand.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,94 @@
+package org.jboss.tools.flow.common.command;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.commands.Command;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.FlowWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * A command for splitting a connection.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class SplitConnectionCommand extends Command {
+
+ private FlowWrapper parent;
+ private NodeWrapper oldSource;
+ private NodeWrapper oldTarget;
+ private ConnectionWrapper oldConnection;
+ private ConnectionWrapper secondConnection;
+ private NodeWrapper newElement;
+
+ public void setNewSecondConnection(ConnectionWrapper connection) {
+ if (connection == null) {
+ throw new IllegalArgumentException("new second connection cannot be
null");
+ }
+ this.secondConnection = connection;
+ }
+
+ public void execute() {
+ if (secondConnection == null) {
+ throw new IllegalStateException("new second connection is still null");
+ }
+ oldConnection.disconnect();
+ parent.addElement(newElement);
+ newElement.setParent(parent);
+ oldConnection.connect(oldSource, newElement);
+ secondConnection.connect(newElement, oldTarget);
+ }
+
+ public void setParent(FlowWrapper flow) {
+ if (flow == null) {
+ throw new IllegalArgumentException("process is null");
+ }
+ parent = flow;
+ }
+
+ public void setElementConnection(ConnectionWrapper connection) {
+ if (connection == null) {
+ throw new IllegalArgumentException("Element connection is null");
+ }
+ this.oldConnection = connection;
+ oldSource = connection.getSource();
+ oldTarget = connection.getTarget();
+ }
+
+ public void setNewElement(NodeWrapper newElement) {
+ if (newElement == null) {
+ throw new IllegalArgumentException("NewElement is null");
+ }
+ this.newElement = newElement;
+
+ }
+
+ public void undo() {
+ oldConnection.disconnect();
+ secondConnection.disconnect();
+ parent.removeElement(newElement);
+ newElement.setParent(null);
+ oldConnection.connect(oldSource, oldTarget);
+ }
+
+ public boolean canExecute() {
+ return parent.acceptsElement(newElement) &&
+ newElement.acceptsIncomingConnection(oldConnection, oldSource) &&
+ newElement.acceptsOutgoingConnection(secondConnection, oldTarget);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/command/SplitConnectionCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/DropDownMenuWithDefaultAction.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/DropDownMenuWithDefaultAction.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/DropDownMenuWithDefaultAction.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,147 @@
+package org.jboss.tools.flow.common.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+public class DropDownMenuWithDefaultAction extends Action implements IMenuCreator {
+
+ private Menu dropDownMenu;
+ private IAction delegate;
+ private List<Object> list;
+ private IPropertyChangeListener enabledListener;
+ private SelectionListener selectionListener;
+
+ public DropDownMenuWithDefaultAction(final IAction action) {
+ this.selectionListener = new ItemSelectionListener(this);
+ setMenuCreator(this);
+ this.dropDownMenu = null;
+ setAction(action);
+ this.list = new ArrayList<Object>();
+ }
+
+ public void dispose() {
+ if (this.dropDownMenu != null) {
+ this.dropDownMenu.dispose();
+ this.dropDownMenu = null;
+ }
+ }
+
+ public void add(final IContributionItem item) {
+ this.list.add(item);
+ }
+
+ public void add(final IAction action) {
+ this.list.add(action);
+ }
+
+ public Menu getMenu(final Control parent) {
+ if (this.dropDownMenu == null) {
+ this.dropDownMenu = new Menu(parent);
+ populateMenu();
+ }
+ return this.dropDownMenu;
+ }
+
+ public Menu getMenu(final Menu parent) {
+ if (this.dropDownMenu == null) {
+ this.dropDownMenu = new Menu(parent);
+ populateMenu();
+ }
+ return this.dropDownMenu;
+ }
+
+ private void populateMenu() {
+ for (Object object: list) {
+ if (object instanceof IContributionItem) {
+ final IContributionItem item = (IContributionItem) object;
+ item.fill(this.dropDownMenu, -1);
+ } else {
+ final IAction action = (IAction) object;
+ final ActionContributionItem item = new ActionContributionItem(action);
+ item.fill(this.dropDownMenu, -1);
+ }
+ }
+ final MenuItem[] items = this.dropDownMenu.getItems();
+ for (int i = 0; i < items.length; i++) {
+ items[i].addSelectionListener(this.selectionListener);
+ }
+ }
+
+ public void setAction(final IAction action) {
+ if (this.enabledListener == null) {
+ this.enabledListener = new EnabledPropertyChangeListener(this);
+ }
+ setText(action.getText());
+ setToolTipText(action.getToolTipText());
+ setImageDescriptor(action.getImageDescriptor());
+ setDisabledImageDescriptor(action.getDisabledImageDescriptor());
+ setEnabled(action.isEnabled());
+ setDescription(action.getDescription());
+ setHelpListener(action.getHelpListener());
+ setHoverImageDescriptor(action.getHoverImageDescriptor());
+ if (this.delegate != null) {
+ this.delegate.removePropertyChangeListener(this.enabledListener);
+ }
+ this.delegate = action;
+ this.delegate.addPropertyChangeListener(this.enabledListener);
+ }
+
+ public void run() {
+ this.delegate.run();
+ }
+
+ public static class EnabledPropertyChangeListener implements IPropertyChangeListener
{
+ private IAction action;
+
+ public EnabledPropertyChangeListener(final IAction action) {
+ this.action = action;
+ }
+
+ public void propertyChange(final PropertyChangeEvent event) {
+ if (event.getProperty().equals(IAction.ENABLED)) {
+ this.action.setEnabled(((Boolean) event.getNewValue())
+ .booleanValue());
+ }
+ }
+ }
+
+ public static class ItemSelectionListener implements SelectionListener {
+ private DropDownMenuWithDefaultAction dropDownMenu;
+
+ public ItemSelectionListener(
+ final DropDownMenuWithDefaultAction dropDownMenu) {
+ this.dropDownMenu = dropDownMenu;
+ }
+
+ public void widgetDefaultSelected(final SelectionEvent e) {
+ final MenuItem menuItem = (MenuItem) e.getSource();
+ if (menuItem.getData() instanceof ActionContributionItem) {
+ final ActionContributionItem item = (ActionContributionItem) menuItem
+ .getData();
+ this.dropDownMenu.setAction(item.getAction());
+ }
+ }
+
+ public void widgetSelected(final SelectionEvent e) {
+ final MenuItem menuItem = (MenuItem) e.getSource();
+ if (menuItem.getData() instanceof ActionContributionItem) {
+ final ActionContributionItem item = (ActionContributionItem) menuItem
+ .getData();
+ this.dropDownMenu.setAction(item.getAction());
+ }
+ }
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/DropDownMenuWithDefaultAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericActionBarContributor.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericActionBarContributor.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericActionBarContributor.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,102 @@
+package org.jboss.tools.flow.common.editor;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.gef.ui.actions.ActionBarContributor;
+import org.eclipse.gef.ui.actions.AlignmentRetargetAction;
+import org.eclipse.gef.ui.actions.DeleteRetargetAction;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.gef.ui.actions.RedoRetargetAction;
+import org.eclipse.gef.ui.actions.UndoRetargetAction;
+import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
+import org.eclipse.gef.ui.actions.ZoomInRetargetAction;
+import org.eclipse.gef.ui.actions.ZoomOutRetargetAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.RetargetAction;
+import org.jboss.tools.flow.common.Activator;
+import org.jboss.tools.flow.common.action.HorizontalAutoLayoutAction;
+import org.jboss.tools.flow.common.action.VerticalAutoLayoutAction;
+
+/**
+ * Common implementation of a ActionBarContributor.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class GenericActionBarContributor extends ActionBarContributor {
+
+ protected void buildActions() {
+ addRetargetAction( new UndoRetargetAction() );
+ addRetargetAction( new RedoRetargetAction() );
+ addRetargetAction( new DeleteRetargetAction() );
+
+ addRetargetAction( new ZoomInRetargetAction() );
+ addRetargetAction( new ZoomOutRetargetAction() );
+
+ addRetargetAction( new AlignmentRetargetAction( PositionConstants.LEFT ) );
+ addRetargetAction( new AlignmentRetargetAction( PositionConstants.CENTER ) );
+ addRetargetAction( new AlignmentRetargetAction( PositionConstants.RIGHT ) );
+ addRetargetAction( new AlignmentRetargetAction( PositionConstants.TOP ) );
+ addRetargetAction( new AlignmentRetargetAction( PositionConstants.MIDDLE ) );
+ addRetargetAction( new AlignmentRetargetAction( PositionConstants.BOTTOM ) );
+
+ addRetargetAction( new RetargetAction(
+ GEFActionConstants.TOGGLE_GRID_VISIBILITY, "Grid" ));
+
+ RetargetAction verticalAutoLayoutAction = new
RetargetAction(VerticalAutoLayoutAction.ID, null);
+ verticalAutoLayoutAction.setImageDescriptor(
+
ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/layoutV.gif")));
+ addRetargetAction(verticalAutoLayoutAction);
+
+ RetargetAction horizontalAutoLayoutAction = new
RetargetAction(HorizontalAutoLayoutAction.ID, null);
+ horizontalAutoLayoutAction.setImageDescriptor(
+
ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/layoutH.gif")));
+ addRetargetAction(horizontalAutoLayoutAction);
+
+ }
+
+ public void contributeToToolBar(IToolBarManager toolBarManager) {
+ toolBarManager.add( getAction( ActionFactory.UNDO.getId() ) );
+ toolBarManager.add( getAction( ActionFactory.REDO.getId() ) );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( new ZoomComboContributionItem( getPage() ) );
+ toolBarManager.add( new Separator() );
+
+ DropDownMenuWithDefaultAction alignMenu = new DropDownMenuWithDefaultAction(
getActionRegistry().getAction( GEFActionConstants.ALIGN_LEFT ) );
+ alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_LEFT ) );
+ alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_CENTER )
);
+ alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_RIGHT )
);
+ alignMenu.add( new Separator() );
+ alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_TOP ) );
+ alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_MIDDLE )
);
+ alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_BOTTOM )
);
+ toolBarManager.add( alignMenu );
+
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY) );
+
+ toolBarManager.add( new Separator());
+ toolBarManager.add( getAction(VerticalAutoLayoutAction.ID));
+ toolBarManager.add( getAction(HorizontalAutoLayoutAction.ID));
+ }
+
+ protected void declareGlobalActionKeys() {
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericActionBarContributor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericContextMenuProvider.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericContextMenuProvider.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericContextMenuProvider.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,61 @@
+package org.jboss.tools.flow.common.editor;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.ContextMenuProvider;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.actions.ActionFactory;
+
+/**
+ * Common implementation of a ContextMenuProvider.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class GenericContextMenuProvider extends ContextMenuProvider {
+
+ private ActionRegistry actionRegistry;
+
+ public GenericContextMenuProvider(GraphicalViewer viewer, ActionRegistry registry) {
+ super(viewer);
+ setActionRegistry(registry);
+ }
+
+ public void buildContextMenu(IMenuManager menu) {
+ GEFActionConstants.addStandardActionGroups(menu);
+ IAction action = getActionRegistry().getAction(ActionFactory.UNDO.getId());
+ menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
+ action = getActionRegistry().getAction(ActionFactory.REDO.getId());
+ menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
+ action = getActionRegistry().getAction(ActionFactory.DELETE.getId());
+ if (action.isEnabled()) {
+ menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
+ }
+ }
+
+ private ActionRegistry getActionRegistry() {
+ return actionRegistry;
+ }
+
+ public void setActionRegistry(ActionRegistry registry) {
+ actionRegistry = registry;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericContextMenuProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericModelEditor.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericModelEditor.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericModelEditor.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,403 @@
+package org.jboss.tools.flow.common.editor;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.EventObject;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+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.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.SWTGraphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.ContextMenuProvider;
+import org.eclipse.gef.DefaultEditDomain;
+import org.eclipse.gef.KeyHandler;
+import org.eclipse.gef.KeyStroke;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.editparts.LayerManager;
+import org.eclipse.gef.editparts.ScalableRootEditPart;
+import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.gef.ui.actions.AlignmentAction;
+import org.eclipse.gef.ui.actions.DirectEditAction;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.gef.ui.actions.ToggleGridAction;
+import org.eclipse.gef.ui.parts.GraphicalEditorWithPalette;
+import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.ImageLoader;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.dialogs.SaveAsDialog;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+import org.jboss.tools.flow.common.Activator;
+import org.jboss.tools.flow.common.action.HorizontalAutoLayoutAction;
+import org.jboss.tools.flow.common.action.VerticalAutoLayoutAction;
+import org.jboss.tools.flow.common.editpart.EditPartFactory;
+import org.jboss.tools.flow.common.registry.LanguageRegistry;
+
+/**
+ * Abstract implementation of a graphical editor.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public abstract class GenericModelEditor extends GraphicalEditorWithPalette {
+
+ private Object model;
+ private boolean savePreviouslyNeeded = false;
+ private KeyHandler sharedKeyHandler;
+ private PaletteRoot root;
+ private OverviewOutlinePage overviewOutlinePage;
+
+ private String language;
+
+ public GenericModelEditor() {
+ setEditDomain(new DefaultEditDomain(this));
+ }
+
+ protected void setModel(Object model) {
+ this.model = model;
+ }
+
+ public Object getModel() {
+ return model;
+ }
+
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+ super.init(site, input);
+ initializeEditDomain();
+ initializeLanguage();
+ }
+
+ protected void initializeEditDomain() {
+ setEditDomain(new DefaultEditDomain(this));
+ getCommandStack().addCommandStackListener(this);
+ }
+
+ protected void initializeLanguage() {
+ language = LanguageRegistry.getLanguageRegisteredFor(getSite().getId());
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void createActions() {
+ super.createActions();
+ ActionRegistry registry = getActionRegistry();
+
+ IAction action = new DirectEditAction((IWorkbenchPart) this);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
+ action = new AlignmentAction((IWorkbenchPart) this,
+ PositionConstants.LEFT);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
+ action = new AlignmentAction((IWorkbenchPart) this,
+ PositionConstants.CENTER);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
+ action = new AlignmentAction((IWorkbenchPart) this,
+ PositionConstants.RIGHT);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
+ action = new AlignmentAction((IWorkbenchPart) this,
+ PositionConstants.TOP);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
+ action = new AlignmentAction((IWorkbenchPart) this,
+ PositionConstants.MIDDLE);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
+ action = new AlignmentAction((IWorkbenchPart) this,
+ PositionConstants.BOTTOM);
+ registry.registerAction(action);
+ getSelectionActions().add(action.getId());
+ }
+
+ public void commandStackChanged(EventObject event) {
+ if (isDirty()) {
+ if (!savePreviouslyNeeded()) {
+ setSavePreviouslyNeeded(true);
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+ } else {
+ setSavePreviouslyNeeded(false);
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+ super.commandStackChanged(event);
+ }
+
+ protected abstract void writeModel(OutputStream os) throws IOException;
+
+ protected void configureGraphicalViewer() {
+ super.configureGraphicalViewer();
+ getGraphicalViewer().setRootEditPart(new ScalableRootEditPart());
+ getGraphicalViewer().setEditPartFactory(createEditPartFactory());
+ getGraphicalViewer().setKeyHandler(
+ new GraphicalViewerKeyHandler(getGraphicalViewer())
+ .setParent(getCommonKeyHandler()));
+
+ IAction showGrid = new ToggleGridAction(getGraphicalViewer());
+ getActionRegistry().registerAction(showGrid);
+
+ IAction layoutVertically = new VerticalAutoLayoutAction(
+ getGraphicalViewer());
+ getActionRegistry().registerAction(layoutVertically);
+ IAction layoutHorizontally = new HorizontalAutoLayoutAction(
+ getGraphicalViewer());
+ getActionRegistry().registerAction(layoutHorizontally);
+
+ ContextMenuProvider provider = new GenericContextMenuProvider(
+ getGraphicalViewer(), getActionRegistry());
+ getGraphicalViewer().setContextMenu(provider);
+ getSite().registerContextMenu(
+ "org.jboss.tools.flow.editor.contextmenu", provider,
+ getGraphicalViewer());
+ }
+
+ protected org.eclipse.gef.EditPartFactory createEditPartFactory() {
+ return new EditPartFactory();
+ }
+
+ protected void initializeGraphicalViewer() {
+ getGraphicalViewer().setContents(model);
+ }
+
+ public void doSave(IProgressMonitor monitor) {
+ try {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ writeModel(out);
+ IFile file = ((IFileEditorInput) getEditorInput()).getFile();
+ file.setContents(new ByteArrayInputStream(out.toByteArray()), true,
+ false, monitor);
+ out.close();
+ 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 {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ writeModel(out);
+ file.create(new ByteArrayInputStream(out.toByteArray()),
+ true, monitor);
+ out.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ try {
+ new ProgressMonitorDialog(getSite().getWorkbenchWindow().getShell())
+ .run(false, true, op);
+ setInput(new FileEditorInput(file));
+ getCommandStack().markSaveLocation();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected KeyHandler getCommonKeyHandler() {
+ if (sharedKeyHandler == null) {
+ sharedKeyHandler = new KeyHandler();
+ sharedKeyHandler
+ .put(KeyStroke.getPressed(SWT.DEL, 127, 0),
+ getActionRegistry().getAction(
+ ActionFactory.DELETE.getId()));
+ sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),
+ getActionRegistry().getAction(
+ GEFActionConstants.DIRECT_EDIT));
+ }
+ return sharedKeyHandler;
+ }
+
+ public boolean isDirty() {
+ return isSaveOnCloseNeeded();
+ }
+
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ public boolean isSaveOnCloseNeeded() {
+ return getCommandStack().isDirty();
+ }
+
+ private boolean savePreviouslyNeeded() {
+ return savePreviouslyNeeded;
+ }
+
+ private void setSavePreviouslyNeeded(boolean value) {
+ savePreviouslyNeeded = value;
+ }
+
+ protected PaletteRoot getPaletteRoot() {
+ if (root == null) {
+ root = createPalette();
+ }
+ return root;
+ }
+
+ protected abstract PaletteRoot createPalette();
+
+ protected void setInput(IEditorInput input) {
+ super.setInput(input);
+
+ IFile file = getFile();
+ setPartName(file.getName());
+ try {
+ InputStream is = file.getContents(false);
+ createModel(is);
+ } catch (Throwable t) {
+ Activator.log(t);
+ }
+ if (getGraphicalViewer() != null) {
+ initializeGraphicalViewer();
+ }
+ }
+
+ public IFile getFile() {
+ return ((IFileEditorInput) getEditorInput()).getFile();
+ }
+
+ public IProject getProject() {
+ IFile file = getFile();
+ if (file != null) {
+ return file.getProject();
+ }
+ return null;
+ }
+
+ protected abstract void createModel(InputStream is);
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class type) {
+ if (type == IContentOutlinePage.class) {
+ return getOverviewOutlinePage();
+ }
+ if (type == ZoomManager.class) {
+ return ((ScalableRootEditPart) getGraphicalViewer()
+ .getRootEditPart()).getZoomManager();
+ }
+ return super.getAdapter(type);
+ }
+
+ protected OverviewOutlinePage getOverviewOutlinePage() {
+ if (null == overviewOutlinePage && null != getGraphicalViewer()) {
+ ScalableRootEditPart rootEditPart = (ScalableRootEditPart) getGraphicalViewer()
+ .getRootEditPart();
+ overviewOutlinePage = new OverviewOutlinePage(rootEditPart);
+ }
+ return overviewOutlinePage;
+ }
+
+// public String getContributorId() {
+// return getSite().getId();
+// }
+
+ /**
+ * Writes the content of this editor to the given stream. Possible formats
+ * are for example SWT.IMAGE_BMP, IMAGE_GIF, IMAGE_JPEG, IMAGE_PNG.
+ *
+ * @param stream
+ * @param format
+ */
+ public void createImage(OutputStream stream, int format) {
+ SWTGraphics g = null;
+ GC gc = null;
+ Image image = null;
+ LayerManager layerManager = (LayerManager) getGraphicalViewer()
+ .getEditPartRegistry().get(LayerManager.ID);
+ IFigure figure = layerManager.getLayer(LayerConstants.PRINTABLE_LAYERS);
+ Rectangle r = figure.getBounds();
+ try {
+ image = new Image(Display.getDefault(), r.width, r.height);
+ gc = new GC(image);
+ g = new SWTGraphics(gc);
+ g.translate(r.x * -1, r.y * -1);
+ figure.paint(g);
+ ImageLoader imageLoader = new ImageLoader();
+ imageLoader.data = new ImageData[] { image.getImageData() };
+ imageLoader.save(stream, format);
+ } catch (Throwable t) {
+ Activator.log(t);
+ } finally {
+ if (g != null) {
+ g.dispose();
+ }
+ if (gc != null) {
+ gc.dispose();
+ }
+ if (image != null) {
+ image.dispose();
+ }
+ }
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/GenericModelEditor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/OverviewOutlinePage.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/OverviewOutlinePage.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/OverviewOutlinePage.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,91 @@
+package org.jboss.tools.flow.common.editor;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.LightweightSystem;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.Viewport;
+import org.eclipse.draw2d.parts.ScrollableThumbnail;
+import org.eclipse.draw2d.parts.Thumbnail;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.editparts.ScalableRootEditPart;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+/**
+ * Common implementation of an outline page.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class OverviewOutlinePage extends Page implements IContentOutlinePage {
+
+ private Canvas overview;
+ private ScalableRootEditPart rootEditPart;
+ private Thumbnail thumbnail;
+
+ public OverviewOutlinePage(ScalableRootEditPart rootEditPart) {
+ this.rootEditPart = rootEditPart;
+ }
+
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ }
+
+ public void createControl(Composite parent) {
+ overview = new Canvas(parent, SWT.NONE);
+ LightweightSystem lws = new LightweightSystem(overview);
+ thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
+ thumbnail.setBorder(new MarginBorder(3));
+ thumbnail.setSource(rootEditPart
+ .getLayer(LayerConstants.PRINTABLE_LAYERS));
+ lws.setContents(thumbnail);
+ }
+
+ public void dispose() {
+ if (null != thumbnail) {
+ thumbnail.deactivate();
+ }
+ super.dispose();
+ }
+
+ public Control getControl() {
+ return overview;
+ }
+
+ public ISelection getSelection() {
+ return StructuredSelection.EMPTY;
+ }
+
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ }
+
+ public void setFocus() {
+ if (getControl() != null) {
+ getControl().setFocus();
+ }
+ }
+
+ public void setSelection(ISelection selection) {
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/OverviewOutlinePage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/PaletteFactory.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/PaletteFactory.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/PaletteFactory.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,78 @@
+package org.jboss.tools.flow.common.editor;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.gef.palette.MarqueeToolEntry;
+import org.eclipse.gef.palette.PaletteContainer;
+import org.eclipse.gef.palette.PaletteDrawer;
+import org.eclipse.gef.palette.PaletteEntry;
+import org.eclipse.gef.palette.PaletteGroup;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.palette.SelectionToolEntry;
+import org.eclipse.gef.palette.ToolEntry;
+
+/**
+ * Factory for creating a RuleFlow palette.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class PaletteFactory {
+
+ public PaletteRoot createPalette() {
+ PaletteRoot palette = new PaletteRoot();
+ palette.addAll(createCategories(palette));
+ return palette;
+ }
+
+ protected List<PaletteContainer> createCategories(PaletteRoot root) {
+ List<PaletteContainer> categories = new
ArrayList<PaletteContainer>();
+ categories.add(createControlGroup(root));
+ categories.add(createComponentsDrawer());
+ return categories;
+ }
+
+ protected PaletteContainer createControlGroup(PaletteRoot root) {
+ PaletteGroup controlGroup = new PaletteGroup("Control Group");
+
+ List<PaletteEntry> entries = new ArrayList<PaletteEntry>();
+
+ ToolEntry tool = new SelectionToolEntry();
+ entries.add(tool);
+ root.setDefaultEntry(tool);
+
+ tool = new MarqueeToolEntry();
+ entries.add(tool);
+
+ controlGroup.addAll(entries);
+ return controlGroup;
+ }
+
+ protected PaletteContainer createComponentsDrawer() {
+ PaletteDrawer drawer = new PaletteDrawer("Components", null);
+ List<PaletteEntry> entries = createComponentEntries();
+ drawer.addAll(entries);
+ return drawer;
+ }
+
+ protected List<PaletteEntry> createComponentEntries() {
+ return new ArrayList<PaletteEntry>();
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editor/PaletteFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/CellEditorLocator.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/CellEditorLocator.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/CellEditorLocator.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,56 @@
+package org.jboss.tools.flow.common.editpart;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.jface.viewers.CellEditor;
+
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * A CellEditorLocator for elements.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class CellEditorLocator implements org.eclipse.gef.tools.CellEditorLocator {
+
+ private Label label;
+
+ public CellEditorLocator(Label label) {
+ setLabel(label);
+ }
+
+ public void relocate(CellEditor cellEditor) {
+ Text text = (Text) cellEditor.getControl();
+ Point pref = text.computeSize(-1, -1);
+ Rectangle rect = label.getTextBounds().getCopy();
+ label.translateToAbsolute(rect);
+ text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1);
+ }
+
+ protected Label getLabel() {
+ return label;
+ }
+
+ protected void setLabel(Label label) {
+ this.label = label;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/CellEditorLocator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ConnectionEditPart.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ConnectionEditPart.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ConnectionEditPart.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,124 @@
+package org.jboss.tools.flow.common.editpart;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.draw2d.AbsoluteBendpoint;
+import org.eclipse.draw2d.BendpointConnectionRouter;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PolygonDecoration;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
+import org.eclipse.gef.requests.CreationFactory;
+import org.jboss.tools.flow.common.policy.ConnectionBendpointEditPolicy;
+import org.jboss.tools.flow.common.policy.ConnectionEditPolicy;
+import org.jboss.tools.flow.common.registry.ElementRegistry;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.DefaultConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.LabelWrapper;
+import org.jboss.tools.flow.common.wrapper.ModelEvent;
+import org.jboss.tools.flow.common.wrapper.ModelListener;
+import org.jboss.tools.flow.common.wrapper.Wrapper;
+
+/**
+ * Implementation of a connection EditPart.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ConnectionEditPart extends AbstractConnectionEditPart implements
ModelListener {
+
+ public ConnectionWrapper getElementConnection() {
+ return (ConnectionWrapper) getModel();
+ }
+
+ public List<Wrapper> getModelChildren() {
+ List<Wrapper> result = new ArrayList<Wrapper>();
+ LabelWrapper label = getElementConnection().getLabel();
+ if (label != null) result.add(label);
+ return result;
+ }
+
+ protected void createEditPolicies() {
+ ConnectionEditPolicy connectionEditPolicy = new ConnectionEditPolicy();
+ connectionEditPolicy.setElementConnectionFactory(getElementConnectionFactory());
+ installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new
ConnectionEndpointEditPolicy());
+ installEditPolicy(EditPolicy.CONNECTION_ROLE, connectionEditPolicy);
+ installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, new
ConnectionBendpointEditPolicy());
+ }
+
+ protected CreationFactory getElementConnectionFactory() {
+ return ElementRegistry.getCreationFactory(getElementConnection().getElement());
+ }
+
+
+ protected Class<?> getElementConnectionType() {
+ return DefaultConnectionWrapper.class;
+ }
+
+ protected IFigure createFigure() {
+ PolylineConnection result = new PolylineConnection();
+ result.setForegroundColor(ColorConstants.gray);
+ result.setConnectionRouter(new BendpointConnectionRouter());
+ result.setTargetDecoration(new PolygonDecoration());
+ return result;
+ }
+
+ public void setSelected(int value) {
+ super.setSelected(value);
+ if (value != EditPart.SELECTED_NONE) {
+ ((PolylineConnection)getFigure()).setLineWidth(2);
+ } else {
+ ((PolylineConnection)getFigure()).setLineWidth(1);
+ }
+ }
+
+ public void modelChanged(ModelEvent event) {
+ if (event.getChangeType() == ConnectionWrapper.CHANGE_BENDPOINTS) {
+ refreshBendpoints();
+ }
+ }
+
+ public void activate() {
+ super.activate();
+ getElementConnection().addListener(this);
+ }
+
+ public void deactivate() {
+ getElementConnection().removeListener(this);
+ super.deactivate();
+ }
+
+ protected void refreshBendpoints() {
+ List<Point> bendpoints = getElementConnection().getBendpoints();
+ List<Point> constraint = new ArrayList<Point>();
+ for (int i = 0; i < bendpoints.size(); i++) {
+ constraint.add(new AbsoluteBendpoint((Point) bendpoints.get(i)));
+ }
+ getConnectionFigure().setRoutingConstraint(constraint);
+ }
+
+ protected void refreshVisuals() {
+ refreshBendpoints();
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ConnectionEditPart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ContainerEditPart.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ContainerEditPart.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ContainerEditPart.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,81 @@
+package org.jboss.tools.flow.common.editpart;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.MouseWheelHelper;
+import org.eclipse.gef.editparts.ViewportMouseWheelHelper;
+import org.jboss.tools.flow.common.figure.ElementContainerFigure;
+import org.jboss.tools.flow.common.policy.ElementContainerLayoutEditPolicy;
+import org.jboss.tools.flow.common.wrapper.AbstractContainerWrapper;
+import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
+import org.jboss.tools.flow.common.wrapper.ModelEvent;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+public class ContainerEditPart extends ElementEditPart {
+
+ protected AbstractContainerWrapper getElementContainerElementWrapper() {
+ return (AbstractContainerWrapper) getModel();
+ }
+
+ protected IFigure createFigure() {
+ return new ElementContainerFigure();
+ }
+
+ protected void createEditPolicies() {
+ super.createEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, null);
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, new
ElementContainerLayoutEditPolicy());
+ }
+
+ public void modelChanged(ModelEvent event) {
+ if (event.getChangeType() == ContainerWrapper.ADD_ELEMENT) {
+ refreshChildren();
+ Object changedObject = event.getChangedObject();
+ if (changedObject != null) {
+ EditPart editPart =
(EditPart)getViewer().getEditPartRegistry().get(changedObject);
+ if (editPart instanceof ElementEditPart) {
+ ((ElementEditPart)editPart).performDirectEdit();
+ }
+ }
+ } else if (event.getChangeType() == ContainerWrapper.REMOVE_ELEMENT) {
+ refreshChildren();
+ } else {
+ super.modelChanged(event);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class key) {
+ if (key == MouseWheelHelper.class) {
+ return new ViewportMouseWheelHelper(this);
+ }
+ return super.getAdapter(key);
+ }
+
+ protected List<NodeWrapper> getModelChildren() {
+ return getElementContainerElementWrapper().getNodeWrappers();
+ }
+
+ public IFigure getContentPane() {
+ return ((ElementContainerFigure) getFigure()).getPane();
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ContainerEditPart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/EditPartFactory.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/EditPartFactory.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/EditPartFactory.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,120 @@
+package org.jboss.tools.flow.common.editpart;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.gef.EditPart;
+import org.jboss.tools.flow.common.figure.IFigureFactory;
+import org.jboss.tools.flow.common.figure.NodeFigureFactory;
+import org.jboss.tools.flow.common.model.Element;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
+import org.jboss.tools.flow.common.wrapper.FlowWrapper;
+import org.jboss.tools.flow.common.wrapper.LabelWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+import org.jboss.tools.flow.common.wrapper.Wrapper;
+
+public class EditPartFactory implements org.eclipse.gef.EditPartFactory {
+
+ public EditPart createEditPart(EditPart context, Object model) {
+ EditPart result = null;
+ if (!(model instanceof Wrapper)) return result;
+ result = createEditPart((Wrapper)model);
+ if (result != null) {
+ result.setModel(model);
+ }
+ return result;
+ }
+
+ protected EditPart createEditPart(Wrapper wrapper) {
+ EditPart result = null;
+ if (wrapper instanceof FlowWrapper) {
+ result = createFlowEditPart((FlowWrapper)wrapper);
+ } else if (wrapper instanceof ContainerWrapper) {
+ result = createContainerEditPart((ContainerWrapper)wrapper);
+ } else if (wrapper instanceof NodeWrapper) {
+ result = createNodeEditPart((NodeWrapper)wrapper);
+ } else if (wrapper instanceof ConnectionWrapper) {
+ result = createConnectionEditPart((ConnectionWrapper)wrapper);
+ } else if (wrapper instanceof LabelWrapper) {
+ result = createLabelEditPart((LabelWrapper)wrapper);
+ }
+ return result;
+ }
+
+ protected EditPart createFlowEditPart(FlowWrapper wrapper) {
+ return createFlowEditPart(wrapper.getElement());
+ }
+
+ protected EditPart createFlowEditPart(Element element) {
+ return new RootEditPart();
+ }
+
+ protected EditPart createContainerEditPart(ContainerWrapper wrapper) {
+ Element element = wrapper.getElement();
+ if (element == null) {
+ return null;
+ } else {
+ return createContainerEditPart(element);
+ }
+ }
+
+ protected EditPart createContainerEditPart(Element element) {
+ return new ContainerEditPart();
+ }
+
+ protected EditPart createNodeEditPart(NodeWrapper wrapper) {
+ Element element = wrapper.getElement();
+ if (element == null) {
+ return null;
+ } else {
+ return createNodeEditPart(element);
+ }
+ }
+
+ protected EditPart createNodeEditPart(Element element) {
+ IConfigurationElement configurationElement =
+ (IConfigurationElement)element.getMetaData("configurationElement");
+ if (configurationElement == null) return null;
+ NodeEditPart result = new NodeEditPart();
+ IFigureFactory figureFactory = new NodeFigureFactory(configurationElement);
+ result.setFigureFactory(figureFactory);
+ return result;
+ }
+
+ protected EditPart createConnectionEditPart(ConnectionWrapper wrapper) {
+ Element element = wrapper.getElement();
+ if (element == null) {
+ return null;
+ } else {
+ return createConnectionEditPart(element);
+ }
+ }
+
+ protected EditPart createConnectionEditPart(Element element) {
+ return new ConnectionEditPart();
+ }
+
+ protected EditPart createLabelEditPart(LabelWrapper wrapper) {
+ return new LabelEditPart();
+ }
+
+ protected EditPart createEditPart(Element element) {
+ IConfigurationElement configurationElement =
+ (IConfigurationElement)element.getMetaData("configurationElement");
+ if (configurationElement == null) return null;
+ IConfigurationElement[] children = configurationElement.getChildren();
+ if (children.length != 1) return null;
+ String type = children[0].getName();
+ if ("flow".equals(type)) {
+ return createFlowEditPart(element);
+ } else if ("container".equals(type)) {
+ return createContainerEditPart(element);
+ } else if ("node".equals(type)) {
+ return createNodeEditPart(element);
+ } else if ("connection".equals(type)) {
+ return createConnectionEditPart(element);
+ } else {
+ return null;
+ }
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/EditPartFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ElementEditPart.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ElementEditPart.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ElementEditPart.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,150 @@
+package org.jboss.tools.flow.common.editpart;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Label;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.NodeEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.jboss.tools.flow.common.figure.ElementFigure;
+import org.jboss.tools.flow.common.policy.ElementDirectEditManager;
+import org.jboss.tools.flow.common.policy.ElementDirectEditPolicy;
+import org.jboss.tools.flow.common.policy.ElementEditPolicy;
+import org.jboss.tools.flow.common.policy.ElementNodeEditPolicy;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.ModelEvent;
+import org.jboss.tools.flow.common.wrapper.ModelListener;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * Default implementation of an element EditPart.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public abstract class ElementEditPart extends AbstractGraphicalEditPart implements
NodeEditPart, ModelListener {
+
+ private DirectEditManager manager;
+
+ public NodeWrapper getElementWrapper() {
+ return (NodeWrapper) getModel();
+ }
+
+ public ElementFigure getElementFigure() {
+ return (ElementFigure) getFigure();
+ }
+
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ElementNodeEditPolicy());
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new ElementEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new ElementDirectEditPolicy());
+ }
+
+ protected List<ConnectionWrapper> getModelSourceConnections() {
+ return getElementWrapper().getOutgoingConnections();
+ }
+
+ protected List<ConnectionWrapper> getModelTargetConnections() {
+ return getElementWrapper().getIncomingConnections();
+ }
+
+ public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
+ return getElementFigure().getSourceConnectionAnchor();
+ }
+
+ public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
+ return getElementFigure().getTargetConnectionAnchor();
+ }
+
+ public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+ return getElementFigure().getSourceConnectionAnchor();
+ }
+
+ public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+ return getElementFigure().getTargetConnectionAnchor();
+ }
+
+ protected void refreshVisuals() {
+ NodeWrapper element = getElementWrapper();
+ ElementFigure figure = (ElementFigure) getFigure();
+ figure.setText(element.getName());
+ if (element.getConstraint().width == -1) {
+ element.getConstraint().width = figure.getBounds().width;
+ }
+ if (element.getConstraint().height == -1) {
+ element.getConstraint().height = figure.getBounds().height;
+ }
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(this, figure,
element.getConstraint());
+ }
+
+ public void modelChanged(ModelEvent event) {
+ if (event.getChangeType() == NodeWrapper.ADD_ELEMENT &&
"incomingConnection".equals(event.getChangeDiscriminator())) {
+ refreshTargetConnections();
+ } else if (event.getChangeType() == NodeWrapper.REMOVE_ELEMENT &&
"incomingConnection".equals(event.getChangeDiscriminator())) {
+ refreshTargetConnections();
+ } else if (event.getChangeType() == NodeWrapper.ADD_ELEMENT &&
"outgoingConnection".equals(event.getChangeDiscriminator())) {
+ refreshSourceConnections();
+ } else if (event.getChangeType() == NodeWrapper.REMOVE_ELEMENT &&
"outgoingConnection".equals(event.getChangeDiscriminator())) {
+ refreshSourceConnections();
+ } else if (event.getChangeType() == NodeWrapper.CHANGE_VISUAL) {
+ refreshVisuals();
+ }
+ }
+
+ public void activate() {
+ super.activate();
+ getElementWrapper().addListener(this);
+ }
+
+ public void deactivate() {
+ getElementWrapper().removeListener(this);
+ super.deactivate();
+ }
+
+ public void performRequest(Request request) {
+ if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
+ performDirectEdit();
+ } if (request.getType() == RequestConstants.REQ_OPEN) {
+ doubleClicked();
+ } else {
+ super.performRequest(request);
+ }
+ }
+
+ protected void doubleClicked() {
+ // do nothing
+ }
+
+ protected void performDirectEdit() {
+ Label label = ((ElementFigure) getFigure()).getLabel();
+ if (label == null) {
+ return;
+ }
+ if (manager == null) {
+ manager = new ElementDirectEditManager(this, new CellEditorLocator(label));
+ }
+ manager.show();
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/ElementEditPart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/LabelEditPart.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/LabelEditPart.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/LabelEditPart.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,134 @@
+package org.jboss.tools.flow.common.editpart;
+
+import org.eclipse.draw2d.FigureUtilities;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.Locator;
+import org.eclipse.draw2d.Polyline;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.DragTracker;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gef.tools.DragEditPartsTracker;
+import org.jboss.tools.flow.common.policy.ElementDirectEditManager;
+import org.jboss.tools.flow.common.policy.ElementDirectEditPolicy;
+import org.jboss.tools.flow.common.policy.LabelGraphicalNodeEditPolicy;
+import org.jboss.tools.flow.common.wrapper.LabelWrapper;
+import org.jboss.tools.flow.common.wrapper.ModelEvent;
+import org.jboss.tools.flow.common.wrapper.ModelListener;
+import org.jboss.tools.flow.common.wrapper.Wrapper;
+
+public class LabelEditPart extends AbstractGraphicalEditPart implements ModelListener {
+
+ private DirectEditManager manager;
+
+ @Override
+ protected IFigure createFigure() {
+ return new Label();
+ }
+
+ @Override
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new LabelGraphicalNodeEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new ElementDirectEditPolicy());
+ }
+
+ protected void refreshVisuals() {
+ String text = getLabelWrapper().getText();
+ Polyline polyline = (Polyline)((ConnectionEditPart)getParent()).getConnectionFigure();
+ Point location = ((LabelWrapper)getModel()).getLocation();
+ if (location == null) {
+ location = calculateInitialLocation(polyline, text);
+ ((LabelWrapper)getModel()).setLocation(location);
+ }
+ Label label = (Label)getFigure();
+ label.setText(text);
+ LabelConstraint constraint = new LabelConstraint(text, location, polyline);
+ ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), constraint);
+ }
+
+ private Point calculateInitialLocation(Polyline polyline, String text) {
+ Dimension textDimension = FigureUtilities.getTextExtents(text, figure.getFont());
+ return new Point(- (textDimension.width +5) , -(textDimension.height + 5));
+ }
+
+ public void performRequest(Request request) {
+ if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
+ performDirectEdit();
+ } else {
+ super.performRequest(request);
+ }
+ }
+
+ protected void performDirectEdit() {
+ Label label = (Label) getFigure();
+ if (label == null) {
+ return;
+ }
+ if (manager == null) {
+ manager = new ElementDirectEditManager(this, new CellEditorLocator(label));
+ }
+ manager.show();
+ }
+
+ public LabelWrapper getLabelWrapper() {
+ return (LabelWrapper)getModel();
+ }
+
+ public DragTracker getDragTracker(Request request) {
+ return new DragEditPartsTracker(this) {
+ protected EditPart getTargetEditPart() {
+ return getParent();
+ }
+ };
+ }
+
+ public void activate() {
+ super.activate();
+ getLabelWrapper().addListener(this);
+ if (getParent().getModel() instanceof Wrapper) {
+ ((Wrapper)getParent().getModel()).addListener(this);
+ }
+ }
+
+ public void deactivate() {
+ if (getParent().getModel() instanceof Wrapper) {
+ ((Wrapper)getParent().getModel()).removeListener(this);
+ }
+ getLabelWrapper().removeListener(this);
+ super.deactivate();
+ }
+
+ public void modelChanged(ModelEvent event) {
+ if (event.getChangeType() == Wrapper.CHANGE_PROPERTY || event.getChangeType() ==
Wrapper.CHANGE_VISUAL) {
+ refreshVisuals();
+ }
+ }
+
+ private class LabelConstraint implements Locator {
+ String text;
+ Point relativeLocation;
+ Polyline polyline;
+ public LabelConstraint(String text, Point location, Polyline polyline) {
+ this.text = text;
+ this.relativeLocation = location;
+ this.polyline = polyline;
+ }
+ public void relocate(IFigure figure) {
+ Dimension minimum = FigureUtilities.getTextExtents(text, figure.getFont());
+ figure.setSize(minimum);
+ Point midPoint = polyline.getPoints().getMidpoint();
+ Point newLocation = relativeLocation.getCopy();
+ newLocation.translate(midPoint);
+ figure.setLocation(newLocation);
+ }
+ }
+
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/LabelEditPart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/NodeEditPart.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/NodeEditPart.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/NodeEditPart.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,21 @@
+package org.jboss.tools.flow.common.editpart;
+
+import org.eclipse.draw2d.IFigure;
+import org.jboss.tools.flow.common.figure.IFigureFactory;
+
+public class NodeEditPart extends ElementEditPart {
+
+ private IFigureFactory figureFactory;
+
+ protected IFigure createFigure() {
+ if (figureFactory != null) {
+ return figureFactory.createFigure();
+ }
+ return null;
+ }
+
+ public void setFigureFactory(IFigureFactory figureFactory) {
+ this.figureFactory = figureFactory;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/NodeEditPart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/RootEditPart.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/RootEditPart.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/RootEditPart.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,124 @@
+package org.jboss.tools.flow.common.editpart;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.eclipse.draw2d.Animation;
+import org.eclipse.draw2d.AutomaticRouter;
+import org.eclipse.draw2d.BendpointConnectionRouter;
+import org.eclipse.draw2d.ConnectionLayer;
+import org.eclipse.draw2d.FanRouter;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.ManhattanConnectionRouter;
+import org.eclipse.draw2d.ShortestPathConnectionRouter;
+import org.eclipse.draw2d.XYLayout;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.SnapToGrid;
+import org.eclipse.gef.SnapToHelper;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.gef.editpolicies.RootComponentEditPolicy;
+import org.eclipse.swt.SWT;
+import org.jboss.tools.flow.common.policy.ElementContainerLayoutEditPolicy;
+import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
+import org.jboss.tools.flow.common.wrapper.FlowWrapper;
+import org.jboss.tools.flow.common.wrapper.ModelEvent;
+import org.jboss.tools.flow.common.wrapper.ModelListener;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * Default implementation of a process EditPart.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class RootEditPart extends AbstractGraphicalEditPart implements ModelListener {
+
+ private FlowWrapper getWrapper() {
+ return (FlowWrapper) getModel();
+ }
+
+ protected IFigure createFigure() {
+ Figure f = new Figure();
+ f.setLayoutManager(new XYLayout());
+ return f;
+ }
+
+ protected void createEditPolicies() {
+ installEditPolicy(EditPolicy.NODE_ROLE, null);
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, null);
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null);
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, new
ElementContainerLayoutEditPolicy());
+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new RootComponentEditPolicy());
+ }
+
+ protected List<NodeWrapper> getModelChildren() {
+ return getWrapper().getNodeWrappers();
+ }
+
+ public void activate() {
+ super.activate();
+ getWrapper().addListener(this);
+ }
+
+ public void deactivate() {
+ getWrapper().removeListener(this);
+ super.deactivate();
+ }
+
+ public void modelChanged(ModelEvent event) {
+ if (event.getChangeType() == ContainerWrapper.ADD_ELEMENT) {
+ refreshChildren();
+ } else if (event.getChangeType() == ContainerWrapper.REMOVE_ELEMENT) {
+ refreshChildren();
+ } else if (event.getChangeType() == FlowWrapper.CHANGE_VISUAL) {
+ refreshVisuals();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ if (adapter == SnapToHelper.class) {
+ Boolean val = (Boolean) getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED);
+ if (val != null && val.booleanValue()) {
+ return new SnapToGrid(this);
+ }
+ }
+ return super.getAdapter(adapter);
+ }
+
+ protected void refreshVisuals() {
+ Animation.markBegin();
+ ConnectionLayer layer = (ConnectionLayer)
getLayer(LayerConstants.CONNECTION_LAYER);
+ if ((getViewer().getControl().getStyle() & SWT.MIRRORED ) == 0) {
+ layer.setAntialias(SWT.ON);
+ }
+
+ if (getWrapper().getRouterLayout().equals(FlowWrapper.ROUTER_LAYOUT_MANUAL)) {
+ AutomaticRouter router = new FanRouter();
+ router.setNextRouter(new BendpointConnectionRouter());
+ layer.setConnectionRouter(router);
+ } else if
(getWrapper().getRouterLayout().equals(FlowWrapper.ROUTER_LAYOUT_MANHATTAN)) {
+ layer.setConnectionRouter(new ManhattanConnectionRouter());
+ } else {
+ layer.setConnectionRouter(new ShortestPathConnectionRouter(getFigure()));
+ }
+ Animation.run(400);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/editpart/RootEditPart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/AbstractElementFigure.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/AbstractElementFigure.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/AbstractElementFigure.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,94 @@
+package org.jboss.tools.flow.common.figure;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.ChopboxAnchor;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.Panel;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Default implementation of an element Figure.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public abstract class AbstractElementFigure extends Panel implements ElementFigure {
+
+ private boolean selected;
+ private Label label = new Label();
+
+ public AbstractElementFigure() {
+ add(label);
+ customizeFigure();
+ }
+
+ public void setIcon(Image icon) {
+ label.setIcon(icon);
+ }
+
+ public void setText(String text) {
+ label.setText(text);
+ }
+
+ public Label getLabel() {
+ return label;
+ }
+
+ public void setColor(Color color) {
+ setBackgroundColor(color);
+ }
+
+ public void setBounds(Rectangle bounds) {
+ super.setBounds(bounds);
+ label.setBounds(bounds);
+ }
+
+ protected abstract void customizeFigure();
+
+ public void setSelected(boolean b) {
+ selected = b;
+ }
+
+ public boolean isSelected() {
+ return selected;
+ }
+
+ public void setFocus(boolean b) {
+ repaint();
+ }
+
+ public ConnectionAnchor getSourceConnectionAnchor() {
+ return new ChopboxAnchor(this);
+ }
+
+ public ConnectionAnchor getTargetConnectionAnchor() {
+ return new ChopboxAnchor(this);
+ }
+
+ public void paint(Graphics g) {
+ int saved = g.getAntialias();
+ g.setAntialias(SWT.ON);
+ super.paint(g);
+ g.setAntialias(saved);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/AbstractElementFigure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/CrossHairDecoration.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/CrossHairDecoration.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/CrossHairDecoration.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,27 @@
+package org.jboss.tools.flow.common.figure;
+
+import org.eclipse.draw2d.PolygonDecoration;
+import org.eclipse.draw2d.geometry.PointList;
+
+public class CrossHairDecoration extends PolygonDecoration {
+
+ public static final PointList CROSSHAIR_TIP = new PointList();
+
+ static {
+ CROSSHAIR_TIP.addPoint(0, 0);
+ CROSSHAIR_TIP.addPoint(-1, 0);
+ CROSSHAIR_TIP.addPoint(-1, -1);
+ CROSSHAIR_TIP.addPoint(-1, 0);
+ CROSSHAIR_TIP.addPoint(-2, 0);
+ CROSSHAIR_TIP.addPoint(-1, 0);
+ CROSSHAIR_TIP.addPoint(-1, 1);
+ CROSSHAIR_TIP.addPoint(-1, 0);
+ }
+
+ public CrossHairDecoration() {
+ setTemplate(CROSSHAIR_TIP);
+ setScale(4, 4);
+ setFill(false);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/CrossHairDecoration.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondAnchor.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondAnchor.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondAnchor.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,47 @@
+package org.jboss.tools.flow.common.figure;
+
+import org.eclipse.draw2d.AbstractConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+public class DiamondAnchor extends AbstractConnectionAnchor {
+
+ public DiamondAnchor(IFigure owner) {
+ super(owner);
+ }
+
+ public Point getLocation(Point reference) {
+ Rectangle r = Rectangle.SINGLETON;
+ r.setBounds(getOwner().getBounds());
+ r.translate(-1, -1);
+ r.resize(1, 1);
+ getOwner().translateToAbsolute(r);
+
+ Point ref = r.getCenter().negate().translate(reference);
+
+ float centerX = r.x + 0.5f * r.width;
+ float centerY = r.y + 0.5f * r.height;
+ float dx, dy;
+
+ if (Math.abs(ref.x * r.height) == Math.abs(Math.abs(ref.y)* r.width )) {
+ dx = ref.x > 0 ? r.width / 4 : - r.width / 4;
+ dy = ref.y > 0 ? r.height / 4 : - r.height / 4;
+ } else if (ref.x == 0) {
+ dx = 0;
+ dy = ref.y > 0 ? r.height / 2 : - r.height / 2;
+ } else {
+
+ float numerator = ref.x * r.height * r.width / 2;
+ float firstDenominator = Math.abs(ref.y) * r.width + ref.x * r.height;
+ float secondDenominator = Math.abs(ref.y) * r.width - ref.x * r.height;
+
+ dx = (ref.x > 0) ? numerator / firstDenominator : numerator / secondDenominator;
+ dy = dx * ref.y / ref.x;
+
+ }
+
+ return new Point(Math.round(centerX + dx), Math.round(centerY + dy));
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondAnchor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondDecoration.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondDecoration.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondDecoration.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,26 @@
+package org.jboss.tools.flow.common.figure;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.PolygonDecoration;
+import org.eclipse.draw2d.geometry.PointList;
+
+public class DiamondDecoration extends PolygonDecoration {
+
+ public static final PointList DIAMOND_TIP = new PointList();
+
+ static {
+ DIAMOND_TIP.addPoint(0, 0);
+ DIAMOND_TIP.addPoint(-2, 2);
+ DIAMOND_TIP.addPoint(-4, 0);
+ DIAMOND_TIP.addPoint(-2, -2);
+ }
+
+ public DiamondDecoration() {
+ setTemplate(DIAMOND_TIP);
+ setScale(3.5, 2);
+ setFill(true);
+ setBackgroundColor(ColorConstants.white);
+ setOpaque(true);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondDecoration.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondElementFigure.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondElementFigure.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondElementFigure.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,44 @@
+package org.jboss.tools.flow.common.figure;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Polygon;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+public class DiamondElementFigure extends AbstractElementFigure {
+
+ protected Polygon diamond;
+
+ @Override
+ protected void customizeFigure() {
+ diamond = new Polygon();
+ diamond.setLineWidth(1);
+ add(diamond, 0);
+ setSize(50, 50);
+ diamond.setPoints(calculatePointList());
+ }
+
+ public void setBounds(Rectangle rectangle) {
+ super.setBounds(rectangle);
+ diamond.setPoints(calculatePointList());
+ }
+
+ private PointList calculatePointList() {
+ PointList result = new PointList();
+ Rectangle bounds = getBounds();
+ result.addPoint(bounds.x + bounds.width / 2 - diamond.getLineWidth() / 4, bounds.y +
diamond.getLineWidth() / 2);
+ result.addPoint(bounds.x + bounds.width - diamond.getLineWidth(), bounds.y +
bounds.height / 2 - diamond.getLineWidth() / 4);
+ result.addPoint(bounds.x + bounds.width / 2 - diamond.getLineWidth() / 4, bounds.y +
bounds.height - diamond.getLineWidth());
+ result.addPoint(bounds.x + diamond.getLineWidth() / 2, bounds.y + bounds.height / 2 -
diamond.getLineWidth() / 4);
+ return result;
+ }
+
+ public ConnectionAnchor getSourceConnectionAnchor() {
+ return new DiamondAnchor(this);
+ }
+
+ public ConnectionAnchor getTargetConnectionAnchor() {
+ return new DiamondAnchor(this);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/DiamondElementFigure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/ElementContainerFigure.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/ElementContainerFigure.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/ElementContainerFigure.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,87 @@
+package org.jboss.tools.flow.common.figure;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.ChopboxAnchor;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.FreeformLayer;
+import org.eclipse.draw2d.FreeformLayout;
+import org.eclipse.draw2d.FreeformViewport;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.LineBorder;
+import org.eclipse.draw2d.ScrollPane;
+import org.eclipse.draw2d.StackLayout;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+
+public class ElementContainerFigure extends Figure implements ElementFigure {
+
+ private IFigure pane;
+ private boolean selected = false;
+
+ public ElementContainerFigure() {
+ setSize(200, 150);
+ ScrollPane scrollpane = new ScrollPane();
+ pane = new FreeformLayer();
+ pane.setLayoutManager(new FreeformLayout());
+ setLayoutManager(new StackLayout());
+ add(scrollpane);
+ scrollpane.setViewport(new FreeformViewport());
+ scrollpane.setContents(pane);
+ setBorder(new LineBorder(1));
+ }
+
+ public void setColor(Color color) {
+ setBackgroundColor(color);
+ }
+
+ public Label getLabel() {
+ return null;
+ }
+
+ public boolean isSelected() {
+ return selected;
+ }
+
+ public void setIcon(Image icon) {
+ // Do nothing
+ }
+
+ public void setSelected(boolean b) {
+ this.selected = b;
+ ((LineBorder) getBorder()).setWidth(b ? 3 : 1);
+ }
+
+ public void setText(String text) {
+ // Do nothing
+ }
+
+ public IFigure getPane() {
+ return pane;
+ }
+
+ public ConnectionAnchor getSourceConnectionAnchor() {
+ return new ChopboxAnchor(this);
+ }
+
+ public ConnectionAnchor getTargetConnectionAnchor() {
+ return new ChopboxAnchor(this);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/ElementContainerFigure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/ElementFigure.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/ElementFigure.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/ElementFigure.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,49 @@
+package org.jboss.tools.flow.common.figure;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Default implementation of an element Figure.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public interface ElementFigure extends IFigure {
+
+ void setIcon(Image icon);
+
+ void setColor(Color color);
+
+ void setText(String text);
+
+ void setSelected(boolean b);
+
+ boolean isSelected();
+
+ Label getLabel();
+
+ ConnectionAnchor getSourceConnectionAnchor();
+
+ ConnectionAnchor getTargetConnectionAnchor();
+
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/ElementFigure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/EllipseElementFigure.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/EllipseElementFigure.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/EllipseElementFigure.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,43 @@
+package org.jboss.tools.flow.common.figure;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Ellipse;
+import org.eclipse.draw2d.EllipseAnchor;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+
+public class EllipseElementFigure extends AbstractElementFigure {
+
+ protected Ellipse ellipse;
+
+ protected void customizeFigure() {
+ ellipse = new Ellipse();
+ add(ellipse, 0);
+ ellipse.setBounds(getBounds());
+ setSize(40, 40);
+ }
+
+ public void setColor(Color color) {
+ ellipse.setBackgroundColor(color);
+ }
+
+ public void setBounds(Rectangle rectangle) {
+ super.setBounds(rectangle);
+ ellipse.setBounds(rectangle);
+ }
+
+ public void setSelected(boolean b) {
+ super.setSelected(b);
+ ellipse.setLineWidth(b ? 3 : 1);
+ repaint();
+ }
+
+ public ConnectionAnchor getSourceConnectionAnchor() {
+ return new EllipseAnchor(this);
+ }
+
+ public ConnectionAnchor getTargetConnectionAnchor() {
+ return new EllipseAnchor(this);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/EllipseElementFigure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/IFigureFactory.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/IFigureFactory.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/IFigureFactory.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,9 @@
+package org.jboss.tools.flow.common.figure;
+
+import org.eclipse.draw2d.IFigure;
+
+public interface IFigureFactory {
+
+ IFigure createFigure();
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/IFigureFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/NodeFigureFactory.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/NodeFigureFactory.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/NodeFigureFactory.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,117 @@
+package org.jboss.tools.flow.common.figure;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+public class NodeFigureFactory implements IFigureFactory {
+
+ private static final HashMap<String, Image> imageMap = new HashMap<String,
Image>();
+ private static final HashMap<String, Color> colorMap = new HashMap<String,
Color>();
+
+ private IConfigurationElement configurationElement;
+
+ public NodeFigureFactory(IConfigurationElement configurationElement) {
+ this.configurationElement = configurationElement;
+ }
+
+ public IFigure createFigure() {
+ ElementFigure result = null;
+ IConfigurationElement figureElement = null;
+ IConfigurationElement[] children = configurationElement.getChildren("node");
+ if (children.length == 1) {
+ children = children[0].getChildren("figure");
+ if (children.length == 1) {
+ figureElement = children[0];
+ }
+ }
+ if (figureElement == null) {
+ return new RectangleElementFigure();
+ }
+ if (figureElement.getAttribute("class") != null) {
+ try {
+ return (IFigure)figureElement.createExecutableExtension("class");
+ }
+ catch (CoreException e) {
+ return null;
+ }
+ }
+ children = figureElement.getChildren();
+ if (children.length < 1) {
+ result = new RectangleElementFigure();
+ } else if ("ellipse".equals(children[0].getName())){
+ result = new EllipseElementFigure();
+ } else if ("rounded-rectangle".equals(children[0].getName())) {
+ result = new RoundedRectangleElementFigure();
+ } else {
+ result = new RectangleElementFigure();
+ }
+ if (figureElement.getAttribute("icon") != null) {
+ String iconPath = figureElement.getAttribute("icon");
+ URL url =
Platform.getBundle(figureElement.getContributor().getName()).getEntry(iconPath);
+ Image icon = null;
+ if (imageMap.containsKey(url.getPath())) {
+ icon = imageMap.get(url.getPath());
+ } else {
+ icon = ImageDescriptor.createFromURL(url).createImage();
+ imageMap.put(url.getPath(), icon);
+ }
+ result.setIcon(icon);
+ } else if (configurationElement.getAttribute("figure") != null) {
+ String iconPath = configurationElement.getAttribute("figure");
+ URL url =
Platform.getBundle(configurationElement.getContributor().getName()).getEntry(iconPath);
+ Image icon = null;
+ if (imageMap.containsKey(url.getPath())) {
+ icon = imageMap.get(url.getPath());
+ } else {
+ icon = ImageDescriptor.createFromURL(url).createImage();
+ imageMap.put(url.getPath(), icon);
+ }
+ result.setIcon(icon);
+ }
+ if (figureElement.getAttribute("color") != null) {
+ String colorString = figureElement.getAttribute("color");
+ Color color = null;
+ if (colorMap.containsKey(colorString)) {
+ color = colorMap.get(colorString);
+ } else {
+ try {
+ StringTokenizer tokenizer = new StringTokenizer(colorString, ",");
+ int[] rgb = new int[3];
+ int i = 0;
+ while (tokenizer.hasMoreTokens()) {
+ rgb[i++] = Integer.parseInt(tokenizer.nextToken());
+ }
+ color = new Color(Display.getCurrent(), rgb[0], rgb[1], rgb[2]);
+ colorMap.put(colorString, color);
+ } catch (NumberFormatException e) {}
+ }
+ result.setColor(color);
+ }
+ Dimension size = new Dimension(result.getSize());
+ if (figureElement.getAttribute("width") != null) {
+ try {
+ size.width = Integer.parseInt(figureElement.getAttribute("width"));
+ } catch (NumberFormatException e) {}
+ }
+ if (figureElement.getAttribute("height") != null) {
+ try {
+ size.height = Integer.parseInt(figureElement.getAttribute("height"));
+ } catch (NumberFormatException e) {}
+ }
+ result.setSize(size);
+ return result;
+ }
+
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/NodeFigureFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/RectangleElementFigure.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/RectangleElementFigure.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/RectangleElementFigure.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,34 @@
+package org.jboss.tools.flow.common.figure;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.LineBorder;
+
+public class RectangleElementFigure extends AbstractElementFigure {
+
+ protected void customizeFigure() {
+ setBorder(new LineBorder(1));
+ setSize(80, 40);
+ }
+
+ public void setSelected(boolean b) {
+ super.setSelected(b);
+ ((LineBorder) getBorder()).setWidth(b ? 3 : 1);
+ repaint();
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/RectangleElementFigure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/RoundedRectangleElementFigure.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/RoundedRectangleElementFigure.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/RoundedRectangleElementFigure.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,52 @@
+package org.jboss.tools.flow.common.figure;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.RoundedRectangle;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+
+public class RoundedRectangleElementFigure extends AbstractElementFigure {
+
+ protected RoundedRectangle rectangle;
+
+ protected void customizeFigure() {
+ rectangle = new RoundedRectangle();
+ rectangle.setCornerDimensions(new Dimension(25, 25));
+ add(rectangle, 0);
+ setSize(92, 52);
+ setSelected(false);
+ }
+
+ public void setColor(Color color) {
+ rectangle.setBackgroundColor(color);
+ }
+
+ public void setBounds(Rectangle rectangle) {
+ super.setBounds(rectangle);
+ Rectangle bounds = rectangle.getCopy();
+ this.rectangle.setBounds(bounds.translate(6, 6).resize(-12, -12));
+ }
+
+ public void setSelected(boolean b) {
+ super.setSelected(b);
+ rectangle.setLineWidth(b ? 3 : 1);
+ repaint();
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/figure/RoundedRectangleElementFigure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Connection.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Connection.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Connection.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,62 @@
+package org.jboss.tools.flow.common.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Represents a connection between two nodes in a workflow.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public interface Connection extends Element {
+
+ /**
+ * Returns the from node of the connection.
+ * @return the from node of the connection.
+ */
+ Node getFrom();
+
+ /**
+ * Set the from node of the connection.
+ */
+ void setFrom(Node node);
+
+ /**
+ * Returns the to node of the connection
+ * @return the to node of the connection
+ */
+ Node getTo();
+
+ /**
+ * Set the to node of the connection.
+ */
+ void setTo(Node node);
+
+ /**
+ * Returns the type of the connection at the from node
+ *
+ * @return the type of the connection at the from node
+ */
+ String getFromType();
+
+ /**
+ * Returns the type of the connection at the to node
+ *
+ * @return the type of the connection at the to node
+ */
+ String getToType();
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Connection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Container.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Container.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Container.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,47 @@
+package org.jboss.tools.flow.common.model;
+
+import java.util.List;
+
+/**
+ * A container of nodes.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public interface Container extends Element{
+
+ /**
+ * Returns the nodes of this node container.
+ *
+ * @return the nodes of this node container
+ */
+ List<Node> getNodes();
+
+ /**
+ * Returns the node with the given id
+ *
+ * @param id
+ * the node id
+ * @return the node with the given id
+ * @throws IllegalArgumentException
+ * if an unknown id is passed
+ */
+ Node getNode(long id);
+
+ /**
+ * Method for adding a node to this node container.
+ * Note that the node will get an id unique for this node container.
+ *
+ * @param node the node to be added
+ * @throws IllegalArgumentException if <code>node</code> is null
+ */
+ void addNode(Node node);
+
+ /**
+ * Method for removing a node from this node container
+ *
+ * @param node the node to be removed
+ * @throws IllegalArgumentException if <code>node</code> is null or
unknown
+ */
+ void removeNode(Node node);
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Container.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultConnection.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultConnection.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultConnection.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,53 @@
+package org.jboss.tools.flow.common.model;
+
+
+public class DefaultConnection extends DefaultElement implements Connection {
+
+ private Node from, to;
+
+ public DefaultConnection() {
+ this(null, null);
+ }
+
+ public DefaultConnection(Node from, Node to) {
+ setFrom(from);
+ setTo(to);
+ }
+
+ public Node getFrom() {
+ return from;
+ }
+
+ public void setFrom(Node node) {
+ if (from != null) {
+ from.removeOutgoingConnection(null, this);
+ }
+ from = node;
+ if (from != null) {
+ from.addOutgoingConnection(null, this);
+ }
+ }
+
+ public Node getTo() {
+ return to;
+ }
+
+ public void setTo(Node node) {
+ if (to != null) {
+ to.removeIncomingConnection(null, this);
+ }
+ to = node;
+ if (to != null) {
+ to.addIncomingConnection(null, this);
+ }
+ }
+
+ public String getFromType() {
+ return null;
+ }
+
+ public String getToType() {
+ return null;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultContainer.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultContainer.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultContainer.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,52 @@
+package org.jboss.tools.flow.common.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class DefaultContainer extends DefaultNode implements Container {
+
+ private String name;
+ private HashMap<String, Object> metaData = new HashMap<String, Object>();
+ private ArrayList<Node> nodes = new ArrayList<Node>();
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Object getMetaData(String key) {
+ return metaData.get(key);
+ }
+
+ public void setMetaData(String key, Object value) {
+ metaData.put(key, value);
+ }
+
+ public List<Node> getNodes() {
+ return nodes;
+ }
+
+ public void addNode(Node node) {
+ nodes.add(node);
+ node.setNodeContainer(this);
+ }
+
+ public void removeNode(Node node) {
+ node.setNodeContainer(null);
+ nodes.remove(node);
+ }
+
+ public Node getNode(long id) {
+ for (Node node : nodes) {
+ if (node.getId() == id) {
+ return node;
+ }
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultContainer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultElement.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultElement.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultElement.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,17 @@
+package org.jboss.tools.flow.common.model;
+
+import java.util.HashMap;
+
+public class DefaultElement implements Element {
+
+ private HashMap<String, Object> metaData = new HashMap<String, Object>();
+
+ public Object getMetaData(String key) {
+ return metaData.get(key);
+ }
+
+ public void setMetaData(String key, Object value) {
+ metaData.put(key, value);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultElement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultFlow.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultFlow.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultFlow.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,88 @@
+package org.jboss.tools.flow.common.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class DefaultFlow extends DefaultElement implements Flow {
+
+ private String name;
+ private HashMap<String, Object> metaData = new HashMap<String, Object>();
+ private ArrayList<Node> nodes = new ArrayList<Node>();
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Object getMetaData(String key) {
+ return metaData.get(key);
+ }
+
+ public void setMetaData(String key, Object value) {
+ metaData.put(key, value);
+ }
+
+ public List<Node> getNodes() {
+ return nodes;
+ }
+
+ public void addNode(Node node) {
+ nodes.add(node);
+ node.setNodeContainer(this);
+ }
+
+ public void removeNode(Node node) {
+ node.setNodeContainer(null);
+ nodes.remove(node);
+ }
+
+ public String getId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getPackageName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getVersion() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setId(String id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setPackageName(String packageName) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setType(String type) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setVersion(String version) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Node getNode(long id) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultFlow.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultNode.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultNode.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultNode.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,77 @@
+package org.jboss.tools.flow.common.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DefaultNode extends DefaultElement implements Node {
+
+ private long id;
+ private String name;
+ private Container container;
+
+ private List<Connection> incomingConnections = new ArrayList<Connection>();
+ private List<Connection> outgoingConnections = new ArrayList<Connection>();
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long l) {
+ id = l;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Container getNodeContainer() {
+ return container;
+ }
+
+ public void setNodeContainer(Container container) {
+ this.container = container;
+ }
+
+ public void addIncomingConnection(String type, Connection connection) {
+ incomingConnections.add(connection);
+ }
+
+ public void addOutgoingConnection(String type, Connection connection) {
+ outgoingConnections.add(connection);
+ }
+
+ public Map<String, List<Connection>> getIncomingConnections() {
+ HashMap<String, List<Connection>> result = new HashMap<String,
List<Connection>>();
+ result.put(null, getIncomingConnections(null));
+ return result;
+ }
+
+ public List<Connection> getIncomingConnections(String type) {
+ return new ArrayList<Connection>(incomingConnections);
+ }
+
+ public Map<String, List<Connection>> getOutgoingConnections() {
+ HashMap<String, List<Connection>> result = new HashMap<String,
List<Connection>>();
+ result.put(null, getOutgoingConnections(null));
+ return result;
+ }
+
+ public List<Connection> getOutgoingConnections(String type) {
+ return new ArrayList<Connection>(outgoingConnections);
+ }
+
+ public void removeIncomingConnection(String type, Connection connection) {
+ incomingConnections.remove(connection);
+ }
+
+ public void removeOutgoingConnection(String type, Connection connection) {
+ outgoingConnections.remove(connection);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/DefaultNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Element.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Element.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Element.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,9 @@
+package org.jboss.tools.flow.common.model;
+
+public interface Element {
+
+ void setMetaData(String name, Object value);
+
+ Object getMetaData(String name);
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Element.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Flow.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Flow.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Flow.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,95 @@
+package org.jboss.tools.flow.common.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Represents a some process definition.
+ * A process has a name and a unique id.
+ * When a new version of a process is created, the name stays the same,
+ * but the id and the version of the process should be different.
+ * Different types of processes could be defined (e.g. RuleFlow).
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public interface Flow extends Container, Element {
+
+ /**
+ * Sets the id of this process.
+ * The id should uniquely identify this process.
+ * @param id the id of the process
+ */
+ void setId(String id);
+
+ /**
+ * Returns the id of this process.
+ * @return the id of this process
+ */
+ String getId();
+
+ /**
+ * Sets the name of this process.
+ * @param name the name of this process
+ */
+ void setName(String name);
+
+ /**
+ * Returns the name of this process.
+ * If no name is specified, null is returned.
+ * @return the name of this process
+ */
+ String getName();
+
+ /**
+ * Sets the version of this process.
+ * @param version the version of this process
+ */
+ void setVersion(String version);
+
+ /**
+ * Returns the version of this process.
+ * If no version is specified, null is returned.
+ * @return the version of this process
+ */
+ String getVersion();
+
+ /**
+ * Sets the type of this process.
+ * @param type the type of this process
+ */
+ void setType(String type);
+
+ /**
+ * Returns the type of this process.
+ * @return the type of this process
+ */
+ String getType();
+
+ /**
+ * Sets the package name of this RuleFlow process
+ *
+ * @param packageName the package name of this RuleFlow process
+ */
+ void setPackageName(String packageName);
+
+ /**
+ * Returns the package name of this RuleFlow process
+ *
+ * @return the package name of this RuleFlow process
+ */
+ String getPackageName();
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Flow.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Node.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Node.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Node.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,91 @@
+package org.jboss.tools.flow.common.model;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a node in a workflow process.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public interface Node extends Element {
+
+ /**
+ * Returns the id of the node
+ *
+ * @return the id of the node
+ */
+ long getId();
+
+ /**
+ * Method for setting the id of the node
+ *
+ * @param id the id of the node
+ */
+ void setId(long id);
+
+ /**
+ * Returns the name of the node
+ *
+ * @return the name of the node
+ */
+ String getName();
+
+ /**
+ * Method for setting the name of the node
+ *
+ * @param name the name of the node
+ */
+ void setName(String name);
+
+ /**
+ * Returns the incoming connections
+ *
+ * @return the incoming connections
+ */
+ Map<String, List<Connection>> getIncomingConnections();
+
+ /**
+ * Returns the outgoing connections
+ *
+ * @return the outgoing connections
+ */
+ Map<String, List<Connection>> getOutgoingConnections();
+
+ void addIncomingConnection(String type, Connection connection);
+
+ void addOutgoingConnection(String type, Connection connection);
+
+ void removeIncomingConnection(String type, Connection connection);
+
+ void removeOutgoingConnection(String type, Connection connection);
+
+ List<Connection> getIncomingConnections(String type);
+
+ List<Connection> getOutgoingConnections(String type);
+
+ Container getNodeContainer();
+
+ void setNodeContainer(Container nodeContainer);
+
+ void setMetaData(String name, Object value);
+
+ Object getMetaData(String name);
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/model/Node.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ConnectionBendpointEditPolicy.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ConnectionBendpointEditPolicy.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ConnectionBendpointEditPolicy.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,65 @@
+package org.jboss.tools.flow.common.policy;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.BendpointEditPolicy;
+import org.eclipse.gef.requests.BendpointRequest;
+import org.jboss.tools.flow.common.command.CreateBendpointCommand;
+import org.jboss.tools.flow.common.command.DeleteBendpointCommand;
+import org.jboss.tools.flow.common.command.MoveBendpointCommand;
+
+/**
+ * Policy for bendpoints of connections.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ConnectionBendpointEditPolicy extends BendpointEditPolicy {
+
+ protected Command getCreateBendpointCommand(BendpointRequest request) {
+ Point point = request.getLocation();
+ getConnection().translateToRelative(point);
+
+ CreateBendpointCommand command = new CreateBendpointCommand();
+ command.setLocation(point);
+ command.setConnection(getHost().getModel());
+ command.setIndex(request.getIndex());
+
+ return command;
+ }
+
+ protected Command getDeleteBendpointCommand(BendpointRequest request) {
+ DeleteBendpointCommand command = new DeleteBendpointCommand();
+ command.setConnectionModel(getHost().getModel());
+ command.setIndex(request.getIndex());
+ return command;
+ }
+
+ protected Command getMoveBendpointCommand(BendpointRequest request) {
+ Point location = request.getLocation();
+ getConnection().translateToRelative(location);
+
+ MoveBendpointCommand command = new MoveBendpointCommand();
+ command.setConnectionModel(getHost().getModel());
+ command.setIndex(request.getIndex());
+ command.setNewLocation(location);
+
+ return command;
+
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ConnectionBendpointEditPolicy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ConnectionEditPolicy.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ConnectionEditPolicy.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ConnectionEditPolicy.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,105 @@
+package org.jboss.tools.flow.common.policy;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gef.requests.CreationFactory;
+import org.eclipse.gef.requests.GroupRequest;
+import org.jboss.tools.flow.common.command.DeleteConnectionCommand;
+import org.jboss.tools.flow.common.command.SplitConnectionCommand;
+import org.jboss.tools.flow.common.editpart.ConnectionEditPart;
+import org.jboss.tools.flow.common.model.Element;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.FlowWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * Policy for editing connections.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ConnectionEditPolicy extends
org.eclipse.gef.editpolicies.ConnectionEditPolicy {
+
+ private CreationFactory elementConnectionFactory;
+
+ public void setElementConnectionFactory(CreationFactory elementConnectionFactory) {
+ this.elementConnectionFactory = elementConnectionFactory;
+ }
+
+ public Command getCommand(Request request) {
+ if (REQ_CREATE.equals(request.getType())) {
+ return getSplitConnectionCommand(request);
+ }
+ return super.getCommand(request);
+ }
+
+ private PolylineConnection getConnectionFigure() {
+ return ((PolylineConnection) ((ConnectionEditPart) getHost()).getFigure());
+ }
+
+ protected Command getDeleteCommand(GroupRequest request) {
+ DeleteConnectionCommand cmd = new DeleteConnectionCommand();
+ ConnectionWrapper connection = (ConnectionWrapper) getHost().getModel();
+ cmd.setAntecedentTaskConnection(connection);
+ cmd.setSource(connection.getSource());
+ cmd.setTarget(connection.getTarget());
+ return cmd;
+ }
+
+ protected Command getSplitConnectionCommand(Request request) {
+ if (elementConnectionFactory == null) {
+ throw new IllegalStateException("DefaultElementConnectionFactory is
null");
+ }
+ SplitConnectionCommand cmd = new SplitConnectionCommand();
+ ConnectionWrapper elementConnection = (ConnectionWrapper)getHost().getModel();
+ ConnectionWrapper newSecondConnection =
(ConnectionWrapper)elementConnectionFactory.getNewObject();
+ // Copy the configurationElement from the first connection as it is empty
+ ((Element)newSecondConnection.getElement()).setMetaData(
+ "configurationElement",
+
((Element)elementConnection.getElement()).getMetaData("configurationElement"));
+ cmd.setElementConnection(elementConnection);
+ cmd.setNewSecondConnection(newSecondConnection);
+ cmd.setParent(((FlowWrapper) ((ConnectionEditPart) getHost())
+ .getSource().getParent().getModel()));
+ cmd.setNewElement(((NodeWrapper) ((CreateRequest) request).getNewObject()));
+ return cmd;
+ }
+
+ public EditPart getTargetEditPart(Request request) {
+ if (REQ_CREATE.equals(request.getType())) {
+ return getHost();
+ }
+ return null;
+ }
+
+ public void eraseTargetFeedback(Request request) {
+ if (REQ_CREATE.equals(request.getType())) {
+ getConnectionFigure().setLineWidth(1);
+ }
+ }
+
+ public void showTargetFeedback(Request request) {
+ if (REQ_CREATE.equals(request.getType())) {
+ getConnectionFigure().setLineWidth(2);
+ }
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ConnectionEditPolicy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementContainerLayoutEditPolicy.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementContainerLayoutEditPolicy.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementContainerLayoutEditPolicy.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,61 @@
+package org.jboss.tools.flow.common.policy;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
+import org.eclipse.gef.requests.CreateRequest;
+import org.jboss.tools.flow.common.command.AddNodeCommand;
+import org.jboss.tools.flow.common.command.ChangeConstraintCommand;
+import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * Policy for performing layout of a process.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ElementContainerLayoutEditPolicy extends XYLayoutEditPolicy {
+
+ protected Command getCreateCommand(CreateRequest request) {
+ AddNodeCommand command = new AddNodeCommand();
+ command.setParent((ContainerWrapper) getHost().getModel());
+ NodeWrapper element = (NodeWrapper) request.getNewObject();
+ element.setConstraint((Rectangle) getConstraintFor(request));
+ command.setChild(element);
+ return command;
+ }
+
+ protected Command getDeleteDependantCommand(Request request) {
+ return null;
+ }
+
+ protected Command createAddCommand(EditPart child, Object constraint) {
+ // TODO this is needed to allow dragging of elements from one container to
another
+ return null;
+ }
+
+ protected Command createChangeConstraintCommand(EditPart child, Object constraint) {
+ ChangeConstraintCommand command = new ChangeConstraintCommand();
+ command.setElement((NodeWrapper) child.getModel());
+ command.setConstraint((Rectangle)constraint);
+ return command;
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementContainerLayoutEditPolicy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementDirectEditManager.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementDirectEditManager.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementDirectEditManager.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,54 @@
+package org.jboss.tools.flow.common.policy;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.tools.CellEditorLocator;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.flow.common.properties.IPropertyId;
+import org.jboss.tools.flow.common.wrapper.Wrapper;
+
+/**
+ * Manager for directly editing elements.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ElementDirectEditManager extends DirectEditManager {
+
+ private IPropertySource propertySource;
+
+ public ElementDirectEditManager(GraphicalEditPart source, CellEditorLocator locator)
{
+ super(source, TextCellEditor.class, locator);
+ Object object = source.getModel();
+ if (object instanceof Wrapper) {
+ propertySource =
(IPropertySource)((Wrapper)object).getAdapter(IPropertySource.class);
+ }
+ }
+
+ protected void initCellEditor() {
+ String initialValue = null;
+ if (propertySource != null) {
+ initialValue = (String)propertySource.getPropertyValue(IPropertyId.NAME);
+ }
+ getCellEditor().setValue(initialValue == null ? "" : initialValue);
+ Text text = (Text) getCellEditor().getControl();
+ text.selectAll();
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementDirectEditManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementDirectEditPolicy.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementDirectEditPolicy.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementDirectEditPolicy.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,58 @@
+package org.jboss.tools.flow.common.policy;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.DirectEditPolicy;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.flow.common.command.RenameElementCommand;
+import org.jboss.tools.flow.common.figure.ElementFigure;
+import org.jboss.tools.flow.common.properties.IPropertyId;
+import org.jboss.tools.flow.common.wrapper.Wrapper;
+
+/**
+ * Policy for directly editing elements.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ElementDirectEditPolicy extends DirectEditPolicy {
+
+ protected Command getDirectEditCommand(DirectEditRequest request) {
+ RenameElementCommand cmd = new RenameElementCommand();
+ cmd.setSource((Wrapper) getHost().getModel());
+ IPropertySource propertySource =
(IPropertySource)((Wrapper)getHost().getModel()).getAdapter(IPropertySource.class);
+ if (propertySource != null) {
+ cmd.setOldName((String)propertySource.getPropertyValue(IPropertyId.NAME));
+ }
+ cmd.setName((String) request.getCellEditor().getValue());
+ return cmd;
+ }
+
+ protected void showCurrentEditValue(DirectEditRequest request) {
+ String value = (String) request.getCellEditor().getValue();
+ IFigure figure = getHostFigure();
+ if (figure instanceof Label) {
+ ((Label)figure).setText(value);
+ } else if (figure instanceof ElementFigure){
+ ((ElementFigure)figure).setText(value);
+ }
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementDirectEditPolicy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementEditPolicy.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementEditPolicy.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementEditPolicy.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,41 @@
+package org.jboss.tools.flow.common.policy;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.ComponentEditPolicy;
+import org.eclipse.gef.requests.GroupRequest;
+import org.jboss.tools.flow.common.command.DeleteNodeCommand;
+import org.jboss.tools.flow.common.wrapper.ContainerWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * Policy for editing elements.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ElementEditPolicy extends ComponentEditPolicy {
+
+ protected Command createDeleteCommand(GroupRequest deleteRequest) {
+ ContainerWrapper parent = (ContainerWrapper) getHost().getParent().getModel();
+ DeleteNodeCommand deleteCmd = new DeleteNodeCommand();
+ deleteCmd.setParent(parent);
+ deleteCmd.setChild((NodeWrapper) (getHost().getModel()));
+ return deleteCmd;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementEditPolicy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementNodeEditPolicy.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementNodeEditPolicy.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementNodeEditPolicy.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,78 @@
+package org.jboss.tools.flow.common.policy;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy;
+import org.eclipse.gef.requests.CreateConnectionRequest;
+import org.eclipse.gef.requests.ReconnectRequest;
+import org.jboss.tools.flow.common.command.ElementConnectionCreateCommand;
+import org.jboss.tools.flow.common.command.ReconnectElementConnectionSourceCommand;
+import org.jboss.tools.flow.common.command.ReconnectElementConnectionTargetCommand;
+import org.jboss.tools.flow.common.editpart.ElementEditPart;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.NodeWrapper;
+
+/**
+ * Policy for editing an element node.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ElementNodeEditPolicy extends GraphicalNodeEditPolicy {
+
+ protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
+ ElementConnectionCreateCommand cmd =
+ (ElementConnectionCreateCommand) request.getStartCommand();
+ cmd.setConnection((ConnectionWrapper) request.getNewObject());
+ cmd.setTarget(getElement());
+ return cmd;
+ }
+
+ protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
+ ElementConnectionCreateCommand cmd =
+ new ElementConnectionCreateCommand();
+ cmd.setConnection((ConnectionWrapper) request.getNewObject());
+ cmd.setSource(getElement());
+ request.setStartCommand(cmd);
+ return cmd;
+ }
+
+ protected ElementEditPart getActivityPart() {
+ return (ElementEditPart) getHost();
+ }
+
+ protected NodeWrapper getElement() {
+ return (NodeWrapper) getHost().getModel();
+ }
+
+ protected Command getReconnectSourceCommand(ReconnectRequest request) {
+ ReconnectElementConnectionSourceCommand cmd
+ = new ReconnectElementConnectionSourceCommand();
+ cmd.setConnection((ConnectionWrapper)
request.getConnectionEditPart().getModel());
+ cmd.setSource(getElement());
+ return cmd;
+ }
+
+ protected Command getReconnectTargetCommand(ReconnectRequest request) {
+ ReconnectElementConnectionTargetCommand cmd
+ = new ReconnectElementConnectionTargetCommand();
+ cmd.setConnection((ConnectionWrapper)
request.getConnectionEditPart().getModel());
+ cmd.setTarget(getElement());
+ return cmd;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/ElementNodeEditPolicy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/LabelGraphicalNodeEditPolicy.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/LabelGraphicalNodeEditPolicy.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/LabelGraphicalNodeEditPolicy.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,25 @@
+package org.jboss.tools.flow.common.policy;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.jboss.tools.flow.common.command.LabelMoveCommand;
+import org.jboss.tools.flow.common.wrapper.LabelWrapper;
+
+public class LabelGraphicalNodeEditPolicy extends NonResizableEditPolicy {
+
+ public Command getMoveCommand(ChangeBoundsRequest request) {
+ if (!(getHost().getModel() instanceof LabelWrapper)) return null;
+ LabelWrapper model = (LabelWrapper)getHost().getModel();
+ Point delta = request.getMoveDelta();
+ return new LabelMoveCommand(model, getParentFigure(), delta);
+ }
+
+ private IFigure getParentFigure() {
+ return ((GraphicalEditPart)getHost().getParent()).getFigure();
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/policy/LabelGraphicalNodeEditPolicy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultContainerWrapperPropertySource.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultContainerWrapperPropertySource.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultContainerWrapperPropertySource.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,65 @@
+package org.jboss.tools.flow.common.properties;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+import org.jboss.tools.flow.common.wrapper.DefaultContainerWrapper;
+
+public class DefaultContainerWrapperPropertySource extends WrapperPropertySource
implements IPropertyId {
+
+ private DefaultContainerWrapper wrapper = null;
+ private IPropertyDescriptor[] propertyDescriptors;
+
+ public DefaultContainerWrapperPropertySource(DefaultContainerWrapper wrapper) {
+ super(wrapper);
+ this.wrapper = wrapper;
+ }
+
+ public Object getEditableValue() {
+ return super.getEditableValue();
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ if (propertyDescriptors == null) {
+ propertyDescriptors = new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(NAME, "Name") {
+ public String getCategory() {
+ return "General";
+ }
+ }
+ };
+ propertyDescriptors = merge(propertyDescriptors, super.getPropertyDescriptors());
+ }
+ return propertyDescriptors;
+ }
+
+ public Object getPropertyValue(Object id) {
+ if (NAME.equals(id)) {
+ return wrapper.getName();
+ } else {
+ return super.getPropertyValue(id);
+ }
+ }
+
+ public boolean isPropertySet(Object id) {
+ if (NAME.equals(id)) {
+ return wrapper.getName() != null;
+ } else {
+ return super.isPropertySet(id);
+ }
+ }
+
+ public void resetPropertyValue(Object id) {
+ super.resetPropertyValue(id);
+ }
+
+ public void setPropertyValue(Object id, Object value) {
+ if (NAME.equals(id)) {
+ if (value instanceof String) {
+ wrapper.setName((String)value);
+ }
+ } else {
+ super.setPropertyValue(id, value);
+ }
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultContainerWrapperPropertySource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultFlowWrapperPropertySource.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultFlowWrapperPropertySource.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultFlowWrapperPropertySource.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,60 @@
+package org.jboss.tools.flow.common.properties;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+import org.jboss.tools.flow.common.wrapper.DefaultFlowWrapper;
+
+public class DefaultFlowWrapperPropertySource extends WrapperPropertySource implements
IPropertyId {
+
+ private DefaultFlowWrapper wrapper = null;
+ private IPropertyDescriptor[] propertyDescriptors;
+
+ public DefaultFlowWrapperPropertySource(DefaultFlowWrapper wrapper) {
+ super(wrapper);
+ this.wrapper = (DefaultFlowWrapper)wrapper;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ if (propertyDescriptors == null) {
+ propertyDescriptors = new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(NAME, "Name") {
+ public String getCategory() {
+ return "General";
+ }
+ }
+ };
+ propertyDescriptors = merge(propertyDescriptors, super.getPropertyDescriptors());
+ }
+ return propertyDescriptors;
+ }
+
+ public Object getPropertyValue(Object id) {
+ if (NAME.equals(id)) {
+ return wrapper.getName();
+ } else {
+ return super.getPropertyValue(id);
+ }
+ }
+
+ public boolean isPropertySet(Object id) {
+ if (NAME.equals(id)) {
+ return wrapper.getName() != null;
+ } else {
+ return super.isPropertySet(id);
+ }
+ }
+
+ public void resetPropertyValue(Object id) {
+ super.resetPropertyValue(id);
+ }
+
+ public void setPropertyValue(Object id, Object value) {
+ if (NAME.equals(id)) {
+ if (value instanceof String) {
+ wrapper.setName((String)value);
+ }
+ } else {
+ super.setPropertyValue(id, value);
+ }
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultFlowWrapperPropertySource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultNodeWrapperPropertySource.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultNodeWrapperPropertySource.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultNodeWrapperPropertySource.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,64 @@
+package org.jboss.tools.flow.common.properties;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+import org.jboss.tools.flow.common.wrapper.DefaultNodeWrapper;
+
+public class DefaultNodeWrapperPropertySource extends WrapperPropertySource implements
IPropertyId {
+
+ private DefaultNodeWrapper wrapper = null;
+ private IPropertyDescriptor[] propertyDescriptors;
+
+ public DefaultNodeWrapperPropertySource(DefaultNodeWrapper wrapper) {
+ super(wrapper);
+ this.wrapper = wrapper;
+ }
+
+ public Object getEditableValue() {
+ return super.getEditableValue();
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ if (propertyDescriptors == null) {
+ propertyDescriptors = new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(NAME, "Name") {
+ public String getCategory() {
+ return "General";
+ }
+ }
+ };
+ propertyDescriptors = merge(propertyDescriptors, super.getPropertyDescriptors());
+ }
+ return propertyDescriptors;
+ }
+
+ public Object getPropertyValue(Object id) {
+ if (NAME.equals(id)) {
+ return wrapper.getName() != null ? wrapper.getName() : "";
+ } else {
+ return super.getPropertyValue(id);
+ }
+ }
+
+ public boolean isPropertySet(Object id) {
+ if (NAME.equals(id)) {
+ return wrapper.getName() != null;
+ } else {
+ return super.isPropertySet(id);
+ }
+ }
+
+ public void resetPropertyValue(Object id) {
+ super.resetPropertyValue(id);
+ }
+
+ public void setPropertyValue(Object id, Object value) {
+ if (NAME.equals(id)) {
+ if (value instanceof String) {
+ wrapper.setName((String)value);
+ }
+ } else {
+ super.setPropertyValue(id, value);
+ }
+ }
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultNodeWrapperPropertySource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/IPropertyId.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/IPropertyId.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/IPropertyId.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,8 @@
+package org.jboss.tools.flow.common.properties;
+
+public interface IPropertyId {
+
+ String NAME = "org.jboss.tools.flow.common.model.name";
+ String LABEL = "org.jboss.tools.flow.common.model.label";
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/IPropertyId.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,79 @@
+package org.jboss.tools.flow.common.properties;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.flow.common.wrapper.Wrapper;
+
+public class WrapperPropertySource implements IPropertySource {
+
+ private Wrapper wrapper;
+ private IPropertySource elementPropertySource;
+
+ public WrapperPropertySource(Wrapper wrapper) {
+ this.wrapper = wrapper;
+ if (wrapper != null && wrapper.getElement() != null) {
+ Object object = wrapper.getElement().getMetaData("propertySource");
+ if (object != null && object instanceof IPropertySource) {
+ elementPropertySource = (IPropertySource)object;
+ }
+ }
+ }
+
+ public Object getEditableValue() {
+ if (elementPropertySource != null) {
+ return elementPropertySource.getEditableValue();
+ }
+ return null;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ if (elementPropertySource != null) {
+ return elementPropertySource.getPropertyDescriptors();
+ }
+ return new IPropertyDescriptor[0];
+ }
+
+ public Object getPropertyValue(Object id) {
+ if (elementPropertySource != null) {
+ return elementPropertySource.getPropertyValue(id);
+ }
+ return null;
+ }
+
+ public boolean isPropertySet(Object id) {
+ if (elementPropertySource != null) {
+ return elementPropertySource.isPropertySet(id);
+ }
+ return false;
+ }
+
+ public void resetPropertyValue(Object id) {
+ if (elementPropertySource != null) {
+ elementPropertySource.resetPropertyValue(id);
+ }
+ }
+
+ public void setPropertyValue(Object id, Object newValue) {
+ if (elementPropertySource != null) {
+ Object oldValue = elementPropertySource.getPropertyValue(id);
+ elementPropertySource.setPropertyValue(id, newValue);
+ wrapper.notifyListeners(Wrapper.CHANGE_PROPERTY, id, wrapper, oldValue, newValue);
+ }
+ }
+
+ protected Wrapper getWrapper() {
+ return wrapper;
+ }
+
+ protected IPropertyDescriptor[] merge(IPropertyDescriptor[] first, IPropertyDescriptor[]
second) {
+ IPropertyDescriptor[] result = new IPropertyDescriptor[first.length + second.length];
+ for (int i = 0; i < first.length; i++) {
+ result[i] = first[i];
+ }
+ for (int i = first.length; i < result.length; i++) {
+ result[i] = second[i - first.length];
+ }
+ return result;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,340 @@
+package org.jboss.tools.flow.common.registry;
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.gef.requests.CreationFactory;
+import org.jboss.tools.flow.common.Logger;
+import org.jboss.tools.flow.common.model.Connection;
+import org.jboss.tools.flow.common.model.Container;
+import org.jboss.tools.flow.common.model.Element;
+import org.jboss.tools.flow.common.model.Flow;
+import org.jboss.tools.flow.common.model.Node;
+import org.jboss.tools.flow.common.strategy.AcceptsElementStrategy;
+import org.jboss.tools.flow.common.strategy.AcceptsIncomingConnectionStrategy;
+import org.jboss.tools.flow.common.strategy.AcceptsOutgoingConnectionStrategy;
+import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.DefaultConnectionWrapper;
+import org.jboss.tools.flow.common.wrapper.DefaultContainerWrapper;
+import org.jboss.tools.flow.common.wrapper.DefaultFlowWrapper;
+import org.jboss.tools.flow.common.wrapper.DefaultLabelWrapper;
+import org.jboss.tools.flow.common.wrapper.DefaultNodeWrapper;
+import org.jboss.tools.flow.common.wrapper.DefaultWrapper;
+import org.jboss.tools.flow.common.wrapper.Wrapper;
+
+public class ElementRegistry {
+
+ private static final String elementsExtensionPointId =
"org.jboss.tools.flow.common.elements";
+ private static HashMap<String, IConfigurationElement> elementMap = null;
+
+
+ private static void initializeRegistry() {
+ elementMap = new HashMap<String, IConfigurationElement>();
+ IConfigurationElement[] configurationElements =
+ Platform.getExtensionRegistry().getConfigurationElementsFor(elementsExtensionPointId);
+ for (IConfigurationElement configurationElement: configurationElements) {
+ elementMap.put(configurationElement.getAttribute("id"),
configurationElement);
+ }
+ }
+
+ private static Wrapper createWrapper(IConfigurationElement configurationElement)
+ throws CoreException {
+ IConfigurationElement[] children = configurationElement.getChildren();
+ if (children.length > 1) return null;
+ if (children.length == 0) {
+ return createDefault(configurationElement);
+ }
+ String type = children[0].getName();
+ if ("flow".equals(type)) {
+ return createFlow(configurationElement);
+ } else if ("container".equals(type)) {
+ return createContainer(configurationElement);
+ } else if ("node".equals(type)) {
+ return createNode(configurationElement);
+ } else if ("connection".equals(type)) {
+ return createConnection(configurationElement);
+ } else {
+ return null;
+ }
+ }
+
+ private static Wrapper createDefault(IConfigurationElement configurationElement)
+ throws CoreException {
+ Object element = configurationElement.createExecutableExtension("class");
+ if (!(element instanceof Element)) {
+ String message = "Expecting to instantiate a
org.jboss.tools.flow.common.model.Element instance.";
+ Logger.logError(message, new RuntimeException(message));
+ return null;
+ }
+ ((Element)element).setMetaData("configurationElement",
configurationElement);
+ DefaultWrapper result = new DefaultWrapper();
+ result.setElement((Element)element);
+ return result;
+ }
+
+ private static Wrapper createConnection(IConfigurationElement configurationElement)
+ throws CoreException {
+ Object element = configurationElement.createExecutableExtension("class");
+ if (!(element instanceof Connection)) {
+ String message = "Expecting to instantiate a
org.jboss.tools.flow.common.model.Connection instance.";
+ Logger.logError(message, new RuntimeException(message));
+ return null;
+ }
+ ((Element)element).setMetaData("configurationElement",
configurationElement);
+ ConnectionWrapper result = new DefaultConnectionWrapper();
+ result.setElement((Element)element);
+ result.setLabel(new DefaultLabelWrapper(result));
+ return result;
+ }
+
+ private static Wrapper createNode(IConfigurationElement configurationElement)
+ throws CoreException {
+ Object element = configurationElement.createExecutableExtension("class");
+ if (!(element instanceof Node)) {
+ String message = "Expecting to instantiate a
org.jboss.tools.flow.common.model.Node instance.";
+ Logger.logError(message, new RuntimeException(message));
+ return null;
+ }
+ ((Node)element).setMetaData("configurationElement", configurationElement);
+ DefaultNodeWrapper result = new DefaultNodeWrapper();
+ result.setElement((Element)element);
+ AcceptsIncomingConnectionStrategy acceptsIncomingConnectionStrategy =
createAcceptsIncomingConnectionStrategy(configurationElement);
+ if (acceptsIncomingConnectionStrategy != null) {
+ acceptsIncomingConnectionStrategy.setNode((Node)element);
+ result.setAcceptsIncomingConnectionStrategy(acceptsIncomingConnectionStrategy);
+ }
+ AcceptsOutgoingConnectionStrategy acceptsOutgoingConnectionStrategy =
createAcceptsOutgoingConnectionStrategy(configurationElement);
+ if (acceptsOutgoingConnectionStrategy != null) {
+ acceptsOutgoingConnectionStrategy.setNode((Node)element);
+ result.setAcceptsOutgoingConnectionStrategy(acceptsOutgoingConnectionStrategy);
+ }
+ ((Node)element).setName(configurationElement.getAttribute("name"));
+ return result;
+ }
+
+ private static Wrapper createContainer(IConfigurationElement configurationElement)
+ throws CoreException {
+ Object element = configurationElement.createExecutableExtension("class");
+ if (!(element instanceof Container)) {
+ String message = "Expecting to instantiate a
org.jboss.tools.flow.common.model.Container instance.";
+ Logger.logError(message, new RuntimeException(message));
+ return null;
+ }
+ ((Element) element).setMetaData("configurationElement",
configurationElement);
+ DefaultContainerWrapper result = new DefaultContainerWrapper();
+ result.setElement((Element)element);
+ AcceptsElementStrategy acceptsElementStrategy =
createAcceptsElementStrategy(configurationElement);
+ if (acceptsElementStrategy != null) {
+ acceptsElementStrategy.setContainer((Container)element);
+ result.setAcceptsElementStrategy(acceptsElementStrategy);
+ }
+ AcceptsIncomingConnectionStrategy acceptsIncomingConnectionStrategy =
createAcceptsIncomingConnectionStrategy(configurationElement);
+ if (acceptsIncomingConnectionStrategy != null) {
+ acceptsIncomingConnectionStrategy.setNode((Node)element);
+ result.setAcceptsIncomingConnectionStrategy(acceptsIncomingConnectionStrategy);
+ }
+ AcceptsOutgoingConnectionStrategy acceptsOutgoingConnectionStrategy =
createAcceptsOutgoingConnectionStrategy(configurationElement);
+ if (acceptsOutgoingConnectionStrategy != null) {
+ acceptsOutgoingConnectionStrategy.setNode((Node)element);
+ result.setAcceptsOutgoingConnectionStrategy(acceptsOutgoingConnectionStrategy);
+ }
+ if (element instanceof Node) {
+ ((Node)element).setName(configurationElement.getAttribute("name"));
+ }
+ return result;
+ }
+
+ private static AcceptsIncomingConnectionStrategy
createAcceptsIncomingConnectionStrategy(IConfigurationElement configurationElement)
+ throws CoreException {
+ Object result = null;
+ IConfigurationElement[] children = configurationElement.getChildren();
+ if (children[0].getAttribute("acceptsIncomingConnectionStrategy") != null) {
+ result =
children[0].createExecutableExtension("acceptsIncomingConnectionStrategy");
+ }
+ return (AcceptsIncomingConnectionStrategy)result;
+ }
+
+ private static AcceptsOutgoingConnectionStrategy
createAcceptsOutgoingConnectionStrategy(IConfigurationElement configurationElement)
+ throws CoreException {
+ Object result = null;
+ IConfigurationElement[] children = configurationElement.getChildren();
+ if (children[0].getAttribute("acceptsOutgoingConnectionStrategy") != null) {
+ result =
children[0].createExecutableExtension("acceptsOutgoingConnectionStrategy");
+ }
+ return (AcceptsOutgoingConnectionStrategy)result;
+ }
+
+ private static AcceptsElementStrategy createAcceptsElementStrategy(IConfigurationElement
configurationElement)
+ throws CoreException {
+ Object result = null;
+ IConfigurationElement[] children = configurationElement.getChildren();
+ if (children[0].getAttribute("acceptsElementStrategy") != null) {
+ result = children[0].createExecutableExtension("acceptsElementStrategy");
+ }
+ return (AcceptsElementStrategy)result;
+ }
+
+ private static Wrapper createFlow(IConfigurationElement configurationElement)
+ throws CoreException {
+ Object element = configurationElement.createExecutableExtension("class");
+ if (!(element instanceof Container)) {
+ String message = "Expecting to instantiate a
org.jboss.tools.flow.common.model.Container instance.";
+ Logger.logError(message, new RuntimeException(message));
+ return null;
+ }
+ ((Element) element).setMetaData("configurationElement",
configurationElement);
+ DefaultFlowWrapper result = new DefaultFlowWrapper();
+ result.setElement((Element)element);
+ AcceptsElementStrategy acceptsElementStrategy =
createAcceptsElementStrategy(configurationElement);
+ if (acceptsElementStrategy != null) {
+ acceptsElementStrategy.setContainer((Container)result.getElement());
+ result.setAcceptsElementStrategy(acceptsElementStrategy);
+ }
+ if (element instanceof Flow) {
+ ((Flow)element).setName(configurationElement.getAttribute("name"));
+ }
+ return result;
+ }
+
+// private static EditPart createConnectionEditPart(final IConfigurationElement
configurationElement) {
+// return new ConnectionEditPart() {
+// };
+// }
+//
+// private static EditPart createNodeEditPart(final IConfigurationElement
configurationElement) {
+// return new ElementEditPart() {
+// protected IFigure createFigure() {
+// ElementFigure result = null;
+// IConfigurationElement figureElement = null;
+// IConfigurationElement[] children =
configurationElement.getChildren("node");
+// if (children.length == 1) {
+// children = children[0].getChildren("figure");
+// if (children.length == 1) {
+// figureElement = children[0];
+// }
+// }
+// if (figureElement == null) {
+// return new RectangleElementFigure();
+// }
+// if (figureElement.getAttribute("class") != null) {
+// try {
+// return (IFigure)figureElement.createExecutableExtension("class");
+// }
+// catch (CoreException e) {
+// return null;
+// }
+// }
+// children = figureElement.getChildren();
+// if (children.length < 1) {
+// result = new RectangleElementFigure();
+// } else if ("ellipse".equals(children[0].getName())){
+// result = new EllipseElementFigure();
+// } else if ("rounded-rectangle".equals(children[0].getName())) {
+// result = new RoundedRectangleElementFigure();
+// } else {
+// result = new RectangleElementFigure();
+// }
+// if (figureElement.getAttribute("icon") != null) {
+// String iconPath = figureElement.getAttribute("icon");
+// URL url =
Platform.getBundle(figureElement.getContributor().getName()).getEntry(iconPath);
+// Image icon = null;
+// if (imageMap.containsKey(url.getPath())) {
+// icon = imageMap.get(url.getPath());
+// } else {
+// icon = ImageDescriptor.createFromURL(url).createImage();
+// imageMap.put(url.getPath(), icon);
+// }
+// result.setIcon(icon);
+// } else if (configurationElement.getAttribute("figure") != null) {
+// String iconPath = configurationElement.getAttribute("figure");
+// URL url =
Platform.getBundle(configurationElement.getContributor().getName()).getEntry(iconPath);
+// Image icon = null;
+// if (imageMap.containsKey(url.getPath())) {
+// icon = imageMap.get(url.getPath());
+// } else {
+// icon = ImageDescriptor.createFromURL(url).createImage();
+// imageMap.put(url.getPath(), icon);
+// }
+// result.setIcon(icon);
+// }
+// if (figureElement.getAttribute("color") != null) {
+// String colorString = figureElement.getAttribute("color");
+// Color color = null;
+// if (colorMap.containsKey(colorString)) {
+// color = colorMap.get(colorString);
+// } else {
+// try {
+// StringTokenizer tokenizer = new StringTokenizer(colorString, ",");
+// int[] rgb = new int[3];
+// int i = 0;
+// while (tokenizer.hasMoreTokens()) {
+// rgb[i++] = Integer.parseInt(tokenizer.nextToken());
+// }
+// color = new Color(Display.getCurrent(), rgb[0], rgb[1], rgb[2]);
+// colorMap.put(colorString, color);
+// } catch (NumberFormatException e) {}
+// }
+// result.setColor(color);
+// }
+// Dimension size = new Dimension(result.getSize());
+// if (figureElement.getAttribute("width") != null) {
+// try {
+// size.width = Integer.parseInt(figureElement.getAttribute("width"));
+// } catch (NumberFormatException e) {}
+// }
+// if (figureElement.getAttribute("height") != null) {
+// try {
+// size.height = Integer.parseInt(figureElement.getAttribute("height"));
+// } catch (NumberFormatException e) {}
+// }
+// result.setSize(size);
+// return result;
+// }
+// };
+// }
+
+ public static Wrapper createWrapper(String elementId) {
+ if (elementMap == null) {
+ initializeRegistry();
+ }
+ IConfigurationElement configurationElement = elementMap.get(elementId);
+ if (configurationElement != null) {
+ try {
+ return createWrapper(configurationElement);
+ } catch (CoreException e) {
+ Logger.logError("Creating a wrapper for " + elementId + "
failed.", e);
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ public static IConfigurationElement getConfigurationElement(String elementId) {
+ return elementMap.get(elementId);
+ }
+
+ public static CreationFactory getCreationFactory(final String elementId) {
+ return new CreationFactory() {
+ public Object getNewObject() {
+ return createWrapper(elementId);
+ }
+ public Object getObjectType() {
+ return elementId;
+ }
+ };
+ }
+
+ public static CreationFactory getCreationFactory(Element element) {
+ String id = null;
+ IConfigurationElement configurationElement =
+ (IConfigurationElement)element.getMetaData("configurationElement");
+ if (configurationElement != null) {
+ id = configurationElement.getAttribute("id");
+ }
+ return id == null ? null : getCreationFactory(id);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/LanguageRegistry.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/LanguageRegistry.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/LanguageRegistry.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,40 @@
+package org.jboss.tools.flow.common.registry;
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+
+public class LanguageRegistry {
+
+ private static final String languagesExtensionPointId =
"org.jboss.tools.flow.common.languages";
+ private static HashMap<String, String> languageMap = null;
+
+ private static void initializeRegistry() {
+ languageMap = new HashMap<String, String>();
+ IConfigurationElement[] configurationElements =
+ Platform.getExtensionRegistry().getConfigurationElementsFor(languagesExtensionPointId);
+ for (IConfigurationElement configElement: configurationElements) {
+ String id = configElement.getAttribute("id");
+ String editor = configElement.getAttribute("editor");
+ if (id != null && editor != null) {
+ languageMap.put(editor, id);
+ }
+ }
+ }
+
+ public static boolean isLanguageRegisteredFor(String editorId) {
+ if (languageMap == null) {
+ initializeRegistry();
+ }
+ return languageMap.containsKey(editorId);
+ }
+
+ public static String getLanguageRegisteredFor(String editorId) {
+ if (languageMap == null) {
+ initializeRegistry();
+ }
+ return languageMap.get(editorId);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/LanguageRegistry.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsElementStrategy.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsElementStrategy.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsElementStrategy.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,11 @@
+package org.jboss.tools.flow.common.strategy;
+
+import org.jboss.tools.flow.common.model.Container;
+
+public interface AcceptsElementStrategy {
+
+ void setContainer(Container container);
+
+ boolean acceptsElement(Object element);
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsElementStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsIncomingConnectionStrategy.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsIncomingConnectionStrategy.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsIncomingConnectionStrategy.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,13 @@
+package org.jboss.tools.flow.common.strategy;
+
+import org.jboss.tools.flow.common.model.Connection;
+import org.jboss.tools.flow.common.model.Node;
+
+public interface AcceptsIncomingConnectionStrategy {
+
+ void setNode(Node node);
+
+ boolean acceptsIncomingConnection(Connection connection, Node source);
+
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsIncomingConnectionStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsOutgoingConnectionStrategy.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsOutgoingConnectionStrategy.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsOutgoingConnectionStrategy.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,13 @@
+package org.jboss.tools.flow.common.strategy;
+
+import org.jboss.tools.flow.common.model.Connection;
+import org.jboss.tools.flow.common.model.Node;
+
+public interface AcceptsOutgoingConnectionStrategy {
+
+ void setNode(Node node);
+
+ boolean acceptsOutgoingConnection(Connection connection, Node target);
+
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/AcceptsOutgoingConnectionStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/SaveElementStrategy.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/SaveElementStrategy.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/SaveElementStrategy.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,11 @@
+package org.jboss.tools.flow.common.strategy;
+
+import org.jboss.tools.flow.common.model.Container;
+
+public interface SaveElementStrategy {
+
+ void setContainer(Container container);
+
+ boolean acceptsElement(Object element);
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/strategy/SaveElementStrategy.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractConnectionWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractConnectionWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractConnectionWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,129 @@
+package org.jboss.tools.flow.common.wrapper;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Point;
+
+/**
+ * A connection between two model elements.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public abstract class AbstractConnectionWrapper extends AbstractWrapper implements
ConnectionWrapper {
+
+ private static final long serialVersionUID = 1L;
+
+ private NodeWrapper source;
+ private NodeWrapper target;
+ private LabelWrapper label;
+ private transient List<Point> bendpoints = new ArrayList<Point>();
+
+ public void localSetSource(NodeWrapper source) {
+ this.source = source;
+ }
+
+ public void localSetTarget(NodeWrapper target) {
+ this.target = target;
+ }
+
+ public void disconnect() {
+ if (source == null) {
+ throw new IllegalStateException("Can't disconnect, source is null");
+ }
+ if (target == null) {
+ throw new IllegalStateException("Can't disconnect, target is null");
+ }
+ source.removeOutgoingConnection(this);
+ target.removeIncomingConnection(this);
+ source = null;
+ target = null;
+ }
+
+ public void connect(NodeWrapper source, NodeWrapper target) {
+ if (source == null) {
+ throw new IllegalArgumentException("source is null");
+ }
+ if (this.source != null) {
+ throw new IllegalStateException("The source of a connection cannot be
changed");
+ }
+ if (target == null) {
+ throw new IllegalArgumentException("target is null");
+ }
+ if (this.target != null) {
+ throw new IllegalStateException("The target of a connection cannot be
changed");
+ }
+ this.source = source;
+ this.target = target;
+ source.addOutgoingConnection(this);
+ target.addIncomingConnection(this);
+ }
+
+
+ public NodeWrapper getSource() {
+ return source;
+ }
+
+ public NodeWrapper getTarget() {
+ return target;
+ }
+
+ public void addBendpoint(int index, Point point) {
+ bendpoints.add(index, point);
+ internalSetBendpoints(bendpoints);
+ notifyListeners(CHANGE_BENDPOINTS);
+ }
+
+ public void removeBendpoint(int index) {
+ bendpoints.remove(index);
+ internalSetBendpoints(bendpoints);
+ notifyListeners(CHANGE_BENDPOINTS);
+ }
+
+ public void replaceBendpoint(int index, Point point) {
+ bendpoints.set(index, point);
+ internalSetBendpoints(bendpoints);
+ notifyListeners(CHANGE_BENDPOINTS);
+ }
+
+ protected void internalSetBendpoints(List<Point> bendPoints) {
+ }
+
+ public void localSetBendpoints(List<Point> bendpoints) {
+ this.bendpoints = bendpoints;
+ }
+
+ public List<Point> getBendpoints() {
+ if (bendpoints == null) {
+ bendpoints = internalGetBendpoints();
+ }
+ return bendpoints;
+ }
+
+ protected abstract List<Point> internalGetBendpoints();
+
+ public void setLabel(LabelWrapper label) {
+ this.label = label;
+ }
+
+ public LabelWrapper getLabel() {
+ return label;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractConnectionWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractContainerWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractContainerWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractContainerWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,70 @@
+package org.jboss.tools.flow.common.wrapper;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class AbstractContainerWrapper extends AbstractNodeWrapper implements
ContainerWrapper {
+
+ List<NodeWrapper> elements = new ArrayList<NodeWrapper>();
+
+ public void addElement(NodeWrapper element) {
+ internalAddElement(element);
+ localAddElement(element);
+ notifyListeners(ADD_ELEMENT, "node", this, null, element);
+ }
+
+ public void localAddElement(NodeWrapper element) {
+ elements.add(element);
+ element.setParent(this);
+ }
+
+ protected abstract void internalAddElement(NodeWrapper element);
+
+ public void removeElement(NodeWrapper element) {
+ internalRemoveElement(element);
+ elements.remove(element);
+ element.setParent(null);
+ notifyListeners(REMOVE_ELEMENT, "node", this, element, null);
+ }
+
+ protected abstract void internalRemoveElement(NodeWrapper element);
+
+ public List<NodeWrapper> getNodeWrappers() {
+ return elements;
+ }
+
+ public FlowWrapper getFlowWrapper() {
+ return getParent().getFlowWrapper();
+ }
+
+ public boolean acceptsElement(NodeWrapper element) {
+ return true;
+ }
+
+ public boolean acceptsIncomingConnection(
+ ConnectionWrapper connection, NodeWrapper source) {
+ return true;
+ }
+
+ public boolean acceptsOutgoingConnection(
+ ConnectionWrapper connection, NodeWrapper target) {
+ return true;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractContainerWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractFlowWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractFlowWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractFlowWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,91 @@
+package org.jboss.tools.flow.common.wrapper;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A wrapper for a process element.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public abstract class AbstractFlowWrapper extends AbstractWrapper implements FlowWrapper
{
+
+ private Map<String, NodeWrapper> nodeWrapperMap = new HashMap<String,
NodeWrapper>();
+ private List<NodeWrapper> nodeWrapperList = new
ArrayList<NodeWrapper>();
+
+ public abstract Integer getRouterLayout();
+
+ public void setRouterLayout(Integer newLayout) {
+ Integer oldLayout = getRouterLayout();
+ internalSetRouterLayout(newLayout);
+ notifyListeners(CHANGE_VISUAL, "routerLayout", this, oldLayout,
newLayout);
+ }
+
+ protected void internalSetRouterLayout(Integer routerLayout) {
+ }
+
+ public List<NodeWrapper> getNodeWrappers() {
+ return Collections.unmodifiableList(
+ new ArrayList<NodeWrapper>(nodeWrapperList));
+ }
+
+ public NodeWrapper getNodeWrapper(String id) {
+ return (NodeWrapper) nodeWrapperMap.get(id);
+ }
+
+ public void addElement(NodeWrapper nodeWrapper) {
+ if (!acceptsElement(nodeWrapper)) return;
+ internalAddElement(nodeWrapper);
+ localAddElement(nodeWrapper);
+ notifyListeners(ADD_ELEMENT, "node", this, null, nodeWrapper);
+ }
+
+ public void localAddElement(NodeWrapper element) {
+ nodeWrapperMap.put(element.getId(), element);
+ nodeWrapperList.add(element);
+ element.setParent(this);
+ }
+
+ public boolean acceptsElement(NodeWrapper element) {
+ return true;
+ }
+
+ protected abstract void internalAddElement(NodeWrapper element);
+
+ public void localRemoveElement(NodeWrapper element) {
+ nodeWrapperMap.remove(element.getId());
+ nodeWrapperList.remove(element);
+ }
+
+ public void removeElement(NodeWrapper element) {
+ localRemoveElement(element);
+ internalRemoveElement(element);
+ notifyListeners(REMOVE_ELEMENT, "node", this, element, null);
+ }
+
+ protected abstract void internalRemoveElement(NodeWrapper element);
+
+ public FlowWrapper getFlowWrapper() {
+ return this;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractFlowWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractLabelWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractLabelWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractLabelWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,30 @@
+package org.jboss.tools.flow.common.wrapper;
+
+import org.eclipse.draw2d.geometry.Point;
+
+public abstract class AbstractLabelWrapper extends AbstractWrapper implements
+ LabelWrapper {
+
+ private Point location = null;
+
+ public Point getLocation() {
+ return location;
+ }
+
+ public String getText() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setLocation(Point newLocation) {
+ Point oldLocation = this.location;
+ this.location = newLocation;
+ notifyListeners(CHANGE_VISUAL, "location", this, oldLocation, newLocation);
+ }
+
+ public void setText(String text) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractLabelWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractNodeWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractNodeWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractNodeWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,144 @@
+package org.jboss.tools.flow.common.wrapper;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * Default wrapper of a model element.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public abstract class AbstractNodeWrapper extends AbstractWrapper implements NodeWrapper
{
+
+ protected static IPropertyDescriptor[] descriptors;
+
+ public static final String NAME = "Name";
+ static {
+ descriptors = new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(NAME, "Name"),
+ };
+ }
+
+ private ContainerWrapper parent;
+ private LabelWrapper label;
+ private transient Rectangle constraint;
+ private List<ConnectionWrapper> incomingConnections = new
ArrayList<ConnectionWrapper>();
+ private List<ConnectionWrapper> outgoingConnections = new
ArrayList<ConnectionWrapper>();
+
+ public void setConstraint(Rectangle constraint) {
+ Rectangle oldConstraint = this.constraint;
+ this.constraint = constraint;
+ internalSetConstraint(constraint);
+ notifyListeners(CHANGE_VISUAL, "constraint", this, oldConstraint,
constraint);
+ }
+
+ protected abstract void internalSetConstraint(Rectangle constraint);
+
+ public Rectangle getConstraint() {
+ if (constraint == null) {
+ constraint = internalGetConstraint();
+ }
+ return constraint;
+ }
+
+ protected abstract Rectangle internalGetConstraint();
+
+ public void setParent(ContainerWrapper parent) {
+ this.parent = parent;
+ }
+
+ public ContainerWrapper getParent() {
+ return parent;
+ }
+
+ public void setLabel(LabelWrapper label) {
+ this.label = label;
+ }
+
+ public LabelWrapper getLabel() {
+ return label;
+ }
+
+ public List<ConnectionWrapper> getOutgoingConnections() {
+ return Collections.unmodifiableList(outgoingConnections);
+ }
+
+ public List<ConnectionWrapper> getIncomingConnections() {
+ return Collections.unmodifiableList(incomingConnections);
+ }
+
+ public void addIncomingConnection(ConnectionWrapper connection) {
+ localAddIncomingConnection(connection);
+ internalAddIncomingConnection(connection);
+ notifyListeners(ADD_ELEMENT, "incomingConnection", this, null, connection);
+ }
+
+ public void localAddIncomingConnection(ConnectionWrapper connection) {
+ incomingConnections.add(connection);
+ }
+
+ protected void internalAddIncomingConnection(ConnectionWrapper connection) {
+ }
+
+ public void removeIncomingConnection(ConnectionWrapper connection) {
+ incomingConnections.remove(connection);
+ internalRemoveIncomingConnection(connection);
+ notifyListeners(REMOVE_ELEMENT, "incomingConnection", this, connection,
null);
+ }
+
+ protected void internalRemoveIncomingConnection(ConnectionWrapper connection) {
+ }
+
+ public void addOutgoingConnection(ConnectionWrapper connection) {
+ localAddOutgoingConnection(connection);
+ internalAddOutgoingConnection(connection);
+ notifyListeners(ADD_ELEMENT, "outgoingConnection", this, null, connection);
+ }
+
+ public void localAddOutgoingConnection(ConnectionWrapper connection) {
+ outgoingConnections.add(connection);
+ }
+
+ protected void internalAddOutgoingConnection(ConnectionWrapper connection) {
+ }
+
+ public void removeOutgoingConnection(ConnectionWrapper connection) {
+ outgoingConnections.remove(connection);
+ internalRemoveOutgoingConnection(connection);
+ notifyListeners(REMOVE_ELEMENT, "outgoingConnection", this, connection,
null);
+ }
+
+ protected void internalRemoveOutgoingConnection(ConnectionWrapper connection) {
+ }
+
+ public void setName(String newLocation) {
+ String oldName = getName();
+ internalSetName(newLocation);
+ notifyListeners(CHANGE_VISUAL, "name", this, oldName, newLocation);
+ }
+
+ protected void internalSetName(String name) {
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractNodeWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,163 @@
+package org.jboss.tools.flow.common.wrapper;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.flow.common.model.Element;
+
+public abstract class AbstractWrapper implements Wrapper {
+
+ private Element element;
+ private transient List<ModelListener> listeners = new
ArrayList<ModelListener>();
+ private Map<Object, List<Element>> children = new HashMap<Object,
List<Element>>();
+
+ public void setElement(Element element) {
+ this.element = element;
+ }
+
+ public Element getElement() {
+ return element;
+ }
+
+ public void addChild(Object type, Element element) {
+ localAddChild(type, element);
+ internalAddChild(type, element);
+ notifyListeners(ADD_ELEMENT, type, this, null, element);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void internalAddChild(Object type, Element element) {
+ Object childList = getPropertyValue(type);
+ if (childList == null || !(childList instanceof List)) return;
+ ((List)childList).add(element);
+ }
+
+ public void localAddChild(Object type, Element element) {
+ List<Element> childList = children.get(type);
+ if (childList == null) {
+ childList = new ArrayList<Element>();
+ children.put(type, childList);
+ }
+ childList.add(element);
+ }
+
+ public void removeChild(Object type, Element element) {
+ localRemoveChild(type, element);
+ internalRemoveChild(type, element);
+ notifyListeners(REMOVE_ELEMENT, type, this, element, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void internalRemoveChild(Object type, Element element) {
+ Object childList = getPropertyValue(type);
+ if (childList == null || !(childList instanceof List)) return;
+ ((List)childList).remove(element);
+ }
+
+ public void localRemoveChild(Object type, Element element) {
+ List<Element> childList = children.get(type);
+ if (childList == null) return;
+ childList.remove(element);
+ if (childList.isEmpty()) {
+ children.remove(type);
+ }
+ }
+
+ public List<Element> getChildren(Object type) {
+ return children.get(type);
+ }
+
+ public void setMetaData(String name, Object value) {
+ if (element != null) {
+ element.setMetaData(name, value);
+ }
+ }
+
+ public Object getMetaData(String name) {
+ if (element != null) {
+ return element.getMetaData(name);
+ }
+ return null;
+ }
+
+ public void addListener(ModelListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeListener(ModelListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void notifyListeners(int type, Object discriminator, Object object, Object
oldValue, Object newValue) {
+ notifyListeners(new ModelEvent(type, discriminator, object, oldValue, newValue));
+ }
+
+ public void notifyListeners(ModelEvent event) {
+ for (int i = 0; i < listeners.size(); i++) {
+ listeners.get(i).modelChanged(event);
+ }
+ }
+
+ public void notifyListeners(int change) {
+ notifyListeners(change, null, null, null, null);
+ }
+
+ public Object getEditableValue() {
+ if (getPropertySource() != null) {
+ getPropertySource().getEditableValue();
+ }
+ return null;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ if (getPropertySource() != null) {
+ return getPropertySource().getPropertyDescriptors();
+ }
+ return null;
+ }
+
+ public Object getPropertyValue(Object id) {
+ if (getPropertySource() != null) {
+ return getPropertySource().getPropertyValue(id);
+ }
+ return null;
+ }
+
+ public boolean isPropertySet(Object id) {
+ if (getPropertySource() != null) {
+ return getPropertySource().isPropertySet(id);
+ }
+ return false;
+ }
+
+ public void resetPropertyValue(Object id) {
+ if (getPropertySource() != null) {
+ getPropertySource().resetPropertyValue(id);
+ }
+ }
+
+ public void setPropertyValue(Object id, Object newValue) {
+ if (getPropertySource() != null) {
+ Object oldValue = getPropertySource().getPropertyValue(id);
+ getPropertySource().setPropertyValue(id, newValue);
+ notifyListeners(CHANGE_PROPERTY, id, this, oldValue, newValue);
+ }
+ }
+
+ protected abstract IPropertySource getPropertySource();
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ if (adapter == Element.class) {
+ return element;
+ } else if (adapter == IPropertySource.class) {
+ return getPropertySource();
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ConnectionWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ConnectionWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ConnectionWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,25 @@
+package org.jboss.tools.flow.common.wrapper;
+
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Point;
+
+public interface ConnectionWrapper extends Wrapper {
+
+ int CHANGE_BENDPOINTS = 1;
+
+ NodeWrapper getSource();
+ NodeWrapper getTarget();
+
+ void disconnect();
+ void connect(NodeWrapper source, NodeWrapper target);
+
+ void addBendpoint(int index, Point location);
+ void replaceBendpoint(int index, Point newLocation);
+ void removeBendpoint(int index);
+ List<Point> getBendpoints();
+
+ void setLabel(LabelWrapper label);
+ LabelWrapper getLabel();
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ConnectionWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ContainerWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ContainerWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ContainerWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,35 @@
+package org.jboss.tools.flow.common.wrapper;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+public interface ContainerWrapper extends Wrapper {
+
+ void addElement(NodeWrapper element);
+
+ void localAddElement(NodeWrapper element);
+
+ void removeElement(NodeWrapper element);
+
+ List<NodeWrapper> getNodeWrappers();
+
+ FlowWrapper getFlowWrapper();
+
+ boolean acceptsElement(NodeWrapper element);
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ContainerWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultConnectionWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultConnectionWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultConnectionWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,97 @@
+package org.jboss.tools.flow.common.wrapper;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.flow.common.model.Connection;
+import org.jboss.tools.flow.common.model.DefaultConnection;
+import org.jboss.tools.flow.common.model.Node;
+import org.jboss.tools.flow.common.properties.WrapperPropertySource;
+
+
+public class DefaultConnectionWrapper extends AbstractConnectionWrapper {
+
+ private IPropertySource propertySource;
+
+ public Connection getConnection() {
+ return (Connection)getElement();
+ }
+
+ protected List<Point> internalGetBendpoints() {
+ return (List<Point>) stringToBendpoints((String)
getConnection().getMetaData("bendpoints"));
+ }
+
+ protected void internalSetBendpoints(List<Point> bendpoints) {
+ getConnection().setMetaData("bendpoints",
bendpointsToString(bendpoints));
+ }
+
+ private String bendpointsToString(List<Point> bendpoints) {
+ if (bendpoints == null) {
+ return null;
+ }
+ String result = "[";
+ for (Iterator<Point> iterator = bendpoints.iterator(); iterator.hasNext();
) {
+ Point point = iterator.next();
+ result += point.x + "," + point.y + (iterator.hasNext() ?
";" : "");
+ }
+ result += "]";
+ return result;
+ }
+
+ private List<Point> stringToBendpoints(String s) {
+ List<Point> result = new ArrayList<Point>();
+ if (s == null) {
+ return result;
+ }
+ s = s.substring(1, s.length() - 1);
+ String[] bendpoints = s.split(";");
+ for (String bendpoint: bendpoints) {
+ String[] xy = bendpoint.split(",");
+ result.add(new Point(new Integer(xy[0]), new Integer(xy[1])));
+ }
+ return result;
+ }
+
+
+ public void connect(NodeWrapper source, NodeWrapper target) {
+ Node from = (Node)source.getElement();
+ Node to = (Node)target.getElement();
+ Connection connection = getConnection();
+ if (connection != null) {
+ connection.setTo(to);
+ connection.setFrom(from);
+ } else {
+ setElement(createConnection(from, to));
+ }
+ super.connect(source, target);
+ }
+
+ protected Connection createConnection(Node from, Node to) {
+ Connection result = new DefaultConnection(from, to);
+ if (getConnection() != null) {
+ result.setMetaData(
+ "configurationElement",
+ getConnection().getMetaData("configurationElement"));
+ }
+ return result;
+ }
+
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new WrapperPropertySource(this);
+ }
+ return propertySource;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPropertySource.class) {
+ return this;
+ }
+ return super.getAdapter(adapter);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultConnectionWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,142 @@
+package org.jboss.tools.flow.common.wrapper;
+
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.flow.common.model.Connection;
+import org.jboss.tools.flow.common.model.Container;
+import org.jboss.tools.flow.common.model.Flow;
+import org.jboss.tools.flow.common.model.Node;
+import org.jboss.tools.flow.common.properties.DefaultContainerWrapperPropertySource;
+import org.jboss.tools.flow.common.strategy.AcceptsElementStrategy;
+import org.jboss.tools.flow.common.strategy.AcceptsIncomingConnectionStrategy;
+import org.jboss.tools.flow.common.strategy.AcceptsOutgoingConnectionStrategy;
+
+public class DefaultContainerWrapper extends AbstractContainerWrapper {
+
+ private AcceptsElementStrategy acceptsElementStrategy;
+ private AcceptsIncomingConnectionStrategy incomingConnectionStrategy;
+ private AcceptsOutgoingConnectionStrategy outgoingConnectionStrategy;
+ private DefaultContainerWrapperPropertySource propertySource;
+
+ protected void internalSetName(String name) {
+ getNode().setName(name);
+ }
+
+ protected void internalAddElement(NodeWrapper element) {
+ Node node = (Node)element.getElement();
+ List<Node> nodes = ((Flow)getFlowWrapper().getElement()).getNodes();
+ long id = 0;
+ for (Node n: nodes) {
+ if (n.getId() > id) {
+ id = n.getId();
+ }
+ }
+ node.setId(++id);
+ ((Container)getParent().getElement()).addNode(node);
+ }
+
+
+ protected void internalRemoveElement(NodeWrapper element) {
+ ((Container)getParent().getElement()).removeNode((Node)element.getElement());
+ }
+
+
+ protected Rectangle internalGetConstraint() {
+ Node node = getNode();
+ Integer x = (Integer) node.getMetaData("x");
+ Integer y = (Integer) node.getMetaData("y");
+ Integer width = (Integer) node.getMetaData("width");
+ Integer height = (Integer) node.getMetaData("height");
+ return new Rectangle(x == null ? 0 : x, y == null ? 0 : y,
+ width == null ? -1 : width, height == null ? -1 : height);
+ }
+
+
+ protected void internalSetConstraint(Rectangle constraint) {
+ Node node = getNode();
+ node.setMetaData("x", constraint.x);
+ node.setMetaData("y", constraint.y);
+ node.setMetaData("width", constraint.width);
+ node.setMetaData("height", constraint.height);
+ }
+
+
+ public String getId() {
+ long id = getNode().getId();
+ return id == -1 ? null : getNode().getId() + "";
+ }
+
+ public String getName() {
+ return getNode().getName();
+ }
+
+ public Node getNode() {
+ return (Node)getElement();
+ }
+
+ public boolean acceptsElement(NodeWrapper wrapper) {
+ if (wrapper == null) {
+ return false;
+ } else if (acceptsElementStrategy != null) {
+ return acceptsElementStrategy.acceptsElement(wrapper.getElement());
+ } else {
+ return getParent().acceptsElement(wrapper);
+ }
+ }
+
+ public void setAcceptsElementStrategy(AcceptsElementStrategy strategy) {
+ this.acceptsElementStrategy = strategy;
+ }
+
+ public void setAcceptsIncomingConnectionStrategy(AcceptsIncomingConnectionStrategy
strategy) {
+ this.incomingConnectionStrategy = strategy;
+ }
+
+ public void setAcceptsOutgoingConnectionStrategy(AcceptsOutgoingConnectionStrategy
strategy) {
+ this.outgoingConnectionStrategy = strategy;
+ }
+
+ public boolean acceptsIncomingConnection(
+ ConnectionWrapper connectionWrapper, NodeWrapper sourceWrapper) {
+ if (connectionWrapper == null || sourceWrapper == null) {
+ return false;
+ } else if (incomingConnectionStrategy != null) {
+ return incomingConnectionStrategy.acceptsIncomingConnection(
+ (Connection)connectionWrapper.getElement(),
+ (Node)sourceWrapper.getElement());
+ } else {
+ return super.acceptsIncomingConnection(connectionWrapper, sourceWrapper);
+ }
+ }
+
+ public boolean acceptsOutgoingConnection(
+ ConnectionWrapper connectionWrapper, NodeWrapper targetWrapper) {
+ if (connectionWrapper == null || targetWrapper == null) {
+ return false;
+ } else if (outgoingConnectionStrategy != null) {
+ return outgoingConnectionStrategy.acceptsOutgoingConnection(
+ (Connection)connectionWrapper.getElement(),
+ (Node)targetWrapper.getElement());
+ } else {
+ return super.acceptsOutgoingConnection(connectionWrapper, targetWrapper);
+ }
+ }
+
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new DefaultContainerWrapperPropertySource(this);
+ }
+ return propertySource;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPropertySource.class) {
+ return this;
+ }
+ return super.getAdapter(adapter);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultFlowWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultFlowWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultFlowWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,80 @@
+package org.jboss.tools.flow.common.wrapper;
+
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.flow.common.model.DefaultFlow;
+import org.jboss.tools.flow.common.model.Flow;
+import org.jboss.tools.flow.common.model.Node;
+import org.jboss.tools.flow.common.properties.DefaultFlowWrapperPropertySource;
+import org.jboss.tools.flow.common.strategy.AcceptsElementStrategy;
+
+public class DefaultFlowWrapper extends AbstractFlowWrapper {
+
+ private AcceptsElementStrategy acceptsElementStrategy;
+ private DefaultFlowWrapperPropertySource propertySource;
+
+ public String getName() {
+ return ((DefaultFlow)getElement()).getName();
+ }
+
+ public void setName(String name) {
+ ((DefaultFlow)getElement()).setName(name);
+ }
+
+ public Integer getRouterLayout() {
+ Integer routerLayout = (Integer)
((Flow)getElement()).getMetaData("routerLayout");
+ if (routerLayout == null) {
+ return ROUTER_LAYOUT_MANUAL;
+ }
+ return routerLayout;
+ }
+
+ public void internalSetRouterLayout(Integer routerLayout) {
+ ((Flow)getElement()).setMetaData("routerLayout", routerLayout);
+ }
+
+ protected void internalAddElement(NodeWrapper element) {
+ Node node = (Node)element.getElement();
+ long id = 0;
+ for (Node n: ((Flow)getElement()).getNodes()) {
+ if (n.getId() > id) {
+ id = n.getId();
+ }
+ }
+ node.setId(++id);
+ ((Flow)getElement()).addNode(node);
+ }
+
+ protected void internalRemoveElement(NodeWrapper element) {
+ ((Flow)getElement()).removeNode((Node)element.getElement());
+ }
+
+ public boolean acceptsElement(NodeWrapper wrapper) {
+ if (wrapper == null) {
+ return false;
+ } else if (acceptsElementStrategy != null) {
+ return acceptsElementStrategy.acceptsElement(wrapper.getElement());
+ } else {
+ return true;
+ }
+ }
+
+ public void setAcceptsElementStrategy(AcceptsElementStrategy strategy) {
+ this.acceptsElementStrategy = strategy;
+ }
+
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new DefaultFlowWrapperPropertySource(this);
+ }
+ return propertySource;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPropertySource.class) {
+ return this;
+ }
+ return super.getAdapter(adapter);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultFlowWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultLabelWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultLabelWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultLabelWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,44 @@
+package org.jboss.tools.flow.common.wrapper;
+
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.flow.common.properties.IPropertyId;
+import org.jboss.tools.flow.common.properties.WrapperPropertySource;
+
+public class DefaultLabelWrapper extends AbstractLabelWrapper implements ModelListener {
+
+ private IPropertySource propertySource;
+
+ public DefaultLabelWrapper(Wrapper owner) {
+ if (owner != null) {
+ setElement(owner.getElement());
+ }
+ }
+
+ public void setText(String text) {
+ getPropertySource().setPropertyValue(IPropertyId.LABEL, text);
+ }
+
+ public String getText() {
+ return (String)getPropertySource().getPropertyValue(IPropertyId.LABEL);
+ }
+
+ public void modelChanged(ModelEvent event) {
+ notifyListeners(event);
+ }
+
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new WrapperPropertySource(this);
+ }
+ return propertySource;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPropertySource.class) {
+ return this;
+ }
+ return super.getAdapter(adapter);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultLabelWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,125 @@
+package org.jboss.tools.flow.common.wrapper;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.flow.common.model.Connection;
+import org.jboss.tools.flow.common.model.Node;
+import org.jboss.tools.flow.common.properties.DefaultNodeWrapperPropertySource;
+import org.jboss.tools.flow.common.strategy.AcceptsIncomingConnectionStrategy;
+import org.jboss.tools.flow.common.strategy.AcceptsOutgoingConnectionStrategy;
+
+public class DefaultNodeWrapper extends AbstractNodeWrapper {
+
+ private AcceptsIncomingConnectionStrategy incomingConnectionStrategy;
+ private AcceptsOutgoingConnectionStrategy outgoingConnectionStrategy;
+ private DefaultNodeWrapperPropertySource propertySource;
+
+ public void setNode(Node node) {
+ setElement(node);
+ }
+
+ public Node getNode() {
+ return (Node) getElement();
+ }
+
+ public String getId() {
+ long id = getNode().getId();
+ return id == -1 ? null : getNode().getId() + "";
+ }
+
+ public String getName() {
+ return getNode().getName();
+ }
+
+ protected void internalSetName(String name) {
+ getNode().setName(name);
+ }
+
+ protected void internalSetConstraint(Rectangle constraint) {
+ Node node = getNode();
+ node.setMetaData("x", constraint.x);
+ node.setMetaData("y", constraint.y);
+ node.setMetaData("width", constraint.width);
+ node.setMetaData("height", constraint.height);
+ }
+
+ public Rectangle internalGetConstraint() {
+ Node node = getNode();
+ Integer x = (Integer) node.getMetaData("x");
+ Integer y = (Integer) node.getMetaData("y");
+ Integer width = (Integer) node.getMetaData("width");
+ Integer height = (Integer) node.getMetaData("height");
+ return new Rectangle(x == null ? 0 : x, y == null ? 0 : y,
+ width == null ? -1 : width, height == null ? -1 : height);
+ }
+
+ public void setAcceptsIncomingConnectionStrategy(AcceptsIncomingConnectionStrategy
strategy) {
+ this.incomingConnectionStrategy = strategy;
+ }
+
+ public void setAcceptsOutgoingConnectionStrategy(AcceptsOutgoingConnectionStrategy
strategy) {
+ this.outgoingConnectionStrategy = strategy;
+ }
+
+ public boolean acceptsIncomingConnection(
+ ConnectionWrapper connectionWrapper, NodeWrapper sourceWrapper) {
+ if (connectionWrapper == null || sourceWrapper == null) {
+ return false;
+ } else if (incomingConnectionStrategy != null) {
+ return incomingConnectionStrategy.acceptsIncomingConnection(
+ (Connection)connectionWrapper.getElement(),
+ (Node)sourceWrapper.getElement());
+ } else {
+ return true;
+ }
+ }
+
+ public boolean acceptsOutgoingConnection(
+ ConnectionWrapper connectionWrapper, NodeWrapper targetWrapper) {
+ if (connectionWrapper == null || targetWrapper == null) {
+ return false;
+ } else if (outgoingConnectionStrategy != null) {
+ return outgoingConnectionStrategy.acceptsOutgoingConnection(
+ (Connection)connectionWrapper.getElement(),
+ (Node)targetWrapper.getElement());
+ } else {
+ return true;
+ }
+ }
+
+ protected void internalAddIncomingConnection(AbstractConnectionWrapper connection) {
+ getNode().addIncomingConnection("",
+ ((DefaultConnectionWrapper) connection).getConnection());
+ }
+
+ protected void internalRemoveIncomingConnection(AbstractConnectionWrapper connection) {
+ getNode().removeIncomingConnection("",
+ ((DefaultConnectionWrapper) connection).getConnection());
+ }
+
+ protected void internalAddOutgoingConnection(AbstractConnectionWrapper connection) {
+ getNode().addOutgoingConnection("",
+ ((DefaultConnectionWrapper) connection).getConnection());
+ }
+
+ protected void internalRemoveOutgoingConnection(AbstractConnectionWrapper connection) {
+ getNode().removeOutgoingConnection("",
+ ((DefaultConnectionWrapper) connection).getConnection());
+ }
+
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new DefaultNodeWrapperPropertySource(this);
+ }
+ return propertySource;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPropertySource.class) {
+ return this;
+ }
+ return super.getAdapter(adapter);
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,17 @@
+package org.jboss.tools.flow.common.wrapper;
+
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.flow.common.properties.WrapperPropertySource;
+
+public class DefaultWrapper extends AbstractWrapper {
+
+ private WrapperPropertySource propertySource;
+
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new WrapperPropertySource(this);
+ }
+ return propertySource;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/FlowWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/FlowWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/FlowWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,14 @@
+package org.jboss.tools.flow.common.wrapper;
+
+public interface FlowWrapper extends ContainerWrapper {
+
+ Integer ROUTER_LAYOUT_MANUAL = new Integer(0);
+ Integer ROUTER_LAYOUT_MANHATTAN = new Integer(1);
+ Integer ROUTER_LAYOUT_SHORTEST_PATH = new Integer(2);
+
+
+ NodeWrapper getNodeWrapper(String id);
+
+ Object getRouterLayout();
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/FlowWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/LabelWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/LabelWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/LabelWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,13 @@
+package org.jboss.tools.flow.common.wrapper;
+
+import org.eclipse.draw2d.geometry.Point;
+
+public interface LabelWrapper extends Wrapper {
+
+ void setText(String text);
+ String getText();
+
+ void setLocation(Point location);
+ Point getLocation();
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/LabelWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelEvent.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelEvent.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelEvent.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,69 @@
+package org.jboss.tools.flow.common.wrapper;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Event notifying a change in a model element.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public class ModelEvent {
+
+ private int changeType;
+ private Object changeDiscriminator;
+ private Object changedObject;
+ private Object oldValue;
+ private Object newValue;
+
+// public ModelEvent(int changeType) {
+// this.changeType = changeType;
+// }
+
+// public ModelEvent(int changeType, Object changedObject) {
+// this.changeType = changeType;
+// this.changedObject = changedObject;
+// }
+
+ public ModelEvent(int changeType, Object changeDiscriminator, Object changedObject,
Object oldValue, Object newValue) {
+ this.changeType = changeType;
+ this.changeDiscriminator = changeDiscriminator;
+ this.changedObject = changedObject;
+ this.oldValue = oldValue;
+ this.newValue = newValue;
+ }
+
+ public int getChangeType() {
+ return changeType;
+ }
+
+ public Object getChangeDiscriminator() {
+ return changeDiscriminator;
+ }
+
+ public Object getChangedObject() {
+ return changedObject;
+ }
+
+ public Object getOldValue() {
+ return oldValue;
+ }
+
+ public Object getNewValue() {
+ return newValue;
+ }
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelEvent.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelListener.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelListener.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelListener.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,28 @@
+package org.jboss.tools.flow.common.wrapper;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A listener for model events.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public interface ModelListener {
+
+ void modelChanged(ModelEvent event);
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/ModelListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/NodeWrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/NodeWrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/NodeWrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,54 @@
+package org.jboss.tools.flow.common.wrapper;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * Wrapper of a model element.
+ *
+ * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris
Verlaenen</a>
+ */
+public interface NodeWrapper extends Wrapper {
+
+ String getId();
+ String getName();
+ void setName(String name);
+
+ void setConstraint(Rectangle constraint);
+ Rectangle getConstraint();
+
+ void setParent(ContainerWrapper parent);
+ ContainerWrapper getParent();
+
+ void setLabel(LabelWrapper label);
+ LabelWrapper getLabel();
+
+ List<ConnectionWrapper> getOutgoingConnections();
+ List<ConnectionWrapper> getIncomingConnections();
+ void addIncomingConnection(ConnectionWrapper connection);
+ void localAddIncomingConnection(ConnectionWrapper connection);
+ void removeIncomingConnection(ConnectionWrapper connection);
+ void addOutgoingConnection(ConnectionWrapper connection);
+ void localAddOutgoingConnection(ConnectionWrapper connection);
+ void removeOutgoingConnection(ConnectionWrapper connection);
+ boolean acceptsIncomingConnection(ConnectionWrapper connection, NodeWrapper source);
+ boolean acceptsOutgoingConnection(ConnectionWrapper connection, NodeWrapper target);
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/NodeWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java 2009-06-12
20:58:42 UTC (rev 15935)
@@ -0,0 +1,34 @@
+package org.jboss.tools.flow.common.wrapper;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.flow.common.model.Element;
+
+
+public interface Wrapper extends IAdaptable, IPropertySource, Element {
+
+// int ADD_INCOMING_CONNECTION = 1;
+// int REMOVE_INCOMING_CONNECTION = 2;
+// int ADD_OUTGOING_CONNECTION = 3;
+// int REMOVE_OUTGOING_CONNECTION = 4;
+ int CHANGE_VISUAL = 5;
+ int ADD_ELEMENT = 6;
+ int REMOVE_ELEMENT = 7;
+ int CHANGE_PROPERTY = 8;
+
+
+
+ void setElement(Element element);
+ Element getElement();
+
+ void addChild(Object type, Element element);
+ void removeChild(Object type, Element element);
+ List<Element> getChildren(Object type);
+
+ void addListener(ModelListener listener);
+ void removeListener(ModelListener listener);
+ void notifyListeners(int changeId, Object changeDiscriminator, Object changedObject,
Object oldValue, Object newValue);
+
+}
Property changes on:
trunk/jbpm/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain