Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java2
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateGraphSupport.java145
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java9
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/SupportUtil.java66
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/editor/RoomDiagramEditor.java5
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/AutoUpdateFeature.java4
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java2
7 files changed, 218 insertions, 15 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java
index c9ca2e2bb..fb56c53b8 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/DiagramTypeProvider.java
@@ -19,7 +19,7 @@ public class DiagramTypeProvider extends AbstractDiagramTypeProvider {
public static final String PROVIDER_ID = "org.eclipse.etrice.ui.behavior.diagramTypeProvider";
- private static final boolean USE_AUTO_UPDATE = false;
+ private static final boolean USE_AUTO_UPDATE = true;
private IToolBehaviorProvider[] toolBehaviorProviders;
private ProviderDispatcher dispatcher;
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 7df900d7b..a5a138264 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
@@ -12,6 +12,10 @@
package org.eclipse.etrice.ui.behavior.support;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -19,8 +23,9 @@ import org.eclipse.etrice.core.naming.RoomNameProvider;
import org.eclipse.etrice.core.room.ChoicePoint;
import org.eclipse.etrice.core.room.State;
import org.eclipse.etrice.core.room.StateGraph;
-import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.etrice.core.room.TrPoint;
+import org.eclipse.etrice.core.room.Transition;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
import org.eclipse.graphiti.features.IAddFeature;
import org.eclipse.graphiti.features.IDeleteFeature;
@@ -53,6 +58,7 @@ import org.eclipse.graphiti.mm.algorithms.RoundedRectangle;
import org.eclipse.graphiti.mm.algorithms.Text;
import org.eclipse.graphiti.mm.algorithms.styles.Font;
import org.eclipse.graphiti.mm.algorithms.styles.Orientation;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
@@ -277,7 +283,7 @@ public class StateGraphSupport {
if (bo instanceof EObject && ((EObject)bo).eIsProxy())
return true;
- return bo instanceof StructureClass;
+ return bo instanceof StateGraph;
}
@Override
@@ -287,9 +293,74 @@ public class StateGraphSupport {
return Reason.createTrueReason("State Graph deleted from model");
}
- // TODOHRR: update of state graph - check for refs added in model not present in diagram
- // also inherited
- // also label
+ StateGraph sg = (StateGraph) bo;
+ ContainerShape shape = (ContainerShape) context.getPictogramElement();
+
+ String reason = "";
+ int missing = 0;
+
+ // check for states added in model not present in diagram (including inherited)
+ {
+ List<State> expectedStates = RoomHelpers.getAllStates(sg);
+ List<State> presentStates = SupportUtil.getStates(shape, fp);
+ for (State state : expectedStates) {
+ if (!presentStates.contains(state))
+ ++missing;
+ }
+ if (missing>0)
+ reason += missing+" missing states\n";
+ }
+
+ // check for transition points added in model not present in diagram (including inherited)
+ {
+ missing = 0;
+ List<TrPoint> expectedTrPoints = RoomHelpers.getAllTrPoints(sg);
+ List<TrPoint> presentTrPoints = SupportUtil.getTrPoints(sg, shape, fp);
+ for (TrPoint tp : expectedTrPoints) {
+ if (!presentTrPoints.contains(tp))
+ ++missing;
+ }
+ if (missing>0)
+ reason += missing+" missing transition points\n";
+ }
+
+ // check for choice points added in model not present in diagram (including inherited)
+ {
+ missing = 0;
+ List<ChoicePoint> expectedCPs = RoomHelpers.getAllChoicePoints(sg);
+ List<ChoicePoint> presentCPs = SupportUtil.getChoicePoints(shape, fp);
+ for (ChoicePoint cp : expectedCPs) {
+ if (!presentCPs.contains(cp))
+ ++missing;
+ }
+ if (missing>0)
+ reason += missing+" missing choice points\n";
+ }
+
+ // check for bindings added in model not present in diagram (including inherited)
+ {
+ missing = 0;
+ List<Transition> expectedBindings = RoomHelpers.getAllTransitions(sg);
+ List<Transition> presentBindings = SupportUtil.getTransitions(getDiagram(), fp);
+ for (Transition binding : expectedBindings) {
+ if (!presentBindings.contains(binding))
+ ++missing;
+ }
+ if (missing>0)
+ reason += missing+" missing transitions\n";
+ }
+
+ // check state path
+ if (!shape.getChildren().isEmpty()) {
+ Shape labelShape = shape.getChildren().get(0);
+ GraphicsAlgorithm ga = labelShape.getGraphicsAlgorithm();
+ if (ga instanceof Text)
+ if (!RoomNameProvider.getStateGraphLabel(sg).equals(((Text)ga).getValue()))
+ reason += "state graph label changed\n";
+ }
+
+ if (!reason.isEmpty())
+ return Reason.createTrueReason(reason.substring(0, reason.length()-1));
return Reason.createFalseReason();
}
@@ -309,7 +380,16 @@ public class StateGraphSupport {
return true;
}
- // TODOHRR: check for refs added in model not present in diagram
+ StateGraph sg = (StateGraph) bo;
+ ContainerShape shape = (ContainerShape) context.getPictogramElement();
+ addMissingItems(sg, shape, fp);
+
+ if (!shape.getChildren().isEmpty()) {
+ Shape labelShape = shape.getChildren().get(0);
+ GraphicsAlgorithm ga = labelShape.getGraphicsAlgorithm();
+ if (ga instanceof Text)
+ ((Text)ga).setValue(RoomNameProvider.getStateGraphLabel(sg));
+ }
return true;
}
@@ -464,6 +544,59 @@ public class StateGraphSupport {
public ICustomFeature[] getCustomFeatures(ICustomContext context) {
return new ICustomFeature[] { new GoUpFeature(fp) };
}
+
+ private static void addMissingItems(StateGraph sg, ContainerShape shape, IFeatureProvider fp) {
+
+ HashMap<String, Anchor> ifitem2anchor = new HashMap<String, Anchor>();
+
+ // states
+ {
+ List<State> present = SupportUtil.getStates(shape, fp, ifitem2anchor);
+ List<State> expected = RoomHelpers.getAllStates(sg);
+ List<State> items = new ArrayList<State>();
+ for (State item : expected) {
+ if (!present.contains(item))
+ items.add(item);
+ }
+ SupportUtil.addStates(items, shape, fp, ifitem2anchor);
+ }
+
+ // transition points
+ {
+ List<TrPoint> present = SupportUtil.getTrPoints(sg, shape, fp, ifitem2anchor);
+ List<TrPoint> expected = RoomHelpers.getAllTrPoints(sg);
+ List<TrPoint> items = new ArrayList<TrPoint>();
+ for (TrPoint item : expected) {
+ if (!present.contains(item))
+ items.add(item);
+ }
+ SupportUtil.addTransitionPoints(items, shape, fp, ifitem2anchor);
+ }
+
+ // choice points
+ {
+ List<ChoicePoint> present = SupportUtil.getChoicePoints(shape, fp, ifitem2anchor);
+ List<ChoicePoint> expected = RoomHelpers.getAllChoicePoints(sg);
+ List<ChoicePoint> items = new ArrayList<ChoicePoint>();
+ for (ChoicePoint item : expected) {
+ if (!present.contains(item))
+ items.add(item);
+ }
+ SupportUtil.addChoicePoints(items, shape, fp, ifitem2anchor);
+ }
+
+ // transitions
+ {
+ List<Transition> present = SupportUtil.getTransitions((Diagram) shape.eContainer(), fp);
+ List<Transition> expected = RoomHelpers.getAllTransitions(sg);
+ List<Transition> items = new ArrayList<Transition>();
+ for (Transition trans : expected) {
+ if (!present.contains(trans))
+ items.add(trans);
+ }
+ SupportUtil.addTransitions(items, shape, fp, ifitem2anchor);
+ }
+ }
}
private class BehaviorProvider extends DefaultToolBehaviorProvider {
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java
index 5c3a0d9d2..a090a25d4 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java
@@ -367,6 +367,10 @@ public class StateSupport {
updateFigure(s, context);
ActorClass ac = SupportUtil.getActorClass(getDiagram());
+ adjustSubgraphLabels(s, ac);
+ }
+
+ private void adjustSubgraphLabels(State s, ActorClass ac) {
if (RoomHelpers.hasSubStructure(s, ac)) {
// update the path text in the sub graph
ContainerShape subShape = ContextSwitcher.getContext(getDiagram(), s.getSubgraph());
@@ -376,6 +380,9 @@ public class StateSupport {
if (ga instanceof Text)
((Text)ga).setValue(RoomNameProvider.getStateGraphLabel(s.getSubgraph()));
}
+ for (State sub : s.getSubgraph().getStates()) {
+ adjustSubgraphLabels(sub, ac);
+ }
}
}
@@ -601,8 +608,6 @@ public class StateSupport {
}
}
- // TODOHRR: check interface ports and spps added to model not present in diagram
-
return Reason.createFalseReason();
}
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 d969dcb26..58a68f9e4 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
@@ -44,6 +44,7 @@ import org.eclipse.graphiti.features.context.impl.AddContext;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.algorithms.styles.Point;
import org.eclipse.graphiti.mm.pictograms.Anchor;
+import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
@@ -296,19 +297,77 @@ public class SupportUtil {
}
}
- public static List<State> getStates(ContainerShape shape, IFeatureProvider fp, Map<String, Anchor> ifitem2anchor) {
+ public static List<State> getStates(ContainerShape shape, IFeatureProvider fp) {
+ return getStates(shape, fp, null);
+ }
+
+ public static List<State> getStates(ContainerShape shape, IFeatureProvider fp, Map<String, Anchor> item2anchor) {
List<State> items = new ArrayList<State>();
for (Shape ch : shape.getChildren()) {
Object bo = fp.getBusinessObjectForPictogramElement(ch);
if (bo instanceof State) {
items.add((State)bo);
- if (ifitem2anchor!=null)
- ifitem2anchor.put(SEP+((State)bo).getName(), ch.getAnchors().get(0));
+ if (item2anchor!=null)
+ item2anchor.put(getKey((State)bo, null), ch.getAnchors().get(0));
}
}
return items;
}
+ public static List<ChoicePoint> getChoicePoints(ContainerShape shape, IFeatureProvider fp) {
+ return getChoicePoints(shape, fp, null);
+ }
+
+ /**
+ * @param shape
+ * @param fp
+ * @return
+ */
+ public static List<ChoicePoint> getChoicePoints(ContainerShape shape, IFeatureProvider fp, Map<String, Anchor> item2anchor) {
+ List<ChoicePoint> items = new ArrayList<ChoicePoint>();
+ for (Shape ch : shape.getChildren()) {
+ Object bo = fp.getBusinessObjectForPictogramElement(ch);
+ if (bo instanceof ChoicePoint) {
+ items.add((ChoicePoint)bo);
+ if (item2anchor!=null)
+ item2anchor.put(getKey((ChoicePoint)bo, null), ch.getAnchors().get(0));
+ }
+ }
+ return items;
+ }
+
+ public static List<TrPoint> getTrPoints(StateGraph sg, ContainerShape shape, IFeatureProvider fp) {
+ return getTrPoints(sg, shape, fp, null);
+ }
+
+ public static List<TrPoint> getTrPoints(StateGraph sg, ContainerShape shape, IFeatureProvider fp, Map<String, Anchor> item2anchor) {
+ List<TrPoint> items = new ArrayList<TrPoint>();
+ for (Shape ch : shape.getChildren()) {
+ Object bo = fp.getBusinessObjectForPictogramElement(ch);
+ if (bo instanceof TrPoint) {
+ items.add((TrPoint)bo);
+ if (item2anchor!=null)
+ item2anchor.put(getKey((TrPoint)bo, sg), ch.getAnchors().get(0));
+ }
+ }
+ return items;
+ }
+
+ /**
+ * @param diagram
+ * @param fp
+ * @return
+ */
+ public static List<Transition> getTransitions(Diagram diagram, IFeatureProvider fp) {
+ List<Transition> transitions = new ArrayList<Transition>();
+ for (Connection conn : diagram.getConnections()) {
+ Object bo = fp.getBusinessObjectForPictogramElement(conn);
+ if (bo instanceof Transition)
+ transitions.add((Transition) bo);
+ }
+ return transitions;
+ }
+
/**
* @param sgShape
* @param node2anchor
@@ -396,6 +455,7 @@ public class SupportUtil {
ContainerShape pe = (ContainerShape) fp.addIfPossible(addContext);
assert(pe!=null): "state should have been created";
assert(!pe.getAnchors().isEmpty()): "state should have an anchor";
+ node2anchor.put(getKey(s, null), pe.getAnchors().get(0));
}
public static void addChoicePoints(List<ChoicePoint> cps, ContainerShape sgShape, IFeatureProvider fp,
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/editor/RoomDiagramEditor.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/editor/RoomDiagramEditor.java
index 7dbd1ce81..afa3532c3 100644
--- a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/editor/RoomDiagramEditor.java
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/editor/RoomDiagramEditor.java
@@ -89,6 +89,11 @@ public class RoomDiagramEditor extends DiagramEditor {
XtextResource xres = (XtextResource) res;
ISerializer serializer = xres.getSerializer();
+ if (!xres.getContents().isEmpty()) {
+ MessageDialog.openError(Display.getDefault().getActiveShell(), "ERROR", "Internal error: part of textual model is empty, can't save");
+ return;
+ }
+
// HOWTO: call serializer to validate the concrete syntax
// this throws an exception which is caught further up the stack
// and a dialog will be displayed
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/AutoUpdateFeature.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/AutoUpdateFeature.java
index 55be585bf..9a0f59349 100644
--- a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/AutoUpdateFeature.java
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/support/AutoUpdateFeature.java
@@ -136,8 +136,8 @@ public class AutoUpdateFeature extends AbstractUpdateFeature {
if (!(container instanceof Diagram)) {
UpdateContext context = new UpdateContext(container);
IUpdateFeature updateFeature = getFeatureProvider().getUpdateFeature(context);
- if (updateFeature.canUpdate(context))
- if (updateFeature!=null && updateFeature.updateNeeded(context).toBoolean())
+ if (updateFeature!=null && updateFeature.canUpdate(context))
+ if (updateFeature.updateNeeded(context).toBoolean())
if (updateFeature.update(context))
doneChanges = true;
}
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java
index 8dc95a778..822370795 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/StructureClassSupport.java
@@ -603,7 +603,7 @@ public class StructureClassSupport {
}
}
- public static void addMissingItems(StructureClass sc, ContainerShape acShape, IFeatureProvider fp) {
+ private static void addMissingItems(StructureClass sc, ContainerShape acShape, IFeatureProvider fp) {
int width = acShape.getGraphicsAlgorithm().getGraphicsAlgorithmChildren().get(0).getWidth();

Back to the top