Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2011-01-16 16:39:57 -0500
committerHenrik Rentz-Reichert2011-01-16 16:39:57 -0500
commit5b2ba6dd7861b46cc905bd8ed1863153c948a4f2 (patch)
tree8720b4464e933339b47272b748cb62100794ea3d
parentcc312decf34379da04003576b17e75944080aa77 (diff)
downloadorg.eclipse.etrice-5b2ba6dd7861b46cc905bd8ed1863153c948a4f2.tar.gz
org.eclipse.etrice-5b2ba6dd7861b46cc905bd8ed1863153c948a4f2.tar.xz
org.eclipse.etrice-5b2ba6dd7861b46cc905bd8ed1863153c948a4f2.zip
ui.behavior: added property dialog for transitions (not complete yet)
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/.classpath7
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/.project28
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/ProviderDispatcher.java6
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateGraphSupport.java9
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java6
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java367
7 files changed, 296 insertions, 128 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior/.classpath b/plugins/org.eclipse.etrice.ui.behavior/.classpath
new file mode 100644
index 000000000..ad32c83a7
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.etrice.ui.behavior/.project b/plugins/org.eclipse.etrice.ui.behavior/.project
new file mode 100644
index 000000000..de09fb560
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.ui.behavior</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>
diff --git a/plugins/org.eclipse.etrice.ui.behavior/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.behavior/META-INF/MANIFEST.MF
index 2fe7e0c81..b1202a42a 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.ui.behavior/META-INF/MANIFEST.MF
@@ -5,6 +5,7 @@ Bundle-SymbolicName: org.eclipse.etrice.ui.behavior;singleton:=true
Bundle-Version: 0.1.0
Bundle-Activator: org.eclipse.etrice.ui.behavior.Activator
Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.1.0",
+ org.eclipse.etrice.ui.common;bundle-version="0.1.0",
org.eclipse.graphiti;bundle-version="0.7.0",
org.eclipse.graphiti.ui;bundle-version="0.7.0",
org.eclipse.ui;bundle-version="3.6.0",
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/ProviderDispatcher.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/ProviderDispatcher.java
index d9ee6b31d..3f90d44bb 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/ProviderDispatcher.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/ProviderDispatcher.java
@@ -40,6 +40,7 @@ import org.eclipse.graphiti.features.context.IUpdateContext;
import org.eclipse.graphiti.features.custom.ICustomFeature;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.algorithms.styles.LineStyle;
+import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.tb.DefaultToolBehaviorProvider;
@@ -130,7 +131,8 @@ public class ProviderDispatcher {
public ICustomFeature[] getCustomFeatures(ICustomContext context) {
return concatAll(
trPointSupport.getFeatureProvider().getCustomFeatures(context),
- stateSupport.getFeatureProvider().getCustomFeatures(context)
+ stateSupport.getFeatureProvider().getCustomFeatures(context),
+ transitionSupport.getFeatureProvider().getCustomFeatures(context)
);
}
}
@@ -312,6 +314,8 @@ public class ProviderDispatcher {
protected IToolBehaviorProvider getToolBehaviorProvider(PictogramElement pe) {
IFeatureProvider fp = getFeatureProvider();
+ if (pe instanceof ConnectionDecorator)
+ pe = (PictogramElement) pe.eContainer();
EObject bo = (EObject) fp.getBusinessObjectForPictogramElement(pe);
if (bo==null)
return null;
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateGraphSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateGraphSupport.java
index 839f2e922..a60fc3da6 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateGraphSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateGraphSupport.java
@@ -235,7 +235,6 @@ public class StateGraphSupport {
}
// TODOHRR: check for refs added in model not present in diagram
- // also add bindings and layer connections
return true;
}
@@ -252,12 +251,16 @@ public class StateGraphSupport {
if (!super.canResizeShape(context))
return false;
+ ContainerShape containerShape = (ContainerShape)context.getShape();
+ Object bo = getBusinessObjectForPictogramElement(containerShape);
+ if (bo instanceof EObject && ((EObject)bo).eIsProxy())
+ return false;
+
int width = context.getWidth()-MARGIN;
int height = context.getHeight()-MARGIN;
int xmax = 0;
int ymax = 0;
- ContainerShape containerShape = (ContainerShape)context.getShape();
- StateGraph sg = (StateGraph) getBusinessObjectForPictogramElement(containerShape);
+ StateGraph sg = (StateGraph) bo;
for (Shape childShape : containerShape.getChildren()) {
if (isOnInterface(sg, getBusinessObjectForPictogramElement(childShape)))
continue;
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java
index 9fa5fd403..9e1d0a2aa 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java
@@ -14,15 +14,11 @@ package org.eclipse.etrice.ui.behavior.support;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.ActorContainerClass;
import org.eclipse.etrice.core.room.ActorContainerRef;
import org.eclipse.etrice.core.room.EntryPoint;
import org.eclipse.etrice.core.room.ExitPoint;
import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.RoomFactory;
-import org.eclipse.etrice.core.room.SPPRef;
import org.eclipse.etrice.core.room.State;
import org.eclipse.etrice.core.room.StateGraph;
import org.eclipse.etrice.core.room.TrPoint;
@@ -773,7 +769,7 @@ public class TrPointSupport {
ccc.setSourceAnchor(anchor);
ContextButtonEntry button = new ContextButtonEntry(null, context);
- button.setText("Create Binding");
+ button.setText("Create Transition");
button.setIconId(ImageProvider.IMG_TRANSITION);
ICreateConnectionFeature[] features = getFeatureProvider().getCreateConnectionFeatures();
for (ICreateConnectionFeature feature : features) {
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java
index a046c6224..7aa8f74a9 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java
@@ -14,8 +14,27 @@ package org.eclipse.etrice.ui.behavior.support;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.etrice.core.naming.RoomNameProvider;
+import org.eclipse.etrice.core.room.BaseState;
+import org.eclipse.etrice.core.room.CPBranchTransition;
+import org.eclipse.etrice.core.room.ChoicePoint;
+import org.eclipse.etrice.core.room.ChoicepointTerminal;
+import org.eclipse.etrice.core.room.ContinuationTransition;
+import org.eclipse.etrice.core.room.InitialTransition;
+import org.eclipse.etrice.core.room.RefinedState;
+import org.eclipse.etrice.core.room.RoomFactory;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.core.room.StateGraph;
+import org.eclipse.etrice.core.room.StateTerminal;
+import org.eclipse.etrice.core.room.SubStateTrPointTerminal;
+import org.eclipse.etrice.core.room.TrPoint;
+import org.eclipse.etrice.core.room.TrPointTerminal;
+import org.eclipse.etrice.core.room.Transition;
+import org.eclipse.etrice.core.room.TransitionTerminal;
+import org.eclipse.etrice.core.room.TriggeredTransition;
import org.eclipse.etrice.core.validation.ValidationUtil;
import org.eclipse.etrice.ui.behavior.ImageProvider;
+import org.eclipse.etrice.ui.behavior.dialogs.TransitionPropertyDialog;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.IAddFeature;
import org.eclipse.graphiti.features.ICreateConnectionFeature;
@@ -26,17 +45,25 @@ import org.eclipse.graphiti.features.IUpdateFeature;
import org.eclipse.graphiti.features.context.IAddConnectionContext;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.ICreateConnectionContext;
+import org.eclipse.graphiti.features.context.ICustomContext;
+import org.eclipse.graphiti.features.context.IDoubleClickContext;
import org.eclipse.graphiti.features.context.IRemoveContext;
import org.eclipse.graphiti.features.context.IUpdateContext;
import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
import org.eclipse.graphiti.features.context.impl.RemoveContext;
+import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
+import org.eclipse.graphiti.features.custom.ICustomFeature;
import org.eclipse.graphiti.features.impl.AbstractAddFeature;
import org.eclipse.graphiti.features.impl.AbstractCreateConnectionFeature;
import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;
import org.eclipse.graphiti.features.impl.Reason;
+import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;
+import org.eclipse.graphiti.mm.algorithms.Polygon;
import org.eclipse.graphiti.mm.algorithms.Polyline;
+import org.eclipse.graphiti.mm.algorithms.Text;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
+import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
@@ -47,28 +74,19 @@ import org.eclipse.graphiti.tb.IToolBehaviorProvider;
import org.eclipse.graphiti.ui.features.DefaultFeatureProvider;
import org.eclipse.graphiti.util.ColorConstant;
import org.eclipse.graphiti.util.IColorConstant;
-
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.ActorContainerClass;
-import org.eclipse.etrice.core.room.ActorContainerRef;
-import org.eclipse.etrice.core.room.Binding;
-import org.eclipse.etrice.core.room.BindingEndPoint;
-import org.eclipse.etrice.core.room.LogicalSystem;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.RoomFactory;
-import org.eclipse.etrice.core.room.StructureClass;
-import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
public class TransitionSupport {
private static final IColorConstant LINE_COLOR = new ColorConstant(0, 0, 0);
+ private static final int LINE_WIDTH = 1;
- class FeatureProvider extends DefaultFeatureProvider {
+ static class FeatureProvider extends DefaultFeatureProvider {
private class CreateFeature extends AbstractCreateConnectionFeature {
- private boolean justStarted = false;
-
public CreateFeature(IFeatureProvider fp) {
super(fp, "Transition", "create Transition");
}
@@ -80,136 +98,154 @@ public class TransitionSupport {
@Override
public boolean canCreate(ICreateConnectionContext context) {
- Port src = getPort(context.getSourceAnchor());
- Port tgt = getPort(context.getTargetAnchor());
- ActorContainerRef srcRef = getRef(context.getSourceAnchor());
+ TransitionTerminal src = getTransitionTerminal(context.getSourceAnchor());
+ TransitionTerminal tgt = getTransitionTerminal(context.getTargetAnchor());
- if (justStarted) {
- justStarted = false;
- beginHighLightMatches(src, srcRef);
- }
+ if (src==null && !isInitialPoint(context.getSourceAnchor()))
+ return false;
+ if (tgt==null)
+ return false;
- if (src==null || tgt==null) {
+ StateGraph sg = getStateGraph(context);
+ if (sg==null)
return false;
- }
- StructureClass ac = getParent(context);
- if (ac==null) {
+ return ValidationUtil.isConnectable(src, tgt, sg);
+ }
+
+ public boolean canStartConnection(ICreateConnectionContext context) {
+ TransitionTerminal src = getTransitionTerminal(context.getSourceAnchor());
+ if (src==null && !isInitialPoint(context.getSourceAnchor()))
return false;
- }
- ActorContainerRef tgtRef = getRef(context.getTargetAnchor());
+ StateGraph sg = getStateGraph(context);
+ if (sg==null)
+ return false;
- return ValidationUtil.isConnectable(src, srcRef, tgt, tgtRef, ac);
+ return ValidationUtil.isConnectable(src, sg);
}
- public boolean canStartConnection(ICreateConnectionContext context) {
- Port src = getPort(context.getSourceAnchor());
- boolean canStart = src!=null;
- if (canStart) {
- ActorContainerRef ref = getRef(context.getSourceAnchor());
- if (ref==null) {
- // this port is local, i.e. owned by the parent itself
- ActorContainerClass acc = (ActorContainerClass) src.eContainer();
- if (!ValidationUtil.isConnectable(src, null, acc))
- canStart = false;
+ @Override
+ public Connection create(ICreateConnectionContext context) {
+ Connection newConnection = null;
+
+ TransitionTerminal src = getTransitionTerminal(context.getSourceAnchor());
+ TransitionTerminal dst = getTransitionTerminal(context.getTargetAnchor());
+ StateGraph sg = getStateGraph(context);
+ if (dst!=null && sg!=null) {
+
+ // TODOHRR-B transition dialog
+ // allow switch between default and non-default CP branch? This would change the transition type
+
+ Transition trans = null;
+ if (src==null) {
+ InitialTransition t = RoomFactory.eINSTANCE.createInitialTransition();
+ t.setTo(dst);
+ trans = t;
+ }
+ else if (src instanceof SubStateTrPointTerminal) {
+ ContinuationTransition t = RoomFactory.eINSTANCE.createContinuationTransition();
+ t.setFrom(src);
+ t.setTo(dst);
+ trans = t;
+ }
+ else if (src instanceof ChoicepointTerminal) {
+ // TODOHRR-B distinguish default branch (ContinuationTransition) and non-default
+ CPBranchTransition t = RoomFactory.eINSTANCE.createCPBranchTransition();
+ t.setFrom(src);
+ t.setTo(dst);
+ trans = t;
}
else {
- ActorContainerClass acc = (ActorContainerClass) ref.eContainer();
- if (!ValidationUtil.isConnectable(src, ref, acc))
- canStart = false;
+ TriggeredTransition t = RoomFactory.eINSTANCE.createTriggeredTransition();
+ t.setFrom(src);
+ t.setTo(dst);
+ trans = t;
+ }
+
+ if (trans instanceof InitialTransition) {
+ trans.setName("init");
}
+ else {
+ String name = RoomNameProvider.getUniqueTransitionName(sg);
+ trans.setName(name);
+ }
+
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ TransitionPropertyDialog dlg = new TransitionPropertyDialog(shell, sg, trans);
+ if (dlg.open()!=Window.OK)
+ // find a method to abort creation
+ //throw new RuntimeException();
+ return null;
+
+ sg.getTransitions().add(trans);
+
+ AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(), context.getTargetAnchor());
+ addContext.setNewObject(trans);
+ newConnection = (Connection) getFeatureProvider().addIfPossible(addContext);
}
- if (canStart)
- justStarted = true;
- return canStart;
+
+ return newConnection;
}
- private Port getPort(Anchor anchor) {
+ private boolean isInitialPoint(Anchor anchor) {
+ if (anchor!=null) {
+ Object obj = getBusinessObjectForPictogramElement(anchor.getParent());
+ if (obj instanceof StateGraph) {
+ Object parent = getBusinessObjectForPictogramElement((ContainerShape) anchor.getParent().eContainer());
+ if (parent instanceof StateGraph)
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private TransitionTerminal getTransitionTerminal(Anchor anchor) {
if (anchor != null) {
Object obj = getBusinessObjectForPictogramElement(anchor.getParent());
- if (obj instanceof Port) {
- return (Port) obj;
+ if (obj instanceof TrPoint) {
+ Object parent = getBusinessObjectForPictogramElement((ContainerShape) anchor.getParent().eContainer());
+ if (parent instanceof State) {
+ BaseState state = (parent instanceof RefinedState)? ((RefinedState)parent).getBase() : (BaseState)parent;
+ SubStateTrPointTerminal sstpt = RoomFactory.eINSTANCE.createSubStateTrPointTerminal();
+ sstpt.setState(state);
+ sstpt.setTrPoint((TrPoint) obj);
+ return sstpt;
+ }
+ else {
+ TrPointTerminal tpt = RoomFactory.eINSTANCE.createTrPointTerminal();
+ tpt.setTrPoint((TrPoint) obj);
+ return tpt;
+ }
+ }
+ else if (obj instanceof State) {
+ BaseState state = (obj instanceof RefinedState)? ((RefinedState)obj).getBase() : (BaseState)obj;
+ StateTerminal st = RoomFactory.eINSTANCE.createStateTerminal();
+ st.setState(state);
+ return st;
+ }
+ else if (obj instanceof ChoicePoint) {
+ ChoicepointTerminal ct = RoomFactory.eINSTANCE.createChoicepointTerminal();
+ ct.setCp((ChoicePoint) obj);
+ return ct;
}
}
return null;
}
- public StructureClass getParent(ICreateConnectionContext context) {
+ public StateGraph getStateGraph(ICreateConnectionContext context) {
ContainerShape shape = (ContainerShape) context.getSourcePictogramElement().eContainer();
Object bo = getBusinessObjectForPictogramElement(shape);
- if (bo instanceof StructureClass)
- return (StructureClass) bo;
+ if (bo instanceof StateGraph)
+ return (StateGraph) bo;
shape = (ContainerShape) shape.eContainer();
bo = getBusinessObjectForPictogramElement(shape);
- if (bo instanceof StructureClass)
- return (StructureClass) bo;
+ if (bo instanceof StateGraph)
+ return (StateGraph) bo;
return null;
}
-
- public ActorContainerRef getRef(Anchor anchor) {
- ContainerShape shape = (ContainerShape) anchor.getParent().eContainer();
- Object bo = getBusinessObjectForPictogramElement(shape);
- if (bo instanceof ActorContainerRef)
- return (ActorContainerRef) bo;
-
- return null;
- }
-
- @Override
- public Connection create(ICreateConnectionContext context) {
- Connection newConnection = null;
-
- endHighLightMatches();
-
- Port src = getPort(context.getSourceAnchor());
- Port dst = getPort(context.getTargetAnchor());
- StructureClass ac = getParent(context);
- if (src!=null && dst!=null && ac!=null) {
- Binding bind = RoomFactory.eINSTANCE.createBinding();
- BindingEndPoint ep1 = RoomFactory.eINSTANCE.createBindingEndPoint();
- ActorContainerRef ar1 = getRef(context.getSourceAnchor());
- ep1.setPort(src);
- ep1.setActorRef(ar1);
- BindingEndPoint ep2 = RoomFactory.eINSTANCE.createBindingEndPoint();
- ActorContainerRef ar2 = getRef(context.getTargetAnchor());
- ep2.setPort(dst);
- ep2.setActorRef(ar2);
- bind.setEndpoint1(ep1);
- bind.setEndpoint2(ep2);
- ac.getBindings().add(bind);
-
- AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(), context.getTargetAnchor());
- addContext.setNewObject(bind);
- newConnection = (Connection) getFeatureProvider().addIfPossible(addContext);
- }
-
- return newConnection;
- }
-
- private void beginHighLightMatches(Port port, ActorContainerRef ref) {
- if (port==null)
- return;
-
- StructureClass acc = (ActorContainerClass) ((ref!=null)? ref.eContainer():port.eContainer());
- if (acc instanceof ActorClass) {
-
- }
- else if (acc instanceof SubSystemClass) {
-
- }
- else if (acc instanceof LogicalSystem) {
-
- }
- else {
- assert(false): "unknown kind of StructureClass";
- }
- }
-
- private void endHighLightMatches() {
- }
}
private class AddFeature extends AbstractAddFeature {
@@ -220,7 +256,7 @@ public class TransitionSupport {
@Override
public boolean canAdd(IAddContext context) {
- if (context instanceof IAddConnectionContext && context.getNewObject() instanceof Binding) {
+ if (context instanceof IAddConnectionContext && context.getNewObject() instanceof Transition) {
return true;
}
return false;
@@ -229,10 +265,9 @@ public class TransitionSupport {
@Override
public PictogramElement add(IAddContext context) {
IAddConnectionContext addConContext = (IAddConnectionContext) context;
- Binding addedEReference = (Binding) context.getNewObject();
+ Transition trans = (Transition) context.getNewObject();
IPeCreateService peCreateService = Graphiti.getPeCreateService();
- // CONNECTION WITH POLYLINE
Connection connection = peCreateService.createFreeFormConnection(getDiagram());
connection.setStart(addConContext.getSourceAnchor());
connection.setEnd(addConContext.getTargetAnchor());
@@ -242,13 +277,40 @@ public class TransitionSupport {
IGaService gaService = Graphiti.getGaService();
Polyline polyline = gaService.createPolyline(connection);
polyline.setForeground(manageColor(LINE_COLOR));
+ polyline.setLineWidth(LINE_WIDTH);
+
+ ConnectionDecorator cd = peCreateService
+ .createConnectionDecorator(connection, false, 1.0, true);
+ createArrow(cd);
+
+ ConnectionDecorator textDecorator =
+ peCreateService.createConnectionDecorator(connection, true,
+ 0.5, true);
+ Text text = gaService.createDefaultText(textDecorator);
+ text.setForeground(manageColor(IColorConstant.BLACK));
+ gaService.setLocation(text, 10, 0);
+ text.setValue("label");
+
// create link and wire it
- link(connection, addedEReference);
+ link(connection, trans);
return connection;
}
+ private Polyline createArrow(GraphicsAlgorithmContainer gaContainer) {
+
+ IGaService gaService = Graphiti.getGaService();
+ Polygon polygon =
+ gaService.createPolygon(gaContainer, new int[] { -15, 5, 0, 0, -15, -5 });
+
+ polygon.setForeground(manageColor(LINE_COLOR));
+ polygon.setBackground(manageColor(LINE_COLOR));
+ polygon.setLineWidth(LINE_WIDTH);
+
+ return polygon;
+ }
+
}
private class UpdateFeature extends AbstractUpdateFeature {
@@ -270,7 +332,7 @@ public class TransitionSupport {
public IReason updateNeeded(IUpdateContext context) {
Object bo = getBusinessObjectForPictogramElement(context.getPictogramElement());
if (bo instanceof EObject && ((EObject)bo).eIsProxy()) {
- return Reason.createTrueReason("Binding deleted from model");
+ return Reason.createTrueReason("Transition deleted from model");
}
return Reason.createFalseReason();
}
@@ -293,6 +355,63 @@ public class TransitionSupport {
}
}
+ private static class PropertyFeature extends AbstractCustomFeature {
+
+ private String name;
+ private String description;
+
+ public PropertyFeature(IFeatureProvider fp) {
+ super(fp);
+ this.name = "Edit Transition";
+ this.description = "Edit Transition";
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public boolean canExecute(ICustomContext context) {
+ PictogramElement[] pes = context.getPictogramElements();
+ if (pes != null && pes.length == 1) {
+ PictogramElement pe = pes[0];
+ if (pe instanceof ConnectionDecorator)
+ pe = (PictogramElement) pe.eContainer();
+ if (!(pe instanceof Connection))
+ return false;
+
+ Object bo = getBusinessObjectForPictogramElement(pe);
+ if (bo instanceof Transition) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void execute(ICustomContext context) {
+ PictogramElement pe = context.getPictogramElements()[0];
+ if (pe instanceof ConnectionDecorator)
+ pe = (PictogramElement) pe.eContainer();
+ Transition trans = (Transition) getBusinessObjectForPictogramElement(pe);
+ StateGraph sg = (StateGraph)trans.eContainer();
+
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ TransitionPropertyDialog dlg = new TransitionPropertyDialog(shell, sg, trans);
+ if (dlg.open()!=Window.OK)
+ // TODOHRR: introduce a method to revert changes, does hasDoneChanges=false roll back changes?
+ //throw new RuntimeException();
+ return;
+ }
+
+ }
+
private IFeatureProvider fp;
public FeatureProvider(IDiagramTypeProvider dtp, IFeatureProvider fp) {
@@ -314,6 +433,11 @@ public class TransitionSupport {
public IUpdateFeature getUpdateFeature(IUpdateContext context) {
return new UpdateFeature(fp);
}
+
+ @Override
+ public ICustomFeature[] getCustomFeatures(ICustomContext context) {
+ return new ICustomFeature[] { new PropertyFeature(fp) };
+ }
}
class BehaviorProvider extends DefaultToolBehaviorProvider {
@@ -321,6 +445,11 @@ public class TransitionSupport {
public BehaviorProvider(IDiagramTypeProvider dtp) {
super(dtp);
}
+
+ @Override
+ public ICustomFeature getDoubleClickFeature(IDoubleClickContext context) {
+ return new FeatureProvider.PropertyFeature(getDiagramTypeProvider().getFeatureProvider());
+ }
}
private FeatureProvider pfp;

Back to the top