Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2013-03-28 10:08:06 +0000
committerJuergen Haug2013-03-28 10:08:06 +0000
commit85c43d2aaaabebd25cd6d9b0b74f56864df30ab7 (patch)
tree384ac335ade02d9482dd0c01a88a8b4104fb14b3
parentf484584d54ffd72f3255c040a4d2d1608c2ff13b (diff)
downloadorg.eclipse.etrice-85c43d2aaaabebd25cd6d9b0b74f56864df30ab7.tar.gz
org.eclipse.etrice-85c43d2aaaabebd25cd6d9b0b74f56864df30ab7.tar.xz
org.eclipse.etrice-85c43d2aaaabebd25cd6d9b0b74f56864df30ab7.zip
[ui.behavior] inherited transitions update
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/SupportUtil.java71
1 files changed, 64 insertions, 7 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/SupportUtil.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/SupportUtil.java
index b9b28c736..6419820a6 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/SupportUtil.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/SupportUtil.java
@@ -13,6 +13,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
@@ -416,6 +417,16 @@ public class SupportUtil {
return transitions;
}
+ private static Map<Transition, Connection> getTransitionsMap(Diagram diagram, IFeatureProvider fp) {
+ Map<Transition, Connection> transitions = new HashMap<Transition, Connection>();
+ for (Connection conn : diagram.getConnections()) {
+ Object bo = fp.getBusinessObjectForPictogramElement(conn);
+ if (bo instanceof Transition)
+ transitions.put((Transition) bo, conn);
+ }
+ return transitions;
+ }
+
/**
* @param sgShape
* @param node2anchor
@@ -579,14 +590,15 @@ public class SupportUtil {
}
// transitions
{
- List<Transition> present = SupportUtil.getTransitions((Diagram) sgShape.eContainer(), fp);
+ Map<Transition, Connection> present = SupportUtil.getTransitionsMap((Diagram) sgShape.eContainer(), fp);
List<Transition> expected = ctx.getTransitions();
- List<Transition> items = new ArrayList<Transition>();
- for (Transition trans : expected) {
- if (!present.contains(trans))
- items.add(trans);
- }
- SupportUtil.addTransitions(items, ctx.getPositionProvider(), sgShape, fp, node2anchor);
+ List<Transition> toAdd = new ArrayList<Transition>();
+ for (Transition trans : expected)
+ if (!present.containsKey(trans))
+ toAdd.add(trans);
+
+ SupportUtil.addTransitions(toAdd, ctx.getPositionProvider(), sgShape, fp, node2anchor);
+ SupportUtil.updateTransitions(present, ctx.getPositionProvider(), sgShape, fp, node2anchor);
}
}
@@ -742,6 +754,51 @@ public class SupportUtil {
}
}
}
+
+ private static void updateTransitions(Map<Transition, Connection> transitions, IPositionProvider positionProvider, ContainerShape sgShape,
+ IFeatureProvider fp, HashMap<String, Anchor> node2anchor) {
+
+ for(Entry<Transition, Connection> e: transitions.entrySet()){
+ Transition trans = e.getKey();
+ Connection conn = e.getValue();
+
+ String from = (trans instanceof InitialTransition)? INITIAL:getKey(((NonInitialTransition)trans).getFrom());
+ String to = getKey(trans.getTo());
+ Anchor newSrc = node2anchor.get(from);
+ Anchor newDst = node2anchor.get(to);
+
+ assert(newSrc!=null && newDst!=null): "transition endpoints must be present";
+
+ if(conn.getStart()!=newSrc)
+ conn.setStart(newSrc);
+ if(conn.getEnd()!=newDst)
+ conn.setEnd(newDst);
+
+ List<Pos> points = positionProvider.getPoints(trans);
+ Iterator<Pos> it = points.iterator();
+ if (points==null || points.isEmpty())
+ continue;
+
+ // first is label position
+ Pos pos = it.next();
+ ConnectionDecorator cd = conn.getConnectionDecorators().get(1);
+ Graphiti.getGaService().setLocation(cd.getGraphicsAlgorithm(), pos.getX(), pos.getY());
+
+ if (conn instanceof FreeFormConnection) {
+ FreeFormConnection fconn = (FreeFormConnection) conn;
+
+ // remaining are bend points
+ fconn.getBendpoints().clear();
+ List<Point> bendpoints = new ArrayList<Point>();
+ while (it.hasNext()) {
+ pos = it.next();
+ Point pt = Graphiti.getGaService().createPoint(pos.getX(), pos.getY());
+ bendpoints.add(pt);
+ }
+ fconn.getBendpoints().addAll(bendpoints);
+ }
+ }
+ }
private static void getAnchors(State state, PictogramElement stateShape,
final HashMap<String, Anchor> node2anchor) {

Back to the top