Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2015-07-28 14:30:06 -0400
committerJuergen Haug2015-07-30 08:36:59 -0400
commitf50f5625b15b390db451e2c3261ba25bcd8fe012 (patch)
treee3dfca4ab41c0afdf4b1244d7f4c311a4eec1b1b
parent783c894f584934f5e6f96c1f2281468d2c70bbc6 (diff)
downloadorg.eclipse.etrice-f50f5625b15b390db451e2c3261ba25bcd8fe012.tar.gz
org.eclipse.etrice-f50f5625b15b390db451e2c3261ba25bcd8fe012.tar.xz
org.eclipse.etrice-f50f5625b15b390db451e2c3261ba25bcd8fe012.zip
Bug 453716 - [ui.behavior] add context dependent behavior of action
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java4
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/.classpath1
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/.gitignore1
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/.project6
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/META-INF/MANIFEST.MF19
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/interfaceitem.gifbin856 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/member.gifbin856 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/method.gifbin856 -> 0 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/rt_method.pngbin0 -> 484 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/rt_method.svg132
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/GeneralActionCodeColorManager.java12
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/GeneralActionCodeScanner.java81
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditor.java8
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditorConfiguration.java40
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditorFactory.java56
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/AbstractActionCodeEditor.java32
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeAssistProcessor.java209
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeColorManager.java9
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeContext.java144
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeEditorConfiguration.java163
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeParser.java274
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeScanner.java132
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/CustomCompletionProposal.xtend32
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionAssistParser.xtend152
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionNamesScanner.java77
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionUIProvider.xtend170
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/SourceViewerActionCodeEditor.java42
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/text/TextActionCodeEditor.java17
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/text/TextActionCodeEditorFactory.java40
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/xtend-gen/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/CustomCompletionProposal.java66
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/xtend-gen/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionAssistParser.java238
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.actioneditor/xtend-gen/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionUIProvider.java379
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/.classpath1
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/.gitignore1
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/.project6
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/ActionCodeEditorRegistry.java9
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/IActionCodeEditor.java8
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/IActionCodeEditorFactory.java17
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/detailcode/IDetailExpressionProvider.xtend53
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/AbstractMemberAwarePropertyDialog.java12
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/detailcode/IDetailExpressionProvider.java81
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/.classpath1
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/.gitignore1
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/.project6
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/detailcode/DefaultDetailExpressionProvider.xtend95
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/detailcode/GuardDetailExpressionProvider.xtend113
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/detailcode/RuntimeDetailExpressionProvider.xtend51
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java5
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java17
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/xtend-gen/org/eclipse/etrice/ui/behavior/detailcode/DefaultDetailExpressionProvider.java264
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/xtend-gen/org/eclipse/etrice/ui/behavior/detailcode/GuardDetailExpressionProvider.java257
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/xtend-gen/org/eclipse/etrice/ui/behavior/detailcode/RuntimeDetailExpressionProvider.java71
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/drafts/DetailExpressionTest.room158
55 files changed, 2706 insertions, 1062 deletions
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
index b26327da9..f73c7ce3b 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/room/util/RoomHelpers.java
@@ -579,7 +579,7 @@ public class RoomHelpers extends FSMHelpers {
Map<String, StandardOperation> map = Maps.newHashMap();
ActorClass base = ac;
while(base != null){
- for(StandardOperation op : ac.getOperations())
+ for(StandardOperation op : base.getOperations())
if(!map.containsKey(op.getName()))
map.put(op.getName(), op);
base = base.getActorBase();
@@ -600,7 +600,7 @@ public class RoomHelpers extends FSMHelpers {
Map<String, StandardOperation> map = Maps.newHashMap();
DataClass base = dc;
while(base != null){
- for(StandardOperation op : dc.getOperations())
+ for(StandardOperation op : base.getOperations())
if(!map.containsKey(op.getName()))
map.put(op.getName(), op);
base = base.getBase();
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/.classpath b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/.classpath
index ad32c83a7..358df1bc1 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/.classpath
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/.classpath
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/.gitignore b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/.gitignore
index ba077a403..16847d1d4 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/.gitignore
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/.gitignore
@@ -1 +1,2 @@
bin
+*._trace \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/.project b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/.project
index 1275912ce..4f0ed160e 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/.project
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/.project
@@ -6,6 +6,11 @@
</projects>
<buildSpec>
<buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
@@ -24,5 +29,6 @@
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/META-INF/MANIFEST.MF
index 6d7733a76..084ab68f1 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/META-INF/MANIFEST.MF
@@ -4,17 +4,26 @@ Bundle-Name: ROOM Action Code Editor
Bundle-SymbolicName: org.eclipse.etrice.ui.behavior.actioneditor;singleton:=true
Bundle-Version: 0.5.0.qualifier
Bundle-Activator: org.eclipse.etrice.ui.behavior.actioneditor.Activator
-Require-Bundle: org.eclipse.ui,
+Require-Bundle: org.eclipse.etrice.core.fsm;bundle-version="0.5.0",
+ org.eclipse.etrice.core.room;bundle-version="0.5.0",
+ org.eclipse.etrice.ui.behavior;bundle-version="0.5.0",
+ org.eclipse.etrice.ui.behavior.fsm;bundle-version="0.5.0",
+ org.eclipse.ui,
org.eclipse.core.runtime,
- org.eclipse.etrice.core.room,
org.eclipse.emf.common,
- org.eclipse.etrice.core.fsm,
org.eclipse.jface.text,
org.eclipse.jdt.ui,
- org.eclipse.etrice.ui.behavior,
- org.eclipse.etrice.ui.behavior.fsm
+ org.eclipse.emf.ecore,
+ org.eclipse.xtext.util,
+ org.eclipse.xtend.lib,
+ org.eclipse.xtend.lib.macro,
+ com.google.guava,
+ org.eclipse.xtext.xbase.lib,
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.etrice.core.room.ui
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.etrice.ui.behavior.actioneditor,
org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer
Bundle-Vendor: eTrice (Incubation)
+
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/interfaceitem.gif b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/interfaceitem.gif
deleted file mode 100644
index 7db9810a0..000000000
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/interfaceitem.gif
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/member.gif b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/member.gif
deleted file mode 100644
index 7c87664cb..000000000
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/member.gif
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/method.gif b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/method.gif
deleted file mode 100644
index 3b0c73e84..000000000
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/method.gif
+++ /dev/null
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/rt_method.png b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/rt_method.png
new file mode 100644
index 000000000..6de31cfd2
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/rt_method.png
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/rt_method.svg b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/rt_method.svg
new file mode 100644
index 000000000..34aaf41bc
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/icons/rt_method.svg
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="rt_method.svg"
+ inkscape:export-filename="C:\Users\Juergen\Desktop\rt_method5.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <linearGradient
+ id="linearGradient10798-1-9-3-7-6-8-9-0-9-1">
+ <stop
+ style="stop-color:#75ba7a;stop-opacity:1;"
+ offset="0"
+ id="stop10800-5-2-1-8-20-6-4-9-8-2" />
+ <stop
+ id="stop10806-6-8-5-3-9-24-8-4-3-2"
+ offset="0.5"
+ style="stop-color:#418a4d;stop-opacity:1" />
+ <stop
+ style="stop-color:#a4c589;stop-opacity:1"
+ offset="1"
+ id="stop10802-1-5-3-0-4-8-4-2-9-2" />
+ </linearGradient>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="16"
+ inkscape:cx="10.700152"
+ inkscape:cy="19.117127"
+ inkscape:document-units="px"
+ inkscape:current-layer="g6438"
+ showgrid="true"
+ inkscape:window-width="1839"
+ inkscape:window-height="862"
+ inkscape:window-x="33"
+ inkscape:window-y="74"
+ inkscape:window-maximized="0"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:snap-global="false">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3949" />
+ <sodipodi:guide
+ position="13.183594,14.550781"
+ orientation="0,1"
+ id="guide4724" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ style="display:inline"
+ transform="translate(0,-1036.3622)">
+ <g
+ transform="matrix(0.27903303,0,0,0.27903303,-100.53208,912.07901)"
+ style="display:inline"
+ id="g11331-3-1-1">
+ <g
+ id="g13408-8"
+ style="fill:#737986;fill-opacity:1;stroke:#595e68;stroke-opacity:1" />
+ </g>
+ <g
+ transform="matrix(-1,0,0,1,16.12959,8.0140628)"
+ style="display:inline"
+ id="g6124-3">
+ <g
+ transform="scale(-1,1)"
+ style="font-size:13.58917427px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Sans"
+ id="text6430" />
+ <g
+ transform="scale(-1,1)"
+ style="font-size:13.58917427px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;display:inline;font-family:Sans"
+ id="g6438">
+ <ellipse
+ style="display:inline;fill:#989e99;fill-opacity:1;stroke:#5c5c5c;stroke-width:0.97602451;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path10796-2-6-2"
+ cx="-9.1460485"
+ cy="1037.255"
+ rx="3.5332656"
+ ry="3.5995569" />
+ <g
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:8.75px;line-height:125%;font-family:Verdana;-inkscape-font-specification:'Verdana, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="text4695">
+ <path
+ d="m -3.1425433,1030.6666 -2.174683,8e-4 0,3.8959 -0.8032227,0 0,-4.7723 2.3925781,0 0.5853272,0.01 z"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:8.75px;line-height:125%;font-family:Verdana;-inkscape-font-specification:'Verdana, Normal';text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1"
+ id="path4720"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccc" />
+ <path
+ d="m -0.10287046,1034.5829 -0.96984864,0 -1.4780273,-0.01 -0.013062,-3.9037 -0.5426025,0 0,-0.8663 0.5426025,0 0,-1.4575 0.8032227,0 0,1.4575 1.65771484,0 0,0.8663 -1.65771484,0 0.01709,3.1511 1.64062503,0.013 z"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:8.75px;line-height:125%;font-family:Verdana;-inkscape-font-specification:'Verdana, Normal';text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1"
+ id="path4722"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccccccccccc" />
+ </g>
+ </g>
+ </g>
+ </g>
+</svg>
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/GeneralActionCodeColorManager.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/GeneralActionCodeColorManager.java
index 929ed0f36..4466b0f1a 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/GeneralActionCodeColorManager.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/GeneralActionCodeColorManager.java
@@ -21,12 +21,12 @@ import org.eclipse.swt.graphics.RGB;
*
* @author jayant
*/
-public class GeneralActionCodeColorManager extends ActionCodeColorManager {
+public class GeneralActionCodeColorManager extends ActionCodeColorManager{
- public static final RGB MULTI_LINE_COMMENT = new RGB(128, 0, 0);
- public static final RGB SINGLE_LINE_COMMENT = new RGB(128, 0, 0);
- public static final RGB KEYWORD = new RGB(0, 0, 128);
- public static final RGB TYPE = new RGB(0, 0, 128);
- public static final RGB STRING = new RGB(0, 128, 0);
+ // Standard coloring eclipse
+ public static final RGB TARGET_KEYWORD = new RGB(127, 0, 85);
+ public static final RGB COMMENT = new RGB(63, 127, 95);
+ public static final RGB STRING = new RGB(42, 0, 255);
+ public static final RGB NUMBER = new RGB(125, 125, 125); // new RGB(0, 0, 0);
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/GeneralActionCodeScanner.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/GeneralActionCodeScanner.java
index cce4d6583..6faad58fd 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/GeneralActionCodeScanner.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/GeneralActionCodeScanner.java
@@ -15,27 +15,43 @@ package org.eclipse.etrice.ui.behavior.actioneditor.modelaware;
import java.util.List;
+import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.ActionCodeColorManager;
import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.ActionCodeEditorConfiguration;
-import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.ActionCodeScanner;
+import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.DetailExpressionNamesScanner;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.NumberRule;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.rules.WordRule;
import org.eclipse.swt.SWT;
+import com.google.common.collect.Lists;
+
/**
* Extends {@link ActionCodeScanner} with rules to identify general language
* features.
*
* @author jayant
*/
-public class GeneralActionCodeScanner extends ActionCodeScanner {
+public class GeneralActionCodeScanner extends DetailExpressionNamesScanner {
+ protected ActionCodeEditorConfiguration configuration;
+ private WordRule wordRule;
+
public GeneralActionCodeScanner(ActionCodeEditorConfiguration configuration) {
super(configuration);
+ this.configuration = configuration;
+
+ // form an instance of the WordRule
+ IToken defaultToken = new Token(new TextAttribute(configuration
+ .getColorManager().getColor(ActionCodeColorManager.DEFAULT)));
+ wordRule = formWordRule(defaultToken);
+
+ addRules(computeRules(configuration));
}
// general language keywords
@@ -46,38 +62,83 @@ public class GeneralActionCodeScanner extends ActionCodeScanner {
"public", "private", "protected", "sizeof",
"typedef", "virtual", "class", "using", "template", "volatile", "mutable", "friend", "inline",
"typeid", "typename", "namespace",
- "const", "int", "float", "double", "short", "long", "unsigned", "signed", "void"};
+ "const", "int", "float", "double", "short", "long", "unsigned", "signed", "void", "true", "false"};
/**
- * {@inheritDoc}
+ * Computes and returns a list({@code not null}) of rules for this scanner.
+ * <p>
+ * Sub-classes may override. To add new rules, append the list supplied by
+ * the superclass. To add new words to the default {@link WordRule}, the
+ * reference of the wordRule could be obtained with {@link #getWordRule()}
+ * method.
+ * </p>
+ *
+ * @param configuration
+ * the {@link ActionCodeEditorConfiguration} for this scanner
+ * @return the list of rules formed
*/
- @Override
protected List<IRule> computeRules(
ActionCodeEditorConfiguration configuration) {
- List<IRule> rules = super.computeRules(configuration);
+ List<IRule> rules = Lists.newArrayList();
IToken keywordToken = new Token(new TextAttribute(configuration
.getColorManager().getColor(
- GeneralActionCodeColorManager.KEYWORD), null, SWT.BOLD));
+ GeneralActionCodeColorManager.TARGET_KEYWORD), null, SWT.BOLD));
IToken stringToken = new Token(new TextAttribute(configuration
.getColorManager().getColor(
GeneralActionCodeColorManager.STRING)));
IToken commentToken = new Token(new TextAttribute(configuration
.getColorManager().getColor(
- GeneralActionCodeColorManager.SINGLE_LINE_COMMENT)));
+ GeneralActionCodeColorManager.COMMENT)));
+ IToken numberToken = new Token(new TextAttribute(configuration
+ .getColorManager().getColor(
+ GeneralActionCodeColorManager.NUMBER)));
// Add rule for single line comments.
rules.add(new EndOfLineRule("//", commentToken));
+ // TODO adjust Damager and Repairer for multi line support
+ //rules.add(new MultiLineRule("/*", "*/", commentToken));
+
// Add rule for strings.
rules.add(new SingleLineRule("\"", "\"", stringToken, '\\'));
rules.add(new SingleLineRule("'", "'", stringToken, '\\'));
+
+ rules.add(new NumberRule(numberToken));
// Add rule for language keywords.
- WordRule wordRule = getWordRule();
for (int i = 0; i < fgKeywords.length; i++)
wordRule.addWord(fgKeywords[i], keywordToken);
+ rules.add(wordRule);
return rules;
}
-} \ No newline at end of file
+
+ /**
+ * Forms the default {@link WordRule} given the defaultToken.
+ * <p>
+ * Subclasses may override to customize the formation of the default Word
+ * Rule.
+ * </p>
+ *
+ * @param defaultToken
+ * the default token to be associated with the word rule
+ * @return the constructed WordRule instance.
+ */
+ protected WordRule formWordRule(IToken defaultToken) {
+ WordRule wordRule = new WordRule(new IWordDetector() {
+
+ @Override
+ public boolean isWordStart(char c) {
+ return Character.isJavaIdentifierStart(c);
+ }
+
+ @Override
+ public boolean isWordPart(char c) {
+ return Character.isJavaIdentifierPart(c);
+ }
+ }, defaultToken);
+
+ return wordRule;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditor.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditor.java
index 49a0298bc..3abaa0ac0 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditor.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditor.java
@@ -13,9 +13,9 @@
package org.eclipse.etrice.ui.behavior.actioneditor.modelaware;
-import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.ActionCodeColorManager;
import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.SourceViewerActionCodeEditor;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
/**
* An extension of the {@link SourceViewerActionCodeEditor} which configures it
@@ -28,11 +28,9 @@ public class ModelAwareActionCodeEditor extends SourceViewerActionCodeEditor {
/** Color Manager for this editor's configuration */
private ActionCodeColorManager fColorManager;
- public ModelAwareActionCodeEditor(ActorClass ac, boolean useMembers,
- boolean useMessages, boolean useRecvMessagesOnly) {
+ public ModelAwareActionCodeEditor(IDetailExpressionProvider exprProvider) {
super();
fColorManager = new ActionCodeColorManager();
- setSourceViewerConfiguration(new ModelAwareActionCodeEditorConfiguration(
- fColorManager, ac, useMembers, useMessages, useRecvMessagesOnly));
+ setSourceViewerConfiguration(new ModelAwareActionCodeEditorConfiguration(fColorManager, exprProvider));
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditorConfiguration.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditorConfiguration.java
index 54862adf3..2abc64154 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditorConfiguration.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditorConfiguration.java
@@ -13,10 +13,10 @@
package org.eclipse.etrice.ui.behavior.actioneditor.modelaware;
-import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.ActionCodeAssistProcessor;
import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.ActionCodeColorManager;
import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.ActionCodeEditorConfiguration;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.contentassist.ContentAssistant;
@@ -35,30 +35,18 @@ import org.eclipse.jface.text.source.ISourceViewer;
*
* @author jayant
*/
-public class ModelAwareActionCodeEditorConfiguration extends
- ActionCodeEditorConfiguration {
-
- public ModelAwareActionCodeEditorConfiguration(
- ActionCodeColorManager colorManager) {
- super(colorManager);
- }
-
- public ModelAwareActionCodeEditorConfiguration(
- ActionCodeColorManager colorManager, ActorClass ac) {
- super(colorManager, ac);
- }
-
- public ModelAwareActionCodeEditorConfiguration(
- ActionCodeColorManager colorManager, ActorClass ac,
- boolean useMembers, boolean useMessages, boolean useRecvMessagesOnly) {
- super(colorManager, ac, useMembers, useMessages, useRecvMessagesOnly);
- }
+public class ModelAwareActionCodeEditorConfiguration extends ActionCodeEditorConfiguration {
/** token scanner for syntax highlighting */
private GeneralActionCodeScanner generalActionCodeScanner;
/** content assist processor for content assistance */
private ActionCodeAssistProcessor actionCodeAssistProcessor;
+ public ModelAwareActionCodeEditorConfiguration(ActionCodeColorManager colorManager,
+ IDetailExpressionProvider exprProvider) {
+ super(colorManager, exprProvider);
+ }
+
/**
* Constructs and returns an instance of the {@link ITokenScanner}. Same
* instance of the scanner is returned on subsequent invocations.
@@ -68,9 +56,8 @@ public class ModelAwareActionCodeEditorConfiguration extends
private GeneralActionCodeScanner getTokenScanner() {
if (generalActionCodeScanner == null) {
generalActionCodeScanner = new GeneralActionCodeScanner(this);
- generalActionCodeScanner.setDefaultReturnToken(new Token(
- new TextAttribute(getColorManager().getColor(
- ActionCodeColorManager.DEFAULT))));
+ generalActionCodeScanner.setDefaultReturnToken(new Token(new TextAttribute(getColorManager().getColor(
+ ActionCodeColorManager.DEFAULT))));
}
return generalActionCodeScanner;
}
@@ -94,12 +81,10 @@ public class ModelAwareActionCodeEditorConfiguration extends
* @author jayant
*/
@Override
- public IPresentationReconciler getPresentationReconciler(
- ISourceViewer sourceViewer) {
+ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconciler reconciler = new PresentationReconciler();
- DefaultDamagerRepairer dr = new DefaultDamagerRepairer(
- getTokenScanner());
+ DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getTokenScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
@@ -115,8 +100,7 @@ public class ModelAwareActionCodeEditorConfiguration extends
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant = new ContentAssistant();
- assistant.setContentAssistProcessor(getContextAssistProcessor(),
- IDocument.DEFAULT_CONTENT_TYPE);
+ assistant.setContentAssistProcessor(getContextAssistProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
assistant.setEmptyMessage("No Proposals.");
assistant.enableAutoActivation(true);
assistant.setAutoActivationDelay(500);
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditorFactory.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditorFactory.java
index 1d74f8104..4a28cfbe9 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditorFactory.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/modelaware/ModelAwareActionCodeEditorFactory.java
@@ -13,56 +13,44 @@
package org.eclipse.etrice.ui.behavior.actioneditor.modelaware;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.etrice.core.fsm.fSM.DetailCode;
-import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.ui.behavior.actioneditor.Activator;
+import java.util.List;
+
+import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.AbstractActionCodeEditor;
import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.SourceViewerActionCodeEditor;
import org.eclipse.etrice.ui.behavior.fsm.actioneditor.IActionCodeEditor;
import org.eclipse.etrice.ui.behavior.fsm.actioneditor.IActionCodeEditorFactory;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
import org.eclipse.swt.widgets.Composite;
+import com.google.common.collect.Lists;
+
/**
* Factory for creation of {@link ModelAwareActionCodeEditor}.
*
* @author jayant
*/
-public class ModelAwareActionCodeEditorFactory implements
- IActionCodeEditorFactory {
-
- @Override
- public IActionCodeEditor createActionCodeEditor(DetailCode detailCode,
- Composite parent, ModelComponent mc, boolean useMembers,
- boolean useMessages, boolean useRecvMessagesOnly) {
-
- SourceViewerActionCodeEditor javaActionCodeEditor = null;
+public class ModelAwareActionCodeEditorFactory implements IActionCodeEditorFactory {
- if (mc instanceof ActorClass) {
- javaActionCodeEditor = new ModelAwareActionCodeEditor(
- (ActorClass) mc, useMembers, useMessages,
- useRecvMessagesOnly);
- try {
- javaActionCodeEditor.init(detailCode);
- } catch (CoreException e) {
- Activator.getDefault().getLog().log(e.getStatus());
- }
- javaActionCodeEditor.createControl(parent);
- } else {
- Activator
- .getDefault()
- .getLog()
- .log(new Status(Status.ERROR, Activator.PLUGIN_ID,
- "Model Componenent " + mc.getComponentName()
- + " is not an instance of ActorClass"));
- }
+ List<AbstractActionCodeEditor> constructedEditors = Lists.newArrayList();
+ @Override
+ public IActionCodeEditor createActionCodeEditor(Composite parent, String detailCode,
+ IDetailExpressionProvider exprProvider) {
+ SourceViewerActionCodeEditor javaActionCodeEditor = new ModelAwareActionCodeEditor(exprProvider);
+ javaActionCodeEditor.init(detailCode);
+ javaActionCodeEditor.createControl(parent);
+
+ constructedEditors.add(javaActionCodeEditor);
+
return javaActionCodeEditor;
}
@Override
public void dispose() {
-
+ for (AbstractActionCodeEditor constructedEditor : constructedEditors) {
+ constructedEditor.dispose();
+ }
+ constructedEditors.clear();
}
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/AbstractActionCodeEditor.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/AbstractActionCodeEditor.java
index 10af70f5b..a09e35674 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/AbstractActionCodeEditor.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/AbstractActionCodeEditor.java
@@ -14,7 +14,6 @@
package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.etrice.core.fsm.fSM.DetailCode;
import org.eclipse.etrice.ui.behavior.fsm.actioneditor.IActionCodeEditor;
import org.eclipse.swt.widgets.Composite;
@@ -22,7 +21,7 @@ import org.eclipse.swt.widgets.Composite;
* Abstract implementation of the {@link IActionCodeEditor} interface. Clients
* need to implement the following methods:
* <ul>
- * <li> {@link #init(DetailCode)}</li>
+ * <li> {@link #init(String)}</li>
* <li> {@link #createControl(Composite)}</li>
* <li> {@link #getControl()}</li>
* <li> {@link #insertText(String)}</li>
@@ -35,12 +34,6 @@ import org.eclipse.swt.widgets.Composite;
*/
public abstract class AbstractActionCodeEditor implements IActionCodeEditor {
- protected DetailCode fDetailCode;
-
- public AbstractActionCodeEditor() {
- fDetailCode = null;
- }
-
/**
* Intializes the editor with the given {@link DetailCode} object. This
* method must be called before the {@link #createControl(Composite)} method
@@ -52,7 +45,7 @@ public abstract class AbstractActionCodeEditor implements IActionCodeEditor {
* if the editor cannot be initialized with the given
* {@code DetailCode} object
*/
- public abstract void init(DetailCode detailCode) throws CoreException;
+ public abstract void init(String detailCode);
/**
* Creates the controls of the editor within the {@code parent}
@@ -61,26 +54,11 @@ public abstract class AbstractActionCodeEditor implements IActionCodeEditor {
* @param parent
*/
public abstract void createControl(Composite parent);
-
+
/**
* Disposes all the resources allocate by the editor.
*/
- public void dispose() {
- fDetailCode = null;
- }
-
- @Override
- public DetailCode getDetailCode() {
- return fDetailCode;
- }
+ public abstract void dispose();
+
- /**
- * Sets the {@link DetailCode} object to be represented by the editor.
- *
- * @param detailCode
- * the DetailCode object being represented by the editor.
- */
- public void setDetailCode(DetailCode detailCode) {
- fDetailCode = detailCode;
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeAssistProcessor.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeAssistProcessor.java
index 6977b5ab6..6c7c74cad 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeAssistProcessor.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeAssistProcessor.java
@@ -14,19 +14,20 @@
package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.ui.behavior.actioneditor.Activator;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider.ExpressionFeature;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.xtext.util.Strings;
+import org.eclipse.xtext.xbase.lib.Pair;
/**
* An Action Editor specific content assist processor. The processor lexically
@@ -40,9 +41,12 @@ public class ActionCodeAssistProcessor implements IContentAssistProcessor {
/** the local reference of the associated configuration */
private ActionCodeEditorConfiguration fConfiguration;
+ private DetailExpressionUIProvider exprProvider;
+
public ActionCodeAssistProcessor(ActionCodeEditorConfiguration configuration) {
super();
fConfiguration = configuration;
+ exprProvider = fConfiguration.getDetailExpressionProvider();
}
/**
@@ -51,34 +55,71 @@ public class ActionCodeAssistProcessor implements IContentAssistProcessor {
* @author jayant
*/
@Override
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
- int offset) {
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
- if (fConfiguration != null) {
- ActionCodeContext context = createContext(viewer, offset);
- if (context.isMethodContext()) {
- proposals.addAll(collectMethodProposals(context));
- } else {
- if (fConfiguration.isMemberAware())
- proposals.addAll(collectMemberProposals(context));
+ // get last context feature + prefix
+ DetailExpressionAssistParser resolver = new DetailExpressionAssistParser(viewer.getDocument(), offset,
+ exprProvider);
+ ExpressionFeature contextFeature = resolver.resolveLatestCompleted();
+ String idPrefix = "";
+ try {
+ idPrefix = resolver.computeIdentifierPrefix(offset);
+ }
+ catch (BadLocationException e) {
+ }
- if (fConfiguration.isMessageAware())
- proposals.addAll(collectInterfaceItemProposals(context));
+ // cancel, if user expects proposals from context, but contextFeature
+ // could not be resolved
+ if (contextFeature == null && isExpressionSeparator(viewer, offset))
+ return new ICompletionProposal[0];
+
+ // create proposals
+ Iterable<ExpressionFeature> features = (contextFeature != null) ? exprProvider.getContextFeaturesWithPrefix(
+ contextFeature, idPrefix) : exprProvider.getInitialFeaturesWithPrefix(idPrefix);
+ for (ExpressionFeature feature : features) {
+ try {
+ proposals.add(createPrefixCompletionProposal(feature, offset, idPrefix));
+ }
+ catch (Exception e) {
}
}
return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
+ private boolean isExpressionSeparator(ITextViewer viewer, int offset) {
+ try {
+ return viewer.getDocument().getChar(offset - 1) == IDetailExpressionProvider.SEPARATOR;
+ }
+ catch (BadLocationException e) {
+ }
+ return false;
+ }
+
+ private ICompletionProposal createPrefixCompletionProposal(ExpressionFeature feature, int offset, String prefix) {
+ Pair<String, Point> completionPair = exprProvider.getCompletion(feature);
+ String completion = completionPair.getKey();
+ String displayString = exprProvider.getDisplayString(feature);
+ if (Strings.isEmpty(displayString))
+ displayString = completion;
+
+ ICompletionProposal proposal = new CompletionProposal(completion, offset - prefix.length(), prefix.length(),
+ completion.length(), exprProvider.getImage(feature), displayString, null, null);
+
+ Point selection = completionPair.getValue();
+ if (selection != null)
+ selection.x += (offset - prefix.length());
+ return new CustomCompletionProposal(proposal, selection);
+ }
+
/**
* {@inheritDoc}
*
* @author jayant
*/
@Override
- public IContextInformation[] computeContextInformation(ITextViewer viewer,
- int offset) {
+ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
return null;
}
@@ -89,7 +130,7 @@ public class ActionCodeAssistProcessor implements IContentAssistProcessor {
*/
@Override
public char[] getCompletionProposalAutoActivationCharacters() {
- return new char[] { ActionCodeContext.METHOD_ITEM_SEPARATOR };
+ return new char[] { IDetailExpressionProvider.SEPARATOR };
}
/**
@@ -122,134 +163,4 @@ public class ActionCodeAssistProcessor implements IContentAssistProcessor {
return null;
}
- /**
- * Create the {@link ActionCodeContext} object for the given invocation.
- *
- * @author jayant
- */
- protected ActionCodeContext createContext(ITextViewer viewer, int offset) {
- ActionCodeParser parser = null;
- if (fConfiguration != null)
- parser = fConfiguration.getActionCodeParser();
- return new ActionCodeContext(viewer, offset, parser);
- }
-
- /**
- * Collect the proposals for method completion. These would only be
- * generated if the Interface Item has been identified in the
- * {@code context} and is followed by
- * {@link ActionCodeContext#METHOD_ITEM_SEPARATOR}.
- *
- * @author jayant
- *
- * @param context
- * the {@link ActionCodeContext} object contain the context of
- * content assist invocation
- * @return the collection of proposals for method completion
- */
- private Collection<ICompletionProposal> collectMethodProposals(
- ActionCodeContext context) {
- Assert.isNotNull(fConfiguration);
-
- List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
- InterfaceItem interfaceItem = context.computeInterfaceItem();
- if (interfaceItem != null) {
- for (String item : fConfiguration.getActionCodeParser()
- .getInterfaceItemMethods(interfaceItem)) {
- ICompletionProposal proposal = createPrefixCompletionProposal(
- context, item, Activator.getImage("icons/method.gif"));
- if (proposal != null)
- proposals.add(proposal);
- }
- }
- return proposals;
- }
-
- /**
- * Collect the proposals for member name completion.
- *
- * @author jayant
- *
- * @param context
- * the {@link ActionCodeContext} object contain the context of
- * content assist invocation
- * @return the collection of proposals for member name completion
- */
- private Collection<ICompletionProposal> collectMemberProposals(
- ActionCodeContext context) {
- Assert.isNotNull(fConfiguration);
-
- List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
- for (String item : fConfiguration.getActionCodeParser().getAllAttributeNames()) {
- ICompletionProposal proposal = createPrefixCompletionProposal(
- context, item, Activator.getImage("icons/member.gif"));
- if (proposal != null)
- proposals.add(proposal);
- }
- for (String item : fConfiguration.getActionCodeParser().getAllOperationNames()) {
- ICompletionProposal proposal = createPrefixCompletionProposal(
- context, item, Activator.getImage("icons/method.gif"));
- if (proposal != null)
- proposals.add(proposal);
- }
- return proposals;
- }
-
- /**
- * Collect the proposals for Interface Item name completion.
- *
- * @author jayant
- *
- * @param context
- * the {@link ActionCodeContext} object contain the context of
- * content assist invocation
- * @return the collection of proposals for Interface Item name completion.
- */
- private Collection<ICompletionProposal> collectInterfaceItemProposals(
- ActionCodeContext context) {
- Assert.isNotNull(fConfiguration);
-
- List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
-
- for (String item : fConfiguration.getActionCodeParser()
- .getAllInterfaceItemNamesWithIndex()) {
- ICompletionProposal proposal = createPrefixCompletionProposal(
- context, item, Activator.getImage("icons/interfaceitem.gif"));
- if (proposal != null)
- proposals.add(proposal);
- }
- return proposals;
- }
-
- /**
- * Utility method for creating proposals given {@code context} and the
- * possible completion string. The proposal is generated only if the
- * character sequence to be completed is a prefix of the {@code completion}
- * string.
- *
- * @author jayant
- *
- * @param context
- * the {@link ActionCodeContext} object contain the context of
- * content assist invocation
- * @param completion
- * the completion string
- * @return completion proposal
- */
- private static ICompletionProposal createPrefixCompletionProposal(
- ActionCodeContext context, String completion, Image img) {
-
- String prefix = context.getPrefix();
- if (completion.startsWith(prefix))
- // replaces the incomplete prefix + selected range with the
- // completion string
- return new CompletionProposal(completion,
- context.getInvocationOffset() - prefix.length(),
- prefix.length() + context.getViewer().getSelectedRange().y,
- completion.length(),
- img,
- null, null, null);
-
- return null;
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeColorManager.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeColorManager.java
index e06f25d7c..b5ab30dce 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeColorManager.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeColorManager.java
@@ -33,13 +33,14 @@ import org.eclipse.swt.widgets.Display;
*/
public class ActionCodeColorManager {
- /** RGB object for member color */
- public static final RGB MEMBER = new RGB(128, 128, 0);
- /** RGB object for interface item color */
- public static final RGB INTERFACE_ITEM = new RGB(255, 128, 0);
/** Default RGB color object */
public static final RGB DEFAULT = new RGB(0, 0, 0);
+ public static final RGB SPECIAL_FEATURE = new RGB(171, 48, 0);
+ public static final RGB OPERATION = new RGB(184, 184, 0);
+ public static final RGB ATTRIBUTE = new RGB(105, 185, 0);
+ public static final RGB INTERFACE_ITEM = new RGB(200, 100, 0);
+
/** Local cache mapping {@link RGB} values with {@link Color} Objects */
protected Map<RGB, Color> fColorTable = new HashMap<RGB, Color>(10);
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeContext.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeContext.java
deleted file mode 100644
index 8831c1e38..000000000
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeContext.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Jayant Gupta
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Jayant Gupta (initial contribution)
- *
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer;
-
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-
-/**
- * A class for maintaining the current context during Content Assistance in
- * Action Code Editor. Helps in identifying the completion context (method or
- * InterafceItem/member) and also the {@link InterfaceItem} on which the assist
- * is invoked.
- *
- * @author jayant
- */
-public class ActionCodeContext extends ContentAssistInvocationContext {
-
- /** the character separating the method name and the interface item */
- public static final char METHOD_ITEM_SEPARATOR = '.';
-
- /** the associated interface item */
- private InterfaceItem fInterfaceItem;
- /** the action code parser object for getting the list of items */
- private ActionCodeParser fActionCodeParser;
- /** is method completion required or InterafceItem/member completion */
- private boolean methodContext;
-
- public ActionCodeContext(ActionCodeParser detailedCodeParser) {
- super();
- fInterfaceItem = null;
- methodContext = false;
- this.fActionCodeParser = detailedCodeParser;
- }
-
- public ActionCodeContext(IDocument document, int offset,
- ActionCodeParser detailedCodeParser) {
- super(document, offset);
- this.fActionCodeParser = detailedCodeParser;
- }
-
- public ActionCodeContext(ITextViewer viewer, int offset,
- ActionCodeParser detailedCodeParser) {
- super(viewer, offset);
- this.fActionCodeParser = detailedCodeParser;
- }
-
- public ActionCodeContext(ITextViewer viewer,
- ActionCodeParser detailedCodeParser) {
- super(viewer);
- this.fActionCodeParser = detailedCodeParser;
- }
-
- /**
- * Compute the {@link InterfaceItem} for the invocation offset.
- *
- * @return the associated interface item. Returns {@code null} is no
- * interface item associated with the invocation.
- */
- public InterfaceItem computeInterfaceItem() {
-
- if (fInterfaceItem == null) {
- if (fActionCodeParser == null)
- return null;
-
- int newOffset;
- try {
- // get the position of character just before the prefix to be
- // complete.
- newOffset = getInvocationOffset()
- - computeIdentifierPrefix().length() - 1;
-
- // if the character is method separator, then proceed with
- // identification of interafecItem.
- if (getDocument().getChar(newOffset) == METHOD_ITEM_SEPARATOR) {
- // method completion is required
- methodContext = true;
-
- // use context API to get the interface name.
- ContentAssistInvocationContext context = new ContentAssistInvocationContext(
- getViewer(), newOffset);
- fInterfaceItem = fActionCodeParser
- .getInterfaceItemfromName(context
- .computeIdentifierPrefix().toString());
- }
- } catch (BadLocationException e) {
- fInterfaceItem = null;
- }
- }
- return fInterfaceItem;
- }
-
- /**
- * Returns whether the required completion is for a method.
- *
- * @return true if the method completion is required
- */
- public boolean isMethodContext() {
- computeInterfaceItem();
- return methodContext;
- }
-
- /**
- * Gets the string of the invocation context which need to be completed.
- *
- * @return the string to be completed (prefix for completion)
- */
- public String getPrefix() {
- String prefix;
- try {
- prefix = computeIdentifierPrefix().toString();
- } catch (BadLocationException e) {
- prefix = "";
- }
- return prefix;
- }
-
- /**
- * {@inheritDoc}
- *
- * @author jayant
- */
- @Override
- public boolean equals(Object obj) {
- if (super.equals(obj) && obj instanceof ActionCodeContext) {
- ActionCodeContext other = (ActionCodeContext) obj;
- return fInterfaceItem.equals(other.fInterfaceItem);
- }
- return false;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeEditorConfiguration.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeEditorConfiguration.java
index 2f9f4fc27..8ac522a24 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeEditorConfiguration.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeEditorConfiguration.java
@@ -13,8 +13,12 @@
package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.core.runtime.Assert;
-import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.ui.RoomUiModule;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
@@ -27,95 +31,18 @@ import org.eclipse.jface.text.source.SourceViewerConfiguration;
*/
public class ActionCodeEditorConfiguration extends SourceViewerConfiguration {
- /** the actor class */
- private ActorClass fActorClass;
- /** use members */
- private boolean fMemberAware;
- /** use messages or operations */
- private boolean fMessageAware;
- /** use receive messages only */
- private boolean fRecvMessagesOnly;
- /** parser for Action Code of the associated actor class */
- private ActionCodeParser parser;
-
/** Color Manager for action code editor */
- private ActionCodeColorManager fColorManager;
-
- public ActionCodeEditorConfiguration(ActionCodeColorManager colorManager) {
- fColorManager = colorManager;
- fActorClass = null;
- fMemberAware = false;
- fMessageAware = false;
- fRecvMessagesOnly = false;
- }
+ private ActionCodeColorManager fColorManager = null;
- public ActionCodeEditorConfiguration(ActionCodeColorManager colorManager,
- ActorClass ac) {
- super();
- fActorClass = ac;
- fColorManager = colorManager;
- fMemberAware = true;
- fMessageAware = true;
- fRecvMessagesOnly = false;
- }
+ private DetailExpressionUIProvider exprProvider;
- public ActionCodeEditorConfiguration(ActionCodeColorManager colorManager,
- ActorClass ac, boolean useMembers, boolean useMessages,
- boolean useRecvMessagesOnly) {
- super();
- fActorClass = ac;
+ public ActionCodeEditorConfiguration(ActionCodeColorManager colorManager, IDetailExpressionProvider exprProvider) {
fColorManager = colorManager;
- fMemberAware = useMembers;
- fMessageAware = useMessages;
- fRecvMessagesOnly = useRecvMessagesOnly;
- }
-
- /**
- * Getter for actor class.
- *
- * @return the associated actor class
- */
- public ActorClass getActorClass() {
- return fActorClass;
- }
-
- /**
- * Getter for use members.
- *
- * @return true if configuration is member aware else false
- */
- public boolean isMemberAware() {
- return fMemberAware;
- }
-
- /**
- * Getter for use messages.
- *
- * @return true if configuration is message aware else false
- */
- public boolean isMessageAware() {
- return fMessageAware;
- }
- /**
- * Getter for use receive only messages.
- *
- * @return true if configuration handles only receive only messages else
- * false
- */
- public boolean isRecvOnly() {
- return fRecvMessagesOnly;
- }
-
- /**
- * Getter for internal action code parser for the associated actor class.
- *
- * @return the parser for action code of the associated actor class
- */
- public ActionCodeParser getActionCodeParser() {
- if (parser == null)
- parser = new ActionCodeParser(fActorClass, fRecvMessagesOnly);
- return parser;
+ if (exprProvider == null)
+ exprProvider = new EmptyDetailExpressionProvider();
+ this.exprProvider = new DetailExpressionUIProvider(exprProvider);
+ RoomUiModule.getInjector().injectMembers(this.exprProvider);
}
/**
@@ -130,63 +57,33 @@ public class ActionCodeEditorConfiguration extends SourceViewerConfiguration {
}
/**
- * Setter for actor class. Invalidates the internal action code parser.
+ * Setter for action code Color Manager.
*
- * @param ac
- * the Actor Class to associate to.
+ * @param colorManager
+ * the color manager to use
*/
- public void setActorClass(ActorClass ac) {
- if (!ac.equals(fActorClass)) {
- fActorClass = ac;
- parser = null;
- }
+ public void setColorManager(ActionCodeColorManager colorManager) {
+ Assert.isNotNull(colorManager);
+ fColorManager = colorManager;
}
- /**
- * Setter for use members.
- *
- * @param useMembers
- * true to make configuration member aware
- */
- public void setMemberAware(boolean useMembers) {
- fMemberAware = useMembers;
+ public DetailExpressionUIProvider getDetailExpressionProvider() {
+ return exprProvider;
}
- /**
- * Setter for use messages.
- *
- * @param useMessages
- * true to make configuration message & operation aware
- */
- public void setMessageAware(boolean useMessages) {
- fMessageAware = useMessages;
- }
+ class EmptyDetailExpressionProvider implements IDetailExpressionProvider {
- /**
- * Setter for use receive messages only. Invalidates the internal action
- * code parser.
- *
- * @param useRecvMessagesOnly
- * true to use receive messages only
- */
- public void setRecvOnly(boolean useRecvMessagesOnly) {
- if (useRecvMessagesOnly != fRecvMessagesOnly) {
- fRecvMessagesOnly = useRecvMessagesOnly;
+ final List<ExpressionFeature> EMPTY_LIST = new ArrayList<ExpressionFeature>();
- // Only invalidate parser if the configuration is message aware.
- if (fMessageAware)
- parser = null;
+ @Override
+ public List<ExpressionFeature> getInitialFeatures() {
+ return EMPTY_LIST;
+ }
+
+ @Override
+ public List<ExpressionFeature> getContextFeatures(ExpressionFeature ctx) {
+ return EMPTY_LIST;
}
- }
- /**
- * Setter for action code Color Manager.
- *
- * @param colorManager
- * the color manager to use
- */
- public void setColorManager(ActionCodeColorManager colorManager) {
- Assert.isNotNull(colorManager);
- fColorManager = colorManager;
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeParser.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeParser.java
deleted file mode 100644
index fd58311ce..000000000
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeParser.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Jayant Gupta
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Jayant Gupta (initial contribution)
- *
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.CommunicationType;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.Operation;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.PortClass;
-import org.eclipse.etrice.core.room.PortOperation;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.ui.behavior.support.SupportUtil;
-
-/**
- * A parser for action code of an actor class. Internally constructs a
- * collection of all member objects and a collection for all available and
- * {@code InterfaceItems} mapped to the possible messages or operations.
- *
- * @author jayant
- */
-public class ActionCodeParser {
-
- /** the actor class */
- private ActorClass ac;
- /** use receive only messages */
- private boolean recvOnly;
- /** map for interface items and associated messages or operations */
- private HashMap<InterfaceItem, List<MethodItemPair>> item2pairs;
- public ActionCodeParser(ActorClass ac, boolean recvOnly) {
- this.ac = ac;
- this.recvOnly = recvOnly;
- }
-
- /**
- * Class for representing a pair of Interface Item and an associated method.
- *
- * @author jayant
- */
- public static class MethodItemPair {
- InterfaceItem item;
-
- public MethodItemPair(InterfaceItem item) {
- super();
- this.item = item;
- }
- }
-
- /**
- * Class for representing a pair of Interface Item and an associated
- * message.
- *
- * @author jayant
- */
- public static class MsgItemPair extends MethodItemPair {
- Message msg;
- boolean out;
-
- public MsgItemPair(InterfaceItem item, Message msg, boolean out) {
- super(item);
- this.msg = msg;
- this.out = out;
- }
- }
-
- /**
- * Class for representing a pair of Interface Item and an associated
- * operation.
- *
- * @author jayant
- */
- public static class OperationItemPair extends MethodItemPair {
- PortOperation op;
-
- public OperationItemPair(InterfaceItem item, PortOperation op) {
- super(item);
- this.op = op;
- }
- }
-
- /**
- * Constructs the map of Interface Items and the list of associated methods
- * in the associated actor class.
- *
- * @return a HashMap of {@link InterfaceItem}s mapped to an List of
- * {@link MethodItemPair}
- */
- public HashMap<InterfaceItem, List<MethodItemPair>> getInterfaceItemMethodMap() {
-
- if (item2pairs == null) {
- item2pairs = new HashMap<InterfaceItem, List<MethodItemPair>>();
-
- RoomHelpers roomHelpers = SupportUtil.getInstance()
- .getRoomHelpers();
- List<InterfaceItem> items = roomHelpers.getAllInterfaceItems(ac);
- for (InterfaceItem item : items) {
- ArrayList<MethodItemPair> pairs = new ArrayList<MethodItemPair>();
- List<Message> out = roomHelpers.getMessageListDeep(item, true);
- if (!recvOnly) {
- for (Message msg : out) {
- if (!msg.isPriv())
- pairs.add(new MsgItemPair(item, msg, true));
- }
- }
- if (roomHelpers.getProtocol(item).getCommType() == CommunicationType.DATA_DRIVEN) {
- List<Message> in = roomHelpers.getMessageListDeep(item,
- false);
- for (Message msg : in) {
- if (!msg.isPriv())
- pairs.add(new MsgItemPair(item, msg, false));
- }
- }
- PortClass pcls = roomHelpers.getPortClass(item);
- if (pcls != null) {
- for (PortOperation op : pcls.getOperations()) {
- if (op.getSendsMsg() != null)
- pairs.add(new OperationItemPair(item, op));
- }
- for (PortOperation op : pcls.getOperations()) {
- if (op.getSendsMsg() == null)
- pairs.add(new OperationItemPair(item, op));
- }
- }
- item2pairs.put(item, pairs);
- }
- }
- return item2pairs;
- }
-
- /**
- * Gets the list of the names of all {@link InterfaceItem} in the associated
- * actor class.
- *
- * @return list of names of all Interface Items.
- */
- public List<String> getAllInterfaceItemNames() {
- List<String> interfaceItemList = new ArrayList<String>();
- for (InterfaceItem interfaceItem : getInterfaceItemMethodMap().keySet()) {
- interfaceItemList.add(interfaceItem.getName());
- }
- return interfaceItemList;
- }
-
- /**
- * Gets the list of the names of all {@link InterfaceItem} in the associated
- * actor class with index, i.e. the name includes an [index] bracket if an
- * interface item is a {@link Port} and has a multiplicity greater than 1.
- *
- * @return list of names of all Interface Items along with index, if
- * required
- */
- public List<String> getAllInterfaceItemNamesWithIndex() {
- List<String> interfaceItemList = new ArrayList<String>();
- for (InterfaceItem interfaceItem : getInterfaceItemMethodMap().keySet()) {
- String index = "";
- if (interfaceItem instanceof Port
- && ((Port) interfaceItem).getMultiplicity() != 1)
- index = "[idx]";
- interfaceItemList.add(interfaceItem.getName() + index);
- }
- return interfaceItemList;
- }
-
- /**
- * Gets a list of the name of all attributes in the associated actor class.
- *
- * @return list of attribute names
- */
- public List<String> getAllAttributeNames() {
- RoomHelpers roomHelpers = SupportUtil.getInstance().getRoomHelpers();
- List<String> result = new ArrayList<String>();
- for (Attribute att : roomHelpers.getAllAttributes(ac)) {
- result.add(att.getName());
- }
- return result;
- }
-
- /**
- * returns a list of all (including inherited) operation names including signature
- *
- * @return list of all operation names (including signature)
- */
- public List<String> getAllOperationNames() {
- RoomHelpers roomHelpers = SupportUtil.getInstance().getRoomHelpers();
- List<String> result = new ArrayList<String>();
- for (Operation op : roomHelpers.getAllOperations(ac)) {
- result.add(op.getName()
- + SupportUtil.getInstance().getRoomNameProvider()
- .getTypedArgumentList(op));
- }
-
- return result;
- }
-
- /**
- * Find the interface item with the given name.
- *
- * @param itemName
- * the name of the interface item
- * @return the {@link InterfaceItem} object with the given name. Returns
- * {@code null} if no such Interface Item.
- */
- public InterfaceItem getInterfaceItemfromName(String itemName) {
- for (InterfaceItem interfaceItem : item2pairs.keySet()) {
- if (interfaceItem.getName().equals(itemName))
- return interfaceItem;
- }
- return null;
- }
-
- /**
- * Gets the list of method names(messages & operations) along with the
- * arguments(data) for the given {@link InterfaceItem}.
- *
- * @param interfaceItem
- * the interface item
- * @return the list of methods
- */
- public List<String> getInterfaceItemMethods(InterfaceItem interfaceItem) {
- List<String> methodList = new ArrayList<String>();
- for (MethodItemPair method : item2pairs.get(interfaceItem)) {
- if (method != null) {
- String methodString = null;
- if (method instanceof MsgItemPair) {
- MsgItemPair pair = (MsgItemPair) method;
- if (pair.out) {
- String data = pair.msg.getData() != null ? pair.msg
- .getData().getName() : "";
- methodString = pair.msg.getName() + "(" + data + ")";
- } else
- methodString = pair.msg.getName();
- } else if (method instanceof OperationItemPair) {
- OperationItemPair pair = (OperationItemPair) method;
- String arglist = SupportUtil.getInstance()
- .getRoomNameProvider().getArguments(pair.op);
- methodString = pair.op.getName() + arglist;
- }
- if (methodString != null)
- methodList.add(methodString);
- }
- }
- return methodList;
- }
-
- /**
- * Gets the list of method names(messages & operations) along with the
- * arguments(data) for the given {@link InterfaceItem} name. Returns an
- * empty list if no interface item with given name.
- *
- * @param interfaceItem
- * the interface item name
- * @return the list of methods
- */
- public List<String> getInterfaceItemMethods(String interfaceItemName) {
- return getInterfaceItemMethods(getInterfaceItemfromName(interfaceItemName));
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeScanner.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeScanner.java
deleted file mode 100644
index c22f0a1f0..000000000
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/ActionCodeScanner.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Jayant Gupta
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Jayant Gupta (initial contribution)
- *
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.rules.IRule;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.IWordDetector;
-import org.eclipse.jface.text.rules.RuleBasedScanner;
-import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.rules.WordRule;
-import org.eclipse.swt.SWT;
-
-/**
- * A extension of the {@link RuleBasedScanner} for
- * {@link ActionCodeEditorConfiguration}. Sets up rules for identifying and
- * associating tokens with Members and InterfaceItems.
- * <p>
- * Sub-classes may override {@link #computeRules(ActionCodeEditorConfiguration)}
- * to supply new rules or add to the given rules.
- * </p>
- *
- * @author jayant
- *
- */
-public class ActionCodeScanner extends RuleBasedScanner {
-
- /** the default word rule for the scanner */
- WordRule wordRule;
-
- public ActionCodeScanner(ActionCodeEditorConfiguration configuration) {
- // form an instance of the WordRule
- IToken defaultToken = new Token(new TextAttribute(configuration
- .getColorManager().getColor(ActionCodeColorManager.DEFAULT)));
- wordRule = formWordRule(defaultToken);
-
- List<IRule> rules = computeRules(configuration);
- setRules(rules.toArray(new IRule[rules.size()]));
- }
-
- /**
- * Computes and returns a list({@code not null}) of rules for this scanner.
- * <p>
- * Sub-classes may override. To add new rules, append the list supplied by
- * the superclass. To add new words to the default {@link WordRule}, the
- * reference of the wordRule could be obtained with {@link #getWordRule()}
- * method.
- * </p>
- *
- * @param configuration
- * the {@link ActionCodeEditorConfiguration} for this scanner
- * @return the list of rules formed
- */
- protected List<IRule> computeRules(
- ActionCodeEditorConfiguration configuration) {
- IToken memberToken = new Token(new TextAttribute(configuration
- .getColorManager().getColor(ActionCodeColorManager.MEMBER)));
- IToken interfaceItemToken = new Token(new TextAttribute(configuration
- .getColorManager().getColor(
- ActionCodeColorManager.INTERFACE_ITEM), null, SWT.BOLD));
-
- List<IRule> rules = new ArrayList<IRule>();
-
- // Add words to wordRule for each Interface Item names.
- if (configuration.isMessageAware())
- for (String item : configuration.getActionCodeParser()
- .getAllInterfaceItemNames())
- wordRule.addWord(item, interfaceItemToken);
-
- // Add word to wordRule rule for each Member names.
- if (configuration.isMemberAware())
- for (String member : configuration.getActionCodeParser()
- .getAllAttributeNames())
- wordRule.addWord(member, memberToken);
-
- // Add wordRule to the list of rules.
- rules.add(wordRule);
-
- return rules;
- }
-
- /**
- * Forms the default {@link WordRule} given the defaultToken.
- * <p>
- * Subclasses may override to customize the formation of the default Word
- * Rule.
- * </p>
- *
- * @param defaultToken
- * the default token to be associated with the word rule
- * @return the constructed WordRule instance.
- */
- protected WordRule formWordRule(IToken defaultToken) {
- WordRule wordRule = new WordRule(new IWordDetector() {
-
- @Override
- public boolean isWordStart(char c) {
- return Character.isJavaIdentifierStart(c);
- }
-
- @Override
- public boolean isWordPart(char c) {
- return Character.isJavaIdentifierPart(c);
- }
- }, defaultToken);
-
- return wordRule;
- }
-
- /**
- * Get the default {@link WordRule}.
- *
- * @return the default word rule.
- */
- public WordRule getWordRule() {
- return wordRule;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/CustomCompletionProposal.xtend b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/CustomCompletionProposal.xtend
new file mode 100644
index 000000000..de92a5b09
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/CustomCompletionProposal.xtend
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer
+
+import org.eclipse.jface.text.IDocument
+import org.eclipse.jface.text.contentassist.ICompletionProposal
+import org.eclipse.swt.graphics.Point
+import org.eclipse.xtend.lib.annotations.Delegate
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
+
+// Default implementation CompletionProposal is final, thus use as delegate
+@FinalFieldsConstructor
+class CustomCompletionProposal implements ICompletionProposal {
+
+ @Delegate
+ val ICompletionProposal delegate
+ val Point selection
+
+ override Point getSelection(IDocument document){
+ if(selection != null) selection else delegate.getSelection(document)
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionAssistParser.xtend b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionAssistParser.xtend
new file mode 100644
index 000000000..dd0367f51
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionAssistParser.xtend
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer
+
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider.ExpressionFeature
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider.ExpressionPostfix
+import org.eclipse.jface.text.BadLocationException
+import org.eclipse.jface.text.IDocument
+import org.eclipse.jface.text.rules.IWordDetector
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
+import org.eclipse.xtext.util.Strings
+
+@FinalFieldsConstructor
+class DetailExpressionAssistParser {
+
+ val IDocument document
+ val int invocationOffset
+ val IDetailExpressionProvider provider
+
+ val IWordDetector anyIdScanner = new IWordDetector() {
+
+ override isWordPart(char c) {
+ Character.isJavaIdentifierPart(c)
+ }
+
+ override isWordStart(char c) {
+ Character.isJavaIdentifierStart(c)
+ }
+
+ }
+
+ def String computeIdentifierPrefix(int offset) throws BadLocationException {
+ var start = offset - 1
+ while (start >= 0 && anyIdScanner.isWordPart(document.getChar(start)))
+ start--
+
+ start++
+ return document.get(start, offset - start)
+ }
+
+ def ExpressionFeature computeExpressionFeature(int offset) throws BadLocationException{
+ var ExpressionPostfix postfixResult
+ var char openingChar
+ var char closingChar
+ switch document.getChar(offset-1).toString {
+ case ')': {
+ postfixResult = ExpressionPostfix.PARENTHESES
+ openingChar = '('
+ closingChar = ')'
+ }
+ case ']': {
+ postfixResult = ExpressionPostfix.BRACKETS
+ openingChar = '['
+ closingChar = ']'
+ }
+ default:
+ postfixResult = ExpressionPostfix.NONE
+ }
+
+ var start = offset
+ if (postfixResult != ExpressionPostfix.NONE) {
+ start--
+ var counter = 1
+ while (start > 0 && counter > 0) {
+ start--
+ switch document.getChar(start) {
+ case openingChar: counter--
+ case closingChar: counter++
+ }
+ }
+ if (counter > 0)
+ postfixResult = null
+ }
+
+ var String idResult
+ try {
+ idResult = computeIdentifierPrefix(start)
+ } catch (BadLocationException e) {
+ }
+
+ return new ExpressionFeature(idResult, postfixResult)
+ }
+
+ /**
+ * Try to resolve latest complete ExpressionFeature, e.g.:
+ * <ul>
+ * <li>port0.m_ => port0</li>
+ * <li> port0. => port0 </li>
+ * <li>port0 => null</li>
+ * </ul>
+ */
+ def ExpressionFeature resolveLatestCompleted() {
+ var lastSeparatorPos = invocationOffset - 1
+
+ // skip invocationPrefix
+ try {
+ val invocationPrefix = computeIdentifierPrefix(invocationOffset)
+ lastSeparatorPos -= invocationPrefix.length
+ } catch (BadLocationException e) {
+ }
+
+ // backward parsing
+ val parsedFeatures = newLinkedList
+ try {
+ while (document.getChar(lastSeparatorPos) == IDetailExpressionProvider.SEPARATOR) {
+ val parseResult = computeExpressionFeature(lastSeparatorPos)
+ if (!parseResult.isValid)
+ return null
+ parsedFeatures.push(parseResult)
+ lastSeparatorPos -= (parseResult.id.length() + 1)
+
+ }
+ } catch (BadLocationException e) {
+ }
+
+ if (parsedFeatures.empty)
+ return null
+
+ // forward matching
+ val firstParseResult = parsedFeatures.pop
+ var lastMatch = provider.initialFeatures.findFirst[matches(firstParseResult)]
+ while (lastMatch != null && !parsedFeatures.isEmpty()) {
+ val nextParseResult = parsedFeatures.pop
+ lastMatch = provider.getContextFeatures(lastMatch).findFirst[matches(nextParseResult)]
+ }
+
+ return lastMatch
+ }
+
+ /**
+ * non-empty id + not-null suffix
+ */
+ private def boolean isValid(ExpressionFeature feature) {
+ !Strings.isEmpty(feature.id) && feature.postfix != null
+ }
+
+ private def boolean matches(ExpressionFeature f1, ExpressionFeature f2) {
+ f1.id == f2.id && f1.postfix == f2.postfix
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionNamesScanner.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionNamesScanner.java
new file mode 100644
index 000000000..a16731d81
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionNamesScanner.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider.ExpressionFeature;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.rules.WordRule;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class DetailExpressionNamesScanner extends RuleBasedScanner {
+
+ // terminal ID: '^'?('a'..'z'|'A'..'Z'|'_')
+ // ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
+ public static IWordDetector getIDWordDetector() {
+ return new IWordDetector() {
+
+ @Override
+ public boolean isWordStart(char c) {
+ return Character.isLowerCase(c) || Character.isUpperCase(c) || c == '_';
+ }
+
+ @Override
+ public boolean isWordPart(char c) {
+ return isWordStart(c) || Character.isDigit(c);
+ }
+ };
+ }
+
+ private final WordRule wordRule;
+
+ public DetailExpressionNamesScanner(ActionCodeEditorConfiguration configuration) {
+ wordRule = new WordRule(getIDWordDetector());
+
+ DetailExpressionUIProvider detailExprProv = configuration.getDetailExpressionProvider();
+ ActionCodeColorManager colorMngr = configuration.getColorManager();
+ Map<TextAttribute, TextAttribute> textAttributes = Maps.newHashMap();
+ for(ExpressionFeature feature : detailExprProv.getInitialFeatures()){
+ TextAttribute attr = new TextAttribute(colorMngr.getColor(detailExprProv.getColor(feature)));
+ if(!textAttributes.containsKey(attr))
+ textAttributes.put(attr, attr);
+ IToken token = new Token(textAttributes.get(attr));
+ wordRule.addWord(feature.getId(), token);
+ }
+ addRules(Lists.newArrayList((IRule)wordRule));
+ }
+
+
+ protected void addRules(List<IRule> rules){
+ List<IRule> newRules = Lists.newArrayList();
+ if(fRules != null)
+ newRules.addAll(Arrays.asList(fRules));
+ newRules.addAll(rules);
+ setRules(newRules.toArray(new IRule[0]));
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionUIProvider.xtend b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionUIProvider.xtend
new file mode 100644
index 000000000..0d4a91df8
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionUIProvider.xtend
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer
+
+import com.google.common.base.Strings
+import com.google.inject.Inject
+import org.eclipse.core.runtime.Assert
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.etrice.core.room.Attribute
+import org.eclipse.etrice.core.room.InterfaceItem
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.Operation
+import org.eclipse.etrice.core.room.Port
+import org.eclipse.etrice.core.room.SPP
+import org.eclipse.etrice.core.room.util.RoomHelpers
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider
+import org.eclipse.jface.viewers.ILabelProvider
+import org.eclipse.swt.graphics.Image
+import org.eclipse.swt.graphics.Point
+import org.eclipse.swt.graphics.RGB
+import org.eclipse.xtend.lib.annotations.Delegate
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
+import org.eclipse.etrice.ui.behavior.detailcode.RuntimeDetailExpressionProvider.RuntimeMethodExpressionData
+import org.eclipse.etrice.ui.behavior.actioneditor.Activator
+
+@FinalFieldsConstructor
+class DetailExpressionUIProvider implements IDetailExpressionProvider {
+
+ static val String IMAGE_RT_METHOD = "icons/rt_method.png"
+
+ @Delegate
+ val IDetailExpressionProvider delegate
+
+ @Inject
+ protected ILabelProvider labelProvider
+
+ @Inject
+ protected RoomHelpers roomHelpers
+
+ /**
+ * Return postfix string and its selection (relative start, length)
+ */
+ def Pair<String, Point> getPostfixReplacement(ExpressionFeature feature) {
+ feature.assertNotNull
+
+ var String[] brackets = switch feature.postfix {
+ case PARENTHESES: #['(', ')']
+ case BRACKETS: #['[', ']']
+ default: return "" -> null
+ }
+ var String replacement = switch data : feature.data {
+ Operation:
+ data.arguments.map[name].join(', ')
+ Message case data.data != null:
+ data.data.name
+ Attribute, // fall through
+ InterfaceItem:
+ '0'
+ default:
+ ''
+ }
+
+ val selection = if(!replacement.empty) new Point(1, replacement.length)
+ brackets.head + replacement + brackets.last -> selection
+ }
+
+ /**
+ * Return completion string and its selection (relative start, length)
+ */
+ def Pair<String, Point> getCompletion(ExpressionFeature feature) {
+ feature.assertNotNull
+
+ var postfix = getPostfixReplacement(feature)
+ var point = postfix.value
+ if (point != null)
+ point.x += feature.id.length
+
+ return feature.id + postfix.key -> point
+ }
+
+ def RGB getColor(ExpressionFeature feature) {
+ feature.assertNotNull
+
+ return switch data : feature.data {
+ InterfaceItem: ActionCodeColorManager.INTERFACE_ITEM
+ Attribute: ActionCodeColorManager.ATTRIBUTE
+ Operation: ActionCodeColorManager.OPERATION
+ EObject: ActionCodeColorManager.SPECIAL_FEATURE
+ }
+ }
+
+ /**
+ * Text format:
+ * {@code completionInfo : typedInfo - classInfo}
+ */
+ def String getDisplayString(ExpressionFeature feature) {
+ feature.assertNotNull
+
+ val data = feature.data
+
+ var completionInfo = feature.id + feature.getPostfixReplacement.key
+ var typedInfo = ""
+ var classInfo = if(data instanceof EObject) data.eClass.name else ""
+ switch data {
+ Attribute:
+ typedInfo = data.type.type.name
+ InterfaceItem:
+ typedInfo = roomHelpers.getProtocol(data).name
+ RuntimeMethodExpressionData:
+ typedInfo = 'int'
+ default: {
+ val label = labelProvider.getText(data)
+ // if label starts with completion then label might be better
+ if(!Strings.commonPrefix(label, completionInfo).empty) completionInfo = label
+ }
+ }
+ // mark port as broadcast
+ if (feature.postfix == ExpressionPostfix.NONE) {
+ switch data {
+ SPP case data.isEventDriven/* fall through */,
+ Port case data.multiplicity > 1 && data.isEventDriven:
+ completionInfo = completionInfo + " (broadcast)"
+ }
+ }
+
+ if(!typedInfo.empty) typedInfo = " : " + typedInfo
+ if(!classInfo.empty) classInfo = " - " + classInfo
+
+ return completionInfo + typedInfo + classInfo
+ }
+
+ def Image getImage(ExpressionFeature feature) {
+ feature.assertNotNull
+
+ switch feature.data {
+ EObject : labelProvider.getImage(feature.data)
+ RuntimeMethodExpressionData: Activator.getImage(IMAGE_RT_METHOD)
+ }
+ }
+
+ /**
+ * Filter by prefix
+ */
+ def getContextFeaturesWithPrefix(ExpressionFeature ctx, String prefix) {
+ delegate.getContextFeatures(ctx).filter[id.startsWith(prefix)]
+ }
+
+ /**
+ * Filter by prefix
+ */
+ def getInitialFeaturesWithPrefix(String prefix) {
+ delegate.initialFeatures.filter[id.startsWith(prefix)]
+ }
+
+ def protected assertNotNull(ExpressionFeature feature) {
+ Assert.isTrue(!Strings.isNullOrEmpty(feature.id))
+ Assert.isNotNull(feature.postfix)
+ Assert.isNotNull(feature.data)
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/SourceViewerActionCodeEditor.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/SourceViewerActionCodeEditor.java
index c4acfd948..a21364ca0 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/SourceViewerActionCodeEditor.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/SourceViewerActionCodeEditor.java
@@ -22,10 +22,8 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.etrice.core.fsm.fSM.DetailCode;
-import org.eclipse.etrice.ui.behavior.actioneditor.Activator;
import org.eclipse.etrice.ui.behavior.fsm.actioneditor.IActionCodeEditor;
-import org.eclipse.etrice.ui.behavior.support.SupportUtil;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
@@ -167,11 +165,8 @@ public class SourceViewerActionCodeEditor extends AbstractActionCodeEditor {
* the {@link DetailCode} object to be represented.
* @return the document being created.
*/
- protected IDocument createDocument(DetailCode detailCode)
- throws CoreException {
- IDocument document = new Document();
- document.set(SupportUtil.getInstance().getRoomHelpers()
- .getDetailCode(detailCode));
+ protected IDocument createDocument(String detailCode) {
+ IDocument document = new Document(detailCode);
return document;
};
@@ -210,7 +205,7 @@ public class SourceViewerActionCodeEditor extends AbstractActionCodeEditor {
* </p>
*/
@Override
- public void init(DetailCode detailCode) throws CoreException {
+ public void init(String detailCode) {
doSetDetailCode(detailCode);
}
@@ -228,6 +223,9 @@ public class SourceViewerActionCodeEditor extends AbstractActionCodeEditor {
fSourceViewer.configure(fConfiguration);
StyledText styledText = fSourceViewer.getTextWidget();
+
+ // set font to global default for editors
+ styledText.setFont(JFaceResources.getTextFont());
// Focus listener to activate and deactivate context
styledText.addFocusListener(new FocusListener() {
@@ -268,23 +266,15 @@ public class SourceViewerActionCodeEditor extends AbstractActionCodeEditor {
fSourceViewer.getTextWidget().notifyListeners(SWT.Modify, null);
}
});
-
- initializeSourceViewer(getDetailCode());
getControl()
.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ initializeSourceViewer();
}
- /**
- * {@inheritDoc}
- */
- @Override
- public void setDetailCode(DetailCode detailCode) {
- try {
- doSetDetailCode(detailCode);
- } catch (CoreException e) {
- Activator.getDefault().getLog().log(e.getStatus());
- }
+ public void setDetailCode(String detailCode) {
+ doSetDetailCode(detailCode);
}
/**
@@ -328,11 +318,10 @@ public class SourceViewerActionCodeEditor extends AbstractActionCodeEditor {
* @throws CoreException
* if the {code detailCode} could not be set
*/
- protected void doSetDetailCode(DetailCode detailCode) throws CoreException {
- super.setDetailCode(detailCode);
+ protected void doSetDetailCode(String detailCode) {
fDocument = createDocument(detailCode);
if (fSourceViewer != null) {
- initializeSourceViewer(detailCode);
+ initializeSourceViewer();
}
}
@@ -342,8 +331,7 @@ public class SourceViewerActionCodeEditor extends AbstractActionCodeEditor {
* @param detailCode
* the detailed Code to be used to initialize the source viewer
*/
- private void initializeSourceViewer(DetailCode detailCode) {
-
+ private void initializeSourceViewer() {
if (fDocument != null) {
fSourceViewer.setDocument(fDocument, null);
fSourceViewer.setEditable(isEditable());
@@ -361,8 +349,6 @@ public class SourceViewerActionCodeEditor extends AbstractActionCodeEditor {
fDocument = null;
fSourceViewer = null;
fConfiguration = null;
-
- super.dispose();
}
/**
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/text/TextActionCodeEditor.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/text/TextActionCodeEditor.java
index 6318d54a1..4105cfa40 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/text/TextActionCodeEditor.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/text/TextActionCodeEditor.java
@@ -13,11 +13,8 @@
package org.eclipse.etrice.ui.behavior.actioneditor.text;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.etrice.core.fsm.fSM.DetailCode;
import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.AbstractActionCodeEditor;
import org.eclipse.etrice.ui.behavior.fsm.actioneditor.IActionCodeEditor;
-import org.eclipse.etrice.ui.behavior.support.SupportUtil;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.swt.SWT;
@@ -43,17 +40,14 @@ public class TextActionCodeEditor extends AbstractActionCodeEditor {
private Text text;
@Override
- public void init(DetailCode detailCode) throws CoreException {
- setDetailCode(detailCode);
+ public void init(String detailCode) {
+ text.setText(detailCode);
}
@Override
public void createControl(Composite parent) {
int style = SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL;
text = new Text(parent, style);
- if (fDetailCode != null)
- text.setText(SupportUtil.getInstance().getRoomHelpers()
- .getDetailCode(fDetailCode));
text.setEnabled(true);
}
@@ -72,4 +66,11 @@ public class TextActionCodeEditor extends AbstractActionCodeEditor {
text.setSelection(offset + begin + 1, offset + end);
text.setFocus();
}
+
+ public void dispose(){
+ if(text != null)
+ text.dispose();
+ text = null;
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/text/TextActionCodeEditorFactory.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/text/TextActionCodeEditorFactory.java
index c37e40621..96f6ae6e7 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/text/TextActionCodeEditorFactory.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/src/org/eclipse/etrice/ui/behavior/actioneditor/text/TextActionCodeEditorFactory.java
@@ -15,14 +15,9 @@ package org.eclipse.etrice.ui.behavior.actioneditor.text;
import java.util.ArrayList;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.etrice.core.fsm.fSM.DetailCode;
-import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.ui.behavior.actioneditor.Activator;
import org.eclipse.etrice.ui.behavior.fsm.actioneditor.IActionCodeEditor;
import org.eclipse.etrice.ui.behavior.fsm.actioneditor.IActionCodeEditorFactory;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
import org.eclipse.swt.widgets.Composite;
/**
@@ -36,30 +31,13 @@ public class TextActionCodeEditorFactory implements IActionCodeEditorFactory {
ArrayList<TextActionCodeEditor> constructedEditors = new ArrayList<TextActionCodeEditor>();
@Override
- public IActionCodeEditor createActionCodeEditor(DetailCode detailCode,
- Composite parent, ModelComponent mc, boolean useMembers,
- boolean useMessages, boolean useRecvMessagesOnly) {
-
- TextActionCodeEditor textActionCodeEditor = null;
-
- if (mc instanceof ActorClass) {
- textActionCodeEditor = new TextActionCodeEditor();
- try {
- textActionCodeEditor.init(detailCode);
- } catch (CoreException e) {
- Activator.getDefault().getLog().log(e.getStatus());
- System.out.println("Cannot Initialize editor");
- }
- textActionCodeEditor.createControl(parent);
- } else {
- Activator
- .getDefault()
- .getLog()
- .log(new Status(Status.ERROR, Activator.PLUGIN_ID,
- "Model Componenent " + mc.getComponentName()
- + " is not an instance of ActorClass"));
- }
-
+ public IActionCodeEditor createActionCodeEditor(Composite parent, String detailCode,
+ IDetailExpressionProvider exprProvider) {
+ TextActionCodeEditor textActionCodeEditor = new TextActionCodeEditor();
+ textActionCodeEditor.createControl(parent);
+ textActionCodeEditor.init(detailCode);
+ constructedEditors.add(textActionCodeEditor);
+
return textActionCodeEditor;
}
@@ -70,4 +48,6 @@ public class TextActionCodeEditorFactory implements IActionCodeEditorFactory {
}
constructedEditors.clear();
}
+
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/xtend-gen/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/CustomCompletionProposal.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/xtend-gen/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/CustomCompletionProposal.java
new file mode 100644
index 000000000..6cc698f6f
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/xtend-gen/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/CustomCompletionProposal.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ */
+package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer;
+
+import com.google.common.base.Objects;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.xtend.lib.annotations.Delegate;
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
+
+@FinalFieldsConstructor
+@SuppressWarnings("all")
+public class CustomCompletionProposal implements ICompletionProposal {
+ @Delegate
+ private final ICompletionProposal delegate;
+
+ private final Point selection;
+
+ public Point getSelection(final IDocument document) {
+ Point _xifexpression = null;
+ boolean _notEquals = (!Objects.equal(this.selection, null));
+ if (_notEquals) {
+ _xifexpression = this.selection;
+ } else {
+ _xifexpression = this.delegate.getSelection(document);
+ }
+ return _xifexpression;
+ }
+
+ public CustomCompletionProposal(final ICompletionProposal delegate, final Point selection) {
+ super();
+ this.delegate = delegate;
+ this.selection = selection;
+ }
+
+ public void apply(final IDocument document) {
+ this.delegate.apply(document);
+ }
+
+ public String getAdditionalProposalInfo() {
+ return this.delegate.getAdditionalProposalInfo();
+ }
+
+ public IContextInformation getContextInformation() {
+ return this.delegate.getContextInformation();
+ }
+
+ public String getDisplayString() {
+ return this.delegate.getDisplayString();
+ }
+
+ public Image getImage() {
+ return this.delegate.getImage();
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/xtend-gen/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionAssistParser.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/xtend-gen/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionAssistParser.java
new file mode 100644
index 000000000..7acb9819c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/xtend-gen/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionAssistParser.java
@@ -0,0 +1,238 @@
+/**
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ */
+package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer;
+
+import com.google.common.base.Objects;
+import java.util.LinkedList;
+import java.util.List;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
+import org.eclipse.xtext.util.Strings;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.Exceptions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@FinalFieldsConstructor
+@SuppressWarnings("all")
+public class DetailExpressionAssistParser {
+ private final IDocument document;
+
+ private final int invocationOffset;
+
+ private final IDetailExpressionProvider provider;
+
+ private final IWordDetector anyIdScanner = new IWordDetector() {
+ public boolean isWordPart(final char c) {
+ return Character.isJavaIdentifierPart(c);
+ }
+
+ public boolean isWordStart(final char c) {
+ return Character.isJavaIdentifierStart(c);
+ }
+ };
+
+ public String computeIdentifierPrefix(final int offset) throws BadLocationException {
+ int start = (offset - 1);
+ while (((start >= 0) && this.anyIdScanner.isWordPart(this.document.getChar(start)))) {
+ start--;
+ }
+ start++;
+ return this.document.get(start, (offset - start));
+ }
+
+ public IDetailExpressionProvider.ExpressionFeature computeExpressionFeature(final int offset) throws BadLocationException {
+ IDetailExpressionProvider.ExpressionPostfix postfixResult = null;
+ char openingChar = 0;
+ char closingChar = 0;
+ char _char = this.document.getChar((offset - 1));
+ String _string = Character.valueOf(_char).toString();
+ boolean _matched = false;
+ if (!_matched) {
+ if (Objects.equal(_string, ")")) {
+ _matched=true;
+ postfixResult = IDetailExpressionProvider.ExpressionPostfix.PARENTHESES;
+ openingChar = '(';
+ closingChar = ')';
+ }
+ }
+ if (!_matched) {
+ if (Objects.equal(_string, "]")) {
+ _matched=true;
+ postfixResult = IDetailExpressionProvider.ExpressionPostfix.BRACKETS;
+ openingChar = '[';
+ closingChar = ']';
+ }
+ }
+ if (!_matched) {
+ postfixResult = IDetailExpressionProvider.ExpressionPostfix.NONE;
+ }
+ int start = offset;
+ boolean _notEquals = (!Objects.equal(postfixResult, IDetailExpressionProvider.ExpressionPostfix.NONE));
+ if (_notEquals) {
+ start--;
+ int counter = 1;
+ while (((start > 0) && (counter > 0))) {
+ {
+ start--;
+ char _char_1 = this.document.getChar(start);
+ boolean _matched_1 = false;
+ if (!_matched_1) {
+ if (Objects.equal(_char_1, openingChar)) {
+ _matched_1=true;
+ counter--;
+ }
+ }
+ if (!_matched_1) {
+ if (Objects.equal(_char_1, closingChar)) {
+ _matched_1=true;
+ counter++;
+ }
+ }
+ }
+ }
+ if ((counter > 0)) {
+ postfixResult = null;
+ }
+ }
+ String idResult = null;
+ try {
+ String _computeIdentifierPrefix = this.computeIdentifierPrefix(start);
+ idResult = _computeIdentifierPrefix;
+ } catch (final Throwable _t) {
+ if (_t instanceof BadLocationException) {
+ final BadLocationException e = (BadLocationException)_t;
+ } else {
+ throw Exceptions.sneakyThrow(_t);
+ }
+ }
+ return new IDetailExpressionProvider.ExpressionFeature(idResult, postfixResult);
+ }
+
+ /**
+ * Try to resolve latest complete ExpressionFeature, e.g.:
+ * <ul>
+ * <li>port0.m_ => port0</li>
+ * <li> port0. => port0 </li>
+ * <li>port0 => null</li>
+ * </ul>
+ */
+ public IDetailExpressionProvider.ExpressionFeature resolveLatestCompleted() {
+ int lastSeparatorPos = (this.invocationOffset - 1);
+ try {
+ final String invocationPrefix = this.computeIdentifierPrefix(this.invocationOffset);
+ int _lastSeparatorPos = lastSeparatorPos;
+ int _length = invocationPrefix.length();
+ lastSeparatorPos = (_lastSeparatorPos - _length);
+ } catch (final Throwable _t) {
+ if (_t instanceof BadLocationException) {
+ final BadLocationException e = (BadLocationException)_t;
+ } else {
+ throw Exceptions.sneakyThrow(_t);
+ }
+ }
+ final LinkedList<IDetailExpressionProvider.ExpressionFeature> parsedFeatures = CollectionLiterals.<IDetailExpressionProvider.ExpressionFeature>newLinkedList();
+ try {
+ while ((this.document.getChar(lastSeparatorPos) == IDetailExpressionProvider.SEPARATOR)) {
+ {
+ final IDetailExpressionProvider.ExpressionFeature parseResult = this.computeExpressionFeature(lastSeparatorPos);
+ boolean _isValid = this.isValid(parseResult);
+ boolean _not = (!_isValid);
+ if (_not) {
+ return null;
+ }
+ parsedFeatures.push(parseResult);
+ int _lastSeparatorPos_1 = lastSeparatorPos;
+ String _id = parseResult.getId();
+ int _length_1 = _id.length();
+ int _plus = (_length_1 + 1);
+ lastSeparatorPos = (_lastSeparatorPos_1 - _plus);
+ }
+ }
+ } catch (final Throwable _t_1) {
+ if (_t_1 instanceof BadLocationException) {
+ final BadLocationException e_1 = (BadLocationException)_t_1;
+ } else {
+ throw Exceptions.sneakyThrow(_t_1);
+ }
+ }
+ boolean _isEmpty = parsedFeatures.isEmpty();
+ if (_isEmpty) {
+ return null;
+ }
+ final IDetailExpressionProvider.ExpressionFeature firstParseResult = parsedFeatures.pop();
+ List<IDetailExpressionProvider.ExpressionFeature> _initialFeatures = this.provider.getInitialFeatures();
+ final Function1<IDetailExpressionProvider.ExpressionFeature, Boolean> _function = new Function1<IDetailExpressionProvider.ExpressionFeature, Boolean>() {
+ public Boolean apply(final IDetailExpressionProvider.ExpressionFeature it) {
+ return Boolean.valueOf(DetailExpressionAssistParser.this.matches(it, firstParseResult));
+ }
+ };
+ IDetailExpressionProvider.ExpressionFeature lastMatch = IterableExtensions.<IDetailExpressionProvider.ExpressionFeature>findFirst(_initialFeatures, _function);
+ while (((!Objects.equal(lastMatch, null)) && (!parsedFeatures.isEmpty()))) {
+ {
+ final IDetailExpressionProvider.ExpressionFeature nextParseResult = parsedFeatures.pop();
+ List<IDetailExpressionProvider.ExpressionFeature> _contextFeatures = this.provider.getContextFeatures(lastMatch);
+ final Function1<IDetailExpressionProvider.ExpressionFeature, Boolean> _function_1 = new Function1<IDetailExpressionProvider.ExpressionFeature, Boolean>() {
+ public Boolean apply(final IDetailExpressionProvider.ExpressionFeature it) {
+ return Boolean.valueOf(DetailExpressionAssistParser.this.matches(it, nextParseResult));
+ }
+ };
+ IDetailExpressionProvider.ExpressionFeature _findFirst = IterableExtensions.<IDetailExpressionProvider.ExpressionFeature>findFirst(_contextFeatures, _function_1);
+ lastMatch = _findFirst;
+ }
+ }
+ return lastMatch;
+ }
+
+ /**
+ * non-empty id + not-null suffix
+ */
+ private boolean isValid(final IDetailExpressionProvider.ExpressionFeature feature) {
+ boolean _and = false;
+ String _id = feature.getId();
+ boolean _isEmpty = Strings.isEmpty(_id);
+ boolean _not = (!_isEmpty);
+ if (!_not) {
+ _and = false;
+ } else {
+ IDetailExpressionProvider.ExpressionPostfix _postfix = feature.getPostfix();
+ boolean _notEquals = (!Objects.equal(_postfix, null));
+ _and = _notEquals;
+ }
+ return _and;
+ }
+
+ private boolean matches(final IDetailExpressionProvider.ExpressionFeature f1, final IDetailExpressionProvider.ExpressionFeature f2) {
+ boolean _and = false;
+ String _id = f1.getId();
+ String _id_1 = f2.getId();
+ boolean _equals = Objects.equal(_id, _id_1);
+ if (!_equals) {
+ _and = false;
+ } else {
+ IDetailExpressionProvider.ExpressionPostfix _postfix = f1.getPostfix();
+ IDetailExpressionProvider.ExpressionPostfix _postfix_1 = f2.getPostfix();
+ boolean _equals_1 = Objects.equal(_postfix, _postfix_1);
+ _and = _equals_1;
+ }
+ return _and;
+ }
+
+ public DetailExpressionAssistParser(final IDocument document, final int invocationOffset, final IDetailExpressionProvider provider) {
+ super();
+ this.document = document;
+ this.invocationOffset = invocationOffset;
+ this.provider = provider;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.actioneditor/xtend-gen/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionUIProvider.java b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/xtend-gen/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionUIProvider.java
new file mode 100644
index 000000000..cb8ff66e0
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.actioneditor/xtend-gen/org/eclipse/etrice/ui/behavior/actioneditor/sourceviewer/DetailExpressionUIProvider.java
@@ -0,0 +1,379 @@
+/**
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ */
+package org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Strings;
+import com.google.inject.Inject;
+import java.util.List;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.Operation;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.SPP;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.ui.behavior.actioneditor.Activator;
+import org.eclipse.etrice.ui.behavior.actioneditor.sourceviewer.ActionCodeColorManager;
+import org.eclipse.etrice.ui.behavior.detailcode.RuntimeDetailExpressionProvider;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.xtend.lib.annotations.Delegate;
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
+import org.eclipse.xtext.xbase.lib.Conversions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.Pair;
+
+@FinalFieldsConstructor
+@SuppressWarnings("all")
+public class DetailExpressionUIProvider implements IDetailExpressionProvider {
+ private final static String IMAGE_RT_METHOD = "icons/rt_method.png";
+
+ @Delegate
+ private final IDetailExpressionProvider delegate;
+
+ @Inject
+ protected ILabelProvider labelProvider;
+
+ @Inject
+ protected RoomHelpers roomHelpers;
+
+ /**
+ * Return postfix string and its selection (relative start, length)
+ */
+ public Pair<String, Point> getPostfixReplacement(final IDetailExpressionProvider.ExpressionFeature feature) {
+ Pair<String, Point> _xblockexpression = null;
+ {
+ this.assertNotNull(feature);
+ String[] _switchResult = null;
+ IDetailExpressionProvider.ExpressionPostfix _postfix = feature.getPostfix();
+ if (_postfix != null) {
+ switch (_postfix) {
+ case PARENTHESES:
+ _switchResult = new String[] { "(", ")" };
+ break;
+ case BRACKETS:
+ _switchResult = new String[] { "[", "]" };
+ break;
+ default:
+ return Pair.<String, Point>of("", null);
+ }
+ } else {
+ return Pair.<String, Point>of("", null);
+ }
+ String[] brackets = _switchResult;
+ String _switchResult_1 = null;
+ Object _data = feature.getData();
+ final Object data = _data;
+ boolean _matched = false;
+ if (!_matched) {
+ if (data instanceof Operation) {
+ _matched=true;
+ EList<VarDecl> _arguments = ((Operation)data).getArguments();
+ final Function1<VarDecl, String> _function = new Function1<VarDecl, String>() {
+ public String apply(final VarDecl it) {
+ return it.getName();
+ }
+ };
+ List<String> _map = ListExtensions.<VarDecl, String>map(_arguments, _function);
+ _switchResult_1 = IterableExtensions.join(_map, ", ");
+ }
+ }
+ if (!_matched) {
+ if (data instanceof Message) {
+ VarDecl _data_1 = ((Message)data).getData();
+ boolean _notEquals = (!Objects.equal(_data_1, null));
+ if (_notEquals) {
+ _matched=true;
+ VarDecl _data_2 = ((Message)data).getData();
+ _switchResult_1 = _data_2.getName();
+ }
+ }
+ }
+ if (!_matched) {
+ if (data instanceof Attribute) {
+ _matched=true;
+ }
+ if (!_matched) {
+ if (data instanceof InterfaceItem) {
+ _matched=true;
+ }
+ }
+ if (_matched) {
+ _switchResult_1 = "0";
+ }
+ }
+ if (!_matched) {
+ _switchResult_1 = "";
+ }
+ String replacement = _switchResult_1;
+ Point _xifexpression = null;
+ boolean _isEmpty = replacement.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ int _length = replacement.length();
+ _xifexpression = new Point(1, _length);
+ }
+ final Point selection = _xifexpression;
+ final String[] _converted_brackets = (String[])brackets;
+ String _head = IterableExtensions.<String>head(((Iterable<String>)Conversions.doWrapArray(_converted_brackets)));
+ String _plus = (_head + replacement);
+ final String[] _converted_brackets_1 = (String[])brackets;
+ String _last = IterableExtensions.<String>last(((Iterable<String>)Conversions.doWrapArray(_converted_brackets_1)));
+ String _plus_1 = (_plus + _last);
+ _xblockexpression = Pair.<String, Point>of(_plus_1, selection);
+ }
+ return _xblockexpression;
+ }
+
+ /**
+ * Return completion string and its selection (relative start, length)
+ */
+ public Pair<String, Point> getCompletion(final IDetailExpressionProvider.ExpressionFeature feature) {
+ this.assertNotNull(feature);
+ Pair<String, Point> postfix = this.getPostfixReplacement(feature);
+ Point point = postfix.getValue();
+ boolean _notEquals = (!Objects.equal(point, null));
+ if (_notEquals) {
+ int _x = point.x;
+ String _id = feature.getId();
+ int _length = _id.length();
+ point.x = (_x + _length);
+ }
+ String _id_1 = feature.getId();
+ String _key = postfix.getKey();
+ String _plus = (_id_1 + _key);
+ return Pair.<String, Point>of(_plus, point);
+ }
+
+ public RGB getColor(final IDetailExpressionProvider.ExpressionFeature feature) {
+ this.assertNotNull(feature);
+ RGB _switchResult = null;
+ Object _data = feature.getData();
+ final Object data = _data;
+ boolean _matched = false;
+ if (!_matched) {
+ if (data instanceof InterfaceItem) {
+ _matched=true;
+ _switchResult = ActionCodeColorManager.INTERFACE_ITEM;
+ }
+ }
+ if (!_matched) {
+ if (data instanceof Attribute) {
+ _matched=true;
+ _switchResult = ActionCodeColorManager.ATTRIBUTE;
+ }
+ }
+ if (!_matched) {
+ if (data instanceof Operation) {
+ _matched=true;
+ _switchResult = ActionCodeColorManager.OPERATION;
+ }
+ }
+ if (!_matched) {
+ if (data instanceof EObject) {
+ _matched=true;
+ _switchResult = ActionCodeColorManager.SPECIAL_FEATURE;
+ }
+ }
+ return _switchResult;
+ }
+
+ /**
+ * Text format:
+ * {@code completionInfo : typedInfo - classInfo}
+ */
+ public String getDisplayString(final IDetailExpressionProvider.ExpressionFeature feature) {
+ this.assertNotNull(feature);
+ final Object data = feature.getData();
+ String _id = feature.getId();
+ Pair<String, Point> _postfixReplacement = this.getPostfixReplacement(feature);
+ String _key = _postfixReplacement.getKey();
+ String completionInfo = (_id + _key);
+ String typedInfo = "";
+ String _xifexpression = null;
+ if ((data instanceof EObject)) {
+ EClass _eClass = ((EObject)data).eClass();
+ _xifexpression = _eClass.getName();
+ } else {
+ _xifexpression = "";
+ }
+ String classInfo = _xifexpression;
+ boolean _matched = false;
+ if (!_matched) {
+ if (data instanceof Attribute) {
+ _matched=true;
+ RefableType _type = ((Attribute)data).getType();
+ DataType _type_1 = _type.getType();
+ String _name = _type_1.getName();
+ typedInfo = _name;
+ }
+ }
+ if (!_matched) {
+ if (data instanceof InterfaceItem) {
+ _matched=true;
+ ProtocolClass _protocol = this.roomHelpers.getProtocol(((InterfaceItem)data));
+ String _name = _protocol.getName();
+ typedInfo = _name;
+ }
+ }
+ if (!_matched) {
+ if (data instanceof RuntimeDetailExpressionProvider.RuntimeMethodExpressionData) {
+ _matched=true;
+ typedInfo = "int";
+ }
+ }
+ if (!_matched) {
+ {
+ final String label = this.labelProvider.getText(data);
+ String _commonPrefix = Strings.commonPrefix(label, completionInfo);
+ boolean _isEmpty = _commonPrefix.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ completionInfo = label;
+ }
+ }
+ }
+ IDetailExpressionProvider.ExpressionPostfix _postfix = feature.getPostfix();
+ boolean _equals = Objects.equal(_postfix, IDetailExpressionProvider.ExpressionPostfix.NONE);
+ if (_equals) {
+ boolean _matched_1 = false;
+ if (!_matched_1) {
+ if (data instanceof SPP) {
+ boolean _isEventDriven = ((SPP)data).isEventDriven();
+ if (_isEventDriven) {
+ _matched_1=true;
+ }
+ }
+ if (!_matched_1) {
+ if (data instanceof Port) {
+ boolean _and = false;
+ int _multiplicity = ((Port)data).getMultiplicity();
+ boolean _greaterThan = (_multiplicity > 1);
+ if (!_greaterThan) {
+ _and = false;
+ } else {
+ boolean _isEventDriven = ((Port)data).isEventDriven();
+ _and = _isEventDriven;
+ }
+ if (_and) {
+ _matched_1=true;
+ }
+ }
+ }
+ if (_matched_1) {
+ completionInfo = (completionInfo + " (broadcast)");
+ }
+ }
+ }
+ boolean _isEmpty = typedInfo.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ typedInfo = (" : " + typedInfo);
+ }
+ boolean _isEmpty_1 = classInfo.isEmpty();
+ boolean _not_1 = (!_isEmpty_1);
+ if (_not_1) {
+ classInfo = (" - " + classInfo);
+ }
+ return ((completionInfo + typedInfo) + classInfo);
+ }
+
+ public Image getImage(final IDetailExpressionProvider.ExpressionFeature feature) {
+ Image _xblockexpression = null;
+ {
+ this.assertNotNull(feature);
+ Image _switchResult = null;
+ Object _data = feature.getData();
+ boolean _matched = false;
+ if (!_matched) {
+ if (_data instanceof EObject) {
+ _matched=true;
+ Object _data_1 = feature.getData();
+ _switchResult = this.labelProvider.getImage(_data_1);
+ }
+ }
+ if (!_matched) {
+ if (_data instanceof RuntimeDetailExpressionProvider.RuntimeMethodExpressionData) {
+ _matched=true;
+ _switchResult = Activator.getImage(DetailExpressionUIProvider.IMAGE_RT_METHOD);
+ }
+ }
+ _xblockexpression = _switchResult;
+ }
+ return _xblockexpression;
+ }
+
+ /**
+ * Filter by prefix
+ */
+ public Iterable<IDetailExpressionProvider.ExpressionFeature> getContextFeaturesWithPrefix(final IDetailExpressionProvider.ExpressionFeature ctx, final String prefix) {
+ List<IDetailExpressionProvider.ExpressionFeature> _contextFeatures = this.delegate.getContextFeatures(ctx);
+ final Function1<IDetailExpressionProvider.ExpressionFeature, Boolean> _function = new Function1<IDetailExpressionProvider.ExpressionFeature, Boolean>() {
+ public Boolean apply(final IDetailExpressionProvider.ExpressionFeature it) {
+ String _id = it.getId();
+ return Boolean.valueOf(_id.startsWith(prefix));
+ }
+ };
+ return IterableExtensions.<IDetailExpressionProvider.ExpressionFeature>filter(_contextFeatures, _function);
+ }
+
+ /**
+ * Filter by prefix
+ */
+ public Iterable<IDetailExpressionProvider.ExpressionFeature> getInitialFeaturesWithPrefix(final String prefix) {
+ List<IDetailExpressionProvider.ExpressionFeature> _initialFeatures = this.delegate.getInitialFeatures();
+ final Function1<IDetailExpressionProvider.ExpressionFeature, Boolean> _function = new Function1<IDetailExpressionProvider.ExpressionFeature, Boolean>() {
+ public Boolean apply(final IDetailExpressionProvider.ExpressionFeature it) {
+ String _id = it.getId();
+ return Boolean.valueOf(_id.startsWith(prefix));
+ }
+ };
+ return IterableExtensions.<IDetailExpressionProvider.ExpressionFeature>filter(_initialFeatures, _function);
+ }
+
+ protected void assertNotNull(final IDetailExpressionProvider.ExpressionFeature feature) {
+ String _id = feature.getId();
+ boolean _isNullOrEmpty = Strings.isNullOrEmpty(_id);
+ boolean _not = (!_isNullOrEmpty);
+ Assert.isTrue(_not);
+ IDetailExpressionProvider.ExpressionPostfix _postfix = feature.getPostfix();
+ Assert.isNotNull(_postfix);
+ Object _data = feature.getData();
+ Assert.isNotNull(_data);
+ }
+
+ public DetailExpressionUIProvider(final IDetailExpressionProvider delegate) {
+ super();
+ this.delegate = delegate;
+ }
+
+ public List<IDetailExpressionProvider.ExpressionFeature> getContextFeatures(final IDetailExpressionProvider.ExpressionFeature ctx) {
+ return this.delegate.getContextFeatures(ctx);
+ }
+
+ public List<IDetailExpressionProvider.ExpressionFeature> getInitialFeatures() {
+ return this.delegate.getInitialFeatures();
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/.classpath b/plugins/org.eclipse.etrice.ui.behavior.fsm/.classpath
index ad32c83a7..358df1bc1 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/.classpath
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/.classpath
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/.gitignore b/plugins/org.eclipse.etrice.ui.behavior.fsm/.gitignore
index ba077a403..16847d1d4 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/.gitignore
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/.gitignore
@@ -1 +1,2 @@
bin
+*._trace \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/.project b/plugins/org.eclipse.etrice.ui.behavior.fsm/.project
index cf04191bc..1b258480d 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/.project
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/.project
@@ -6,6 +6,11 @@
</projects>
<buildSpec>
<buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
@@ -24,5 +29,6 @@
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.behavior.fsm/META-INF/MANIFEST.MF
index 0f4f33001..efd1b7ef7 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/META-INF/MANIFEST.MF
@@ -17,13 +17,13 @@ Require-Bundle: org.eclipse.etrice.core.common.ui;bundle-version="0.5.0",
org.eclipse.emf.transaction;bundle-version="1.4.0",
org.eclipse.xtext.ui;bundle-version="2.6.0",
org.eclipse.xtext.xbase.lib;bundle-version="2.6.0",
- org.eclipse.xtext.ui.shared;bundle-version="2.6.0",
- org.eclipse.etrice.abstractexec.behavior;bundle-version="0.5.0"
+ org.eclipse.xtext.ui.shared;bundle-version="2.6.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.etrice.ui.behavior.fsm.actioneditor,
org.eclipse.etrice.ui.behavior.fsm.actioneditor.preferences,
org.eclipse.etrice.ui.behavior.fsm.commands,
+ org.eclipse.etrice.ui.behavior.fsm.detailcode,
org.eclipse.etrice.ui.behavior.fsm.dialogs,
org.eclipse.etrice.ui.behavior.fsm.editor,
org.eclipse.etrice.ui.behavior.fsm.provider,
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/ActionCodeEditorRegistry.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/ActionCodeEditorRegistry.java
index 6645d4b50..83dd12cf7 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/ActionCodeEditorRegistry.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/ActionCodeEditorRegistry.java
@@ -22,8 +22,8 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;
-import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
import org.eclipse.etrice.ui.behavior.fsm.Activator;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
import org.eclipse.swt.widgets.Composite;
/**
@@ -106,14 +106,11 @@ public class ActionCodeEditorRegistry {
*
* @return the {@link IActionCodeEditor} instance or <code>null</code>
*/
- public IActionCodeEditor newActionCodeEditor(DetailCode detailCode,
- Composite parent, ModelComponent mc, boolean useMembers,
- boolean useMessages, boolean useRecvMessagesOnly) {
+ public IActionCodeEditor newActionCodeEditor(Composite parent, String text, IDetailExpressionProvider exprProvider) {
IActionCodeEditorFactory factory = getFactory();
if (factory == null)
return null;
- return factory.createActionCodeEditor(detailCode, parent, mc,
- useMembers, useMessages, useRecvMessagesOnly);
+ return factory.createActionCodeEditor(parent, text, exprProvider);
}
/**
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/IActionCodeEditor.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/IActionCodeEditor.java
index 8da8e96d2..7ae1c91bf 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/IActionCodeEditor.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/IActionCodeEditor.java
@@ -13,7 +13,6 @@
package org.eclipse.etrice.ui.behavior.fsm.actioneditor;
-import org.eclipse.etrice.core.fsm.fSM.DetailCode;
import org.eclipse.swt.widgets.Control;
/**
@@ -25,13 +24,6 @@ import org.eclipse.swt.widgets.Control;
public interface IActionCodeEditor {
/**
- * Getter for the {@link DetailCode} object being represented by the editor.
- *
- * @return the DetailCode object associated with the editor instance
- */
- DetailCode getDetailCode();
-
- /**
* Getter for the editor {@link Control} representing the Action Code.
*
* @return the Control within the editor
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/IActionCodeEditorFactory.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/IActionCodeEditorFactory.java
index f3bd06e7d..74239e6a1 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/IActionCodeEditorFactory.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/actioneditor/IActionCodeEditorFactory.java
@@ -13,8 +13,7 @@
package org.eclipse.etrice.ui.behavior.fsm.actioneditor;
-import org.eclipse.etrice.core.fsm.fSM.DetailCode;
-import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
import org.eclipse.swt.widgets.Composite;
/**
@@ -28,23 +27,11 @@ public interface IActionCodeEditorFactory {
* Create a new instance of an implementation of the
* {@link IActionCodeEditor} with given configuration parameters.
*
- * @param detailCode
- * the {@link DetailCode} object to be represented
* @param parent
* the {@link Composite} which will hold the editor
- * @param ac
- * the {@link ActorClass} class containing the detail Code
- * @param useMembers
- * true if the editor is to be member aware
- * @param useMessages
- * true if the editor is to be message aware
- * @param useRecvMessagesOnly
- * true if the editor is to use only receive only messages
* @return the created instance of the action code editor.
*/
- IActionCodeEditor createActionCodeEditor(DetailCode detailCode,
- Composite parent, ModelComponent ac, boolean useMembers,
- boolean useMessages, boolean useRecvMessagesOnly);
+ IActionCodeEditor createActionCodeEditor(Composite parent, String detailCode, IDetailExpressionProvider exprProvider);
/**
* Disposes all the resources allocate by the factory.
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/detailcode/IDetailExpressionProvider.xtend b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/detailcode/IDetailExpressionProvider.xtend
new file mode 100644
index 000000000..9db27e1db
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/detailcode/IDetailExpressionProvider.xtend
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.ui.behavior.fsm.detailcode
+
+import java.util.List
+import org.eclipse.xtend.lib.annotations.Accessors
+
+/**
+ * Defines detail expressions = <i>ExpressionFeature ('.' ExpressionFeature)* </i>
+ */
+interface IDetailExpressionProvider {
+
+ static val char SEPARATOR = '.'
+
+ /**
+ * A list of ExpressionFeatures, without preceding '.' and that can start a context
+ * @return not null
+ */
+ def List<ExpressionFeature> getInitialFeatures()
+
+ /**
+ * A list of ExpressionFeatures, that can follow ctx
+ * @param ctx having non-null entries
+ * @return not null
+ */
+ def List<ExpressionFeature> getContextFeatures(ExpressionFeature ctx)
+
+ /**
+ * ExpressionFeature = <i>id(postfix)?</i> with <i> postfix = '(' .* ')' | '[' .* ']'
+ */
+ @Accessors // @Data
+ static class ExpressionFeature {
+ val String id
+ val ExpressionPostfix postfix
+ Object data
+ }
+
+ enum ExpressionPostfix {
+ NONE,
+ PARENTHESES,
+ BRACKETS
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/AbstractMemberAwarePropertyDialog.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/AbstractMemberAwarePropertyDialog.java
index 98e1bebd9..b2f2d5373 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/AbstractMemberAwarePropertyDialog.java
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/dialogs/AbstractMemberAwarePropertyDialog.java
@@ -28,6 +28,8 @@ import org.eclipse.etrice.ui.behavior.fsm.actioneditor.ActionCodeEditorRegistry;
import org.eclipse.etrice.ui.behavior.fsm.actioneditor.ActionCodeEditorRegistry.ActionCodeEditorRegistryEntry;
import org.eclipse.etrice.ui.behavior.fsm.actioneditor.IActionCodeEditor;
import org.eclipse.etrice.ui.behavior.fsm.actioneditor.preferences.PreferenceConstants;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
+import org.eclipse.etrice.ui.behavior.fsm.support.FSMSupportUtil;
import org.eclipse.etrice.ui.common.base.dialogs.AbstractPropertyDialog;
import org.eclipse.etrice.ui.common.base.dialogs.MultiValidator2;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -177,9 +179,9 @@ public abstract class AbstractMemberAwarePropertyDialog extends AbstractProperty
*/
protected IActionCodeEditor createActionCodeEditor(Composite parent,
String label, DetailCode detailCode, EObject obj,
- EStructuralFeature feat, IConverter s2m, IConverter m2s) {
+ EStructuralFeature feat, IConverter s2m, IConverter m2s, IDetailExpressionProvider exprPovider) {
return createActionCodeEditor(parent, label, detailCode, obj, feat,
- null, null, s2m, m2s, true, true, false);
+ null, null, s2m, m2s, true, true, false, exprPovider);
}
/**
@@ -219,7 +221,7 @@ public abstract class AbstractMemberAwarePropertyDialog extends AbstractProperty
String label, DetailCode detailCode, EObject obj,
EStructuralFeature feat, IValidator singleValidator,
MultiValidator2 multiValidator, IConverter s2m, IConverter m2s,
- boolean useMembers, boolean useMessages, boolean useRecvMessagesOnly) {
+ boolean useMembers, boolean useMessages, boolean useRecvMessagesOnly, IDetailExpressionProvider exprPovider) {
Label l = getToolkit().createLabel(parent, label, SWT.NONE);
l.setLayoutData(new GridData(SWT.NONE));
@@ -237,8 +239,8 @@ public abstract class AbstractMemberAwarePropertyDialog extends AbstractProperty
ActionCodeEditorRegistryEntry editorEntry = ActionCodeEditorRegistry.INSTANCE.getEditorWithId(id);
if(editorEntry == null)
return null;
- IActionCodeEditor actionCodeEditor = editorEntry.newActionCodeEditor(detailCode, parent,
- mc, useMembers, useMessages, useRecvMessagesOnly);
+ String editorText = FSMSupportUtil.getInstance().getFSMHelpers().getDetailCode(detailCode);
+ IActionCodeEditor actionCodeEditor = editorEntry.newActionCodeEditor(parent, editorText, exprPovider);
if (actionCodeEditor != null) {
configureMemberAwareness(actionCodeEditor, useMembers, useMessages,
useRecvMessagesOnly);
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/detailcode/IDetailExpressionProvider.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/detailcode/IDetailExpressionProvider.java
new file mode 100644
index 000000000..a9ef19f2b
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/detailcode/IDetailExpressionProvider.java
@@ -0,0 +1,81 @@
+/**
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ */
+package org.eclipse.etrice.ui.behavior.fsm.detailcode;
+
+import java.util.List;
+import org.eclipse.xtend.lib.annotations.Accessors;
+import org.eclipse.xtext.xbase.lib.Pure;
+
+/**
+ * Defines detail expressions = <i>ExpressionFeature ('.' ExpressionFeature)* </i>
+ */
+@SuppressWarnings("all")
+public interface IDetailExpressionProvider {
+ /**
+ * ExpressionFeature = <i>id(postfix)?</i> with <i> postfix = '(' .* ')' | '[' .* ']'
+ */
+ @Accessors
+ public static class ExpressionFeature {
+ private final String id;
+
+ private final IDetailExpressionProvider.ExpressionPostfix postfix;
+
+ private Object data;
+
+ public ExpressionFeature(final String id, final IDetailExpressionProvider.ExpressionPostfix postfix) {
+ super();
+ this.id = id;
+ this.postfix = postfix;
+ }
+
+ @Pure
+ public String getId() {
+ return this.id;
+ }
+
+ @Pure
+ public IDetailExpressionProvider.ExpressionPostfix getPostfix() {
+ return this.postfix;
+ }
+
+ @Pure
+ public Object getData() {
+ return this.data;
+ }
+
+ public void setData(final Object data) {
+ this.data = data;
+ }
+ }
+
+ public enum ExpressionPostfix {
+ NONE,
+
+ PARENTHESES,
+
+ BRACKETS;
+ }
+
+ public final static char SEPARATOR = '.';
+
+ /**
+ * A list of ExpressionFeatures, without preceding '.' and that can start a context
+ * @return not null
+ */
+ public abstract List<IDetailExpressionProvider.ExpressionFeature> getInitialFeatures();
+
+ /**
+ * A list of ExpressionFeatures, that can follow ctx
+ * @param ctx having non-null entries
+ * @return not null
+ */
+ public abstract List<IDetailExpressionProvider.ExpressionFeature> getContextFeatures(final IDetailExpressionProvider.ExpressionFeature ctx);
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/.classpath b/plugins/org.eclipse.etrice.ui.behavior/.classpath
index ad32c83a7..358df1bc1 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/.classpath
+++ b/plugins/org.eclipse.etrice.ui.behavior/.classpath
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
diff --git a/plugins/org.eclipse.etrice.ui.behavior/.gitignore b/plugins/org.eclipse.etrice.ui.behavior/.gitignore
index ba077a403..65847a73f 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/.gitignore
+++ b/plugins/org.eclipse.etrice.ui.behavior/.gitignore
@@ -1 +1,2 @@
bin
+*._trace
diff --git a/plugins/org.eclipse.etrice.ui.behavior/.project b/plugins/org.eclipse.etrice.ui.behavior/.project
index de09fb560..791747c8c 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/.project
+++ b/plugins/org.eclipse.etrice.ui.behavior/.project
@@ -6,6 +6,11 @@
</projects>
<buildSpec>
<buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
@@ -24,5 +29,6 @@
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
diff --git a/plugins/org.eclipse.etrice.ui.behavior/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.ui.behavior/META-INF/MANIFEST.MF
index 240e7cf12..0fccfb415 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.ui.behavior/META-INF/MANIFEST.MF
@@ -24,5 +24,6 @@ Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: Eclipse eTrice (Incubation)
Export-Package: org.eclipse.etrice.ui.behavior,
+ org.eclipse.etrice.ui.behavior.detailcode,
org.eclipse.etrice.ui.behavior.editor,
org.eclipse.etrice.ui.behavior.support
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/detailcode/DefaultDetailExpressionProvider.xtend b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/detailcode/DefaultDetailExpressionProvider.xtend
new file mode 100644
index 000000000..b40dbb3de
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/detailcode/DefaultDetailExpressionProvider.xtend
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+package org.eclipse.etrice.ui.behavior.detailcode
+
+import java.util.List
+import org.eclipse.etrice.core.room.Attribute
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.core.room.InterfaceItem
+import org.eclipse.etrice.core.room.Port
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
+import org.eclipse.etrice.core.room.SPP
+import org.eclipse.etrice.core.room.SAP
+/**
+ * Defines expression for fsm detail code of an ActorClass
+ */
+@FinalFieldsConstructor
+class DefaultDetailExpressionProvider extends GuardDetailExpressionProvider {
+
+ override getInitialFeatures() {
+ val List<ExpressionFeature> scope = newArrayList
+
+ if (currentEventMessage != null)
+ scope += createExprFeature(currentEventMessage.data)
+ actorClass.allInterfaceItems.forEach [
+ switch it {
+ SPP case isEventDriven/* fall through */,
+ Port case isEventDriven && multiplicity > 1: {
+ scope += createExprFeature // additional feature for broadcast
+ scope += createExprFeature(ExpressionPostfix.BRACKETS)
+ }
+ Port case multiplicity > 1/* fall through */,
+ SPP:
+ scope += createExprFeature(ExpressionPostfix.BRACKETS)
+ default:
+ scope += createExprFeature
+ }
+ ]
+ scope += actorClass.latestOperations.map[createExprFeature(ExpressionPostfix.PARENTHESES)]
+ scope += actorClass.allAttributes.map[
+ switch (size) {
+ case size > 1: createExprFeature(ExpressionPostfix.BRACKETS)
+ default: createExprFeature
+ }]
+
+ return scope
+ }
+
+ override getContextFeatures(ExpressionFeature ctx) {
+ ctx.assertNotNull
+
+ val List<ExpressionFeature> scope = newArrayList
+ switch obj : ctx.data {
+ Port case obj.multiplicity == 1/* fall through */,
+ SAP: scope +=
+ obj.protocol.getAllOperations(!obj.conjugated).map[createExprFeature(ExpressionPostfix.PARENTHESES)]
+ }
+ switch obj : ctx.data {
+ InterfaceItem: {
+ val pc = obj.protocol
+ switch pc.commType {
+ case EVENT_DRIVEN:
+ scope += pc.getAllMessages(obj.conjugated).map[createExprFeature(ExpressionPostfix.PARENTHESES)]
+ case DATA_DRIVEN:
+ if (obj.conjugated)
+ scope += pc.allIncomingMessages.map[createExprFeature(ExpressionPostfix.PARENTHESES)]
+ else
+ scope += pc.allIncomingMessages.map[createExprFeature]
+ case SYNCHRONOUS: {
+ }
+ }
+
+ // TODO Attributes ?
+ }
+ Attribute case obj.type.type instanceof DataClass: {
+ val dc = obj.type.type as DataClass
+ scope += dc.allAttributes.map[
+ if(size > 1) createExprFeature(ExpressionPostfix.BRACKETS) else createExprFeature]
+ // not supported yet by code translation:
+ // scope += dc.latestOperations.map[createExprFeature(ExpressionPostfix.PARENTHESES)]
+ }
+ }
+
+ return scope
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/detailcode/GuardDetailExpressionProvider.xtend b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/detailcode/GuardDetailExpressionProvider.xtend
new file mode 100644
index 000000000..287548c3b
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/detailcode/GuardDetailExpressionProvider.xtend
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+package org.eclipse.etrice.ui.behavior.detailcode
+
+import com.google.common.base.Function
+import com.google.common.base.Strings
+import java.util.List
+import org.eclipse.core.runtime.Assert
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.etrice.core.room.ActorClass
+import org.eclipse.etrice.core.room.Attribute
+import org.eclipse.etrice.core.room.DataClass
+import org.eclipse.etrice.core.room.InterfaceItem
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.Port
+import org.eclipse.etrice.core.room.util.RoomHelpers
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider
+import org.eclipse.etrice.ui.behavior.support.SupportUtil
+import org.eclipse.xtend.lib.annotations.Accessors
+import org.eclipse.xtext.util.SimpleAttributeResolver
+
+/**
+ * Defines expression for fsm guards of an ActorClass
+ * <ul>
+ * <li>attributes and operations of ActorClass</li>
+ * <li>data-driven incoming messages</li>
+ * </ul>
+ */
+class GuardDetailExpressionProvider implements IDetailExpressionProvider {
+
+ @Accessors protected val ActorClass actorClass
+
+ @Accessors protected Message currentEventMessage
+
+ protected val extension RoomHelpers roomHelpers
+ protected val Function<EObject, String> nameProvider = SimpleAttributeResolver.NAME_RESOLVER
+
+ new(ActorClass actorClass){
+ this.actorClass = actorClass
+ roomHelpers = SupportUtil.getInstance.roomHelpers
+ }
+
+ override getInitialFeatures() {
+ val List<ExpressionFeature> scope = newArrayList
+
+ if(currentEventMessage != null)
+ scope += createExprFeature(currentEventMessage.data)
+ scope += actorClass.allInterfaceItems.filter[isDataDriven && !isConjugated].map[
+ switch it {
+ Port case multiplicity > 1: createExprFeature(ExpressionPostfix.BRACKETS)
+ default: createExprFeature
+ }]
+ scope += actorClass.latestOperations.map[createExprFeature(ExpressionPostfix.PARENTHESES)]
+ scope += actorClass.allAttributes.map[
+ switch (size) {
+ case size > 1: createExprFeature(ExpressionPostfix.BRACKETS)
+ default: createExprFeature
+ }]
+
+ return scope
+ }
+
+ override getContextFeatures(ExpressionFeature ctx) {
+ ctx.assertNotNull
+
+ val List<ExpressionFeature> scope = newArrayList
+ switch obj : ctx.data {
+ InterfaceItem: {
+ val pc = obj.protocol
+ switch pc.commType {
+ case DATA_DRIVEN:
+ if (!obj.conjugated)
+ scope += pc.allIncomingMessages.map[createExprFeature]
+ }
+ }
+ Attribute case obj.type.type instanceof DataClass: {
+ val dc = obj.type.type as DataClass
+ scope += dc.allAttributes.map[
+ if(size > 1) createExprFeature(ExpressionPostfix.BRACKETS) else createExprFeature]
+ scope += dc.latestOperations.map[createExprFeature(ExpressionPostfix.PARENTHESES)]
+ }
+ }
+
+ return scope
+ }
+
+ def protected createExprFeature(EObject eObj) {
+ createExprFeature(eObj, ExpressionPostfix.NONE)
+ }
+
+ def protected createExprFeature(EObject eObj, ExpressionPostfix postfix) {
+ val feature = new ExpressionFeature(nameProvider.apply(eObj), postfix)
+ feature.data = eObj
+
+ return feature
+ }
+
+ def protected assertNotNull(ExpressionFeature feature) {
+ Assert.isTrue(!Strings.isNullOrEmpty(feature.id))
+ Assert.isNotNull(feature.postfix)
+ Assert.isNotNull(feature.data)
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/detailcode/RuntimeDetailExpressionProvider.xtend b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/detailcode/RuntimeDetailExpressionProvider.xtend
new file mode 100644
index 000000000..4fb5662eb
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/detailcode/RuntimeDetailExpressionProvider.xtend
@@ -0,0 +1,51 @@
+package org.eclipse.etrice.ui.behavior.detailcode
+
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.etrice.core.room.InterfaceItem
+import org.eclipse.etrice.core.room.Port
+import org.eclipse.etrice.core.room.SPP
+import org.eclipse.xtend.lib.annotations.Accessors
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
+
+/**
+ * Defines expression that does not have an model representation. Extends {@link DefaultDetailExpressionProvider}
+ */
+@FinalFieldsConstructor
+class RuntimeDetailExpressionProvider extends DefaultDetailExpressionProvider {
+
+ public static val RT_METHOD_GET_REPLICATION = "getReplication"
+
+ @Accessors
+ static class RuntimeMethodExpressionData {
+ //val String methodName
+ //EObject eObj
+ }
+
+ override getContextFeatures(ExpressionFeature ctx) {
+ val scope = super.getContextFeatures(ctx)
+
+ switch obj : ctx.data {
+ InterfaceItem: {
+ if (ctx.postfix == ExpressionPostfix.NONE) {
+ switch obj {
+ Port case obj.multiplicity > 1/* fall through */,
+ SPP: {
+ // not supported yet by code translation
+ //scope += createRtMethodExprFeature(RT_METHOD_GET_REPLICATION, obj)
+ }
+ }
+ }
+ }
+ }
+
+ return scope
+ }
+
+ protected def createRtMethodExprFeature(String methodName, EObject eObj) {
+ val feature = new ExpressionFeature(methodName, ExpressionPostfix.PARENTHESES)
+ feature.data = new RuntimeMethodExpressionData()
+
+ return feature
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java
index 7621e7442..6fe2c8825 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java
@@ -18,6 +18,7 @@ import org.eclipse.etrice.core.fsm.validation.FSMValidationUtilXtend.Result;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.ui.behavior.Activator;
+import org.eclipse.etrice.ui.behavior.detailcode.RuntimeDetailExpressionProvider;
import org.eclipse.etrice.ui.behavior.fsm.actioneditor.IActionCodeEditor;
import org.eclipse.etrice.ui.behavior.fsm.dialogs.AbstractMemberAwarePropertyDialog;
import org.eclipse.etrice.ui.behavior.fsm.dialogs.DetailCodeToString;
@@ -51,6 +52,7 @@ public class StatePropertyDialog extends AbstractMemberAwarePropertyDialog imple
}
}
+ private ActorClass ac;
private State state;
private boolean inherited;
@@ -73,6 +75,7 @@ public class StatePropertyDialog extends AbstractMemberAwarePropertyDialog imple
public StatePropertyDialog(Shell shell, ActorClass ac, State s, boolean edit) {
super(shell, edit?"Edit State":"View State", ac);
+ this.ac = ac;
this.state = s;
Activator.getDefault().getInjector().injectMembers(this);
@@ -207,7 +210,7 @@ public class StatePropertyDialog extends AbstractMemberAwarePropertyDialog imple
StringToDetailCode s2m, DetailCodeToString m2s) {
IActionCodeEditor entry = super.createActionCodeEditor(parent, label,
- detailCode, state, feat, s2m, m2s);
+ detailCode, state, feat, s2m, m2s, new RuntimeDetailExpressionProvider(ac));
Control control;
if (entry != null)
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 15674978d..32e9a6380 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
@@ -28,7 +28,10 @@ import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.ui.behavior.Activator;
+import org.eclipse.etrice.ui.behavior.detailcode.GuardDetailExpressionProvider;
+import org.eclipse.etrice.ui.behavior.detailcode.RuntimeDetailExpressionProvider;
import org.eclipse.etrice.ui.behavior.fsm.actioneditor.IActionCodeEditor;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
import org.eclipse.etrice.ui.behavior.fsm.dialogs.AbstractMemberAwarePropertyDialog;
import org.eclipse.etrice.ui.behavior.fsm.dialogs.DetailCodeToString;
import org.eclipse.etrice.ui.behavior.fsm.dialogs.ITransitionPropertyDialog;
@@ -91,6 +94,7 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
}
}
+ private ActorClass ac;
private Transition trans;
private List<AbstractInterfaceItem> interfaceItems = new ArrayList<AbstractInterfaceItem>();
private DetailCodeToString m2s;
@@ -107,6 +111,7 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
public TransitionPropertyDialog(Shell shell, ActorClass ac, Transition trans) {
super(shell, "Edit Transition", ac);
+ this.ac = ac;
this.trans = trans;
Activator.getDefault().getInjector().injectMembers(this);
@@ -189,7 +194,7 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
trans,
FSMPackage.eINSTANCE.getGuardedTransition_Guard(), gv,
s2m_not_null, m2s_null_empty, true, true, true,
- "empty guard");
+ "empty guard", new GuardDetailExpressionProvider(ac));
}
}
@@ -208,7 +213,7 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
trans,
FSMPackage.eINSTANCE.getCPBranchTransition_Condition(),
gv, s2m_not_null, m2s_null_empty, true, true, true,
- "empty condition");
+ "empty condition", new GuardDetailExpressionProvider(ac));
}
}
@@ -225,14 +230,14 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
createActionCodeEditor(body, "&Action Code:",
refined.getAction(), refined,
FSMPackage.eINSTANCE.getRefinedTransition_Action(),
- null, s2m, m2s, true, true, false, null);
+ null, s2m, m2s, true, true, false, null, new RuntimeDetailExpressionProvider(ac));
}
}
else
{
createActionCodeEditor(body, "&Action Code:", trans.getAction(),
trans, FSMPackage.eINSTANCE.getTransition_Action(), null,
- s2m, m2s, true, true, false, null);
+ s2m, m2s, true, true, false, null, new RuntimeDetailExpressionProvider(ac));
}
createMembersAndMessagesButtons(body);
@@ -318,11 +323,11 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
DetailCode detailCode, EObject obj, EStructuralFeature feat,
IValidator singleValidator, IConverter s2m, IConverter m2s,
boolean useMembers, boolean useMessages,
- boolean useRecvMessagesOnly, String decoratorString) {
+ boolean useRecvMessagesOnly, String decoratorString, IDetailExpressionProvider exprProvider) {
IActionCodeEditor entry = super.createActionCodeEditor(parent, label,
detailCode, obj, feat, singleValidator, null, s2m, m2s,
- useMembers, useMessages, useRecvMessagesOnly);
+ useMembers, useMessages, useRecvMessagesOnly, exprProvider);
Control control;
if (entry != null)
diff --git a/plugins/org.eclipse.etrice.ui.behavior/xtend-gen/org/eclipse/etrice/ui/behavior/detailcode/DefaultDetailExpressionProvider.java b/plugins/org.eclipse.etrice.ui.behavior/xtend-gen/org/eclipse/etrice/ui/behavior/detailcode/DefaultDetailExpressionProvider.java
new file mode 100644
index 000000000..fc88e0277
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior/xtend-gen/org/eclipse/etrice/ui/behavior/detailcode/DefaultDetailExpressionProvider.java
@@ -0,0 +1,264 @@
+/**
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ */
+package org.eclipse.etrice.ui.behavior.detailcode;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.Iterables;
+import java.util.List;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.CommunicationType;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.PortOperation;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.SAP;
+import org.eclipse.etrice.core.room.SPP;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.ui.behavior.detailcode.GuardDetailExpressionProvider;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+
+/**
+ * Defines expression for fsm detail code of an ActorClass
+ */
+@FinalFieldsConstructor
+@SuppressWarnings("all")
+public class DefaultDetailExpressionProvider extends GuardDetailExpressionProvider {
+ public List<IDetailExpressionProvider.ExpressionFeature> getInitialFeatures() {
+ final List<IDetailExpressionProvider.ExpressionFeature> scope = CollectionLiterals.<IDetailExpressionProvider.ExpressionFeature>newArrayList();
+ boolean _notEquals = (!Objects.equal(this.currentEventMessage, null));
+ if (_notEquals) {
+ VarDecl _data = this.currentEventMessage.getData();
+ IDetailExpressionProvider.ExpressionFeature _createExprFeature = this.createExprFeature(_data);
+ scope.add(_createExprFeature);
+ }
+ List<InterfaceItem> _allInterfaceItems = this.roomHelpers.getAllInterfaceItems(this.actorClass);
+ final Procedure1<InterfaceItem> _function = new Procedure1<InterfaceItem>() {
+ public void apply(final InterfaceItem it) {
+ boolean _matched = false;
+ if (!_matched) {
+ if (it instanceof SPP) {
+ boolean _isEventDriven = ((SPP)it).isEventDriven();
+ if (_isEventDriven) {
+ _matched=true;
+ }
+ }
+ if (!_matched) {
+ if (it instanceof Port) {
+ boolean _and = false;
+ boolean _isEventDriven = ((Port)it).isEventDriven();
+ if (!_isEventDriven) {
+ _and = false;
+ } else {
+ int _multiplicity = ((Port)it).getMultiplicity();
+ boolean _greaterThan = (_multiplicity > 1);
+ _and = _greaterThan;
+ }
+ if (_and) {
+ _matched=true;
+ }
+ }
+ }
+ if (_matched) {
+ IDetailExpressionProvider.ExpressionFeature _createExprFeature = DefaultDetailExpressionProvider.this.createExprFeature(it);
+ scope.add(_createExprFeature);
+ IDetailExpressionProvider.ExpressionFeature _createExprFeature_1 = DefaultDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.BRACKETS);
+ scope.add(_createExprFeature_1);
+ }
+ }
+ if (!_matched) {
+ if (it instanceof Port) {
+ int _multiplicity = ((Port)it).getMultiplicity();
+ boolean _greaterThan = (_multiplicity > 1);
+ if (_greaterThan) {
+ _matched=true;
+ }
+ }
+ if (!_matched) {
+ if (it instanceof SPP) {
+ _matched=true;
+ }
+ }
+ if (_matched) {
+ IDetailExpressionProvider.ExpressionFeature _createExprFeature_2 = DefaultDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.BRACKETS);
+ scope.add(_createExprFeature_2);
+ }
+ }
+ if (!_matched) {
+ IDetailExpressionProvider.ExpressionFeature _createExprFeature_3 = DefaultDetailExpressionProvider.this.createExprFeature(it);
+ scope.add(_createExprFeature_3);
+ }
+ }
+ };
+ IterableExtensions.<InterfaceItem>forEach(_allInterfaceItems, _function);
+ List<StandardOperation> _latestOperations = this.roomHelpers.getLatestOperations(this.actorClass);
+ final Function1<StandardOperation, IDetailExpressionProvider.ExpressionFeature> _function_1 = new Function1<StandardOperation, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final StandardOperation it) {
+ return DefaultDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.PARENTHESES);
+ }
+ };
+ List<IDetailExpressionProvider.ExpressionFeature> _map = ListExtensions.<StandardOperation, IDetailExpressionProvider.ExpressionFeature>map(_latestOperations, _function_1);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map);
+ List<Attribute> _allAttributes = this.roomHelpers.getAllAttributes(this.actorClass);
+ final Function1<Attribute, IDetailExpressionProvider.ExpressionFeature> _function_2 = new Function1<Attribute, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final Attribute it) {
+ IDetailExpressionProvider.ExpressionFeature _switchResult = null;
+ int _size = it.getSize();
+ boolean _matched = false;
+ if (!_matched) {
+ int _size_1 = it.getSize();
+ boolean _greaterThan = (_size_1 > 1);
+ if (_greaterThan) {
+ _matched=true;
+ _switchResult = DefaultDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.BRACKETS);
+ }
+ }
+ if (!_matched) {
+ _switchResult = DefaultDetailExpressionProvider.this.createExprFeature(it);
+ }
+ return _switchResult;
+ }
+ };
+ List<IDetailExpressionProvider.ExpressionFeature> _map_1 = ListExtensions.<Attribute, IDetailExpressionProvider.ExpressionFeature>map(_allAttributes, _function_2);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map_1);
+ return scope;
+ }
+
+ public List<IDetailExpressionProvider.ExpressionFeature> getContextFeatures(final IDetailExpressionProvider.ExpressionFeature ctx) {
+ this.assertNotNull(ctx);
+ final List<IDetailExpressionProvider.ExpressionFeature> scope = CollectionLiterals.<IDetailExpressionProvider.ExpressionFeature>newArrayList();
+ Object _data = ctx.getData();
+ final Object obj = _data;
+ boolean _matched = false;
+ if (!_matched) {
+ if (obj instanceof Port) {
+ int _multiplicity = ((Port)obj).getMultiplicity();
+ boolean _equals = (_multiplicity == 1);
+ if (_equals) {
+ _matched=true;
+ }
+ }
+ if (!_matched) {
+ if (obj instanceof SAP) {
+ _matched=true;
+ }
+ }
+ if (_matched) {
+ ProtocolClass _protocol = this.roomHelpers.getProtocol(((InterfaceItem)obj));
+ boolean _isConjugated = this.roomHelpers.isConjugated(((InterfaceItem)obj));
+ boolean _not = (!_isConjugated);
+ List<PortOperation> _allOperations = this.roomHelpers.getAllOperations(_protocol, _not);
+ final Function1<PortOperation, IDetailExpressionProvider.ExpressionFeature> _function = new Function1<PortOperation, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final PortOperation it) {
+ return DefaultDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.PARENTHESES);
+ }
+ };
+ List<IDetailExpressionProvider.ExpressionFeature> _map = ListExtensions.<PortOperation, IDetailExpressionProvider.ExpressionFeature>map(_allOperations, _function);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map);
+ }
+ }
+ Object _data_1 = ctx.getData();
+ final Object obj_1 = _data_1;
+ boolean _matched_1 = false;
+ if (!_matched_1) {
+ if (obj_1 instanceof InterfaceItem) {
+ _matched_1=true;
+ final ProtocolClass pc = this.roomHelpers.getProtocol(((InterfaceItem)obj_1));
+ CommunicationType _commType = pc.getCommType();
+ if (_commType != null) {
+ switch (_commType) {
+ case EVENT_DRIVEN:
+ boolean _isConjugated_1 = this.roomHelpers.isConjugated(((InterfaceItem)obj_1));
+ List<Message> _allMessages = this.roomHelpers.getAllMessages(pc, _isConjugated_1);
+ final Function1<Message, IDetailExpressionProvider.ExpressionFeature> _function_1 = new Function1<Message, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final Message it) {
+ return DefaultDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.PARENTHESES);
+ }
+ };
+ List<IDetailExpressionProvider.ExpressionFeature> _map_1 = ListExtensions.<Message, IDetailExpressionProvider.ExpressionFeature>map(_allMessages, _function_1);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map_1);
+ break;
+ case DATA_DRIVEN:
+ boolean _isConjugated_2 = this.roomHelpers.isConjugated(((InterfaceItem)obj_1));
+ if (_isConjugated_2) {
+ List<Message> _allIncomingMessages = this.roomHelpers.getAllIncomingMessages(pc);
+ final Function1<Message, IDetailExpressionProvider.ExpressionFeature> _function_2 = new Function1<Message, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final Message it) {
+ return DefaultDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.PARENTHESES);
+ }
+ };
+ List<IDetailExpressionProvider.ExpressionFeature> _map_2 = ListExtensions.<Message, IDetailExpressionProvider.ExpressionFeature>map(_allIncomingMessages, _function_2);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map_2);
+ } else {
+ List<Message> _allIncomingMessages_1 = this.roomHelpers.getAllIncomingMessages(pc);
+ final Function1<Message, IDetailExpressionProvider.ExpressionFeature> _function_3 = new Function1<Message, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final Message it) {
+ return DefaultDetailExpressionProvider.this.createExprFeature(it);
+ }
+ };
+ List<IDetailExpressionProvider.ExpressionFeature> _map_3 = ListExtensions.<Message, IDetailExpressionProvider.ExpressionFeature>map(_allIncomingMessages_1, _function_3);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map_3);
+ }
+ break;
+ case SYNCHRONOUS:
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ if (!_matched_1) {
+ if (obj_1 instanceof Attribute) {
+ RefableType _type = ((Attribute)obj_1).getType();
+ DataType _type_1 = _type.getType();
+ if ((_type_1 instanceof DataClass)) {
+ _matched_1=true;
+ RefableType _type_2 = ((Attribute)obj_1).getType();
+ DataType _type_3 = _type_2.getType();
+ final DataClass dc = ((DataClass) _type_3);
+ List<Attribute> _allAttributes = this.roomHelpers.getAllAttributes(dc);
+ final Function1<Attribute, IDetailExpressionProvider.ExpressionFeature> _function_1 = new Function1<Attribute, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final Attribute it) {
+ IDetailExpressionProvider.ExpressionFeature _xifexpression = null;
+ int _size = it.getSize();
+ boolean _greaterThan = (_size > 1);
+ if (_greaterThan) {
+ _xifexpression = DefaultDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.BRACKETS);
+ } else {
+ _xifexpression = DefaultDetailExpressionProvider.this.createExprFeature(it);
+ }
+ return _xifexpression;
+ }
+ };
+ List<IDetailExpressionProvider.ExpressionFeature> _map_1 = ListExtensions.<Attribute, IDetailExpressionProvider.ExpressionFeature>map(_allAttributes, _function_1);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map_1);
+ }
+ }
+ }
+ return scope;
+ }
+
+ public DefaultDetailExpressionProvider(final ActorClass actorClass) {
+ super(actorClass);
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/xtend-gen/org/eclipse/etrice/ui/behavior/detailcode/GuardDetailExpressionProvider.java b/plugins/org.eclipse.etrice.ui.behavior/xtend-gen/org/eclipse/etrice/ui/behavior/detailcode/GuardDetailExpressionProvider.java
new file mode 100644
index 000000000..a62e9745a
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior/xtend-gen/org/eclipse/etrice/ui/behavior/detailcode/GuardDetailExpressionProvider.java
@@ -0,0 +1,257 @@
+/**
+ * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug (initial contribution)
+ */
+package org.eclipse.etrice.ui.behavior.detailcode;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Strings;
+import com.google.common.collect.Iterables;
+import java.util.List;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.CommunicationType;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.VarDecl;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
+import org.eclipse.etrice.ui.behavior.support.SupportUtil;
+import org.eclipse.xtend.lib.annotations.Accessors;
+import org.eclipse.xtext.util.SimpleAttributeResolver;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.Extension;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.Pure;
+
+/**
+ * Defines expression for fsm guards of an ActorClass
+ * <ul>
+ * <li>attributes and operations of ActorClass</li>
+ * <li>data-driven incoming messages</li>
+ * </ul>
+ */
+@SuppressWarnings("all")
+public class GuardDetailExpressionProvider implements IDetailExpressionProvider {
+ @Accessors
+ protected final ActorClass actorClass;
+
+ @Accessors
+ protected Message currentEventMessage;
+
+ @Extension
+ protected final RoomHelpers roomHelpers;
+
+ protected final Function<EObject, String> nameProvider = SimpleAttributeResolver.NAME_RESOLVER;
+
+ public GuardDetailExpressionProvider(final ActorClass actorClass) {
+ this.actorClass = actorClass;
+ SupportUtil _instance = SupportUtil.getInstance();
+ RoomHelpers _roomHelpers = _instance.getRoomHelpers();
+ this.roomHelpers = _roomHelpers;
+ }
+
+ public List<IDetailExpressionProvider.ExpressionFeature> getInitialFeatures() {
+ final List<IDetailExpressionProvider.ExpressionFeature> scope = CollectionLiterals.<IDetailExpressionProvider.ExpressionFeature>newArrayList();
+ boolean _notEquals = (!Objects.equal(this.currentEventMessage, null));
+ if (_notEquals) {
+ VarDecl _data = this.currentEventMessage.getData();
+ IDetailExpressionProvider.ExpressionFeature _createExprFeature = this.createExprFeature(_data);
+ scope.add(_createExprFeature);
+ }
+ List<InterfaceItem> _allInterfaceItems = this.roomHelpers.getAllInterfaceItems(this.actorClass);
+ final Function1<InterfaceItem, Boolean> _function = new Function1<InterfaceItem, Boolean>() {
+ public Boolean apply(final InterfaceItem it) {
+ boolean _and = false;
+ boolean _isDataDriven = GuardDetailExpressionProvider.this.roomHelpers.isDataDriven(it);
+ if (!_isDataDriven) {
+ _and = false;
+ } else {
+ boolean _isConjugated = GuardDetailExpressionProvider.this.roomHelpers.isConjugated(it);
+ boolean _not = (!_isConjugated);
+ _and = _not;
+ }
+ return Boolean.valueOf(_and);
+ }
+ };
+ Iterable<InterfaceItem> _filter = IterableExtensions.<InterfaceItem>filter(_allInterfaceItems, _function);
+ final Function1<InterfaceItem, IDetailExpressionProvider.ExpressionFeature> _function_1 = new Function1<InterfaceItem, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final InterfaceItem it) {
+ IDetailExpressionProvider.ExpressionFeature _switchResult = null;
+ boolean _matched = false;
+ if (!_matched) {
+ if (it instanceof Port) {
+ int _multiplicity = ((Port)it).getMultiplicity();
+ boolean _greaterThan = (_multiplicity > 1);
+ if (_greaterThan) {
+ _matched=true;
+ _switchResult = GuardDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.BRACKETS);
+ }
+ }
+ }
+ if (!_matched) {
+ _switchResult = GuardDetailExpressionProvider.this.createExprFeature(it);
+ }
+ return _switchResult;
+ }
+ };
+ Iterable<IDetailExpressionProvider.ExpressionFeature> _map = IterableExtensions.<InterfaceItem, IDetailExpressionProvider.ExpressionFeature>map(_filter, _function_1);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map);
+ List<StandardOperation> _latestOperations = this.roomHelpers.getLatestOperations(this.actorClass);
+ final Function1<StandardOperation, IDetailExpressionProvider.ExpressionFeature> _function_2 = new Function1<StandardOperation, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final StandardOperation it) {
+ return GuardDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.PARENTHESES);
+ }
+ };
+ List<IDetailExpressionProvider.ExpressionFeature> _map_1 = ListExtensions.<StandardOperation, IDetailExpressionProvider.ExpressionFeature>map(_latestOperations, _function_2);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map_1);
+ List<Attribute> _allAttributes = this.roomHelpers.getAllAttributes(this.actorClass);
+ final Function1<Attribute, IDetailExpressionProvider.ExpressionFeature> _function_3 = new Function1<Attribute, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final Attribute it) {
+ IDetailExpressionProvider.ExpressionFeature _switchResult = null;
+ int _size = it.getSize();
+ boolean _matched = false;
+ if (!_matched) {
+ int _size_1 = it.getSize();
+ boolean _greaterThan = (_size_1 > 1);
+ if (_greaterThan) {
+ _matched=true;
+ _switchResult = GuardDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.BRACKETS);
+ }
+ }
+ if (!_matched) {
+ _switchResult = GuardDetailExpressionProvider.this.createExprFeature(it);
+ }
+ return _switchResult;
+ }
+ };
+ List<IDetailExpressionProvider.ExpressionFeature> _map_2 = ListExtensions.<Attribute, IDetailExpressionProvider.ExpressionFeature>map(_allAttributes, _function_3);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map_2);
+ return scope;
+ }
+
+ public List<IDetailExpressionProvider.ExpressionFeature> getContextFeatures(final IDetailExpressionProvider.ExpressionFeature ctx) {
+ this.assertNotNull(ctx);
+ final List<IDetailExpressionProvider.ExpressionFeature> scope = CollectionLiterals.<IDetailExpressionProvider.ExpressionFeature>newArrayList();
+ Object _data = ctx.getData();
+ final Object obj = _data;
+ boolean _matched = false;
+ if (!_matched) {
+ if (obj instanceof InterfaceItem) {
+ _matched=true;
+ final ProtocolClass pc = this.roomHelpers.getProtocol(((InterfaceItem)obj));
+ CommunicationType _commType = pc.getCommType();
+ if (_commType != null) {
+ switch (_commType) {
+ case DATA_DRIVEN:
+ boolean _isConjugated = this.roomHelpers.isConjugated(((InterfaceItem)obj));
+ boolean _not = (!_isConjugated);
+ if (_not) {
+ List<Message> _allIncomingMessages = this.roomHelpers.getAllIncomingMessages(pc);
+ final Function1<Message, IDetailExpressionProvider.ExpressionFeature> _function = new Function1<Message, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final Message it) {
+ return GuardDetailExpressionProvider.this.createExprFeature(it);
+ }
+ };
+ List<IDetailExpressionProvider.ExpressionFeature> _map = ListExtensions.<Message, IDetailExpressionProvider.ExpressionFeature>map(_allIncomingMessages, _function);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ if (!_matched) {
+ if (obj instanceof Attribute) {
+ RefableType _type = ((Attribute)obj).getType();
+ DataType _type_1 = _type.getType();
+ if ((_type_1 instanceof DataClass)) {
+ _matched=true;
+ RefableType _type_2 = ((Attribute)obj).getType();
+ DataType _type_3 = _type_2.getType();
+ final DataClass dc = ((DataClass) _type_3);
+ List<Attribute> _allAttributes = this.roomHelpers.getAllAttributes(dc);
+ final Function1<Attribute, IDetailExpressionProvider.ExpressionFeature> _function = new Function1<Attribute, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final Attribute it) {
+ IDetailExpressionProvider.ExpressionFeature _xifexpression = null;
+ int _size = it.getSize();
+ boolean _greaterThan = (_size > 1);
+ if (_greaterThan) {
+ _xifexpression = GuardDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.BRACKETS);
+ } else {
+ _xifexpression = GuardDetailExpressionProvider.this.createExprFeature(it);
+ }
+ return _xifexpression;
+ }
+ };
+ List<IDetailExpressionProvider.ExpressionFeature> _map = ListExtensions.<Attribute, IDetailExpressionProvider.ExpressionFeature>map(_allAttributes, _function);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map);
+ List<StandardOperation> _latestOperations = this.roomHelpers.getLatestOperations(dc);
+ final Function1<StandardOperation, IDetailExpressionProvider.ExpressionFeature> _function_1 = new Function1<StandardOperation, IDetailExpressionProvider.ExpressionFeature>() {
+ public IDetailExpressionProvider.ExpressionFeature apply(final StandardOperation it) {
+ return GuardDetailExpressionProvider.this.createExprFeature(it, IDetailExpressionProvider.ExpressionPostfix.PARENTHESES);
+ }
+ };
+ List<IDetailExpressionProvider.ExpressionFeature> _map_1 = ListExtensions.<StandardOperation, IDetailExpressionProvider.ExpressionFeature>map(_latestOperations, _function_1);
+ Iterables.<IDetailExpressionProvider.ExpressionFeature>addAll(scope, _map_1);
+ }
+ }
+ }
+ return scope;
+ }
+
+ protected IDetailExpressionProvider.ExpressionFeature createExprFeature(final EObject eObj) {
+ return this.createExprFeature(eObj, IDetailExpressionProvider.ExpressionPostfix.NONE);
+ }
+
+ protected IDetailExpressionProvider.ExpressionFeature createExprFeature(final EObject eObj, final IDetailExpressionProvider.ExpressionPostfix postfix) {
+ String _apply = this.nameProvider.apply(eObj);
+ final IDetailExpressionProvider.ExpressionFeature feature = new IDetailExpressionProvider.ExpressionFeature(_apply, postfix);
+ feature.setData(eObj);
+ return feature;
+ }
+
+ protected void assertNotNull(final IDetailExpressionProvider.ExpressionFeature feature) {
+ String _id = feature.getId();
+ boolean _isNullOrEmpty = Strings.isNullOrEmpty(_id);
+ boolean _not = (!_isNullOrEmpty);
+ Assert.isTrue(_not);
+ IDetailExpressionProvider.ExpressionPostfix _postfix = feature.getPostfix();
+ Assert.isNotNull(_postfix);
+ Object _data = feature.getData();
+ Assert.isNotNull(_data);
+ }
+
+ @Pure
+ public ActorClass getActorClass() {
+ return this.actorClass;
+ }
+
+ @Pure
+ public Message getCurrentEventMessage() {
+ return this.currentEventMessage;
+ }
+
+ public void setCurrentEventMessage(final Message currentEventMessage) {
+ this.currentEventMessage = currentEventMessage;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/xtend-gen/org/eclipse/etrice/ui/behavior/detailcode/RuntimeDetailExpressionProvider.java b/plugins/org.eclipse.etrice.ui.behavior/xtend-gen/org/eclipse/etrice/ui/behavior/detailcode/RuntimeDetailExpressionProvider.java
new file mode 100644
index 000000000..94c4e6d7c
--- /dev/null
+++ b/plugins/org.eclipse.etrice.ui.behavior/xtend-gen/org/eclipse/etrice/ui/behavior/detailcode/RuntimeDetailExpressionProvider.java
@@ -0,0 +1,71 @@
+package org.eclipse.etrice.ui.behavior.detailcode;
+
+import com.google.common.base.Objects;
+import java.util.List;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.SPP;
+import org.eclipse.etrice.ui.behavior.detailcode.DefaultDetailExpressionProvider;
+import org.eclipse.etrice.ui.behavior.fsm.detailcode.IDetailExpressionProvider;
+import org.eclipse.xtend.lib.annotations.Accessors;
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
+
+/**
+ * Defines expression that does not have an model representation. Extends {@link DefaultDetailExpressionProvider}
+ */
+@FinalFieldsConstructor
+@SuppressWarnings("all")
+public class RuntimeDetailExpressionProvider extends DefaultDetailExpressionProvider {
+ @Accessors
+ public static class RuntimeMethodExpressionData {
+ }
+
+ public final static String RT_METHOD_GET_REPLICATION = "getReplication";
+
+ public List<IDetailExpressionProvider.ExpressionFeature> getContextFeatures(final IDetailExpressionProvider.ExpressionFeature ctx) {
+ final List<IDetailExpressionProvider.ExpressionFeature> scope = super.getContextFeatures(ctx);
+ Object _data = ctx.getData();
+ final Object obj = _data;
+ boolean _matched = false;
+ if (!_matched) {
+ if (obj instanceof InterfaceItem) {
+ _matched=true;
+ IDetailExpressionProvider.ExpressionPostfix _postfix = ctx.getPostfix();
+ boolean _equals = Objects.equal(_postfix, IDetailExpressionProvider.ExpressionPostfix.NONE);
+ if (_equals) {
+ boolean _matched_1 = false;
+ if (!_matched_1) {
+ if (obj instanceof Port) {
+ int _multiplicity = ((Port)obj).getMultiplicity();
+ boolean _greaterThan = (_multiplicity > 1);
+ if (_greaterThan) {
+ _matched_1=true;
+ }
+ }
+ if (!_matched_1) {
+ if (obj instanceof SPP) {
+ _matched_1=true;
+ }
+ }
+ if (_matched_1) {
+ }
+ }
+ }
+ }
+ }
+ return scope;
+ }
+
+ protected IDetailExpressionProvider.ExpressionFeature createRtMethodExprFeature(final String methodName, final EObject eObj) {
+ final IDetailExpressionProvider.ExpressionFeature feature = new IDetailExpressionProvider.ExpressionFeature(methodName, IDetailExpressionProvider.ExpressionPostfix.PARENTHESES);
+ RuntimeDetailExpressionProvider.RuntimeMethodExpressionData _runtimeMethodExpressionData = new RuntimeDetailExpressionProvider.RuntimeMethodExpressionData();
+ feature.setData(_runtimeMethodExpressionData);
+ return feature;
+ }
+
+ public RuntimeDetailExpressionProvider(final ActorClass actorClass) {
+ super(actorClass);
+ }
+}
diff --git a/tests/org.eclipse.etrice.generator.common.tests/drafts/DetailExpressionTest.room b/tests/org.eclipse.etrice.generator.common.tests/drafts/DetailExpressionTest.room
new file mode 100644
index 000000000..0295cb7fa
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.common.tests/drafts/DetailExpressionTest.room
@@ -0,0 +1,158 @@
+RoomModel DetailExpressionTest {
+
+ import room.basic.types.* from "../../org.eclipse.etrice.modellib.c/model/Types.room"
+
+ import room.basic.service.timing.* from "../../org.eclipse.etrice.modellib.c/model/TimingService.room"
+
+ LogicalSystem System_DetailExpression {
+ SubSystemRef subSystemRef: SubSystem_DetailExpression
+ }
+
+ SubSystemClass SubSystem_DetailExpression {
+ ActorRef timer: ATimingService
+ ActorRef actorRef: Tester
+ LayerConnection ref actorRef satisfied_by timer.timer
+ LogicalThread defaultThread
+ }
+
+ async ActorClass Tester {
+ Interface {
+ Port portNotVisible : PEventdriven
+ SPP sppEvent: PEventdriven
+ }
+ Structure {
+ Port rPortEvent: PEventdriven
+ Port rPortData: PDatadriven
+ Port rReplEvent [5]: PEventdriven
+ conjugated Port cPortEvent: PEventdriven
+ conjugated Port cPortData: PDatadriven
+ conjugated Port cReplEvent [5]: PEventdriven
+ ServiceImplementation of sppEvent
+ SAP sapEvent: PTimer
+ Attribute numberArray[5] : int32
+ Attribute infoData : DDataNested
+ }
+ Behavior {
+ Operation actorOp(param: int32): boolean {
+ "return true;"
+ }
+ StateMachine {
+ Transition init: initial -> idle
+ Transition eventTrans: idle -> state1 {
+ triggers {
+ <out1: cPortEvent guard {
+ "/* TODO activate action code editor */"
+ "rPortData.in1 == numberArray[3] &&"
+ "accessibleMessageData && infoData.flag"
+ }>
+ }
+ action {
+ "// TODO syntax highlightiing"
+ "rPortEvent.out1(true);"
+ "rPortData.in1;"
+ "rReplEvent[0].out1(true);"
+ "rReplEvent.out1(true); // broadcast"
+ "cPortEvent.in1();"
+ "cPortData.in1(32);"
+ "cReplEvent[3].in1();"
+ "cReplEvent.in1(); // broadcast"
+ "sapEvent.startTimeout(1000);"
+ "sppEvent[4].out1(true);"
+ "sppEvent.out1(true); // broadcast"
+ "rPortEvent.regularOp(32);"
+ "cPortEvent.conjugatedOp(32);"
+ "actorOp(32);"
+ "int number = numberArray[0];"
+ "DData nestedData = infoData.nested;"
+ "int port = infoData.nested.tcpPort;"
+ ""
+ "// TODO content assist: special event data"
+ "int data = (accessibleMessageData)? 1 : 0;"
+ ""
+ "// -- not supported yet by code translation --"
+ "// getReplication():"
+ "// int replSize1 = rReplEvent.getReplication();"
+ "// int replSize2 = cReplEvent.getReplication();"
+ "// int replSize2 = sppEvent.getReplication();"
+ ""
+ "// DataClass operations:"
+ "// infoData.operation(32);"
+ "// infoData.nested.set(\"127.0.0.1\", 8080);"
+ }
+ }
+ Transition guardedTrans: idle -> state2 {
+ guard {
+ "rPortData.in1 == numberArray[3] && infoData.flag"
+ }
+ }
+ State idle
+ State state1
+ State state2
+ }
+ }
+ }
+
+ ProtocolClass PEventdriven {
+ incoming {
+ Message in1()
+ }
+ outgoing {
+ Message out1(accessibleMessageData:boolean)
+ }
+ regular PortClass
+ {
+ Operation regularOp(param: int32): boolean {
+ "return true;"
+ }
+ Attribute regularAttr: int32
+ }
+ conjugated PortClass
+ {
+ Operation conjugatedOp(param: int32): boolean {
+ "return true;"
+ }
+ Attribute conjugatedAttr: int32
+ }
+ }
+
+ datadriven ProtocolClass PDatadriven {
+ incoming {
+ Message in1(data: int32)
+ }
+ /* not supported yet
+ regular PortClass
+ {
+ Operation regularOp(param: int32): boolean {
+ ""
+ }
+ Attribute regularAttr: int32
+ }
+ conjugated PortClass
+ {
+ Operation conjugatedOp(param: int32): boolean {
+ ""
+ }
+ Attribute conjugatedAttr: int32
+ }
+ * /*
+ */
+ }
+
+ DataClass DDataNested {
+ Attribute flag: boolean
+ Attribute array[5]: int32
+ Attribute nested: DData
+ Operation dataOp(number: int32){
+ ""
+ }
+ }
+
+ DataClass DData {
+ Attribute iPAddr: string
+ Attribute tcpPort: int32
+ Operation dataOp(ip: string, port: int32) {
+ ""
+ }
+ }
+
+} \ No newline at end of file

Back to the top