Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-05-16 10:12:16 +0000
committerHenrik Rentz-Reichert2012-05-16 10:12:16 +0000
commit14d717f8332c03da23bd456e3de8b1df0e9120a7 (patch)
tree8c9fa1e9be949836cf8afd3df2a9f200b61193b9 /plugins/org.eclipse.etrice.ui.behavior/src
parent6914e68608e3a09515cf404b711c4e4d8792a419 (diff)
downloadorg.eclipse.etrice-14d717f8332c03da23bd456e3de8b1df0e9120a7.tar.gz
org.eclipse.etrice-14d717f8332c03da23bd456e3de8b1df0e9120a7.tar.xz
org.eclipse.etrice-14d717f8332c03da23bd456e3de8b1df0e9120a7.zip
[ui.behavior] more fixes around inheritance
Diffstat (limited to 'plugins/org.eclipse.etrice.ui.behavior/src')
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/editor/BehaviorEditor.java53
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/DiagramUpdateFeature.java20
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java20
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/SupportUtil.java2
4 files changed, 90 insertions, 5 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/editor/BehaviorEditor.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/editor/BehaviorEditor.java
index d7fe4c187..9625c8498 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/editor/BehaviorEditor.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/editor/BehaviorEditor.java
@@ -10,15 +10,19 @@ package org.eclipse.etrice.ui.behavior.editor;
import java.util.ArrayList;
+import java.util.HashMap;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.etrice.core.naming.RoomNameProvider;
import org.eclipse.etrice.core.room.ActorClass;
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.util.RoomHelpers;
@@ -101,6 +105,7 @@ public class BehaviorEditor extends RoomDiagramEditor {
getEditingDomain().getCommandStack().execute(new RecordingCommand(getEditingDomain()) {
protected void doExecute() {
removeEmptySubgraphs();
+ rebaseRefinedStates();
removeUnusedRefinedStates();
}
});
@@ -182,4 +187,52 @@ public class BehaviorEditor extends RoomDiagramEditor {
EcoreUtil.delete(shape, true);
}
}
+
+ protected void rebaseRefinedStates() {
+ @SuppressWarnings("restriction")
+ Diagram diagram = getDiagramTypeProvider().getDiagram();
+ ActorClass ac = SupportUtil.getActorClass(diagram);
+
+ if (ac.getStateMachine()==null)
+ return;
+
+ ArrayList<RefinedState> refinedStates = new ArrayList<RefinedState>();
+ ArrayList<String> paths = new ArrayList<String>();
+ HashMap<String, RefinedState> path2rs = new HashMap<String, RefinedState>();
+ TreeIterator<EObject> it = ac.getStateMachine().eAllContents();
+ while (it.hasNext()) {
+ EObject obj = it.next();
+ if (obj instanceof RefinedState) {
+ refinedStates.add((RefinedState) obj);
+ String path = RoomNameProvider.getFullPath((RefinedState) obj);
+ paths.add(path);
+ path2rs.put(path, (RefinedState) obj);
+ }
+ }
+
+ // we sort the paths to have paths with same beginning in descending length
+ java.util.Collections.sort(paths, java.util.Collections.reverseOrder());
+
+ // find the best matching context
+ HashMap<RefinedState, RefinedState> rs2parent = new HashMap<RefinedState, RefinedState>();
+ for (RefinedState rs : refinedStates) {
+ String fullPath = RoomNameProvider.getFullPath(rs);
+ for (String path : paths) {
+ if (!fullPath.equals(path) && fullPath.startsWith(path) && fullPath.charAt(path.length())==RoomNameProvider.PATH_SEP.charAt(0)) {
+ RefinedState parent = path2rs.get(path);
+ if (!(parent.getSubgraph()!=null && parent.getSubgraph().getStates().contains(rs)))
+ rs2parent.put(rs, parent);
+ break;
+ }
+ }
+ }
+
+ // move all to the new context
+ for (RefinedState rs : rs2parent.keySet()) {
+ RefinedState parent = rs2parent.get(rs);
+ if (parent.getSubgraph()==null)
+ parent.setSubgraph(RoomFactory.eINSTANCE.createStateGraph());
+ parent.getSubgraph().getStates().add(rs);
+ }
+ }
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/DiagramUpdateFeature.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/DiagramUpdateFeature.java
index dd9586003..fe401312f 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/DiagramUpdateFeature.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/DiagramUpdateFeature.java
@@ -27,6 +27,7 @@ import org.eclipse.graphiti.features.context.impl.RemoveContext;
import org.eclipse.graphiti.features.context.impl.UpdateContext;
import org.eclipse.graphiti.features.impl.AbstractUpdateFeature;
import org.eclipse.graphiti.features.impl.Reason;
+import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Shape;
@@ -80,6 +81,12 @@ public class DiagramUpdateFeature extends AbstractUpdateFeature {
}
}
+ // check for dangling connections
+ for (Connection conn : getDiagram().getConnections()) {
+ if (conn.getStart()==null || conn.getEnd()==null)
+ return Reason.createTrueReason();
+ }
+
return Reason.createFalseReason();
}
@@ -108,6 +115,19 @@ public class DiagramUpdateFeature extends AbstractUpdateFeature {
}
}
+ // remove dangling connections
+ ArrayList<Connection> connections = new ArrayList<Connection>(getDiagram().getConnections());
+ for (Connection conn : connections) {
+ if (conn.getStart()==null || conn.getEnd()==null) {
+ IRemoveContext rc = new RemoveContext(conn);
+ IRemoveFeature removeFeature = getFeatureProvider().getRemoveFeature(rc);
+ if (removeFeature != null) {
+ removeFeature.remove(rc);
+ changed = true;
+ }
+ }
+ }
+
return changed;
}
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 718fb16df..b8e98914c 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
@@ -676,13 +676,23 @@ public class StateSupport {
if (!super.canResizeShape(context))
return false;
- int width = context.getWidth()-MARGIN;
- int height = context.getHeight()-MARGIN;
- if (width>0 && height>0)
- if (width < MIN_SIZE_X+MARGIN || height < MIN_SIZE_Y+MARGIN)
+ Object bo = getBusinessObjectForPictogramElement(context.getPictogramElement());
+
+ if (bo instanceof State) {
+ State s = (State) bo;
+ if (SupportUtil.isInherited(getDiagram(), s))
return false;
+
+ int width = context.getWidth()-MARGIN;
+ int height = context.getHeight()-MARGIN;
+ if (width>0 && height>0)
+ if (width < MIN_SIZE_X+MARGIN || height < MIN_SIZE_Y+MARGIN)
+ return false;
+
+ return true;
+ }
- return true;
+ return false;
}
@Override
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 b6bb584d3..376ac22d5 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
@@ -591,6 +591,7 @@ public class SupportUtil {
for (Shape shape : shapes) {
EObject bo = linkService.getBusinessObjectForLinkedPictogramElement(shape);
if (bo==node) {
+ // relocate and resize the invisible rectangle
GraphicsAlgorithm ga = shape.getGraphicsAlgorithm();
// System.out.println(RoomNameProvider.getFullPath(node)+": "+ga.getX()+" "+ga.getY()+" "+ga.getWidth()+" "+ga.getHeight());
// System.out.println(" -> "+ps.getX()+" "+ps.getY()+" "+ps.getWidth()+" "+ps.getHeight());
@@ -609,6 +610,7 @@ public class SupportUtil {
ps.getHeight()+2*margin
);
+ // have to call the layout to adjust the visible border
LayoutContext lc = new LayoutContext(shape);
fp.layoutIfPossible(lc);
break;

Back to the top