Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2014-11-26 12:33:45 -0500
committerHenrik Rentz-Reichert2014-12-05 02:48:32 -0500
commitf98dcd973aa82ad5064f93f288c65dc603860940 (patch)
tree250435440184e01d5da2c44c5a98589f38bffd38
parentdf24c8618ce1db71f02a1a809b0bf5bfd475edeb (diff)
downloadorg.eclipse.etrice-f98dcd973aa82ad5064f93f288c65dc603860940.tar.gz
org.eclipse.etrice-f98dcd973aa82ad5064f93f288c65dc603860940.tar.xz
org.eclipse.etrice-f98dcd973aa82ad5064f93f288c65dc603860940.zip
[ui.behavior] fixed inheritance update
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/ChoicePointSupport.java19
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/FSMSupportUtil.java43
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/StateGraphSupport.java73
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/StateSupport.java16
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/TrPointSupport.java17
5 files changed, 77 insertions, 91 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/ChoicePointSupport.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/ChoicePointSupport.java
index 85fb69a82..b666977d1 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/ChoicePointSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/ChoicePointSupport.java
@@ -336,25 +336,6 @@ public class ChoicePointSupport {
return Reason.createTrueReason("ChoicePoint deleted from model");
}
- // check if cp still owned/inherited
- // TODOHRR-B check inheritance
-// ChoicePoint cp = (ChoicePoint) bo;
-// ContainerShape containerShape = (ContainerShape)context.getPictogramElement();
-// bo = getBusinessObjectForPictogramElement(containerShape);
-// if (bo instanceof StateGraph) {
-// StateGraph sg = (StateGraph) bo;
-// boolean found = false;
-// do {
-// if (sg==cp.eContainer())
-// found = true;
-// sg = sg.getBase();
-// }
-// while (!found && sg!=null);
-//
-// if (!found)
-// return Reason.createTrueReason("TransitionPoint not inherited anymore");
-// }
-
return Reason.createFalseReason();
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/FSMSupportUtil.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/FSMSupportUtil.java
index 51146c325..6eba57389 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/FSMSupportUtil.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/FSMSupportUtil.java
@@ -13,6 +13,7 @@
package org.eclipse.etrice.ui.behavior.fsm.support;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -49,16 +50,17 @@ import org.eclipse.etrice.core.fsm.util.FSMHelpers;
import org.eclipse.etrice.core.fsm.util.FSMUtil;
import org.eclipse.etrice.core.fsm.validation.FSMValidationUtil;
import org.eclipse.etrice.ui.behavior.fsm.commands.StateGraphContext;
-import org.eclipse.etrice.ui.behavior.fsm.support.ContextSwitcher;
-import org.eclipse.etrice.ui.behavior.fsm.support.IPositionProvider;
import org.eclipse.etrice.ui.behavior.fsm.support.IPositionProvider.Pos;
import org.eclipse.etrice.ui.behavior.fsm.support.IPositionProvider.PosAndSize;
import org.eclipse.etrice.ui.common.base.support.CommonSupportUtil;
import org.eclipse.graphiti.datatypes.ILocation;
import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.IRemoveFeature;
+import org.eclipse.graphiti.features.context.IRemoveContext;
import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
import org.eclipse.graphiti.features.context.impl.AddContext;
import org.eclipse.graphiti.features.context.impl.LayoutContext;
+import org.eclipse.graphiti.features.context.impl.RemoveContext;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.algorithms.styles.Point;
import org.eclipse.graphiti.mm.pictograms.Anchor;
@@ -600,14 +602,20 @@ public class FSMSupportUtil {
List<State> expected = ctx.getStates();
List<State> toAdd = new ArrayList<State>();
List<State> toUpdate = new ArrayList<State>();
+ List<State> toRemove = new ArrayList<State>();
for (State item : expected) {
if (present.contains(item))
toUpdate.add(item);
else
toAdd.add(item);
}
+ for(State item : present){
+ if(!expected.contains(item))
+ toRemove.add(item);
+ }
addStateGraphNodes(toAdd, ctx.getPositionProvider(), sgShape, fp, node2anchor);
updateStateGraphNodes(toUpdate, shapes, ctx.getPositionProvider(), fp);
+ removeGraphicalRepresentation(toRemove, shapes, fp);
}
// transition points
@@ -618,14 +626,20 @@ public class FSMSupportUtil {
List<TrPoint> expected = ctx.getTrPoints();
List<TrPoint> toAdd = new ArrayList<TrPoint>();
List<TrPoint> toUpdate = new ArrayList<TrPoint>();
+ List<TrPoint> toRemove = new ArrayList<TrPoint>();
for (TrPoint item : expected) {
if (present.contains(item))
toUpdate.add(item);
else
toAdd.add(item);
}
+ for(TrPoint item : present){
+ if(!expected.contains(item))
+ toRemove.add(item);
+ }
addStateGraphNodes(toAdd, ctx.getPositionProvider(), sgShape, fp, node2anchor);
updateStateGraphNodes(toUpdate, shapes, ctx.getPositionProvider(), fp);
+ removeGraphicalRepresentation(toRemove, shapes, fp);
}
// choice points
@@ -636,14 +650,20 @@ public class FSMSupportUtil {
List<ChoicePoint> expected = ctx.getChPoints();
List<ChoicePoint> toAdd = new ArrayList<ChoicePoint>();
List<ChoicePoint> toUpdate = new ArrayList<ChoicePoint>();
+ List<ChoicePoint> toRemove = new ArrayList<ChoicePoint>();
for (ChoicePoint item : expected) {
if (present.contains(item))
toUpdate.add(item);
else
toAdd.add(item);
}
+ for(ChoicePoint item : present){
+ if(!expected.contains(item))
+ toRemove.add(item);
+ }
addStateGraphNodes(toAdd, ctx.getPositionProvider(), sgShape, fp, node2anchor);
updateStateGraphNodes(toUpdate, shapes, ctx.getPositionProvider(), fp);
+ removeGraphicalRepresentation(toRemove, shapes, fp);
}
getSubTpAnchors(sgShape, node2anchor);
@@ -677,12 +697,17 @@ public class FSMSupportUtil {
Map<Transition, Connection> present = getTransitionsMap(sgShape, fp);
List<Transition> expected = ctx.getTransitions();
List<Transition> toAdd = new ArrayList<Transition>();
+ List<Transition> toRemove = new ArrayList<Transition>();
for (Transition trans : expected)
if (!present.containsKey(trans))
toAdd.add(trans);
-
+ for(Transition item : present.keySet()){
+ if(!expected.contains(item))
+ toRemove.add(item);
+ }
addTransitions(toAdd, ctx.getPositionProvider(), sgShape, fp, node2anchor);
updateTransitions(present, ctx.getPositionProvider(), sgShape, fp, node2anchor);
+ removeGraphicalRepresentation(toRemove, present.values(), fp);
}
}
@@ -841,6 +866,18 @@ public class FSMSupportUtil {
}
}
}
+
+ public void removeGraphicalRepresentation(Collection<? extends EObject> toRemove, Collection<? extends PictogramElement> pictograms, IFeatureProvider fp) {
+ for(EObject bo : toRemove)
+ for(PictogramElement pe : pictograms)
+ if(fp.getBusinessObjectForPictogramElement(pe) == bo){
+ IRemoveContext rc = new RemoveContext(pe);
+ IRemoveFeature removeFeature = fp.getRemoveFeature(rc);
+ if (removeFeature != null)
+ removeFeature.remove(rc);
+ break;
+ }
+ }
private void updateTransitions(Map<Transition, Connection> transitions, IPositionProvider positionProvider, ContainerShape sgShape,
IFeatureProvider fp, HashMap<String, Anchor> node2anchor) {
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/StateGraphSupport.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/StateGraphSupport.java
index 282ada565..e690751e6 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/StateGraphSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/StateGraphSupport.java
@@ -13,7 +13,7 @@
package org.eclipse.etrice.ui.behavior.fsm.support;
import java.util.ArrayList;
-import java.util.List;
+import java.util.Set;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.EList;
@@ -73,6 +73,8 @@ import org.eclipse.graphiti.ui.features.DefaultFeatureProvider;
import org.eclipse.graphiti.util.ColorConstant;
import org.eclipse.graphiti.util.IColorConstant;
+import com.google.common.collect.Sets;
+
public class StateGraphSupport {
public static final int MARGIN = 40;
@@ -309,60 +311,59 @@ public class StateGraphSupport {
String reason = "";
int missing = 0;
+ int obsolete = 0;
if (context instanceof StateGraphUpdateContext) {
StateGraphContext ctx = ((StateGraphUpdateContext)context).getContext();
// check for states added in model not present in diagram (including inherited)
{
- List<State> expectedStates = ctx.getStates();
- List<State> presentStates = FSMSupportUtil.getInstance().getStates(shape, fp);
- for (State state : expectedStates) {
- if (!presentStates.contains(state))
- ++missing;
- }
- if (missing>0)
- reason += missing+" missing states\n";
+ Set<State> expected = Sets.newHashSet(ctx.getStates());
+ Set<State> present = Sets.newHashSet(FSMSupportUtil.getInstance().getStates(shape, fp));
+
+ if((missing = Sets.difference(expected, present).size()) > 0)
+ reason += missing+" missing states\n";
+ if((obsolete = Sets.difference(present, expected).size()) > 0)
+ reason += obsolete+" obsolete states\n";
}
// check for transition points added in model not present in diagram (including inherited)
{
- missing = 0;
- List<TrPoint> expectedTrPoints = ctx.getTrPoints();
- List<TrPoint> presentTrPoints = FSMSupportUtil.getInstance().getTrPoints(sg, shape, fp);
- for (TrPoint tp : expectedTrPoints) {
- if (!presentTrPoints.contains(tp))
- ++missing;
- }
- if (missing>0)
- reason += missing+" missing transition points\n";
+ missing = obsolete = 0;
+ Set<TrPoint> expected = Sets.newHashSet(ctx.getTrPoints());
+ Set<TrPoint> present = Sets.newHashSet(FSMSupportUtil.getInstance().getTrPoints(sg, shape, fp));
+
+ if((missing = Sets.difference(expected, present).size()) > 0)
+ reason += missing+" missing transition points\n";
+ if((obsolete = Sets.difference(present, expected).size()) > 0)
+ reason += obsolete+" obsolete transition points\n";
}
// check for choice points added in model not present in diagram (including inherited)
{
- missing = 0;
- List<ChoicePoint> expectedCPs = ctx.getChPoints();
- List<ChoicePoint> presentCPs = FSMSupportUtil.getInstance().getChoicePoints(shape, fp);
- for (ChoicePoint cp : expectedCPs) {
- if (!presentCPs.contains(cp))
- ++missing;
- }
- if (missing>0)
- reason += missing+" missing choice points\n";
+ missing = obsolete = 0;
+ Set<ChoicePoint> expected = Sets.newHashSet(ctx.getChPoints());
+ Set<ChoicePoint> present = Sets.newHashSet(FSMSupportUtil.getInstance().getChoicePoints(shape, fp));
+
+ if((missing = Sets.difference(expected, present).size()) > 0)
+ reason += missing+" missing choice points\n";
+ if((obsolete = Sets.difference(present, expected).size()) > 0)
+ reason += obsolete+" obsolete choice points\n";
}
+
// check for transitions added in model not present in diagram (including inherited)
{
- missing = 0;
- List<Transition> expectedTrans = ctx.getTransitions();
- List<Transition> presentTrans = FSMSupportUtil.getInstance().getTransitions(getDiagram(), fp);
- for (Transition trans : expectedTrans) {
- if (!presentTrans.contains(trans))
- ++missing;
- }
- if (missing>0)
- reason += missing+" missing transitions\n";
+ missing = obsolete = 0;
+ Set<Transition> expected = Sets.newHashSet(ctx.getTransitions());
+ Set<Transition> present = Sets.newHashSet(FSMSupportUtil.getInstance().getTransitions(getDiagram(), fp));
+
+ if((missing = Sets.difference(expected, present).size()) > 0)
+ reason += missing+" missing transitions\n";
+ if((obsolete = Sets.difference(present, expected).size()) > 0)
+ reason += obsolete+" obsolete transitions\n";
}
+
}
// check state path
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/StateSupport.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/StateSupport.java
index 28a723fc3..c12d65fd1 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/StateSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/StateSupport.java
@@ -624,22 +624,6 @@ public class StateSupport {
State s = (State) bo;
ModelComponent mainAc = FSMSupportUtil.getInstance().getModelComponent(getDiagram());
- // check if state still owned/inherited
- {
- ModelComponent mc = FSMSupportUtil.getInstance().getFSMHelpers().getModelComponent(s);
- ModelComponent tmp = mainAc;
- boolean found = false;
- do {
- if (tmp==mc)
- found = true;
- tmp = tmp.getBase();
- }
- while (!found && tmp!=null);
-
- if (!found)
- return Reason.createTrueReason("State not inherited anymore");
- }
-
// check sub structure hint
{
boolean hasSubStruct = FSMSupportUtil.getInstance().getFSMHelpers().hasSubStructure(s, mainAc);
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/TrPointSupport.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/TrPointSupport.java
index fa9794ff2..6a6814e5a 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/TrPointSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/TrPointSupport.java
@@ -578,24 +578,7 @@ public class TrPointSupport {
return Reason.createTrueReason("Transition Point deleted from model");
}
TrPoint tp = (TrPoint) bo;
-
- // check if tp still owned/inherited
ContainerShape containerShape = (ContainerShape)context.getPictogramElement();
- bo = getBusinessObjectForPictogramElement(containerShape);
- // TODOHRR-B check inheritance
-// if (bo instanceof StateGraph) {
-// StateGraph sg = (StateGraph) bo;
-// boolean found = false;
-// do {
-// if (sg==tp.eContainer())
-// found = true;
-// sg = sg.getBase();
-// }
-// while (!found && sg!=null);
-//
-// if (!found)
-// return Reason.createTrueReason("TransitionPoint not inherited anymore");
-// }
GraphicsAlgorithm ga = containerShape.getChildren().get(0).getGraphicsAlgorithm();
if (ga instanceof Text) {

Back to the top