Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2011-11-07 09:44:04 -0500
committerHenrik Rentz-Reichert2011-11-07 09:44:04 -0500
commita87f5e8c60ce7681288f4633a950912a399d5878 (patch)
tree7f0e22f4183d69d24ece9838fd01b357919d5f63 /plugins/org.eclipse.etrice.ui.structure
parent322377ba648359f0a15d53e529651958b47d789f (diff)
downloadorg.eclipse.etrice-a87f5e8c60ce7681288f4633a950912a399d5878.tar.gz
org.eclipse.etrice-a87f5e8c60ce7681288f4633a950912a399d5878.tar.xz
org.eclipse.etrice-a87f5e8c60ce7681288f4633a950912a399d5878.zip
[core.room, generator, generator.java] port multiplicity may be * (value -1)
changed grammar and adjusted ui and generator. generator.java computes the correct number for a given instance
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/PortPropertyDialog.java50
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java4
2 files changed, 47 insertions, 7 deletions
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 f9f9e45fa..51be6e292 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
@@ -16,6 +16,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;
@@ -91,18 +92,54 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
public IStatus validate(Object value) {
if (value instanceof Integer) {
int m = (Integer) value;
- if (m<=0)
- return ValidationStatus.error("multiplicity must be positive");
+ if (m==0)
+ return ValidationStatus.error("multiplicity must not be 0");
+ if (m<-1)
+ return ValidationStatus.error("multiplicity must be -1 or positive");
if (!mayChange) {
- if (old==1 && m>1)
+ if (old==1 && (m>1 || m==-1))
return ValidationStatus.error("cannot make connected port replicated");
- if (old>1 && m==1)
+ if ((old>1 || old==-1) && m==1)
return ValidationStatus.error("cannot make connected port not replicated");
}
}
return Status.OK_STATUS;
}
}
+
+ static class Multiplicity2StringConverter extends Converter {
+
+ public Multiplicity2StringConverter() {
+ super(Integer.class, String.class);
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ if (fromObject instanceof Integer) {
+ int val = (Integer) fromObject;
+ if (val==-1)
+ return "*";
+ else
+ return fromObject.toString();
+ }
+ return fromObject;
+ }
+
+ }
+
+ static class String2MultiplicityConverter extends Converter {
+ String2MultiplicityConverter() {
+ super(String.class, Integer.class);
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ if (fromObject.equals("*"))
+ return -1;
+ else
+ return Integer.parseInt((String) fromObject);
+ }
+ }
private Port port;
private IScope scope;
@@ -170,7 +207,10 @@ public class PortPropertyDialog extends AbstractPropertyDialog {
Button conj = createCheck(body, "Conjugated:", port, RoomPackage.eINSTANCE.getPort_Conjugated());
if (!internal && !refitem && (acc instanceof ActorClass))
createRelayCheck(body, mform.getToolkit());
- Text multi = createText(body, "Multiplicity:", port, RoomPackage.eINSTANCE.getPort_Multiplicity(), mv);
+
+ Multiplicity2StringConverter m2s = new Multiplicity2StringConverter();
+ String2MultiplicityConverter s2m = new String2MultiplicityConverter();
+ Text multi = createText(body, "Multiplicity:", port, RoomPackage.eINSTANCE.getPort_Multiplicity(), mv, s2m, m2s, false);
if (!newPort) {
// TODOHRR: check whether port is used externally?
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java
index 9e5a34119..3a4f7d627 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/PortSupport.java
@@ -326,7 +326,7 @@ public class PortSupport extends InterfaceItemSupport {
}
IGaService gaService = Graphiti.getGaService();
- if (port.getMultiplicity()>1) {
+ if (port.isReplicated()) {
Rectangle rect = gaService.createRectangle(invisibleRectangle);
rect.setForeground(darkColor);
rect.setBackground(brightDolor);
@@ -463,7 +463,7 @@ public class PortSupport extends InterfaceItemSupport {
kind += "C";
if (ValidationUtil.isRelay(port))
kind += "R";
- if (port.getMultiplicity()>1)
+ if (port.isReplicated())
kind += "M";
return kind;
}

Back to the top