Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-03-30 13:22:12 -0400
committerHenrik Rentz-Reichert2012-03-30 13:22:12 -0400
commita13ef6ab5bd7ac7c768b96aff36ddf36c735a0cd (patch)
tree320275d5adf408f0018012314de9a732e49e7d1f /plugins/org.eclipse.etrice.ui.structure
parent383c9a66b3f4b2a964a0c5fec160430604df7140 (diff)
downloadorg.eclipse.etrice-a13ef6ab5bd7ac7c768b96aff36ddf36c735a0cd.tar.gz
org.eclipse.etrice-a13ef6ab5bd7ac7c768b96aff36ddf36c735a0cd.tar.xz
org.eclipse.etrice-a13ef6ab5bd7ac7c768b96aff36ddf36c735a0cd.zip
[core.room, generator, ui.structure] bug 375748: allow replicated actors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=375748
Diffstat (limited to 'plugins/org.eclipse.etrice.ui.structure')
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/ActorContainerRefPropertyDialog.java50
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/PortPropertyDialog.java33
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/ActorContainerRefSupport.java202
3 files changed, 205 insertions, 80 deletions
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/ActorContainerRefPropertyDialog.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/ActorContainerRefPropertyDialog.java
index 1130614e1..4fe506547 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/ActorContainerRefPropertyDialog.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/ActorContainerRefPropertyDialog.java
@@ -26,6 +26,7 @@ import org.eclipse.etrice.core.room.ActorContainerClass;
import org.eclipse.etrice.core.room.ActorContainerRef;
import org.eclipse.etrice.core.room.ActorRef;
import org.eclipse.etrice.core.room.LogicalSystem;
+import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.RoomPackage;
import org.eclipse.etrice.core.room.StructureClass;
import org.eclipse.etrice.core.room.SubSystemClass;
@@ -106,6 +107,22 @@ public class ActorContainerRefPropertyDialog extends AbstractPropertyDialog {
return Status.OK_STATUS;
}
}
+
+ class SizeValidator implements IValidator {
+
+ public SizeValidator() {
+ }
+
+ @Override
+ public IStatus validate(Object value) {
+ if (value instanceof Integer) {
+ int m = (Integer) value;
+ if (m<=0)
+ return ValidationStatus.error("multiplicity must not be positive");
+ }
+ return Status.OK_STATUS;
+ }
+ }
private ActorContainerRef ref;
private IScope scope;
@@ -156,22 +173,49 @@ public class ActorContainerRefPropertyDialog extends AbstractPropertyDialog {
}
}
- Text name = createText(body, "Name:", ref, RoomPackage.eINSTANCE.getActorContainerRef_Name(), nv);
+ Text name = createText(body, "&Name:", ref, RoomPackage.eINSTANCE.getActorContainerRef_Name(), nv);
Combo refClass = refIsActor?
- createComboUsingDesc(body, "Actor Class:", ref, ActorClass.class, RoomPackage.eINSTANCE.getActorRef_Type(), actors, RoomPackage.eINSTANCE.getRoomClass_Name(), pv)
- : createComboUsingDesc(body, "SubSystem Class:", ref, SubSystemClass.class, RoomPackage.eINSTANCE.getSubSystemRef_Type(), actors, RoomPackage.eINSTANCE.getRoomClass_Name(), pv);
+ createComboUsingDesc(body, "Actor &Class:", ref, ActorClass.class, RoomPackage.eINSTANCE.getActorRef_Type(), actors, RoomPackage.eINSTANCE.getRoomClass_Name(), pv)
+ : createComboUsingDesc(body, "SubSystem &Class:", ref, SubSystemClass.class, RoomPackage.eINSTANCE.getSubSystemRef_Type(), actors, RoomPackage.eINSTANCE.getRoomClass_Name(), pv);
createDecorator(name, "invalid name");
createDecorator(refClass, "no class selected");
if (!newRef) {
refClass.setEnabled(false);
+ createInfoDecorator(refClass, "class fixed for exisiting ref");
}
+ if (ref instanceof ActorRef) {
+ Text size = createText(body, "&Multiplicity", ref, RoomPackage.eINSTANCE.getActorRef_Size(), new SizeValidator());
+ if (hasInterfacePortWithMultiplicityAny(((ActorRef) ref).getType())) {
+ size.setEnabled(false);
+ createInfoDecorator(size, "size fixed since actor has interface ports with multiplicity *");
+ }
+ else {
+ createDecorator(size, "multiplicity");
+ }
+ }
+
name.selectAll();
name.setFocus();
}
+ /**
+ * @param ac
+ * @return
+ */
+ private boolean hasInterfacePortWithMultiplicityAny(ActorClass ac) {
+ if (ac==null)
+ return false;
+
+ for (Port p : ac.getIfPorts()) {
+ if (p.getMultiplicity()<0)
+ return true;
+ }
+ return false;
+ }
+
@Override
protected Image getImage() {
return Activator.getImage("icons/Structure.gif");
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/PortPropertyDialog.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/PortPropertyDialog.java
index 52ff2d145..295da7f96 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/PortPropertyDialog.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/dialogs/PortPropertyDialog.java
@@ -83,10 +83,12 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
private boolean mayChange;
private int old;
+ private boolean multAnyAllowed;
- public MultiplicityValidator(boolean mayChange, int old) {
+ public MultiplicityValidator(boolean mayChange, int old, boolean multAnyAllowed) {
this.mayChange = mayChange;
this.old = old;
+ this.multAnyAllowed = multAnyAllowed;
}
@Override
@@ -103,6 +105,8 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
if ((old>1 || old==-1) && m==1)
return ValidationStatus.error("cannot change connected port to not replicated");
}
+ if (m==-1 && !multAnyAllowed)
+ return ValidationStatus.error("multiplicity * not allowed (actor used replicated)");
if (port.getProtocol()!=null && port.getProtocol().getCommType()==CommunicationType.DATA_DRIVEN) {
if (m!=1)
@@ -195,9 +199,15 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
@Override
protected void createContent(IManagedForm mform, Composite body, DataBindingContext bindingContext) {
boolean connected = ValidationUtil.isReferencedInModel(port);
+ boolean multiplicityAnyAllowed = true;
+ ActorContainerClass parent = (ActorContainerClass) port.eContainer();
+ if (parent instanceof ActorClass) {
+ if (ValidationUtil.isReferencedAsReplicatedInModel((ActorClass) parent))
+ multiplicityAnyAllowed = false;
+ }
NameValidator nv = new NameValidator();
ProtocolValidator pv = new ProtocolValidator();
- MultiplicityValidator mv = new MultiplicityValidator(newPort || !connected, port.getMultiplicity());
+ MultiplicityValidator mv = new MultiplicityValidator(newPort || !connected, port.getMultiplicity(), multiplicityAnyAllowed);
ArrayList<IEObjectDescription> protocols = new ArrayList<IEObjectDescription>();
Iterator<IEObjectDescription> it = scope.getAllElements().iterator();
@@ -208,30 +218,37 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
protocols.add(desc);
}
- Text name = createText(body, "Name:", port, RoomPackage.eINSTANCE.getInterfaceItem_Name(), nv);
- Combo protocol = createComboUsingDesc(body, "Protocol:", port, ProtocolClass.class, RoomPackage.eINSTANCE.getInterfaceItem_Protocol(), protocols, RoomPackage.eINSTANCE.getRoomClass_Name(), pv);
- Button conj = createCheck(body, "Conjugated:", port, RoomPackage.eINSTANCE.getPort_Conjugated());
+ Text name = createText(body, "&Name:", port, RoomPackage.eINSTANCE.getInterfaceItem_Name(), nv);
+ Combo protocol = createComboUsingDesc(body, "&Protocol:", port, ProtocolClass.class, RoomPackage.eINSTANCE.getInterfaceItem_Protocol(), protocols, RoomPackage.eINSTANCE.getRoomClass_Name(), pv);
+ Button conj = createCheck(body, "&Conjugated:", port, RoomPackage.eINSTANCE.getPort_Conjugated());
if (!internal && !refitem && (acc instanceof ActorClass))
createRelayCheck(body, !connected, mform.getToolkit());
Multiplicity2StringConverter m2s = new Multiplicity2StringConverter();
String2MultiplicityConverter s2m = new String2MultiplicityConverter();
- Text multi = createText(body, "Multiplicity:", port, RoomPackage.eINSTANCE.getPort_Multiplicity(), mv, s2m, m2s, false);
+ Text multi = createText(body, "&Multiplicity:", port, RoomPackage.eINSTANCE.getPort_Multiplicity(), mv, s2m, m2s, false);
if (!newPort) {
- // TODOHRR: check whether port is used externally?
if (connected) {
protocol.setEnabled(false);
+ createInfoDecorator(protocol, "only changeable for unconnected ports");
conj.setEnabled(false);
- if (port.getMultiplicity()==1)
+ createInfoDecorator(conj, "only changeable for unconnected ports");
+ if (port.getMultiplicity()==1) {
multi.setEnabled(false);
+ createInfoDecorator(multi, "only changeable for unconnected ports");
+ }
}
if (refitem) {
name.setEnabled(false);
+ createInfoDecorator(name, "inherited");
protocol.setEnabled(false);
+ createInfoDecorator(protocol, "inherited");
conj.setEnabled(false);
+ createInfoDecorator(conj, "inherited");
multi.setEnabled(false);
+ createInfoDecorator(multi, "inherited");
}
}
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 b46f3f3b5..5e969ebb1 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
@@ -81,6 +81,7 @@ import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.AnchorContainer;
import org.eclipse.graphiti.mm.pictograms.ChopboxAnchor;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
@@ -107,6 +108,8 @@ public class ActorContainerRefSupport {
public static final int MIN_SIZE_X = 100;
public static final int MIN_SIZE_Y = 60;
public static final int MARGIN = 30;
+ private static final int SIZE_FRAME_SIZE = 25;
+ private static final int REPLICATED_RECT_OFFSET = 3;
public static final IColorConstant LINE_COLOR = new ColorConstant(0, 0, 0);
public static final IColorConstant INHERITED_COLOR = new ColorConstant(100, 100, 100);
@@ -223,50 +226,27 @@ public class ActorContainerRefSupport {
ContainerShape acShape = context.getTargetContainer();
// CONTAINER SHAPE WITH RECTANGLE
- IPeCreateService peCreateService = Graphiti.getPeCreateService();
ContainerShape containerShape =
- peCreateService.createContainerShape(acShape, true);
+ Graphiti.getPeCreateService().createContainerShape(acShape, true);
Graphiti.getPeService().setPropertyValue(containerShape, Constants.TYPE_KEY, Constants.REF_TYPE);
- int width = context.getWidth() <= 0 ? DEFAULT_SIZE_X : context.getWidth();
- int height = context.getHeight() <= 0 ? DEFAULT_SIZE_Y : context.getHeight();
-
- EObject parent = acShape.getLink().getBusinessObjects().get(0);
+ EObject parent = (EObject) getBusinessObjectForPictogramElement(acShape);
boolean inherited = isInherited(ar, parent);
+
Color lineColor = manageColor(inherited?INHERITED_COLOR:LINE_COLOR);
- IGaService gaService = Graphiti.getGaService();
{
- final Rectangle invisibleRectangle = gaService.createInvisibleRectangle(containerShape);
- gaService.setLocationAndSize(invisibleRectangle,
+ int width = context.getWidth() <= 0 ? DEFAULT_SIZE_X : context.getWidth();
+ int height = context.getHeight() <= 0 ? DEFAULT_SIZE_Y : context.getHeight();
+ final Rectangle invisibleRectangle = Graphiti.getGaService().createInvisibleRectangle(containerShape);
+ Graphiti.getGaService().setLocationAndSize(invisibleRectangle,
context.getX()-(width/2+MARGIN), context.getY()-(height/2+MARGIN), width + 2*MARGIN, height + 2*MARGIN);
- Rectangle borderRect = gaService.createRectangle(invisibleRectangle);
- borderRect.setForeground(lineColor);
- borderRect.setBackground(manageColor(BACKGROUND));
- borderRect.setLineWidth(LINE_WIDTH);
- gaService.setLocationAndSize(borderRect, MARGIN, MARGIN, width, height);
-
- addSubStructureHint(ar, borderRect, lineColor);
-
- // anchor for layer connections
- ChopboxAnchor anchor = peCreateService.createChopboxAnchor(containerShape);
- anchor.setReferencedGraphicsAlgorithm(borderRect);
+ createRefFigure(ar, getDiagram(), containerShape, invisibleRectangle, lineColor, manageColor(BACKGROUND));
+ }
// create link and wire it
link(containerShape, ar);
- }
-
- // the first child shape is the label
- {
- Shape labelShape = peCreateService.createShape(containerShape, false);
- Text label = gaService.createDefaultText(getDiagram(), labelShape, RoomNameProvider.getRefLabelName(ar));
- label.setForeground(lineColor);
- label.setBackground(lineColor);
- label.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
- label.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
- gaService.setLocationAndSize(label, MARGIN, MARGIN, width, height);
- }
// other child shapes may follow
if (inherited) {
@@ -382,7 +362,8 @@ public class ActorContainerRefSupport {
@Override
public void execute(ICustomContext context) {
- ActorContainerRef acr = (ActorContainerRef) getBusinessObjectForPictogramElement(context.getPictogramElements()[0]);
+ ContainerShape containerShape = (ContainerShape) context.getPictogramElements()[0];
+ ActorContainerRef acr = (ActorContainerRef) getBusinessObjectForPictogramElement(containerShape);
StructureClass sc = (StructureClass)acr.eContainer();
IScopeProvider scopeProvider = ((DiagramTypeProvider)getFeatureProvider().getDiagramTypeProvider()).getScopeProvider();
@@ -394,7 +375,12 @@ public class ActorContainerRefSupport {
throw new OperationCanceledException();
doneChanges = true;
- updateLabel(acr, context.getPictogramElements()[0]);
+ //updateLabel(acr, context.getPictogramElements()[0]);
+
+ EObject parent = (EObject) getBusinessObjectForPictogramElement(containerShape.getContainer());
+ boolean inherited = isInherited(acr, parent);
+ Color lineColor = manageColor(inherited?INHERITED_COLOR:LINE_COLOR);
+ createRefFigure(acr, getDiagram(), containerShape, (Rectangle)containerShape.getGraphicsAlgorithm(), lineColor, manageColor(BACKGROUND));
}
@Override
@@ -807,41 +793,6 @@ public class ActorContainerRefSupport {
return ar.eContainer()!=parent;
}
- private static boolean hasSubStructure(ActorContainerRef acr) {
- if (acr instanceof ActorRef) {
- if (!((ActorRef) acr).getType().getActorRefs().isEmpty())
- return true;
- }
- else if (acr instanceof SubSystemRef) {
- if (!((SubSystemRef)acr).getType().getActorRefs().isEmpty())
- return true;
- }
- return false;
- }
-
- private static void addSubStructureHint(ActorContainerRef acr,
- Rectangle borderRect, Color lineColor) {
-
- int x = borderRect.getWidth()-35;
- int y = borderRect.getHeight()-30;
- IGaService gaService = Graphiti.getGaService();
- Rectangle hint1 = gaService.createRectangle(borderRect);
- hint1.setForeground(lineColor);
- hint1.setFilled(false);
- hint1.setLineWidth(LINE_WIDTH);
- gaService.setLocationAndSize(hint1, x+5, y, 20, 10);
- Rectangle hint2 = gaService.createRectangle(borderRect);
- hint2.setForeground(lineColor);
- hint2.setFilled(false);
- hint2.setLineWidth(LINE_WIDTH);
- gaService.setLocationAndSize(hint2, x, y+15, 20, 10);
-
- if (!hasSubStructure(acr)) {
- hint1.setLineVisible(false);
- hint2.setLineVisible(false);
- }
- }
-
protected static void updateSubStructureHint(ActorContainerRef acr, GraphicsAlgorithm borderRect) {
boolean hasSubStructure = hasSubStructure(acr);
@@ -922,6 +873,119 @@ public class ActorContainerRefSupport {
}
}
+ private static void createRefFigure(ActorContainerRef ar,
+ Diagram diagram, ContainerShape containerShape, final Rectangle invisibleRectangle,
+ Color lineColor, Color bgColor) {
+
+ invisibleRectangle.getGraphicsAlgorithmChildren().clear();
+ if (!containerShape.getChildren().isEmpty()) {
+ // potentially there are two text labels which we remove before re-creating
+ Shape shape = containerShape.getChildren().get(0);
+ if (shape.getGraphicsAlgorithm() instanceof Text)
+ containerShape.getChildren().remove(0);
+ shape = containerShape.getChildren().get(0);
+ if (shape.getGraphicsAlgorithm() instanceof Text)
+ containerShape.getChildren().remove(0);
+ }
+
+ int width = invisibleRectangle.getWidth()-2*MARGIN;
+ int height = invisibleRectangle.getHeight()-2*MARGIN;
+
+ IGaService gaService = Graphiti.getGaService();
+ if (ar instanceof ActorRef && ((ActorRef)ar).getSize()>1) {
+ Rectangle rect = gaService.createRectangle(invisibleRectangle);
+ rect.setForeground(lineColor);
+ rect.setBackground(bgColor);
+ rect.setLineWidth(LINE_WIDTH);
+ gaService.setLocationAndSize(rect, MARGIN+REPLICATED_RECT_OFFSET, MARGIN-REPLICATED_RECT_OFFSET, width, height);
+ }
+
+ Rectangle borderRect = gaService.createRectangle(invisibleRectangle);
+ borderRect.setForeground(lineColor);
+ borderRect.setBackground(bgColor);
+ borderRect.setLineWidth(LINE_WIDTH);
+ gaService.setLocationAndSize(borderRect, MARGIN, MARGIN, width, height);
+
+ if (ar instanceof ActorRef && ((ActorRef)ar).getSize()>1) {
+ Rectangle sizeFrame = gaService.createRectangle(invisibleRectangle);
+ sizeFrame.setForeground(lineColor);
+ sizeFrame.setBackground(bgColor);
+ sizeFrame.setLineWidth(LINE_WIDTH);
+ gaService.setLocationAndSize(sizeFrame, MARGIN+width-SIZE_FRAME_SIZE, MARGIN, SIZE_FRAME_SIZE, SIZE_FRAME_SIZE);
+ }
+
+ addSubStructureHint(ar, borderRect, lineColor);
+
+ IPeCreateService peCreateService = Graphiti.getPeCreateService();
+
+ // anchor for layer connections
+ if (containerShape.getAnchors().isEmpty()) {
+ ChopboxAnchor anchor = peCreateService.createChopboxAnchor(containerShape);
+ anchor.setReferencedGraphicsAlgorithm(borderRect);
+ }
+ else {
+ // we just set the referenced GA
+ containerShape.getAnchors().get(0).setReferencedGraphicsAlgorithm(borderRect);
+ }
+
+ // the first child shape is the label
+ {
+ Shape labelShape = peCreateService.createShape(containerShape, false);
+ Text label = gaService.createDefaultText(diagram, labelShape, RoomNameProvider.getRefLabelName(ar));
+ label.setForeground(lineColor);
+ label.setBackground(lineColor);
+ label.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
+ label.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
+ gaService.setLocationAndSize(label, MARGIN, MARGIN, width, height);
+ }
+
+ if (ar instanceof ActorRef && ((ActorRef)ar).getSize()>1) {
+ Shape labelShape = peCreateService.createShape(containerShape, false);
+ Integer size = ((ActorRef)ar).getSize();
+ Text label = gaService.createDefaultText(diagram, labelShape, size.toString());
+ label.setForeground(lineColor);
+ label.setBackground(lineColor);
+ label.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
+ label.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
+ gaService.setLocationAndSize(label, MARGIN+width-SIZE_FRAME_SIZE, MARGIN, SIZE_FRAME_SIZE, SIZE_FRAME_SIZE);
+ }
+ }
+
+ private static void addSubStructureHint(ActorContainerRef acr,
+ Rectangle borderRect, Color lineColor) {
+
+ int x = borderRect.getWidth()-35;
+ int y = borderRect.getHeight()-30;
+ IGaService gaService = Graphiti.getGaService();
+ Rectangle hint1 = gaService.createRectangle(borderRect);
+ hint1.setForeground(lineColor);
+ hint1.setFilled(false);
+ hint1.setLineWidth(LINE_WIDTH);
+ gaService.setLocationAndSize(hint1, x+5, y, 20, 10);
+ Rectangle hint2 = gaService.createRectangle(borderRect);
+ hint2.setForeground(lineColor);
+ hint2.setFilled(false);
+ hint2.setLineWidth(LINE_WIDTH);
+ gaService.setLocationAndSize(hint2, x, y+15, 20, 10);
+
+ if (!hasSubStructure(acr)) {
+ hint1.setLineVisible(false);
+ hint2.setLineVisible(false);
+ }
+ }
+
+ private static boolean hasSubStructure(ActorContainerRef acr) {
+ if (acr instanceof ActorRef) {
+ if (!((ActorRef) acr).getType().getActorRefs().isEmpty())
+ return true;
+ }
+ else if (acr instanceof SubSystemRef) {
+ if (!((SubSystemRef)acr).getType().getActorRefs().isEmpty())
+ return true;
+ }
+ return false;
+ }
+
private FeatureProvider pfp;
private BehaviorProvider tbp;

Back to the top