summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2011-07-26 15:29:18 (EDT)
committerHenrik Rentz-Reichert2011-07-26 15:29:18 (EDT)
commitcf093a190c905d05d44680bc4d85c85bbec221fb (patch)
tree9ec1222d7db31f14119fad83bd000e89c83bd5fb
parent3b2a7dd687a30405ef9f13a50e086c5790725cae (diff)
downloadorg.eclipse.etrice-cf093a190c905d05d44680bc4d85c85bbec221fb.zip
org.eclipse.etrice-cf093a190c905d05d44680bc4d85c85bbec221fb.tar.gz
org.eclipse.etrice-cf093a190c905d05d44680bc4d85c85bbec221fb.tar.bz2
[ui.behavior] guard validation for data driven state machine (non-empty)
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/DetailCodeToString.java9
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StringToDetailCode.java22
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java8
3 files changed, 34 insertions, 5 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/DetailCodeToString.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/DetailCodeToString.java
index 1425cfc..af3c729 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/DetailCodeToString.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/DetailCodeToString.java
@@ -5,8 +5,15 @@ import org.eclipse.etrice.core.room.DetailCode;
public class DetailCodeToString extends Converter {
+ private boolean nullIsEmpty;
+
public DetailCodeToString() {
+ this(false);
+ }
+
+ public DetailCodeToString(boolean nullIsEmpty) {
super(DetailCode.class, String.class);
+ this.nullIsEmpty = nullIsEmpty;
}
@Override
@@ -18,6 +25,6 @@ public class DetailCodeToString extends Converter {
}
return result;
}
- return null;
+ return nullIsEmpty? "":null;
}
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StringToDetailCode.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StringToDetailCode.java
index dc607a0..67d7ea4 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StringToDetailCode.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StringToDetailCode.java
@@ -6,8 +6,15 @@ import org.eclipse.etrice.core.room.RoomFactory;
public class StringToDetailCode extends Converter {
- public StringToDetailCode() {
+ private boolean emptyIsNull;
+
+ public StringToDetailCode(boolean emptyIsNull) {
super(String.class, DetailCode.class);
+ this.emptyIsNull = emptyIsNull;
+ }
+
+ public StringToDetailCode() {
+ this(true);
}
@Override
@@ -15,11 +22,11 @@ public class StringToDetailCode extends Converter {
if (fromObject instanceof String) {
String code = (String) fromObject;
if (code.isEmpty())
- return null;
+ return emptyIsNull? null:createEmptyDetailCode();
String trimmed = code.trim();
if (trimmed.isEmpty())
- return null;
+ return emptyIsNull? null:createEmptyDetailCode();
// TODOHRR: make work also for UNIX/Mac line endings
String[] cmds = code.split("\r\n");
@@ -35,4 +42,13 @@ public class StringToDetailCode extends Converter {
return null;
}
+ /**
+ * @return
+ */
+ private DetailCode createEmptyDetailCode() {
+ DetailCode dc = RoomFactory.eINSTANCE.createDetailCode();
+ dc.getCommands().add("");
+ return dc;
+ }
+
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java
index 781310d..986b1ed 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java
@@ -174,6 +174,8 @@ public class TransitionPropertyDialog extends AbstractPropertyDialog {
private EList<Message> currentMsgs;
private DetailCodeToString m2s;
private StringToDetailCode s2m;
+ private StringToDetailCode s2m_not_null;
+ private DetailCodeToString m2s_null_empty;
private Text guardText;
private Button removeMifButton;
private boolean triggerError = false;
@@ -185,7 +187,9 @@ public class TransitionPropertyDialog extends AbstractPropertyDialog {
this.ac = getActorClass(sg);
m2s = new DetailCodeToString();
+ m2s_null_empty = new DetailCodeToString(true);
s2m = new StringToDetailCode();
+ s2m_not_null = new StringToDetailCode(false);
interfaceItems = RoomHelpers.getAllInterfaceItems(ac);
}
@@ -247,10 +251,12 @@ public class TransitionPropertyDialog extends AbstractPropertyDialog {
if (trans instanceof GuardedTransition) {
GuardValidator gv = new GuardValidator();
- Text cond = createText(body, "Guard:", trans, RoomPackage.eINSTANCE.getGuardedTransition_Guard(), gv, s2m, m2s, true);
+ Text cond = createText(body, "Guard:", trans, RoomPackage.eINSTANCE.getGuardedTransition_Guard(), gv, s2m_not_null, m2s_null_empty, true);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
cond.setLayoutData(gd);
+
+ createDecorator(cond, "empty guard");
}
if (trans instanceof CPBranchTransition) {