summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2013-08-06 13:53:58 (EDT)
committerJuergen Haug2013-08-06 13:53:58 (EDT)
commit3b8403120c3258c1eb807319f5f07ab2a85e8f28 (patch)
tree20e62a158403209f06c6ad6c3c61d5139b8336da
parent885e5869ff2b1904e963c49be0c2f1cabb3c0cc0 (diff)
downloadorg.eclipse.etrice-3b8403120c3258c1eb807319f5f07ab2a85e8f28.zip
org.eclipse.etrice-3b8403120c3258c1eb807319f5f07ab2a85e8f28.tar.gz
org.eclipse.etrice-3b8403120c3258c1eb807319f5f07ab2a85e8f28.tar.bz2
[ui.structure.tests] updated test for 2256fc2refs/changes/74/15174/1
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java44
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DiagramUtil.java14
-rw-r--r--tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithInheritance.java10
-rw-r--r--tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithReferences.java2
4 files changed, 44 insertions, 26 deletions
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java
index 0dfaed3..b2d4192 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java
@@ -135,20 +135,20 @@ public class ActorContainerRefSupport {
public static final IColorConstant INHERITED_COLOR = new ColorConstant(100, 100, 100);
public static final IColorConstant BACKGROUND = new ColorConstant(200, 200, 200);
+ public static final String GRAPHIC_ITEM_KEY = "actorref_graphic_element";
+ public static final String HATCHED_LINE = "hatched_line";
+ public static final String LAYERCONN_ANCHOR = "layerconn_anchor";
+ public static final String MAIN_BORDER = "mainborder";
+ public static final String NAME_SHAPE = "name_shape";
+ public static final String REPL_BORDER = "replborder";
+ public static final String SIZE_FRAME = "sizeframe";
+ public static final String SIZE_SHAPE = "size_shape";
+ public static final String SUBSTRUCTURE = "substructure";
+
private static class FeatureProvider extends DefaultFeatureProvider {
private static class ActorRefGraphicsAccess {
- private static final String PROP_KEY = "actorref_graphic_element";
- private static final String MAIN_BORDER = "mainborder";
- private static final String REPL_BORDER = "replborder";
- private static final String SIZE_FRAME = "sizeframe";
- private static final String SUBSTRUCTURE = "substructure";
- private static final String HATCHED_LINE = "hatched_line";
- private static final String NAME_SHAPE = "name_shape";
- private static final String SIZE_SHAPE = "size_shape";
- private static final String LAYERCONN_ANCHOR = "layerconn_anchor";
-
private IPeService peService;
private ContainerShape containerShape;
@@ -223,7 +223,7 @@ public class ActorContainerRefSupport {
List<PropertyContainer> result = new ArrayList<PropertyContainer>();
for(PropertyContainer p : items)
- if(propValue.equals(peService.getPropertyValue(p, PROP_KEY)))
+ if(propValue.equals(peService.getPropertyValue(p, GRAPHIC_ITEM_KEY)))
result.add(p);
return result;
@@ -231,7 +231,7 @@ public class ActorContainerRefSupport {
private PropertyContainer findFirst(List<? extends PropertyContainer> items, String propValue){
for(PropertyContainer p : items)
- if(propValue.equals(peService.getPropertyValue(p, PROP_KEY)))
+ if(propValue.equals(peService.getPropertyValue(p, GRAPHIC_ITEM_KEY)))
return p;
return null;
@@ -248,14 +248,14 @@ public class ActorContainerRefSupport {
{
// repl borderRect
Rectangle rect = gaService.createRectangle(invRectangle);
- peService.setPropertyValue(rect, PROP_KEY, REPL_BORDER);
+ peService.setPropertyValue(rect, GRAPHIC_ITEM_KEY, REPL_BORDER);
rect.setLineWidth(LINE_WIDTH);
gaService.setLocationAndSize(rect, MARGIN+REPLICATED_RECT_OFFSET, MARGIN-REPLICATED_RECT_OFFSET, width, height);
}
{
// main borderRect
Rectangle borderRect = gaService.createRectangle(invRectangle);
- peService.setPropertyValue(borderRect, PROP_KEY, MAIN_BORDER);
+ peService.setPropertyValue(borderRect, GRAPHIC_ITEM_KEY, MAIN_BORDER);
borderRect.setLineWidth(LINE_WIDTH);
gaService.setLocationAndSize(borderRect, MARGIN, MARGIN, width, height);
addSubStructureHint();
@@ -264,14 +264,14 @@ public class ActorContainerRefSupport {
{
// size frame
Rectangle sizeFrame = gaService.createRectangle(invRectangle);
- peService.setPropertyValue(sizeFrame, PROP_KEY, SIZE_FRAME);
+ peService.setPropertyValue(sizeFrame, GRAPHIC_ITEM_KEY, SIZE_FRAME);
sizeFrame.setLineWidth(LINE_WIDTH);
gaService.setLocationAndSize(sizeFrame, MARGIN+width-SIZE_FRAME_SIZE, MARGIN, SIZE_FRAME_SIZE, SIZE_FRAME_SIZE);
}
{
// acr name
Shape labelShape = peCreateService.createShape(containerShape, false);
- peService.setPropertyValue(labelShape, PROP_KEY, NAME_SHAPE);
+ peService.setPropertyValue(labelShape, GRAPHIC_ITEM_KEY, NAME_SHAPE);
Text label = gaService.createDefaultText(diagram, labelShape);
label.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
label.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
@@ -281,7 +281,7 @@ public class ActorContainerRefSupport {
{
// repl size
Shape labelShape = peCreateService.createShape(containerShape, false);
- peService.setPropertyValue(labelShape, PROP_KEY, SIZE_SHAPE);
+ peService.setPropertyValue(labelShape, GRAPHIC_ITEM_KEY, SIZE_SHAPE);
Text label = gaService.createDefaultText(diagram, labelShape);
label.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
label.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
@@ -292,7 +292,7 @@ public class ActorContainerRefSupport {
private void createRefFigureAnchor(){
// anchor for layer connections
ChopboxAnchor anchor = Graphiti.getPeCreateService().createChopboxAnchor(containerShape);
- peService.setPropertyValue(anchor, PROP_KEY, LAYERCONN_ANCHOR);
+ peService.setPropertyValue(anchor, GRAPHIC_ITEM_KEY, LAYERCONN_ANCHOR);
anchor.setReferencedGraphicsAlgorithm(getMainBorder());
}
@@ -351,7 +351,7 @@ public class ActorContainerRefSupport {
}
Polyline line = gaService.createPlainPolyline(mainBorder, new int[] {x0, y0, x1, y1});
- Graphiti.getPeService().setPropertyValue(line, PROP_KEY, HATCHED_LINE);
+ Graphiti.getPeService().setPropertyValue(line, GRAPHIC_ITEM_KEY, HATCHED_LINE);
line.setTransparency(0.4);
}
}
@@ -362,12 +362,12 @@ public class ActorContainerRefSupport {
int y = mainBorder.getHeight()-30;
IGaService gaService = Graphiti.getGaService();
Rectangle hint1 = gaService.createRectangle(mainBorder);
- Graphiti.getPeService().setPropertyValue(hint1, PROP_KEY, SUBSTRUCTURE);
+ Graphiti.getPeService().setPropertyValue(hint1, GRAPHIC_ITEM_KEY, SUBSTRUCTURE);
hint1.setFilled(false);
hint1.setLineWidth(LINE_WIDTH);
gaService.setLocationAndSize(hint1, x+5, y, 20, 10);
Rectangle hint2 = gaService.createRectangle(mainBorder);
- Graphiti.getPeService().setPropertyValue(hint2, PROP_KEY, SUBSTRUCTURE);
+ Graphiti.getPeService().setPropertyValue(hint2, GRAPHIC_ITEM_KEY, SUBSTRUCTURE);
hint2.setFilled(false);
hint2.setLineWidth(LINE_WIDTH);
gaService.setLocationAndSize(hint2, x, y+15, 20, 10);
@@ -1280,6 +1280,8 @@ public class ActorContainerRefSupport {
private FeatureProvider pfp;
private BehaviorProvider tbp;
+
+
public ActorContainerRefSupport(IDiagramTypeProvider dtp, IFeatureProvider fp) {
pfp = new FeatureProvider(dtp,fp);
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DiagramUtil.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DiagramUtil.java
index c40cc5e..f50137e 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DiagramUtil.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/DiagramUtil.java
@@ -12,6 +12,8 @@
package org.eclipse.etrice.ui.structure.support;
+import java.util.List;
+
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.room.ActorContainerRef;
import org.eclipse.etrice.core.room.Binding;
@@ -19,12 +21,15 @@ import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.LayerConnection;
import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.etrice.ui.structure.support.provider.IPositionProvider.PosAndSize;
+import org.eclipse.graphiti.mm.Property;
+import org.eclipse.graphiti.mm.PropertyContainer;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.services.ILinkService;
+import org.eclipse.graphiti.services.IPeService;
public class DiagramUtil {
@@ -60,4 +65,13 @@ public class DiagramUtil {
public static PosAndSize getPosAndSize(GraphicsAlgorithm ga){
return new PosAndSize(ga.getX(), ga.getY(), ga.getWidth(), ga.getHeight());
}
+
+ public static PropertyContainer findProp(List<? extends PropertyContainer> items, String key, String value){
+ IPeService peService = Graphiti.getPeService();
+ for(PropertyContainer p : items)
+ if(value.equals(peService.getPropertyValue(p, key)))
+ return p;
+
+ return null;
+ }
}
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithInheritance.java b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithInheritance.java
index 792f9ef..a5496ee 100644
--- a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithInheritance.java
+++ b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithInheritance.java
@@ -31,6 +31,7 @@ import org.eclipse.etrice.ui.structure.DiagramAccess;
import org.eclipse.etrice.ui.structure.StructureTestActivator;
import org.eclipse.etrice.ui.structure.support.ActorContainerRefSupport;
import org.eclipse.etrice.ui.structure.support.BindingSupport;
+import org.eclipse.etrice.ui.structure.support.DiagramUtil;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.algorithms.Rectangle;
import org.eclipse.graphiti.mm.algorithms.Text;
@@ -107,15 +108,16 @@ public class TestActorClassWithInheritance extends TestBase {
assertTrue("ga is rectangle", childShape.getGraphicsAlgorithm() instanceof Rectangle);
assertFalse("ga is invisible", childShape.getGraphicsAlgorithm().getFilled());
assertFalse("ga is invisible", childShape.getGraphicsAlgorithm().getLineVisible());
- assertEquals("border rect", 1, childShape.getGraphicsAlgorithm().getGraphicsAlgorithmChildren().size());
- GraphicsAlgorithm borderRect = childShape.getGraphicsAlgorithm().getGraphicsAlgorithmChildren().get(0);
+ GraphicsAlgorithm borderRect = (GraphicsAlgorithm) DiagramUtil.findProp(childShape.getGraphicsAlgorithm().getGraphicsAlgorithmChildren(),
+ ActorContainerRefSupport.GRAPHIC_ITEM_KEY, ActorContainerRefSupport.MAIN_BORDER);
+ assertNotNull("borderRect", borderRect);
if (inherited)
- assertTrue("border rect background", isEqual(borderRect.getForeground(), ActorContainerRefSupport.INHERITED_COLOR));
+ assertTrue("border rect foreground", isEqual(borderRect.getForeground(), ActorContainerRefSupport.INHERITED_COLOR));
else
assertTrue("border rect background", isEqual(borderRect.getForeground(), ActorContainerRefSupport.LINE_COLOR));
// ports of actor refs
- assertEquals("grand child shapes", 3, ((ContainerShape)childShape).getChildren().size());
+ assertEquals("grand child shapes", 4, ((ContainerShape)childShape).getChildren().size());
for (Shape grandChildShape : ((ContainerShape)childShape).getChildren()) {
// skip the actor ref label
if (grandChildShape.getGraphicsAlgorithm() instanceof Text)
diff --git a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithReferences.java b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithReferences.java
index 45b5cc0..8e943c6 100644
--- a/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithReferences.java
+++ b/tests/org.eclipse.etrice.ui.structure.tests/src/org/eclipse/etrice/ui/structure/commands/TestActorClassWithReferences.java
@@ -80,7 +80,7 @@ public class TestActorClassWithReferences extends TestBase {
nRefs++;
// ports of actor refs
- assertEquals("grand child shapes", 2, ((ContainerShape)childShape).getChildren().size());
+ assertEquals("grand child shapes", 3, ((ContainerShape)childShape).getChildren().size());
for (Shape grandChildShape : ((ContainerShape)childShape).getChildren()) {
// skip the actor ref label
if (grandChildShape.getGraphicsAlgorithm() instanceof Text)