Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracuccuru2013-04-15 09:36:44 +0000
committeracuccuru2013-04-15 09:36:44 +0000
commit4ba0b2f8f73db89b98e1681803f938e40f8602af (patch)
treeb2033668b0e340c39494ce618bb9b71c5d824821 /sandbox/Moka
parent2b2d59735152e6dfa2cbd6169763c21cac961a90 (diff)
downloadorg.eclipse.papyrus-4ba0b2f8f73db89b98e1681803f938e40f8602af.tar.gz
org.eclipse.papyrus-4ba0b2f8f73db89b98e1681803f938e40f8602af.tar.xz
org.eclipse.papyrus-4ba0b2f8f73db89b98e1681803f938e40f8602af.zip
405389: [Moka] Papyrus shall provide a generic and extendible framework for execution and debugging of models
https://bugs.eclipse.org/bugs/show_bug.cgi?id=405389
Diffstat (limited to 'sandbox/Moka')
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/.classpath7
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/.project28
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/META-INF/MANIFEST.MF30
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/build.properties5
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/brkp_16x16.gifbin0 -> 197 bytes
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/brkpd_16x16.gifbin0 -> 139 bytes
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/debug.gifbin0 -> 348 bytes
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/moka_icon.pngbin0 -> 539 bytes
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/sample.gifbin0 -> 983 bytes
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/plugin.xml211
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/Activator.java63
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/decoration/BreakpointDecoration.java106
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/handlers/MokaAbstractHandler.java65
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/handlers/ToggleBreakpointActivationHandler.java67
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/handlers/ToggleBreakpointHandler.java75
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/launch/MokaLaunchConfigurationTabGroup.java42
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/launch/SelectEObjectTab.java261
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/preferences/MokaPreferencePage.java59
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/AnimationUtils.java347
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/DebugMarkerMappingToPseudoSelector.java52
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/IPresentation.java55
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/MokaDebugModelPresentation.java179
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/views/MokaAnimationView.java141
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/.classpath7
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/.project28
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/.settings/net.sf.jautodoc.prefs5
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/META-INF/MANIFEST.MF36
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/OSGI-INF/l10n/bundle.properties7
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/about.html28
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/build.properties7
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/icons/moka_icon.pngbin0 -> 539 bytes
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/plugin.pdoc4
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/plugin.xml45
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/schema/engine.exsd125
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/Activator.java63
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/MokaConstants.java195
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/IMarshaler.java152
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/Marshaller.java336
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/EventMessage.java55
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/Start_Event.java79
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/isuspendresume/Resume_Event.java69
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/isuspendresume/Suspend_Event.java90
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/iterminate/Terminate_Event.java57
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/Ack.java32
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ReplyMessage.java30
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/istackframe/GetVariables_Reply.java58
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ithread/GetStackFrames_Reply.java59
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ivalue/GetValueString_Reply.java57
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ivariable/GetReferenceTypeName_Reply.java57
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ivariable/GetValue_Reply.java58
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/RequestMessage.java30
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ibreakpointlistener/AddBreakpoint_Request.java56
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ibreakpointlistener/RemoveBreakpoint_Request.java56
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/idisconnect/Disconnect_Request.java33
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/istackframe/GetVariables_Request.java61
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/isuspendresume/Resume_Request.java75
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/isuspendresume/Suspend_Request.java75
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/iterminate/Terminate_Request.java57
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ithread/GetStackFrames_Request.java57
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ivalue/GetValueString_Request.java57
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ivariable/GetReferenceTypeName_Request.java59
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ivariable/GetValue_Request.java57
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaBreakpoint.java196
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaDebugElement.java109
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaDebugTarget.java741
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaJobChangeListener.java54
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaProcess.java305
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaStackFrame.java345
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaThread.java329
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaValue.java124
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaVariable.java138
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/engine/AbstractExecutionEngine.java536
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/engine/IExecutionEngine.java198
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/engine/MokaExecutionEngineJob.java54
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/launch/EditorUtils.java133
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/launch/MokaLaunchDelegate.java214
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/launch/OpenPapyrusEditorRunnable.java61
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/locator/MokaSourceLocator.java78
80 files changed, 7834 insertions, 0 deletions
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/.classpath b/sandbox/Moka/org.eclipse.papyrus.moka.ui/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/.project b/sandbox/Moka/org.eclipse.papyrus.moka.ui/.project
new file mode 100644
index 00000000000..0b08087e3e6
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.moka.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/.settings/org.eclipse.jdt.core.prefs b/sandbox/Moka/org.eclipse.papyrus.moka.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..44217f8c068
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/META-INF/MANIFEST.MF b/sandbox/Moka/org.eclipse.papyrus.moka.ui/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..a4c7a8faf69
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Ui
+Bundle-SymbolicName: org.eclipse.papyrus.moka.ui;singleton:=true
+Bundle-Version: 0.10.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.moka.ui.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.moka;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
+ org.eclipse.debug.core;bundle-version="3.8.0",
+ org.eclipse.debug.ui;bundle-version="3.9.0",
+ org.eclipse.papyrus.infra.widgets;bundle-version="0.10.0",
+ org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
+ org.eclipse.gef;bundle-version="3.9.0",
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.7.0",
+ org.eclipse.papyrus.uml.diagram.common;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.services.decoration;bundle-version="0.10.0",
+ org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.3.0",
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.0",
+ org.eclipse.ui.ide;bundle-version="3.9.0",
+ org.eclipse.papyrus.editor;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.gmfdiag.css;bundle-version="0.10.0",
+ org.eclipse.e4.ui.css.core;bundle-version="0.10.100",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.services.markerlistener;bundle-version="0.10.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.papyrus.moka.ui.presentation
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/build.properties b/sandbox/Moka/org.eclipse.papyrus.moka.ui/build.properties
new file mode 100644
index 00000000000..6f20375d6c7
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/brkp_16x16.gif b/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/brkp_16x16.gif
new file mode 100644
index 00000000000..a831fe72782
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/brkp_16x16.gif
Binary files differ
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/brkpd_16x16.gif b/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/brkpd_16x16.gif
new file mode 100644
index 00000000000..74b26c31a4d
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/brkpd_16x16.gif
Binary files differ
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/debug.gif b/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/debug.gif
new file mode 100644
index 00000000000..d90a29fead8
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/debug.gif
Binary files differ
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/moka_icon.png b/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/moka_icon.png
new file mode 100644
index 00000000000..67391356053
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/moka_icon.png
Binary files differ
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/sample.gif b/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/sample.gif
new file mode 100644
index 00000000000..34fb3c9d8cb
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/icons/sample.gif
Binary files differ
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/plugin.xml b/sandbox/Moka/org.eclipse.papyrus.moka.ui/plugin.xml
new file mode 100644
index 00000000000..9960bfa42eb
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/plugin.xml
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup">
+ <menu
+ icon="icons/moka_icon.png"
+ id="org.eclipse.papyrus.views.modelexplorer.popup.moka"
+ label="Moka">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.papyrus.views.modelexplorer.popup.moka">
+ <menu
+ icon="icons/debug.gif"
+ id="org.eclipse.papyrus.views.modelexplorer.popup.moka.debug"
+ label="Debug">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.papyrus.views.modelexplorer.popup.moka.debug">
+ <command
+ commandId="org.eclipse.papyrus.moka.togglebreakpoint"
+ icon="icons/brkp_16x16.gif"
+ id="org.eclipse.papyrus.moka.togglebreakpoint"
+ label="Toggle breakpoint"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.moka.togglebreakpointactivation"
+ icon="icons/brkpd_16x16.gif"
+ id="org.eclipse.papyrus.moka.togglebreakpointactivation"
+ label="Toggle breakpoint activation"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu">
+ <menu
+ icon="icons/moka_icon.png"
+ id="org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu.moka"
+ label="Moka">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu.moka">
+ <menu
+ icon="icons/debug.gif"
+ id="org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu.moka.debug"
+ label="Debug">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu.moka.debug">
+ <command
+ commandId="org.eclipse.papyrus.moka.togglebreakpoint"
+ icon="icons/brkp_16x16.gif"
+ id="org.eclipse.papyrus.moka.togglebreakpoint.diagram"
+ label="Toggle breakpoint"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.moka.togglebreakpointactivation"
+ icon="icons/brkpd_16x16.gif"
+ id="org.eclipse.papyrus.moka.togglebreakpointactivation.diagram"
+ label="Toggle breakpoint activation"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.moka.ui.breakpoint.handlers.ToggleBreakpointHandler"
+ description="ToggleBreakpoint"
+ id="org.eclipse.papyrus.moka.togglebreakpoint"
+ name="ToggleBreakpoing">
+ </command>
+ <command
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.moka.ui.breakpoint.handlers.ToggleBreakpointActivationHandler"
+ description="ToggleBreakpointActivation"
+ id="org.eclipse.papyrus.moka.togglebreakpointactivation"
+ name="ToggleBreakpointActivation">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.debugModelPresentations">
+ <debugModelPresentation
+ class="org.eclipse.papyrus.moka.ui.presentation.MokaDebugModelPresentation"
+ id="org.eclipse.papyrus.moka">
+ </debugModelPresentation>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <launchConfigurationTabGroup
+ class="org.eclipse.papyrus.moka.ui.launch.MokaLaunchConfigurationTabGroup"
+ id="org.eclipse.papyrus.moka.ui.launchConfigurationTabGroup"
+ type="org.eclipse.papyrus.moka.launchConfiguration">
+ </launchConfigurationTabGroup>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+ configTypeID="org.eclipse.papyrus.moka.launchConfiguration"
+ icon="icons/moka_icon.png"
+ id="org.eclipse.papyrus.moka.ui.launchConfigurationTypeImage">
+ </launchConfigurationTypeImage>
+ </extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.eclipse.papyrus.moka.ui.preferences.MokaPreferencePage"
+ id="org.eclipse.papyrus.moka.ui.preferences"
+ name="Moka preference page">
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.services.decoration.decorationSpecificFunctions">
+ <client
+ class="org.eclipse.papyrus.moka.ui.breakpoint.decoration.BreakpointDecoration"
+ decorationType="org.eclipse.papyrus.moka.breakpointmarker">
+ </client>
+ </extension>
+ <extension
+ id="org.eclipse.papyrus.moka.ui.suspendedmarker"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.papyrus.modelmarker">
+ </super>
+ <persistent
+ value="false">
+ </persistent>
+ </extension>
+ <extension
+ id="org.eclipse.papyrus.moka.ui.animationmarker"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.papyrus.modelmarker">
+ </super>
+ <persistent
+ value="false">
+ </persistent>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.gmfdiag.css.markertopseudoselectormappingprovider">
+ <provider
+ class="org.eclipse.papyrus.moka.ui.presentation.DebugMarkerMappingToPseudoSelector">
+ </provider>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.eclipse.debug.ui.DebugPerspective">
+ <view
+ id="org.eclipse.papyrus.moka.ui.views.MokaAnimationView"
+ ratio="0.25"
+ relationship="right"
+ relative="org.eclipse.ui.views.ProblemView">
+ </view>
+ </perspectiveExtension>
+ </extension>
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ id="org.eclipse.papyrus.moka.ui"
+ name="Moka Animation View Category">
+ </category>
+ <view
+ category="org.eclipse.papyrus.moka.ui"
+ class="org.eclipse.papyrus.moka.ui.views.MokaAnimationView"
+ icon="icons/moka_icon.png"
+ id="org.eclipse.papyrus.moka.ui.views.MokaAnimationView"
+ name="Animation">
+ </view>
+ </extension>
+
+</plugin>
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/Activator.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/Activator.java
new file mode 100644
index 00000000000..46a62bdfee1
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/Activator.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.moka.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/decoration/BreakpointDecoration.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/decoration/BreakpointDecoration.java
new file mode 100644
index 00000000000..da452e52f4e
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/decoration/BreakpointDecoration.java
@@ -0,0 +1,106 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui.breakpoint.decoration;
+
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions;
+import org.eclipse.papyrus.infra.services.decoration.util.Decoration.PreferedPosition;
+import org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.eclipse.papyrus.moka.ui.Activator;
+
+/**
+ * An implementation of IDecorationSpecificFunctions, in order to attach
+ * specific decorations to Moka Breakpoint Markers.
+ *
+ */
+public class BreakpointDecoration implements IDecorationSpecificFunctions {
+
+ public static final String activeBreakpoint16 = "icons/brkp_16x16.gif";
+
+ public static final String inActiveBreakpoint16 = "icons/brkpd_16x16.gif";
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions#getImageDescriptorForGE(org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker)
+ */
+ public ImageDescriptor getImageDescriptorForGE(IPapyrusMarker marker) {
+ org.eclipse.papyrus.infra.widgets.Activator widgetsActivator = org.eclipse.papyrus.infra.widgets.Activator.getDefault();
+ ImageDescriptor overlay = null;
+ boolean isEnabled = marker.getAttribute(IBreakpoint.ENABLED, false);
+ if(isEnabled) {
+ overlay = widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, activeBreakpoint16);
+ }
+ else {
+ overlay = widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, inActiveBreakpoint16);
+ }
+
+ return overlay;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions#getImageDescriptorForME(org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker)
+ */
+ public ImageDescriptor getImageDescriptorForME(IPapyrusMarker marker) {
+ org.eclipse.papyrus.infra.widgets.Activator widgetsActivator = org.eclipse.papyrus.infra.widgets.Activator.getDefault();
+ ImageDescriptor overlay = null;
+ boolean isEnabled = marker.getAttribute(IBreakpoint.ENABLED, false);
+ if(isEnabled) {
+ overlay = widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, activeBreakpoint16);
+ }
+ else {
+ overlay = widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, inActiveBreakpoint16);
+ }
+
+ return overlay;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions#getPreferedPosition(org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker)
+ */
+ public PreferedPosition getPreferedPosition(IPapyrusMarker marker) {
+ return PreferedPosition.SOUTH_EAST;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions#getMessage(org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker)
+ */
+ public String getMessage(IPapyrusMarker marker) {
+ boolean isEnabled = marker.getAttribute(IBreakpoint.ENABLED, false) ;
+ return (isEnabled ? "" : "disabled ") + "breakpoint" ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions#getPriority(org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker)
+ */
+ public int getPriority(IPapyrusMarker marker) {
+ return 0; // all markers have same priority (and we should not have multiple markers on the same model element).
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions#supportsMarkerPropagation()
+ */
+ public MarkChildren supportsMarkerPropagation() {
+ return MarkChildren.NO;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions#markerPropagation(org.eclipse.emf.common.util.EList)
+ */
+ public IPapyrusDecoration markerPropagation(EList<IPapyrusDecoration> childDecorations) {
+ return null;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/handlers/MokaAbstractHandler.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/handlers/MokaAbstractHandler.java
new file mode 100644
index 00000000000..5610524e1ce
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/handlers/MokaAbstractHandler.java
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui.breakpoint.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.emf.utils.BusinessModelResolver;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * An abstract handler, used as a basis for ToggleBreakpointActivationHandler, and ToggleBreakpointHandler.
+ *
+ */
+public abstract class MokaAbstractHandler extends AbstractHandler {
+
+ /**
+ * <pre>
+ * Get the selected element, the first selected element if several are selected or null
+ * if no selection or the selection is not an {@link EObject}.
+ *
+ * @return selected {@link EObject} or null
+ * </pre>
+ *
+ */
+ protected EObject getSelectedElement() {
+ EObject eObject = null;
+ Object selection = null;
+
+ // Get current selection
+ selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+
+ // Get first element if the selection is an IStructuredSelection
+ if(selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+ selection = structuredSelection.getFirstElement();
+ }
+
+ // Treat non-null selected object (try to adapt and return EObject)
+ if(selection != null) {
+ if(selection instanceof IAdaptable) {
+ selection = ((IAdaptable)selection).getAdapter(EObject.class);
+ }
+
+ Object businessObject = BusinessModelResolver.getInstance().getBusinessModel(selection);
+ if(businessObject instanceof EObject) {
+ eObject = (EObject)businessObject;
+ }
+ }
+ return eObject;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/handlers/ToggleBreakpointActivationHandler.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/handlers/ToggleBreakpointActivationHandler.java
new file mode 100644
index 00000000000..350d911d167
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/handlers/ToggleBreakpointActivationHandler.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui.breakpoint.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointManager;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.debug.MokaBreakpoint;
+
+/**
+ * An handler for managing activation/deactivation of a Moka Breakpoint
+ *
+ */
+public class ToggleBreakpointActivationHandler extends MokaAbstractHandler implements IHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ EObject selectedElement = this.getSelectedElement() ;
+ String selectedElementURI = EcoreUtil.getURI(selectedElement).toString() ;
+ if (selectedElement != null) {
+ IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager() ;
+ IBreakpoint[] breakpoints = breakpointManager.getBreakpoints(MokaConstants.MOKA_DEBUG_MODEL_ID) ;
+ IBreakpoint alreadyDefinedBreakpoint = null ;
+ for (int i = 0 ; i < breakpoints.length && alreadyDefinedBreakpoint == null ; i++) {
+ MokaBreakpoint breakpoint = (MokaBreakpoint)breakpoints[i] ;
+ EObject eObjectOfBreakpoint = breakpoint.getModelElement() ;
+ if (eObjectOfBreakpoint != null && EcoreUtil.getURI(eObjectOfBreakpoint).toString().equals(selectedElementURI)) {
+ alreadyDefinedBreakpoint = breakpoint ;
+ }
+ }
+
+ if (alreadyDefinedBreakpoint != null) {
+ try {
+ boolean enabledOrDisabled = !alreadyDefinedBreakpoint.isEnabled() ;
+ alreadyDefinedBreakpoint.setEnabled(enabledOrDisabled) ;
+ DebugPlugin.getDefault().getBreakpointManager().fireBreakpointChanged(alreadyDefinedBreakpoint) ;
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ return null;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/handlers/ToggleBreakpointHandler.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/handlers/ToggleBreakpointHandler.java
new file mode 100644
index 00000000000..58465be61d5
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/breakpoint/handlers/ToggleBreakpointHandler.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui.breakpoint.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointManager;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.debug.MokaBreakpoint;
+
+/**
+ * A handler for managing creation/destruction of a Moka Breakpoint
+ *
+ */
+public class ToggleBreakpointHandler extends MokaAbstractHandler implements IHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ EObject selectedElement = this.getSelectedElement() ;
+ String selectedElementURI = EcoreUtil.getURI(selectedElement).toString() ;
+ if (selectedElement != null) {
+ IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager() ;
+ IBreakpoint[] breakpoints = breakpointManager.getBreakpoints(MokaConstants.MOKA_DEBUG_MODEL_ID) ;
+ IBreakpoint alreadyDefinedBreakpoint = null ;
+ for (int i = 0 ; i < breakpoints.length && alreadyDefinedBreakpoint == null ; i++) {
+ MokaBreakpoint breakpoint = (MokaBreakpoint)breakpoints[i] ;
+ String eObjectOfBreakpointUri = null ;
+ try {
+ eObjectOfBreakpointUri = (String)breakpoint.getMarker().getAttribute(EValidator.URI_ATTRIBUTE);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (eObjectOfBreakpointUri.equals(selectedElementURI)) {
+ alreadyDefinedBreakpoint = breakpoint ;
+ }
+ }
+ try {
+ if (alreadyDefinedBreakpoint != null) {
+ breakpointManager.removeBreakpoint(alreadyDefinedBreakpoint, true) ;
+ }
+ else {
+ MokaBreakpoint breakpoint = new MokaBreakpoint() ;
+ breakpoint.toggleBreakpoint(selectedElement) ;
+ breakpointManager.addBreakpoint(breakpoint) ;
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ return null;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/launch/MokaLaunchConfigurationTabGroup.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/launch/MokaLaunchConfigurationTabGroup.java
new file mode 100644
index 00000000000..28cd62f9d53
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/launch/MokaLaunchConfigurationTabGroup.java
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui.launch;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+
+/**
+ * A tab group for edition of Moka launch configurations
+ *
+ */
+public class MokaLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
+
+ public MokaLaunchConfigurationTabGroup() {
+ // Do nothing
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
+ */
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+ new SelectEObjectTab(),
+ new CommonTab()
+ };
+ setTabs(tabs);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/launch/SelectEObjectTab.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/launch/SelectEObjectTab.java
new file mode 100644
index 00000000000..3dbf8c3c6fb
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/launch/SelectEObjectTab.java
@@ -0,0 +1,261 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui.launch;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
+import org.eclipse.papyrus.infra.emf.providers.strategy.SemanticEMFContentProvider;
+import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog;
+import org.eclipse.papyrus.infra.widgets.providers.WorkspaceContentProvider;
+import org.eclipse.papyrus.moka.launch.MokaLaunchDelegate;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+
+/**
+ * A tab used as part of a MokaLaunchConfigurationTabGroup.
+ * It enables to select a resource, a model element in this
+ * resource (this is the root element for the execution),
+ * and to specify arguments for the execution.
+ *
+ */
+public class SelectEObjectTab extends AbstractLaunchConfigurationTab {
+
+ protected String labelText = "EObject selection" ;
+ protected Label selectedResourceLabel ;
+ protected Label selectedEObjectLabel ;
+ protected Text selectedResourceText ;
+ protected Text selectedEObjectText ;
+ protected Button browseButton ;
+ protected Button browseEObjectButton ;
+ protected Label argsLabel ;
+ protected Text argsText ;
+ protected IFile currentFile = null ;
+ protected EObject currentEObject = null ;
+ protected ResourceSet resourceSet = null ;
+
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.BORDER);
+ setControl(comp) ;
+ comp.setLayout(new GridLayout(3, false)) ;
+ this.createSelectedResourceText(comp) ;
+ this.createBrowseWorkspaceButton(comp, "Browse", null, false, 1) ;
+ this.createSelectedEObjectText(comp) ;
+ this.createBrowseResourceButton(comp, "Browse", null, false, 1) ;
+ this.createArgsText(comp) ;
+ }
+
+ protected void createSelectedResourceText(Composite parent) {
+ selectedResourceLabel = new Label(parent, SWT.NONE);
+ selectedResourceLabel.setText("Selected resource:");
+ selectedResourceLabel.setToolTipText("Press Browse to selecte a new resource");
+ selectedResourceText = new Text(parent, SWT.BORDER) ;
+ selectedResourceText.setEditable(false) ;
+ //selectedResourceText.setText("No resource selected") ;
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ selectedResourceText.setLayoutData(gd) ;
+ selectedResourceText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ }
+
+ protected void createBrowseWorkspaceButton(Composite parent, String label, Image image, boolean checked, int hspan) {
+ browseButton = new Button(parent, SWT.BORDER);
+ browseButton.setFont(parent.getFont());
+ browseButton.setSelection(checked);
+ if(image != null) {
+ browseButton.setImage(image);
+ }
+ if(label != null) {
+ browseButton.setText(label);
+ }
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ gd.horizontalSpan = hspan;
+ browseButton.setLayoutData(gd) ;
+
+ browseButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+
+ TreeSelectorDialog dialog = new TreeSelectorDialog(getShell());
+ if(labelText != null) {
+ dialog.setTitle(labelText);
+ }
+ dialog.setContentProvider(new WorkspaceContentProvider());
+ dialog.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
+
+ if(currentFile != null && currentFile.exists()) {
+ dialog.setInitialSelections(new IFile[]{ currentFile });
+ }
+
+ dialog.open() ;
+ Object[] selection = dialog.getResult() ;
+ if (dialog.getReturnCode() == Dialog.OK && selection.length > 0 && (selection[0] instanceof IFile)) {
+ currentFile = (IFile)selection[0] ;
+ URI fileURI = URI.createPlatformResourceURI(currentFile.getFullPath().toString(), true) ;
+ selectedResourceText.setText(fileURI.toString()) ;
+ }
+ }
+ });
+ }
+
+ protected void createSelectedEObjectText(Composite parent) {
+ selectedEObjectLabel = new Label(parent, SWT.NONE);
+ selectedEObjectLabel.setText("Selected eObject:");
+ selectedEObjectLabel.setToolTipText("Press Browse to select the EObject to execute");
+ selectedEObjectText = new Text(parent, SWT.BORDER) ;
+ selectedEObjectText.setEditable(false) ;
+ //selectedEObjectText.setText("No eObject selected") ;
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ selectedEObjectText.setLayoutData(gd) ;
+ selectedEObjectText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ }
+
+ protected void createBrowseResourceButton(Composite parent, String label, Image image, boolean checked, int hspan) {
+ browseEObjectButton = new Button(parent, SWT.BORDER);
+ browseEObjectButton.setFont(parent.getFont());
+ browseEObjectButton.setSelection(checked);
+ if(image != null) {
+ browseEObjectButton.setImage(image);
+ }
+ if(label != null) {
+ browseEObjectButton.setText(label);
+ }
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ gd.horizontalSpan = hspan;
+ browseEObjectButton.setLayoutData(gd) ;
+
+ browseEObjectButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ if (selectedResourceText == null || selectedResourceText.isDisposed())
+ return ;
+ String resourcePath = selectedResourceText.getText() ;
+ if (resourceSet == null) ;
+ resourceSet = new ResourceSetImpl() ;
+ @SuppressWarnings("unused")
+ Resource resource = resourceSet.getResource(URI.createURI(resourcePath), true) ;
+
+ TreeSelectorDialog dialog = new TreeSelectorDialog(getShell());
+ if(labelText != null) {
+ dialog.setTitle(labelText);
+ }
+ dialog.setContentProvider(new SemanticEMFContentProvider(resourceSet));
+ dialog.setLabelProvider(new EMFLabelProvider());
+
+ if(currentEObject != null) {
+ dialog.setInitialSelections(new EObject[]{currentEObject});
+ }
+
+ dialog.open() ;
+ Object[] selection = dialog.getResult() ;
+ if (dialog.getReturnCode() == Dialog.OK && selection.length > 0 && (selection[0] instanceof EObject)) {
+ currentEObject = (EObject)selection[0] ;
+ selectedEObjectText.setText(new EMFLabelProvider().getText(currentEObject)) ;
+ }
+ }
+ });
+ }
+
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ }
+
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ try {
+ String init_uri = configuration.getAttribute(MokaLaunchDelegate.URI_ATTRIBUTE_NAME, "") ;
+ selectedResourceText.setText(init_uri) ;
+ if (! init_uri.equals("")) {
+ currentFile = (IFile)ResourcesPlugin.getWorkspace().getRoot().findMember(init_uri);
+ URI uri = URI.createURI(init_uri) ;
+ if (resourceSet == null)
+ resourceSet = new ResourceSetImpl() ;
+ Resource resource = resourceSet.getResource(uri, true) ;
+ if (resource != null) {
+ String init_fragment = configuration.getAttribute(MokaLaunchDelegate.FRAGMENT_ATTRIBUTE_NAME, "") ;
+ currentEObject = resource.getEObject(init_fragment) ;
+ selectedEObjectText.setText(new EMFLabelProvider().getText(currentEObject)) ;
+ }
+ else {
+ resourceSet = null ;
+ }
+ }
+ String init_args = configuration.getAttribute(MokaLaunchDelegate.ARGS_ATTRIBUTE_NAME, "") ;
+ argsText.setText(init_args) ;
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected void createArgsText(Composite parent) {
+ argsLabel = new Label(parent, SWT.NONE) ;
+ argsLabel.setText("Args:") ;
+ argsLabel.setToolTipText("Specify arguments for the execution of the EObject") ;
+ GridData gdLabel = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gdLabel.horizontalSpan = 3 ;
+ gdLabel.verticalSpan = 1 ;
+ argsLabel.setLayoutData(gdLabel) ;
+
+ argsText = new Text(parent, SWT.BORDER) ;
+ argsText.setEditable(true) ;
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.horizontalSpan = 3 ;
+ gd.verticalSpan = 3 ;
+ argsText.setLayoutData(gd) ;
+ argsText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ }
+
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ configuration.setAttribute(MokaLaunchDelegate.URI_ATTRIBUTE_NAME, selectedResourceText.getText()) ;
+ if (currentEObject != null) {
+ configuration.setAttribute(MokaLaunchDelegate.FRAGMENT_ATTRIBUTE_NAME, currentEObject.eResource().getURIFragment(currentEObject)) ;
+ }
+ configuration.setAttribute(MokaLaunchDelegate.ARGS_ATTRIBUTE_NAME, argsText.getText()) ;
+ }
+
+ public String getName() {
+ return "EObject selection";
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/preferences/MokaPreferencePage.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/preferences/MokaPreferencePage.java
new file mode 100644
index 00000000000..03a4568d9e5
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/preferences/MokaPreferencePage.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui.preferences;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * A preference page for Moka. It enables to select the
+ * default execution engine, to be used when a launch
+ * configuration is started.
+ * FIXME It should part of Papyrus preferences
+ *
+ */
+public class MokaPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+ public MokaPreferencePage() {
+ super(GRID);
+ setPreferenceStore(org.eclipse.papyrus.moka.Activator.getDefault().getPreferenceStore());
+ setDescription("");
+ }
+
+ public void init(IWorkbench workbench) {
+ }
+
+ @Override
+ protected void createFieldEditors() {
+ String[][] names = getRegisteredExecutionEnginesAsStringArray();
+ this.addField(new RadioGroupFieldEditor(MokaConstants.MOKA_DEFAULT_EXECUTION_ENGINE_PREF, "Default execution engine", 1, names, getFieldEditorParent()));
+ }
+
+ protected String[][] getRegisteredExecutionEnginesAsStringArray() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] config = registry.getConfigurationElementsFor(MokaConstants.MOKA_ENGINE_EXTENSION_POINT_ID);
+ String[][] names = new String[config.length][2];
+ for(int i = 0; i < config.length; i++) {
+ names[i][0] = config[i].getNamespaceIdentifier();
+ names[i][1] = config[i].getNamespaceIdentifier();
+ }
+ return names;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/AnimationUtils.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/AnimationUtils.java
new file mode 100644
index 00000000000..83a17b0c403
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/AnimationUtils.java
@@ -0,0 +1,347 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui.presentation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.RootEditPart;
+import org.eclipse.gef.ui.parts.GraphicalEditor;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;
+import org.eclipse.papyrus.infra.services.markerlistener.PapyrusMarkerAdapter;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.debug.MokaBreakpoint;
+import org.eclipse.papyrus.moka.launch.EditorUtils;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * Some facilities to manage animation in diagrams.
+ *
+ */
+public class AnimationUtils {
+
+ /**
+ * The static instance for this class
+ */
+ protected static AnimationUtils eInstance = null ;
+
+ /**
+ * An EObject -> 'Suspended' marker map
+ */
+ protected static Map<EObject, IPapyrusMarker> eObjectToSuspendedMarker = new HashMap<EObject, IPapyrusMarker>() ;
+
+ /**
+ * An EObject -> 'Animation' marker map
+ */
+ protected static Map<EObject, IPapyrusMarker> eObjectToAnimationMarker = new HashMap<EObject, IPapyrusMarker>() ;
+
+ /**
+ * An EObject -> List<Diagram> map
+ */
+ protected static Map<EObject, List<Diagram>> eObjectToDiagrams = new HashMap<EObject, List<Diagram>>() ;
+
+ private AnimationUtils() {
+
+ }
+
+ public static void init() {
+ // Reinitializes hash maps
+ eObjectToAnimationMarker = new HashMap<EObject, IPapyrusMarker>() ;
+ eObjectToSuspendedMarker = new HashMap<EObject, IPapyrusMarker>() ;
+ eObjectToDiagrams = new HashMap<EObject, List<Diagram> >() ;
+ }
+
+ /**
+ * Returns an instance of AnimationUtils. Guarantees that AnimationUtils is instantiated only once.
+ *
+ * @return An instance of AnimationUtils
+ */
+ public static AnimationUtils getInstance() {
+ if (eInstance == null)
+ eInstance = new AnimationUtils() ;
+ return eInstance ;
+ }
+
+ /**
+ * Retrieves all diagrams in which the given model element has a graphical representation
+ *
+ * @param modelElement The model element for which diagrams where it appears have to be retrieved
+ * @return all diagrams in which the given model element has a graphical representation
+ */
+ public List<Diagram> getDiagrams(EObject modelElement) {
+ List<Diagram> matchingDiagrams = eObjectToDiagrams.get(modelElement) ;
+ if (matchingDiagrams != null) {
+ return matchingDiagrams ;
+ }
+
+ Resource resource = modelElement.eResource() ;
+ ResourceSet resourceSet = resource.getResourceSet() ;
+
+ final String resourceNotationURI = modelElement.eResource().getURI().toString().replaceAll(".uml", ".notation") ;
+ @SuppressWarnings("unused")
+ Resource notationResource = resourceSet.getResource(URI.createURI(resourceNotationURI), true) ;
+ List<EObject> matchingObjects = new ArrayList<EObject>() ;
+ matchingObjects.add(modelElement) ;
+
+ Map<EObject, Collection<Setting>> maps = EcoreUtil.UsageCrossReferencer.findAll(matchingObjects, resourceSet);
+ matchingDiagrams = new ArrayList<Diagram>() ;
+
+ for(Object key : maps.keySet()) {
+ for(Setting setting : maps.get(key)) {
+ if(setting.getEObject() instanceof View) {
+ Diagram diagram = ((View)setting.getEObject()).getDiagram();
+ if(! matchingDiagrams.contains(diagram)) {
+ matchingDiagrams.add(diagram) ;
+ }
+ }
+ }
+ }
+
+ eObjectToDiagrams.put(modelElement, matchingDiagrams) ;
+
+ return matchingDiagrams ;
+ }
+
+ /**
+ * In the case where the list of diagrams for the given modelElement has already been retrieved,
+ * resets this list
+ *
+ * @param modelElement The model element for which the list of diagrams has to be reset
+ */
+ public void resetDiagrams(EObject modelElement) {
+ eObjectToDiagrams.remove(modelElement) ;
+ }
+
+ /**
+ * Opens the given diagram (or puts focus on diagram if this diagram is already opened) in the current active papyrus editor.
+ * By construction, the active papyrus editor is supposed to be opened with the appropriate .di file.
+ * openDiagram is called by MokaDebugModelPresentation.addAnnotations(), which is always called after MokaDebugModelPresentation.getEditorInput() is called.
+ * MokaDebugModelPresentation.getEditorInput() returns a FileEditorInput for the .di model to which the given Diagram belongs.
+ *
+ * @param diagram The diagram to be opened.
+ */
+ public void openDiagram(final Diagram diagram, boolean closeOpenedDiagrams) {
+ IEditorPart part = EditorUtils.getEditorPart(diagram) ;
+ ServicesRegistry servicesRegistry = (ServicesRegistry)part.getAdapter(ServicesRegistry.class);
+ try {
+ final IPageManager pageMngr = ServiceUtils.getInstance().getIPageManager(servicesRegistry) ;
+ try {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (pageMngr.isOpen(diagram))
+ pageMngr.selectPage(diagram) ;
+ else {
+ TransactionalEditingDomain domain = (TransactionalEditingDomain)EMFHelper.resolveEditingDomain(diagram) ;
+ OpenDiagramCommand updateCommand = new OpenDiagramCommand(diagram, pageMngr, domain);
+ domain.getCommandStack().execute(updateCommand) ;
+ }
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace() ;
+ }
+ } catch (ServiceException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ /**
+ * A convenience method for retrieving the diagram edit part corresponding to a graphical editor.
+ *
+ * @return the diagram edit part corresponding to the given editor
+ */
+ public RootEditPart getRootEditPart(GraphicalEditor editor) {
+ return (RootEditPart)editor.getAdapter(EditPart.class);
+ }
+
+ /**
+ * Adds a "Suspended" marker to the given semantic element
+ *
+ * @param semanticElement The semantic element to which a "Suspended" marker has to be attached
+ */
+ public void addSuspendedMarker(EObject semanticElement) {
+ if (eObjectToSuspendedMarker.get(semanticElement) != null)
+ // Marker already exists
+ return ;
+ if (semanticElement.eIsProxy())
+ semanticElement = resolve(semanticElement) ;
+ IResource iresource = MokaBreakpoint.getIResource(semanticElement.eResource()) ;
+ try {
+ if (iresource != null) {
+ String uriOfSemanticElement = EcoreUtil.getURI(semanticElement).toString() ;
+ IMarker marker = iresource.createMarker(MokaConstants.MOKA_SUSPENDED_MARKER_ID);
+ marker.setAttribute(EValidator.URI_ATTRIBUTE, uriOfSemanticElement) ;
+ eObjectToSuspendedMarker.put(semanticElement, PapyrusMarkerAdapter.wrap(semanticElement.eResource(), marker)) ;
+ }
+ } catch (CoreException ce) {
+ ce.printStackTrace() ;
+ }
+ }
+
+ /**
+ * Removes the "Suspended" marker for all semantic elements suspended in the context of the given thread
+ *
+ * @param thread The thread for which "Suspend" markers have to be removed from suspended semantic elements
+ */
+ public void removeSuspendedMarker(IThread thread) {
+ for (EObject key : eObjectToSuspendedMarker.keySet()) {
+ IPapyrusMarker stackFrameMarker = eObjectToSuspendedMarker.get(key) ;
+ try {
+ stackFrameMarker.delete() ;
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ eObjectToSuspendedMarker.clear() ;
+ }
+
+ /**
+ * Adds an "Animation" marker to the given semantic element
+ *
+ * @param semanticElement The semantic element to which an "Animation" marker has to be attached
+ */
+ public void addAnimationMarker(EObject semanticElement) {
+ if (eObjectToAnimationMarker.get(semanticElement) != null)
+ // Marker already exists
+ return ;
+ if (semanticElement.eIsProxy())
+ semanticElement = resolve(semanticElement) ;
+ IResource iresource = MokaBreakpoint.getIResource(semanticElement.eResource()) ;
+ try {
+ if (iresource != null) {
+ String uriOfSemanticElement = EcoreUtil.getURI(semanticElement).toString() ;
+ if (MokaConstants.MOKA_OPEN_DIAGRAM_IN_AUTOMATIC_ANIMATION) {
+ List<Diagram> diagrams = getDiagrams(semanticElement) ;
+ for (Diagram d : diagrams) {
+ openDiagram(d, false) ;
+ }
+ }
+ IMarker marker = iresource.createMarker(MokaConstants.MOKA_ANIMATION_MARKER_ID);
+ marker.setAttribute(EValidator.URI_ATTRIBUTE, uriOfSemanticElement) ;
+ eObjectToAnimationMarker.put(semanticElement, PapyrusMarkerAdapter.wrap(semanticElement.eResource(), marker)) ;
+ }
+ } catch (CoreException ce) {
+ ce.printStackTrace() ;
+ }
+ }
+
+ /**
+ * Removes the "Animation" marker associated with the given semantic element, if any
+ *
+ * @param semanticElement The semantic element to which an "Animation" marker has to be attached
+ */
+ public void removeAnimationMarker(EObject semanticElement) {
+ if (semanticElement.eIsProxy())
+ semanticElement = resolve(semanticElement) ;
+ IPapyrusMarker stackFrameMarker = eObjectToAnimationMarker.get(semanticElement) ;
+ if (stackFrameMarker != null) {
+ try {
+ stackFrameMarker.delete() ;
+ eObjectToAnimationMarker.remove(semanticElement) ;
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Resolve the given semantic element in the case where it is a proxy.
+ * This is supposed to happen only when, in the course of execution,
+ * the editor for the model being executed is closed.
+ * This may imply re-creation of a new IEditorPart.
+ *
+ * @param semanticElement The semantic element that needs to be resolved
+ * @return the resolved semantic element
+ */
+ public static EObject resolve(EObject semanticElement) {
+ if (semanticElement.eIsProxy()) {
+ getInstance().resetDiagrams(semanticElement) ;
+ IEditorPart part = EditorUtils.getEditorPart(semanticElement) ;
+ ServicesRegistry registry = (ServicesRegistry) part.getAdapter(ServicesRegistry.class) ;
+ ResourceSet resourceSet = null ;
+ try {
+ resourceSet = registry.getService(ModelSet.class) ;
+ } catch (ServiceException e) {
+ resourceSet = new ResourceSetImpl() ;
+ }
+ semanticElement = EcoreUtil.resolve(semanticElement, resourceSet) ;
+ }
+ return semanticElement ;
+ }
+
+ /**
+ * A command for opening a diagram
+ *
+ */
+ protected class OpenDiagramCommand extends RecordingCommand {
+
+ protected Diagram diagram ;
+ protected IPageManager pageMngr ;
+
+ /**
+ * Constructor for the OpenDiagramCommand.
+ *
+ * @param diagram The diagram to be opened
+ * @param pageMngr The page manager to be used for opening the diagram
+ * @param domain The editing domain in which the command will be executed
+ */
+ public OpenDiagramCommand(Diagram diagram, IPageManager pageMngr, TransactionalEditingDomain domain) {
+ super(domain) ;
+ this.diagram = diagram ;
+ this.pageMngr = pageMngr ;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor
+ * , org.eclipse.core.runtime.IAdaptable)
+ */
+ @Override
+ protected void doExecute() {
+ this.pageMngr.openPage(diagram) ;
+ //this.pageMngr.selectPage(diagram) ;
+ }
+
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/DebugMarkerMappingToPseudoSelector.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/DebugMarkerMappingToPseudoSelector.java
new file mode 100644
index 00000000000..a9481db8d4d
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/DebugMarkerMappingToPseudoSelector.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui.presentation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.papyrus.infra.gmfdiag.css.service.IMarkerToPseudoSelectorMappingProvider;
+import org.eclipse.papyrus.moka.MokaConstants;
+
+/**
+ * A mapping between markers defined by Moka,
+ * a corresponding CSS pseudo selectors.
+ * These pseudo selectors can be used in CSS styles,
+ * in order to attach a specific style with one of these markers.
+ *
+ */
+public class DebugMarkerMappingToPseudoSelector implements IMarkerToPseudoSelectorMappingProvider {
+
+ protected Map<String, String> mappings ;
+
+ protected final static String BREAKPOINT_MARKER_PSEUDO_SELECTOR = "breakpoint" ;
+ protected final static String SUSPENDED_MARKER_PSEUDO_SELECTOR = "suspended" ;
+ protected final static String ANIMATION_MARKER_PSEUDO_SELECTOR = "animation" ;
+
+ public DebugMarkerMappingToPseudoSelector() {
+ // Do nothing
+ }
+
+ public Map<String, String> getMappings() {
+ if (this.mappings == null) {
+ this.mappings = new HashMap<String, String>() ;
+ // Adds pseudo selectors for 'breakpoint', 'suspended' and 'animation' markers
+ this.mappings.put(MokaConstants.MOKA_BREAKPOINT_MARKER_ID, BREAKPOINT_MARKER_PSEUDO_SELECTOR) ;
+ this.mappings.put(MokaConstants.MOKA_SUSPENDED_MARKER_ID, SUSPENDED_MARKER_PSEUDO_SELECTOR) ;
+ this.mappings.put(MokaConstants.MOKA_ANIMATION_MARKER_ID, ANIMATION_MARKER_PSEUDO_SELECTOR) ;
+ }
+ return this.mappings ;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/IPresentation.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/IPresentation.java
new file mode 100644
index 00000000000..79e1ea13312
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/IPresentation.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui.presentation;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This interface shall be implemented by specific IStrackFrame, IVariable and IValue,
+ * in order to return some specific presentation information, which are automatically
+ * used by the debug framework.
+ *
+ */
+public interface IPresentation {
+
+ /**
+ * Returns the label for this element.
+ * This is effective for the following kind of element:
+ * - IStackFrame
+ *
+ * @return The label for this element
+ */
+ public String getLabel() ;
+
+ /**
+ * Returns the details corresponding to this element.
+ * Details are displayed in the Variable panel of the Debug perspective.
+ * This is effective for the following kind of element:
+ * - IValue
+ *
+ * @return Returns the details corresponding to this element.
+ */
+ public String getDetails() ;
+
+ /**
+ * Returns the image for this element.
+ * This is effective for the following kind of element:
+ * - IStackFrame
+ * - IVariable
+ *
+ * @return The image for this element.
+ */
+ public Image getImage() ;
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/MokaDebugModelPresentation.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/MokaDebugModelPresentation.java
new file mode 100644
index 00000000000..da45600286c
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/MokaDebugModelPresentation.java
@@ -0,0 +1,179 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui.presentation;
+
+import java.util.List;
+
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.ui.IDebugEditorPresentation;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.IValueDetailListener;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.debug.MokaBreakpoint;
+import org.eclipse.papyrus.moka.debug.MokaStackFrame;
+import org.eclipse.papyrus.moka.launch.EditorUtils;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * An implementation of IDebugModelPresentation and IDebugEditorPresentation
+ *
+ */
+public class MokaDebugModelPresentation implements IDebugModelPresentation, IDebugEditorPresentation {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ */
+ public void addListener(ILabelProviderListener listener) {
+ // Do nothing
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
+ */
+ public void dispose() {
+ // Do nothing
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
+ */
+ public boolean isLabelProperty(Object element, String property) {
+ // Do nothing
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ */
+ public void removeListener(ILabelProviderListener listener) {
+ // Do nothing
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(java.lang.Object)
+ */
+ public IEditorInput getEditorInput(Object element) {
+ EObject modelElement = null ;
+ if (element instanceof MokaBreakpoint) {
+ modelElement = ((MokaBreakpoint)element).getModelElement() ;
+ }
+ else if (element instanceof EObject) {
+ modelElement = (EObject)element ;
+ }
+ if (modelElement == null) {
+ return null ;
+ }
+ FileEditorInput input = EditorUtils.getFileEditorInput(modelElement) ;
+ return input ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ISourcePresentation#getEditorId(org.eclipse.ui.IEditorInput, java.lang.Object)
+ */
+ public String getEditorId(IEditorInput input, Object element) {
+ return MokaConstants.PAPYRUS_EDITOR_ID ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDebugModelPresentation#setAttribute(java.lang.String, java.lang.Object)
+ */
+ public void setAttribute(String attribute, Object value) {
+ // Do nothing
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDebugModelPresentation#getImage(java.lang.Object)
+ */
+ public Image getImage(Object element) {
+ if (element instanceof IPresentation) {
+ return ((IPresentation)element).getImage() ;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDebugModelPresentation#getText(java.lang.Object)
+ */
+ public String getText(Object element) {
+ if (element instanceof IPresentation) {
+ return ((IPresentation)element).getLabel() ;
+ }
+ if (element instanceof MokaBreakpoint) {
+ return ((MokaBreakpoint)element).getLabel() ;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDebugModelPresentation#computeDetail(org.eclipse.debug.core.model.IValue, org.eclipse.debug.ui.IValueDetailListener)
+ */
+ public void computeDetail(IValue value, IValueDetailListener listener) {
+ if (value instanceof IPresentation) {
+ String detail = ((IPresentation)value).getDetails() ;
+ if (detail != null) {
+ listener.detailComputed(value, detail) ;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDebugEditorPresentation#addAnnotations(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IStackFrame)
+ */
+ public boolean addAnnotations(IEditorPart editorPart, IStackFrame frame) {
+ if (frame instanceof MokaStackFrame) {
+ MokaStackFrame stackFrame = (MokaStackFrame)frame ;
+ EObject modelElement = stackFrame.getModelElement() ;
+ if(modelElement.eIsProxy()) {
+ AnimationUtils.getInstance().resetDiagrams(modelElement) ;
+ ServicesRegistry servicesRegistry = (ServicesRegistry)editorPart.getAdapter(ServicesRegistry.class) ;
+ ResourceSet resourceSet = null ;
+ try {
+ resourceSet = servicesRegistry.getService(ModelSet.class) ;
+ } catch (ServiceException e) {
+ resourceSet = new ResourceSetImpl() ;
+ }
+ modelElement = (EcoreUtil.resolve(modelElement, resourceSet)) ;
+ }
+ List<Diagram> diagrams = AnimationUtils.getInstance().getDiagrams(modelElement) ;
+ for (Diagram diagram : diagrams) {
+ AnimationUtils.getInstance().openDiagram(diagram, false) ;
+ }
+ AnimationUtils.getInstance().addSuspendedMarker(modelElement) ;
+ return true ;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.IDebugEditorPresentation#removeAnnotations(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IThread)
+ */
+ public void removeAnnotations(IEditorPart editorPart, IThread thread) {
+ AnimationUtils.getInstance().removeSuspendedMarker(thread) ;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/views/MokaAnimationView.java b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/views/MokaAnimationView.java
new file mode 100644
index 00000000000..e497ab1e1ed
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/views/MokaAnimationView.java
@@ -0,0 +1,141 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.ui.views;
+
+
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Slider;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+
+/**
+ * A view which enables to control:
+ * - Automatic animation,
+ * - Automatic diagram opening during automatic animation
+ * - Delay between two animation steps
+ */
+
+public class MokaAnimationView extends ViewPart {
+
+ /**
+ * The ID of the view as specified by the extension.
+ */
+ public static final String ID = "org.eclipse.papyrus.moka.ui.views.MokaAnimationView";
+
+ /**
+ * The constructor.
+ */
+ public MokaAnimationView() {
+ // Do nothing
+ }
+
+ /**
+ * Creates the view and initializes it.
+ */
+ public void createPartControl(Composite parent) {
+ Composite self = new Composite(parent, SWT.BORDER) ;
+
+ // A Composite needs a layout
+ GridLayout gridLayout = new GridLayout(2, false);
+ gridLayout.marginWidth = 5;
+ gridLayout.marginHeight = 5;
+ gridLayout.verticalSpacing = 0;
+ gridLayout.horizontalSpacing = 0;
+ self.setLayout(gridLayout);
+
+ // Self has a layout. We can put objects inside.
+ final Button autoAnimButton = new Button(self, SWT.CHECK) ;
+ GridData autoAnimGridData = new GridData();
+ autoAnimGridData.horizontalSpan = 2 ;
+ autoAnimButton.setLayoutData(autoAnimGridData);
+ autoAnimButton.setText("Animate") ;
+ autoAnimButton.setSelection(MokaConstants.MOKA_AUTOMATIC_ANIMATION) ;
+
+ final Button autoOpenButton = new Button(self, SWT.CHECK) ;
+ GridData autoOpenGridData = new GridData();
+ autoOpenGridData.horizontalSpan = 2 ;
+ autoOpenButton.setLayoutData(autoOpenGridData);
+ autoOpenButton.setText("Open diagrams automatically") ;
+ autoOpenButton.setSelection(MokaConstants.MOKA_OPEN_DIAGRAM_IN_AUTOMATIC_ANIMATION) ;
+ autoOpenButton.setEnabled(MokaConstants.MOKA_AUTOMATIC_ANIMATION) ;
+
+ final Slider animationDelaySlider = new Slider(self, SWT.HORIZONTAL) ;
+ final Label sliderLabel = new Label(self, SWT.NONE) ;
+ sliderLabel.setText("Animation delay: " + MokaConstants.MOKA_ANIMATION_DELAY + " ms") ;
+ animationDelaySlider.setEnabled(MokaConstants.MOKA_AUTOMATIC_ANIMATION) ;
+ animationDelaySlider.setValues(MokaConstants.MOKA_ANIMATION_DELAY /*selection*/,
+ 50 /*minimum*/,
+ 550 /*maximum*/,
+ 50 /*thumb*/,
+ 10 /*increment*/,
+ 50 /*pageIncrement*/) ;
+
+ autoAnimButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ MokaConstants.MOKA_AUTOMATIC_ANIMATION = autoAnimButton.getSelection() ;
+ autoOpenButton.setEnabled(MokaConstants.MOKA_AUTOMATIC_ANIMATION) ;
+ animationDelaySlider.setEnabled(MokaConstants.MOKA_AUTOMATIC_ANIMATION) ;
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Nothing special
+ }
+ }) ;
+
+ autoOpenButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ MokaConstants.MOKA_OPEN_DIAGRAM_IN_AUTOMATIC_ANIMATION = autoOpenButton.getSelection() ;
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Nothing special
+ }
+ }) ;
+
+ animationDelaySlider.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ MokaConstants.MOKA_ANIMATION_DELAY = animationDelaySlider.getSelection() ;
+ sliderLabel.setText("Animation delay: " + MokaConstants.MOKA_ANIMATION_DELAY + " ms ") ;
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Nothing special
+ }
+ }) ;
+
+ // Create the help context id for the viewer's control
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(self, "org.eclipse.papyrus.moka.ui.viewer");
+ }
+
+
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ // Do nothing
+ }
+} \ No newline at end of file
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/.classpath b/sandbox/Moka/org.eclipse.papyrus.moka/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/.project b/sandbox/Moka/org.eclipse.papyrus.moka/.project
new file mode 100644
index 00000000000..2b559f59f30
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.moka</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/.settings/net.sf.jautodoc.prefs b/sandbox/Moka/org.eclipse.papyrus.moka/.settings/net.sf.jautodoc.prefs
new file mode 100644
index 00000000000..5e08e5ce35d
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/.settings/net.sf.jautodoc.prefs
@@ -0,0 +1,5 @@
+add_header=true
+eclipse.preferences.version=1
+header_text=/*****************************************************************************\r\n * Copyright (c) 2013 CEA LIST.\r\n *\r\n * \r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n *\r\n * Contributors\:\r\n * CEA LIST - Initial API and implementation\r\n *\r\n *****************************************************************************/
+replace_header=true
+replacements=<?xml version\="1.0" standalone\="yes"?>\n\n<replacements>\n<replacement key\="get" scope\="1" mode\="0">Gets the</replacement>\n<replacement key\="set" scope\="1" mode\="0">Sets the</replacement>\n<replacement key\="add" scope\="1" mode\="0">Adds the</replacement>\n<replacement key\="edit" scope\="1" mode\="0">Edits the</replacement>\n<replacement key\="remove" scope\="1" mode\="0">Removes the</replacement>\n<replacement key\="init" scope\="1" mode\="0">Inits the</replacement>\n<replacement key\="parse" scope\="1" mode\="0">Parses the</replacement>\n<replacement key\="create" scope\="1" mode\="0">Creates the</replacement>\n<replacement key\="build" scope\="1" mode\="0">Builds the</replacement>\n<replacement key\="is" scope\="1" mode\="0">Checks if is</replacement>\n<replacement key\="print" scope\="1" mode\="0">Prints the</replacement>\n<replacement key\="has" scope\="1" mode\="0">Checks for</replacement>\n</replacements>\n\n
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/.settings/org.eclipse.jdt.core.prefs b/sandbox/Moka/org.eclipse.papyrus.moka/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..44217f8c068
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/META-INF/MANIFEST.MF b/sandbox/Moka/org.eclipse.papyrus.moka/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..769f6b0e515
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/META-INF/MANIFEST.MF
@@ -0,0 +1,36 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Moka
+Bundle-SymbolicName: org.eclipse.papyrus.moka;singleton:=true
+Bundle-Version: 0.10.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.moka.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.debug.core;bundle-version="3.7.100",
+ org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
+ org.eclipse.uml2.uml;bundle-version="4.0.1",
+ org.eclipse.emf.transaction;bundle-version="1.4.0",
+ org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.6.0",
+ org.eclipse.papyrus.infra.gmfdiag.css;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.services.markerlistener;bundle-version="0.10.0",
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0",
+ org.eclipse.ui.ide;bundle-version="3.9.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.papyrus.moka,
+ org.eclipse.papyrus.moka.communication,
+ org.eclipse.papyrus.moka.communication.event,
+ org.eclipse.papyrus.moka.communication.event.isuspendresume,
+ org.eclipse.papyrus.moka.communication.event.iterminate,
+ org.eclipse.papyrus.moka.communication.reply,
+ org.eclipse.papyrus.moka.communication.reply.istackframe,
+ org.eclipse.papyrus.moka.communication.reply.ithread,
+ org.eclipse.papyrus.moka.communication.reply.ivalue,
+ org.eclipse.papyrus.moka.communication.reply.ivariable,
+ org.eclipse.papyrus.moka.communication.request,
+ org.eclipse.papyrus.moka.communication.request.isuspendresume,
+ org.eclipse.papyrus.moka.communication.request.iterminate,
+ org.eclipse.papyrus.moka.debug,
+ org.eclipse.papyrus.moka.engine,
+ org.eclipse.papyrus.moka.launch
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/OSGI-INF/l10n/bundle.properties b/sandbox/Moka/org.eclipse.papyrus.moka/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000000..9cc642aa713
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,7 @@
+#Properties file for org.eclipse.papyrus.moka
+command.description = Execute the behavior with the registered execution engine
+command.name = Execute
+page.name = Moka
+extension-point.name = ExecutionEngine
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = Moka (Incubation) \ No newline at end of file
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/about.html b/sandbox/Moka/org.eclipse.papyrus.moka/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/build.properties b/sandbox/Moka/org.eclipse.papyrus.moka/build.properties
new file mode 100644
index 00000000000..d26a07ad76d
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ schema/
+src.includes = about.html
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/icons/moka_icon.png b/sandbox/Moka/org.eclipse.papyrus.moka/icons/moka_icon.png
new file mode 100644
index 00000000000..67391356053
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/icons/moka_icon.png
Binary files differ
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/plugin.pdoc b/sandbox/Moka/org.eclipse.papyrus.moka/plugin.pdoc
new file mode 100644
index 00000000000..45da37f970e
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/plugin.pdoc
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<doc:Documentation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:doc="http://www.eclipse.org/papyrus/documentation/plugin/documentation" description="Moka is an extendible framework for model execution.">
+ <referent firstName="Arnaud" lastName="Cuccuru" eMail="arnaud.cuccuru@cea.fr" currentCompany="CEA LIST"/>
+</doc:Documentation>
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/plugin.xml b/sandbox/Moka/org.eclipse.papyrus.moka/plugin.xml
new file mode 100644
index 00000000000..a8de5353a7f
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/plugin.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="engine" name="ExecutionEngine" schema="schema/engine.exsd"/>
+ <extension
+ point="org.eclipse.debug.core.breakpoints">
+ <breakpoint
+ class="org.eclipse.papyrus.moka.debug.MokaBreakpoint"
+ id="org.eclipse.papyrus.moka.breakpoint"
+ markerType="org.eclipse.papyrus.moka.breakpointmarker">
+ </breakpoint>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ delegate="org.eclipse.papyrus.moka.launch.MokaLaunchDelegate"
+ id="org.eclipse.papyrus.moka.launchConfiguration"
+ modes="run, debug"
+ name="Moka launch configuration"
+ sourceLocatorId="org.eclipse.papyrus.moka.sourceLocator">
+ </launchConfigurationType>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.sourceLocators">
+ <sourceLocator
+ class="org.eclipse.papyrus.moka.locator.MokaSourceLocator"
+ id="org.eclipse.papyrus.moka.sourceLocator"
+ name="Moka source locator">
+ </sourceLocator>
+ </extension>
+ <extension
+ id="org.eclipse.papyrus.moka.breakpointmarker"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.debug.core.breakpointMarker">
+ </super>
+ <super
+ type="org.eclipse.papyrus.modelmarker">
+ </super>
+ <persistent
+ value="true">
+ </persistent>
+ </extension>
+
+</plugin>
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/schema/engine.exsd b/sandbox/Moka/org.eclipse.papyrus.moka/schema/engine.exsd
new file mode 100644
index 00000000000..7761e4cac56
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/schema/engine.exsd
@@ -0,0 +1,125 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.moka" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.papyrus.moka" id="engine" name="ExecutionEngine"/>
+ </appinfo>
+ <documentation>
+ Contributing to this extension point enables to register a new execution engine for Moka. A contribution just have to provide an implementation for the IExecutionEngine interface.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ <documentation>
+ Contributing to this extension point enables to register a new execution engine for Moka. A contribution just have to provide an implementation for the IExecutionEngine interface.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="engine"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="engine">
+ <complexType>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.moka.engine.IExecutionEngine"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ Cf. org.eclipse.papyrus.moka.fuml.FUMLExecutionEngine
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ /*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/Activator.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/Activator.java
new file mode 100644
index 00000000000..b4dc65c1ae4
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/Activator.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.moka"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/MokaConstants.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/MokaConstants.java
new file mode 100644
index 00000000000..0037ea30442
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/MokaConstants.java
@@ -0,0 +1,195 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka;
+
+public class MokaConstants {
+
+ public final static String PAPYRUS_EDITOR_ID = "org.eclipse.papyrus.infra.core.papyrusEditor" ;
+
+ /**
+ * The ID of the "moka debug model". All moka debug elements use/return this ID.
+ */
+ public final static String MOKA_DEBUG_MODEL_ID = "org.eclipse.papyrus.moka" ;
+
+ /**
+ * ID of the moka breakpoint marker type
+ */
+ public final static String MOKA_BREAKPOINT_MARKER_ID = "org.eclipse.papyrus.moka.breakpointmarker" ;
+
+ /**
+ * ID of the moka suspended marker type
+ */
+ public final static String MOKA_SUSPENDED_MARKER_ID = "org.eclipse.papyrus.moka.ui.suspendedmarker" ;
+
+ /**
+ * ID of the moka animation marker type
+ */
+ public final static String MOKA_ANIMATION_MARKER_ID ="org.eclipse.papyrus.moka.ui.animationmarker" ;
+
+ /**
+ * ID of the moka 'engine' extension point
+ */
+ public final static String MOKA_ENGINE_EXTENSION_POINT_ID = "org.eclipse.papyrus.moka.engine" ;
+
+ /**
+ * ID of the moka 'Default execution engine'
+ */
+ public final static String MOKA_DEFAULT_EXECUTION_ENGINE_PREF = "Default execution engine" ;
+
+ /**
+ * To be used by clients providing 'auto-steps' execution.
+ */
+ public static boolean MOKA_AUTOMATIC_ANIMATION = true ;
+
+ /**
+ * To be used by clients providing 'auto-steps' execution.
+ */
+ public static boolean MOKA_OPEN_DIAGRAM_IN_AUTOMATIC_ANIMATION = true ;
+
+ /**
+ * Default delay between two animation steps.
+ * To be used by clients providing automatic animation.
+ */
+ public static int MOKA_ANIMATION_DELAY = 50 ;
+
+
+ /**
+ * Constants underlying the communication protocol between the debug target and the actual execution engine
+ */
+
+ //////////
+ // Generic
+ //////////
+ /**
+ * Prefix for generic acknowledgment sent by the target program
+ */
+ public final static String ack = "ack" ;
+ /**
+ * Prefix for a start event
+ */
+ public final static String event_start = "event_start" ;
+
+ //////////////////////////
+ // IDebugTarget
+ //////////////////////////
+ /**
+ * Prefix for a getThreads request
+ */
+ public final static String request_getThreads = "request_getThreads" ;
+ /**
+ * Prefix for a getName request
+ */
+ public final static String request_getName = "request_getName" ;
+
+ //////////////////////////
+ // IBreakpointListener
+ //////////////////////////
+ /**
+ * Prefix for an addBreakpoint request (called in the MokaDebugTarget realization of IBreakpointListener.breakpointAdded and IBreakpointListener.breakpointChanged)
+ */
+ public final static String request_addBreakpoint = "request_addBreakpoint" ;
+ /**
+ * Prefix for a removeBreakpoint request (called in the MokaDebugTarget realization of IBreakpointListener.breakpointRemoved and IBreakpointListener.breakpointChanged)
+ */
+ public final static String request_removeBreakpoint = "request_removeBreakpoint" ;
+
+ //////////////////////////
+ // IDisconnect
+ //////////////////////////
+ /**
+ * Prefix for a disconnect request
+ */
+ public final static String request_disconnect = "request_disconnect" ;
+
+ //////////////////////////
+ // IMemoryBlockRetrieval
+ //////////////////////////
+ /**
+ * Prefix for a getMemoryBlock request
+ */
+ public final static String request_getMemoryBlock = "request_getMemoryBlock" ;
+
+ //////////////////////////
+ // ISuspendResume
+ //////////////////////////
+ /**
+ * Prefix for a resume request
+ */
+ public final static String request_resume = "request_resume" ;
+ /**
+ * Prefix for a resume event
+ */
+ public final static String event_resume = "event_resume" ;
+ /**
+ * Prefix for a suspend request
+ */
+ public final static String request_suspend = "request_suspend" ;
+ /**
+ * Prefix for a suspend event
+ */
+ public final static String event_suspend = "event_suspend" ;
+
+ //////////////////////////
+ // ITerminate
+ //////////////////////////
+ /**
+ * Prefix for a terminate request
+ */
+ public final static String request_terminate = "request_terminate" ;
+ /**
+ * Prefix for a terminate event
+ */
+ public final static String event_terminate = "event_terminate" ;
+
+ //////////////////////////
+ // IThread
+ //////////////////////////
+ /**
+ * Prefix for a getStackFrames request
+ */
+ public final static String request_getStackFrames = "request_getStackFrames" ;
+
+ //////////////////////////
+ // IStackFrame
+ //////////////////////////
+ /**
+ * Prefix for a getVariables request
+ */
+ public final static String request_getVariables = "request_getVariables" ;
+ /**
+ * Prefix for a getRegisterGroups request
+ */
+ public final static String request_getRegisterGroups = "request_getRegisterGroups" ;
+
+ //////////////////////////
+ // IVariable
+ //////////////////////////
+ /**
+ * Prefix for a getValue request
+ */
+ public final static String request_getValue = "request_getValue" ;
+ /**
+ * Prefix for a getReferenceTypeName request
+ */
+ public final static String request_getReferenceTypeName = "request_getReferenceTypeName" ;
+
+ //////////////////////////
+ // IValue
+ //////////////////////////
+ /**
+ * Prefix for a getValueString request
+ */
+ public final static String request_getValueString = "request_getValueString" ;
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/IMarshaler.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/IMarshaler.java
new file mode 100644
index 00000000000..8573cab63f9
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/IMarshaler.java
@@ -0,0 +1,152 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication;
+
+import org.eclipse.papyrus.moka.communication.event.Start_Event;
+import org.eclipse.papyrus.moka.communication.event.isuspendresume.Resume_Event;
+import org.eclipse.papyrus.moka.communication.event.isuspendresume.Suspend_Event;
+import org.eclipse.papyrus.moka.communication.event.iterminate.Terminate_Event;
+import org.eclipse.papyrus.moka.communication.reply.istackframe.GetVariables_Reply;
+import org.eclipse.papyrus.moka.communication.reply.ithread.GetStackFrames_Reply;
+import org.eclipse.papyrus.moka.communication.reply.ivalue.GetValueString_Reply;
+import org.eclipse.papyrus.moka.communication.reply.ivariable.GetReferenceTypeName_Reply;
+import org.eclipse.papyrus.moka.communication.reply.ivariable.GetValue_Reply;
+import org.eclipse.papyrus.moka.communication.request.ibreakpointlistener.AddBreakpoint_Request;
+import org.eclipse.papyrus.moka.communication.request.ibreakpointlistener.RemoveBreakpoint_Request;
+import org.eclipse.papyrus.moka.communication.request.idisconnect.Disconnect_Request;
+import org.eclipse.papyrus.moka.communication.request.istackframe.GetVariables_Request;
+import org.eclipse.papyrus.moka.communication.request.isuspendresume.Resume_Request;
+import org.eclipse.papyrus.moka.communication.request.isuspendresume.Suspend_Request;
+import org.eclipse.papyrus.moka.communication.request.iterminate.Terminate_Request;
+import org.eclipse.papyrus.moka.communication.request.ithread.GetStackFrames_Request;
+import org.eclipse.papyrus.moka.communication.request.ivalue.GetValueString_Request;
+import org.eclipse.papyrus.moka.communication.request.ivariable.GetReferenceTypeName_Request;
+import org.eclipse.papyrus.moka.communication.request.ivariable.GetValue_Request;
+
+/**
+ * Interface used to establish communications between the debug target
+ * and the actual execution engine. For the different kind of communications
+ * that may occur (events, requests, replies), this interface defines a set
+ * of methods corresponding to marshaling / unmarshaling of corresponding
+ * messages.
+ * The idea is to separate the logic of request, reply and event creation/handling
+ * from the logic of communication realization. The communication package introduces
+ * a hierarchy of message classes, representing the different kind of requests,
+ * replies and events that can be exchanged between the actual execution engine and
+ * the debug model implementation.
+ *
+ */
+public interface IMarshaler {
+
+ //******************
+ // Marshalling / Unmarshalling of a CREATE DebugEvent (emitted when the target program is ready to receive requests)
+ //
+ // ******************/
+ public String start_event_marshal(Start_Event event) ;
+ public Start_Event start_event_unmarshal(String request) ;
+
+ //******************
+ // Marshalling / Unmarshalling of Request related to IBreakpointListener.breakpointAdded() and IBreakpointListener.breakpointChanged()
+ //
+ // ******************/
+ public String addBreakpoint_request_marshal(AddBreakpoint_Request request) ;
+ public AddBreakpoint_Request addBreakpoint_request_unmarshal(String request) ;
+
+ //******************
+ // Marshalling / Unmarshalling of Request related to IBreakpointListener.breakpointRemoved() and IBreakpointListener.breakpointChanged()
+ //
+ // ******************/
+ public String removeBreakpoint_request_marshal(RemoveBreakpoint_Request request) ;
+ public RemoveBreakpoint_Request removeBreakpoint_request_unmarshal(String request) ;
+
+ //******************
+ // Marshalling / Unmarshalling of Request related to IDisconnect.disconnect()
+ //
+ // ******************/
+ public String disconnect_request_marshal(Disconnect_Request request) ;
+ public Disconnect_Request disconnect_request_unmarshal(String request) ;
+
+ //******************
+ // Marshalling / Unmarshalling of Request/Event related to ISuspendResume.resume()
+ //
+ // ******************/
+ public String resume_request_marshal(Resume_Request request) ;
+ public Resume_Request resume_request_unmarshal(String request) ;
+ public String resume_event_marshal(Resume_Event event) ;
+ public Resume_Event resume_event_unmarshal(String event) ;
+
+ //******************
+ // Marshalling / Unmarshalling of Request/Event related to ISuspendResume.suspend()
+ //
+ // ******************/
+ public String suspend_request_marshal(Suspend_Request request) ;
+ public Suspend_Request suspend_request_unmarshal(String request) ;
+ public String suspend_event_marshal(Suspend_Event event) ;
+ public Suspend_Event suspend_event_unmarshal(String event) ;
+
+ //******************
+ // Marshalling / Unmarshalling of Request/Event related to ITerminate.terminate()
+ //
+ // ******************/
+ public String terminate_request_marshal(Terminate_Request request) ;
+ public Terminate_Request terminate_request_unmarshal(String request) ;
+ public String terminate_event_marshal(Terminate_Event event) ;
+ public Terminate_Event terminate_event_unmarshal(String event) ;
+
+ //******************
+ // Marshalling / Unmarshalling of Request/Reply related to IThread.getStackFrames()
+ //
+ // ******************/
+ public String getStackFrames_request_marshal(GetStackFrames_Request request) ;
+ public GetStackFrames_Request getStackFrames_request_unmarshal(String request) ;
+ public String getStackFrames_reply_marshal(GetStackFrames_Reply reply) ;
+ public GetStackFrames_Reply getStackFrames_reply_unmarshal(String reply) ;
+
+ //******************
+ // Marshalling / Unmarshalling of Request/Reply related to IStackFrame.getVariables()
+ //
+ // ******************/
+ public String getVariables_request_marshal(GetVariables_Request request) ;
+ public GetVariables_Request getVariables_request_unmarshal(String request) ;
+ public String getVariables_reply_marshal(GetVariables_Reply reply) ;
+ public GetVariables_Reply getVariables_reply_unmarshal(String reply) ;
+
+
+ //******************
+ // Marshalling / Unmarshalling of Request/Reply related to IVariable.getValue()
+ //
+ // ******************/
+ public String getValue_request_marshal(GetValue_Request request) ;
+ public GetValue_Request getValue_request_unmarshal(String request) ;
+ public String getValue_reply_marshal(GetValue_Reply reply) ;
+ public GetValue_Reply getValue_reply_unmarshal(String reply) ;
+
+ //******************
+ // Marshalling / Unmarshalling of Request/Reply related to IVariable.getReferenceTypeName()
+ //
+ // ******************/
+ public String getReferenceTypeName_request_marshal(GetReferenceTypeName_Request request) ;
+ public GetReferenceTypeName_Request getReferenceTypeName_request_unmarshal(String request) ;
+ public String getReferenceTypeName_reply_marshal(GetReferenceTypeName_Reply reply) ;
+ public GetReferenceTypeName_Reply getReferenceTypeName_reply_unmarshal(String reply) ;
+
+ //******************
+ // Marshalling / Unmarshalling of Request/Reply related to IValue.getValueString()
+ //
+ // ******************/
+ public String getValueString_request_marshal(GetValueString_Request request) ;
+ public GetValueString_Request getValueString_request_unmarshal(String request) ;
+ public String getValueString_reply_marshal(GetValueString_Reply reply) ;
+ public GetValueString_Reply getValueString_reply_unmarshal(String reply) ;
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/Marshaller.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/Marshaller.java
new file mode 100644
index 00000000000..a895762ad30
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/Marshaller.java
@@ -0,0 +1,336 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.communication.event.Start_Event;
+import org.eclipse.papyrus.moka.communication.event.isuspendresume.Resume_Event;
+import org.eclipse.papyrus.moka.communication.event.isuspendresume.Suspend_Event;
+import org.eclipse.papyrus.moka.communication.event.iterminate.Terminate_Event;
+import org.eclipse.papyrus.moka.communication.reply.istackframe.GetVariables_Reply;
+import org.eclipse.papyrus.moka.communication.reply.ithread.GetStackFrames_Reply;
+import org.eclipse.papyrus.moka.communication.reply.ivalue.GetValueString_Reply;
+import org.eclipse.papyrus.moka.communication.reply.ivariable.GetReferenceTypeName_Reply;
+import org.eclipse.papyrus.moka.communication.reply.ivariable.GetValue_Reply;
+import org.eclipse.papyrus.moka.communication.request.ibreakpointlistener.AddBreakpoint_Request;
+import org.eclipse.papyrus.moka.communication.request.ibreakpointlistener.RemoveBreakpoint_Request;
+import org.eclipse.papyrus.moka.communication.request.idisconnect.Disconnect_Request;
+import org.eclipse.papyrus.moka.communication.request.istackframe.GetVariables_Request;
+import org.eclipse.papyrus.moka.communication.request.isuspendresume.Resume_Request;
+import org.eclipse.papyrus.moka.communication.request.isuspendresume.Suspend_Request;
+import org.eclipse.papyrus.moka.communication.request.iterminate.Terminate_Request;
+import org.eclipse.papyrus.moka.communication.request.ithread.GetStackFrames_Request;
+import org.eclipse.papyrus.moka.communication.request.ivalue.GetValueString_Request;
+import org.eclipse.papyrus.moka.communication.request.ivariable.GetReferenceTypeName_Request;
+import org.eclipse.papyrus.moka.communication.request.ivariable.GetValue_Request;
+
+
+/**
+ * A default implementation for the IMarshaler interface.
+ *
+ * This default implementation of IMarshaller simulates marshaling and
+ * unmarshaling of messages.
+ * When a marshal operation is called, the returned string is simply a
+ * key for the given Request, Reply or Event object. This key is generated
+ * using the java.Object method hashCode(). In the case of a Request or
+ * Event object, the key is prefixed with a string describing the nature
+ * of the Request or Event (prefixes are defined in class MokaConstants).
+ * This prefix is used for request and event dispatching in
+ * AbstractExecutionEngine and MokaDebugTarget respectively.
+ * The generated string is used as a key for a map entry (i.e., messages),
+ * where the given Request, Reply or Event object is the associated value.
+ * Unmarshaling then simply consists in returning the value corresponding
+ * to a key in the messages map, and removing this element from the map.
+ * In the case where the actual execution engine is implemented as an eclipse
+ * plug-in, usage of this default Marshaler should be considered by clients.
+ * MokaDebugTarget and AbstractExecutionEngine implement a communication protocol,
+ * which determines the order in which request, reply and event messages may be exchanged,
+ * and hiding to contributor (in the case where they extend AbstractExecutionEngine)
+ * interactions with the marshaling / unmarshaling mechanism.
+
+ * This class encapsulates a static instance of interface IMarshaller,
+ * which can be accessed by calling stating method getInstance().
+ * By default, an instance of Marshaler will be returned.
+ * However, a particular execution engine has the possibility an alternative
+ * implementation, by calling method setMarshalerInstance() at the beginning
+ * of the execution.
+ *
+ */
+public class Marshaller implements IMarshaler {
+
+ protected static IMarshaler eInstance = null ;
+
+ public static synchronized IMarshaler getInstance() {
+ if (eInstance == null)
+ eInstance = new Marshaller() ;
+ return eInstance ;
+ }
+
+ public static void setMarshalerInstance(IMarshaler marshaller) {
+ eInstance = marshaller ;
+ }
+
+ private Marshaller() {
+
+ }
+
+ protected Map<String, Object> messages = new HashMap<String, Object>() ;
+
+ public String start_event_marshal(Start_Event event) {
+ String key = MokaConstants.event_start + event.hashCode() ;
+ messages.put(key, event) ;
+ return key;
+ }
+
+ public Start_Event start_event_unmarshal(String request) {
+ Object evt = messages.get(request) ;
+ messages.remove(request) ;
+ return (Start_Event) evt ;
+ }
+
+ public String addBreakpoint_request_marshal(AddBreakpoint_Request request) {
+ String key = MokaConstants.request_addBreakpoint + request.hashCode() ;
+ messages.put(key, request) ;
+ return key;
+ }
+
+ public AddBreakpoint_Request addBreakpoint_request_unmarshal(String request) {
+ Object req = messages.get(request) ;
+ messages.remove(request) ;
+ return (AddBreakpoint_Request) req ;
+ }
+
+ public String removeBreakpoint_request_marshal(RemoveBreakpoint_Request request) {
+ String key = MokaConstants.request_removeBreakpoint + request.hashCode() ;
+ messages.put(key, request) ;
+ return key;
+ }
+
+ public RemoveBreakpoint_Request removeBreakpoint_request_unmarshal(String request) {
+ Object req = messages.get(request) ;
+ messages.remove(request) ;
+ return (RemoveBreakpoint_Request) req ;
+ }
+
+ public String disconnect_request_marshal(Disconnect_Request request) {
+ String key = MokaConstants.request_disconnect + request.hashCode() ;
+ messages.put(key, request) ;
+ return key;
+ }
+
+ public Disconnect_Request disconnect_request_unmarshal(String request) {
+ Object req = messages.get(request) ;
+ messages.remove(request) ;
+ return (Disconnect_Request) req ;
+ }
+
+
+ public String resume_request_marshal(Resume_Request request) {
+ String key = MokaConstants.request_resume + request.hashCode() ;
+ messages.put(key, request) ;
+ return key;
+ }
+
+ public Resume_Request resume_request_unmarshal(String request) {
+ Object req = messages.get(request) ;
+ messages.remove(request) ;
+ return (Resume_Request) req ;
+ }
+
+ public String resume_event_marshal(Resume_Event event) {
+ String key = MokaConstants.event_resume + event.hashCode() ;
+ messages.put(key, event) ;
+ return key;
+ }
+
+ public Resume_Event resume_event_unmarshal(String event) {
+ Object evt = messages.get(event) ;
+ messages.remove(event) ;
+ return (Resume_Event) evt ;
+ }
+
+ public String suspend_request_marshal(Suspend_Request request) {
+ String key = MokaConstants.request_suspend + request.hashCode() ;
+ messages.put(key, request) ;
+ return key;
+ }
+
+ public Suspend_Request suspend_request_unmarshal(String request) {
+ Object req = messages.get(request) ;
+ messages.remove(request) ;
+ return (Suspend_Request) req ;
+ }
+
+ public String suspend_event_marshal(Suspend_Event event) {
+ String key = MokaConstants.event_suspend + event.hashCode() ;
+ messages.put(key, event) ;
+ return key;
+ }
+
+ public Suspend_Event suspend_event_unmarshal(String event) {
+ Object evt = messages.get(event) ;
+ messages.remove(event) ;
+ return (Suspend_Event) evt ;
+ }
+
+ public String terminate_request_marshal(Terminate_Request request) {
+ String key = MokaConstants.request_terminate + request.hashCode() ;
+ messages.put(key, request) ;
+ return key;
+ }
+
+ public Terminate_Request terminate_request_unmarshal(String request) {
+ Object req = messages.get(request) ;
+ messages.remove(request) ;
+ return (Terminate_Request) req ;
+ }
+
+ public String terminate_event_marshal(Terminate_Event event) {
+ String key = MokaConstants.event_terminate + event.hashCode() ;
+ messages.put(key, event) ;
+ return key;
+ }
+
+ public Terminate_Event terminate_event_unmarshal(String event) {
+ Object evt = messages.get(event) ;
+ messages.remove(event) ;
+ return (Terminate_Event) evt ;
+ }
+
+ public String getStackFrames_request_marshal(GetStackFrames_Request request) {
+ String key = MokaConstants.request_getStackFrames + request.hashCode() ;
+ messages.put(key, request) ;
+ return key;
+ }
+
+ public GetStackFrames_Request getStackFrames_request_unmarshal(String request) {
+ Object req = messages.get(request) ;
+ messages.remove(request) ;
+ return (GetStackFrames_Request) req ;
+ }
+
+ public String getStackFrames_reply_marshal(GetStackFrames_Reply reply) {
+ String key = "" + reply.hashCode() ;
+ messages.put(key, reply) ;
+ return key;
+ }
+
+ public GetStackFrames_Reply getStackFrames_reply_unmarshal(String reply) {
+ Object rep = messages.get(reply) ;
+ messages.remove(reply) ;
+ return (GetStackFrames_Reply) rep ;
+ }
+
+ public String getVariables_request_marshal(GetVariables_Request request) {
+ String key = MokaConstants.request_getVariables + request.hashCode() ;
+ messages.put(key, request) ;
+ return key;
+ }
+
+ public GetVariables_Request getVariables_request_unmarshal(String request) {
+ Object req = messages.get(request) ;
+ messages.remove(request) ;
+ return (GetVariables_Request) req ;
+ }
+
+ public String getVariables_reply_marshal(GetVariables_Reply reply) {
+ String key = "" + reply.hashCode() ;
+ messages.put(key, reply) ;
+ return key;
+ }
+
+ public GetVariables_Reply getVariables_reply_unmarshal(String reply) {
+ Object rep = messages.get(reply) ;
+ messages.remove(reply) ;
+ return (GetVariables_Reply) rep ;
+ }
+
+ public String getValue_request_marshal(GetValue_Request request) {
+ String key = MokaConstants.request_getValue + request.hashCode() ;
+ messages.put(key, request) ;
+ return key;
+ }
+
+ public GetValue_Request getValue_request_unmarshal(String request) {
+ Object req = messages.get(request) ;
+ messages.remove(request) ;
+ return (GetValue_Request) req ;
+ }
+
+ public String getValue_reply_marshal(GetValue_Reply reply) {
+ String key = "" + reply.hashCode() ;
+ messages.put(key, reply) ;
+ return key;
+ }
+
+ public GetValue_Reply getValue_reply_unmarshal(String reply) {
+ Object rep = messages.get(reply) ;
+ messages.remove(reply) ;
+ return (GetValue_Reply) rep ;
+ }
+
+ public String getReferenceTypeName_request_marshal(GetReferenceTypeName_Request request) {
+ String key = MokaConstants.request_getReferenceTypeName + request.hashCode() ;
+ messages.put(key, request) ;
+ return key;
+ }
+
+ public GetReferenceTypeName_Request getReferenceTypeName_request_unmarshal(String request) {
+ Object req = messages.get(request) ;
+ messages.remove(request) ;
+ return (GetReferenceTypeName_Request) req ;
+ }
+
+ public String getReferenceTypeName_reply_marshal(GetReferenceTypeName_Reply reply) {
+ String key = "" + reply.hashCode() ;
+ messages.put(key, reply) ;
+ return key;
+ }
+
+ public GetReferenceTypeName_Reply getReferenceTypeName_reply_unmarshal(String reply) {
+ Object rep = messages.get(reply) ;
+ messages.remove(reply) ;
+ return (GetReferenceTypeName_Reply) rep ;
+ }
+
+ public String getValueString_request_marshal(GetValueString_Request request) {
+ String key = MokaConstants.request_getValueString + request.hashCode() ;
+ messages.put(key, request) ;
+ return key;
+ }
+
+ public GetValueString_Request getValueString_request_unmarshal(String request) {
+ Object req = messages.get(request) ;
+ messages.remove(request) ;
+ return (GetValueString_Request) req ;
+ }
+
+ public String getValueString_reply_marshal(GetValueString_Reply reply) {
+ String key = "" + reply.hashCode() ;
+ messages.put(key, reply) ;
+ return key;
+ }
+
+ public GetValueString_Reply getValueString_reply_unmarshal(String reply) {
+ Object rep = messages.get(reply) ;
+ messages.remove(reply) ;
+ return (GetValueString_Reply) rep ;
+ }
+
+
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/EventMessage.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/EventMessage.java
new file mode 100644
index 00000000000..a9d35b9c5a0
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/EventMessage.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.event;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.model.IDebugElement;
+
+/**
+ * Abstract class representing communication of an event (e.g., suspend, resume, etc.)
+ *
+ */
+public abstract class EventMessage {
+
+ /**
+ * the debug element from which this event originated
+ */
+ protected IDebugElement source ;
+
+ /**
+ * the kind of event
+ */
+ protected int eventKind ;
+
+ /**
+ * the actual debug event
+ */
+ protected DebugEvent debugEvent ;
+
+ /**
+ * Marshal this Event message, so that it can be communicated between
+ * the debug target and the actual execution engine
+ *
+ * @return A String encoding of this event message
+ */
+ public abstract String marshal() ;
+
+ /**
+ * Returns the actual debug event associated with this message
+ *
+ * @return the actual debug event associated with this message
+ */
+ public abstract DebugEvent getDebugEvent() ;
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/Start_Event.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/Start_Event.java
new file mode 100644
index 00000000000..4db66ea2b3b
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/Start_Event.java
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.event;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.debug.MokaThread;
+
+/**
+ * An event message representing a Start event.
+ * This message is emitted by the AbstractExecution engine,
+ * to inform the debug target that it is properly started and that it
+ * is ready to handle requests.
+ *
+ */
+public class Start_Event extends EventMessage {
+
+ /**
+ * The threads available at the execution engine when the start_event message was emitted
+ */
+ protected MokaThread[] threads ;
+
+ /**
+ * Constructs a Start_Event message from a source and an array of threads.
+ * source is usually the debug target. The idea is that, while this message is
+ * emitted from the execution engine to the debug target, the debug target then
+ * notifies the debug framework that a message occurred.
+ * From the debug framework standpoint, the source of the start event is therefore
+ * the debug target itself.
+ * threads represent the threads available at the execution engine when
+ * it is ready to start.
+ *
+ * @param source The source for the debug event
+ * @param threads The threads available when the execution is started
+ */
+ public Start_Event(IDebugElement source, MokaThread[] threads) {
+ this.source = source;
+ this.threads = threads ;
+ this.eventKind = DebugEvent.CREATE ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.event.Event#marshal()
+ */
+ public String marshal() {
+ return Marshaller.getInstance().start_event_marshal(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.event.Event#getDebugEvent()
+ */
+ public DebugEvent getDebugEvent() {
+ if (this.debugEvent == null)
+ this.debugEvent = new DebugEvent(source, eventKind) ;
+ return this.debugEvent;
+ }
+
+ /**
+ * Returns the threads available at the execution engine when the start_event message was emitted
+ *
+ * @return the threads available at the execution engine when the start_event message was emitted
+ */
+ public MokaThread[] getThreads() {
+ return this.threads ;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/isuspendresume/Resume_Event.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/isuspendresume/Resume_Event.java
new file mode 100644
index 00000000000..d1e27a71f1e
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/isuspendresume/Resume_Event.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.event.isuspendresume;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.event.EventMessage;
+
+/**
+ * An event message representing a Resume event.
+ * This message is emitted by the AbstractExecution engine,
+ * in response to a Resume_Request.
+ *
+ */
+public class Resume_Event extends EventMessage {
+
+ /**
+ * The details about the reason for this resume event (e.g., step_over, step_into, etc.)
+ */
+ protected int resumeDetail ;
+
+ /**
+ * Constructs a Resume_Event from the given source and details.
+ * Source is supposed to be same element as in the Resume_Request
+ * which preceded the creation of this Resume_Event.
+ * (e.g., if the Resume_Request was for a specific IThread, then the source
+ * of the created Resume_Event should be the same IThread).
+ * resumeDetail provides additional details about the reason of this
+ * resume event. The value of resumeDetail should be the same as in the
+ * Resume_Request which preceded the creation of this Resume_Event.
+ *
+ * @param source The source for this Resume_Event
+ * @param resumeDetail The reason/detail of this Resume_Event
+ */
+ public Resume_Event(IDebugElement source, int resumeDetail) {
+ this.source = source;
+ this.resumeDetail = resumeDetail;
+ this.eventKind = DebugEvent.RESUME ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.event.EventMessage#marshal()
+ */
+ public String marshal() {
+ return Marshaller.getInstance().resume_event_marshal(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.event.EventMessage#getDebugEvent()
+ */
+ public DebugEvent getDebugEvent() {
+ if (this.debugEvent == null)
+ this.debugEvent = new DebugEvent(source, eventKind, resumeDetail) ;
+ return this.debugEvent;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/isuspendresume/Suspend_Event.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/isuspendresume/Suspend_Event.java
new file mode 100644
index 00000000000..32e9f713435
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/isuspendresume/Suspend_Event.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.event.isuspendresume;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.event.EventMessage;
+import org.eclipse.papyrus.moka.debug.MokaThread;
+
+/**
+ * An event message representing a Suspend event.
+ * This message is emitted by the AbstractExecution engine,
+ * either in response to a Suspend_Request, or when the actual
+ * execution engine encountered a reason for suspending
+ * (e.g., a breakpoint has been encountered, a step has ended)
+ *
+ */
+public class Suspend_Event extends EventMessage {
+
+ /**
+ * The reason/detail of this Suspend_Event
+ */
+ protected int suspendDetail ;
+
+ /**
+ * The threads available at the execution engine when it emitted this Suspend_Event message
+ */
+ protected MokaThread[] threads ;
+
+ /**
+ * Constructs a Suspend_Event from the given source, suspendDetail an array of threads.
+ * Source is supposed to be same element as in the Resume_Request
+ * which preceded the creation of this Resume_Event, if any. Otherwise, it can be any debug element
+ * on which the actual execution element may find a reason to suspend (e.g., the debug target, a thread).
+ * resumeDetail provides additional details about the reason of this
+ * resume event. The value of resumeDetail should be the same as in the
+ * Resume_Request which preceded the creation of this Resume_Event, if any. Otherwise, it will typically
+ * correspond to the fact that the execution engine encountered a breakpoint, or ended a step.
+ * threads represent the threads available at the execution engine when
+ * it suspended and emitted this event message.
+ *
+ * @param source The source for this Suspend_Event
+ * @param suspendDetail The reason/detail of this Suspend_Event
+ * @param threads The threads available at the execution engine when it emitted this Suspend_Event message
+ */
+ public Suspend_Event(IDebugElement source, int suspendDetail, MokaThread[] threads) {
+ this.source = source;
+ this.suspendDetail = suspendDetail;
+ this.threads = threads ;
+ this.eventKind = DebugEvent.SUSPEND ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.event.EventMessage#marshal()
+ */
+ public String marshal() {
+ return Marshaller.getInstance().suspend_event_marshal(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.event.EventMessage#getDebugEvent()
+ */
+ public DebugEvent getDebugEvent() {
+ if (this.debugEvent == null)
+ this.debugEvent = new DebugEvent(source, eventKind, suspendDetail) ;
+ return this.debugEvent;
+ }
+
+ /**
+ * Returns the threads available at the execution engine when it emitted this Suspend_Event message
+ *
+ * @return The threads available at the execution engine when it emitted this Suspend_Event message
+ */
+ public MokaThread[] getThreads() {
+ return this.threads ;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/iterminate/Terminate_Event.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/iterminate/Terminate_Event.java
new file mode 100644
index 00000000000..8f52fa27668
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/event/iterminate/Terminate_Event.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.event.iterminate;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.event.EventMessage;
+
+/**
+ * An event message representing a Terminate event.
+ * This message is emitted by the AbstractExecution engine,
+ * to inform the debug target that it has properly terminated
+ * to execute.
+ *
+ */
+public class Terminate_Event extends EventMessage {
+
+ /**
+ * Construct a terminate event from the given source.
+ * The source is usually the debug target. See Start_Event for the rationale.
+ *
+ * @param source The source for the terminate event
+ */
+ public Terminate_Event(IDebugElement source) {
+ this.source = source;
+ this.eventKind = DebugEvent.TERMINATE ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.event.Event#marshal()
+ */
+ public String marshal() {
+ return Marshaller.getInstance().terminate_event_marshal(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.event.Event#getDebugEvent()
+ */
+ public DebugEvent getDebugEvent() {
+ if (this.debugEvent == null)
+ this.debugEvent = new DebugEvent(source, eventKind) ;
+ return this.debugEvent;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/Ack.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/Ack.java
new file mode 100644
index 00000000000..7ff1be68d5e
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/Ack.java
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.reply;
+
+import org.eclipse.papyrus.moka.MokaConstants;
+
+/**
+ * A reply message used to synchronize the debug target and the execution engine,
+ * in case where no specific additional information needs to be conveyed.
+ *
+ */
+public class Ack extends ReplyMessage {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.reply.ReplyMessage#marshal()
+ */
+ public String marshal() {
+ return MokaConstants.ack ;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ReplyMessage.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ReplyMessage.java
new file mode 100644
index 00000000000..13f52e308db
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ReplyMessage.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.reply;
+
+/**
+ * Abstract class representing communication of a reply
+ *
+ */
+public abstract class ReplyMessage {
+
+ /**
+ * Marshal this Reply message, so that it can be communicated between
+ * the debug target and the actual execution engine
+ *
+ * @return A String encoding of this reply message
+ */
+ public abstract String marshal() ;
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/istackframe/GetVariables_Reply.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/istackframe/GetVariables_Reply.java
new file mode 100644
index 00000000000..1200076e09c
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/istackframe/GetVariables_Reply.java
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.reply.istackframe;
+
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.reply.ReplyMessage;
+import org.eclipse.papyrus.moka.debug.MokaVariable;
+
+/**
+ * A reply message, emitted by the execution engine in response
+ * to a GetVariable_Request
+ *
+ */
+public class GetVariables_Reply extends ReplyMessage {
+
+ /**
+ * The variables associated with this reply message
+ */
+ protected MokaVariable[] variables ;
+
+ /**
+ * Constructs a reply message from an array of Variables
+ *
+ * @param variables The variables associated with this reply message
+ */
+ public GetVariables_Reply(MokaVariable[] variables) {
+ super();
+ this.variables = variables;
+ }
+
+ /**
+ * Returns the variables associated with this reply message
+ *
+ * @return The variables associated with this reply message
+ */
+ public MokaVariable[] getVariables() {
+ return variables;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.reply.ReplyMessage#marshal()
+ */
+ public String marshal() {
+ return Marshaller.getInstance().getVariables_reply_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ithread/GetStackFrames_Reply.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ithread/GetStackFrames_Reply.java
new file mode 100644
index 00000000000..816fc515772
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ithread/GetStackFrames_Reply.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.reply.ithread;
+
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.reply.ReplyMessage;
+
+/**
+ * A reply message, emitted by the execution engine in response
+ * to a GetStackFrames_Request
+ *
+ */
+public class GetStackFrames_Reply extends ReplyMessage {
+
+ /**
+ * The stack associated with this reply message
+ */
+ protected IStackFrame[] stackFrames ;
+
+ /**
+ * Constructs a reply message from an array of stack frames
+ *
+ * @param stackFrames The stack associated with this reply message
+ */
+ public GetStackFrames_Reply(IStackFrame[] stackFrames) {
+ this.stackFrames = stackFrames;
+ if (this.stackFrames == null)
+ this.stackFrames = new IStackFrame[]{} ;
+ }
+
+ /**
+ * Returns the stack associated with this reply message
+ *
+ * @return the stack associated with this reply message
+ */
+ public IStackFrame[] getStackFrames() {
+ return stackFrames;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.reply.ReplyMessage#marshal()
+ */
+ public String marshal() {
+ return Marshaller.getInstance().getStackFrames_reply_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ivalue/GetValueString_Reply.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ivalue/GetValueString_Reply.java
new file mode 100644
index 00000000000..c40a2c4b3cb
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ivalue/GetValueString_Reply.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.reply.ivalue;
+
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.reply.ReplyMessage;
+
+/**
+ * A reply message, emitted by the execution engine in response
+ * to a GetValueString_Request
+ *
+ */
+public class GetValueString_Reply extends ReplyMessage {
+
+ /**
+ * The textual value representation associated with this reply message
+ */
+ protected String textualRepresentation ;
+
+ /**
+ * Constructs a reply message from a string
+ *
+ * @param textualRepresentation The textual value representation associated with this reply message
+ */
+ public GetValueString_Reply(String textualRepresentation) {
+ super();
+ this.textualRepresentation = textualRepresentation ;
+ }
+
+ /**
+ * Returns The textual value representation associated with this reply message
+ *
+ * @return The textual value representation associated with this reply message
+ */
+ public String getValueString() {
+ return this.textualRepresentation ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.reply.ReplyMessage#marshal()
+ */
+ public String marshal() {
+ return Marshaller.getInstance().getValueString_reply_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ivariable/GetReferenceTypeName_Reply.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ivariable/GetReferenceTypeName_Reply.java
new file mode 100644
index 00000000000..80cd39e3d76
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ivariable/GetReferenceTypeName_Reply.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.reply.ivariable;
+
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.reply.ReplyMessage;
+
+/**
+ * A reply message, emitted by the execution engine in response
+ * to a GetReferenceTypeName_Request
+ *
+ */
+public class GetReferenceTypeName_Reply extends ReplyMessage {
+
+ /**
+ * The string representing the reference type name
+ */
+ protected String referenceTypeName ;
+
+ /**
+ * Constructs a reply message from a string
+ *
+ * @param referenceTypeName a string representing the reference type name
+ */
+ public GetReferenceTypeName_Reply(String referenceTypeName) {
+ super();
+ this.referenceTypeName = referenceTypeName ;
+ }
+
+ /**
+ * Returns the string representing the reference type name associated with this message
+ *
+ * @return the string representing the reference type name associated with this message
+ */
+ public String getReferenceTypeName() {
+ return this.referenceTypeName ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.reply.ReplyMessage#marshal()
+ */
+ public String marshal() {
+ return Marshaller.getInstance().getReferenceTypeName_reply_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ivariable/GetValue_Reply.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ivariable/GetValue_Reply.java
new file mode 100644
index 00000000000..9812d0c1802
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/reply/ivariable/GetValue_Reply.java
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.reply.ivariable;
+
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.reply.ReplyMessage;
+import org.eclipse.papyrus.moka.debug.MokaValue;
+
+/**
+ * A reply message, emitted by the execution engine in response
+ * to a GetValue_Request
+ *
+ */
+public class GetValue_Reply extends ReplyMessage {
+
+ /**
+ * The value associated with this reply message
+ */
+ protected MokaValue value ;
+
+ /**
+ * Constructs a GetValue_Reply from the given value
+ *
+ * @param value The value associated with this reply message
+ */
+ public GetValue_Reply(MokaValue value) {
+ super();
+ this.value = value ;
+ }
+
+ /**
+ * Returns the value associated with this reply message
+ *
+ * @return The value associated with this reply message
+ */
+ public MokaValue getValue() {
+ return value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.reply.ReplyMessage#marshal()
+ */
+ public String marshal() {
+ return Marshaller.getInstance().getValue_reply_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/RequestMessage.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/RequestMessage.java
new file mode 100644
index 00000000000..868c0e2709a
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/RequestMessage.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.request;
+
+/**
+ * Abstract class representing communication of a request
+ *
+ */
+public abstract class RequestMessage {
+
+ /**
+ * Marshal this Request message, so that it can be communicated between
+ * the debug target and the actual execution engine
+ *
+ * @return A String encoding of this request message
+ */
+ public abstract String marshall() ;
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ibreakpointlistener/AddBreakpoint_Request.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ibreakpointlistener/AddBreakpoint_Request.java
new file mode 100644
index 00000000000..fd99fee9429
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ibreakpointlistener/AddBreakpoint_Request.java
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.request.ibreakpointlistener;
+
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.request.RequestMessage;
+import org.eclipse.papyrus.moka.debug.MokaBreakpoint;
+
+/**
+ * A message representing a request for adding a breakpoint.
+ * This is emitted from the debug target, to the execution engine.
+ *
+ */
+public class AddBreakpoint_Request extends RequestMessage {
+
+ /**
+ * The breakpoint associated with this request message
+ */
+ protected MokaBreakpoint breakpoint ;
+
+ /**
+ * Constructs a request message from the given breakpoint
+ *
+ * @param breakpoint The breakpoint associated with this request message
+ */
+ public AddBreakpoint_Request(MokaBreakpoint breakpoint) {
+ this.breakpoint = breakpoint ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.request.RequestMessage#marshall()
+ */
+ public String marshall() {
+ return Marshaller.getInstance().addBreakpoint_request_marshal(this);
+ }
+
+ /**
+ * Returns the breakpoint associated with this request message
+ *
+ * @return The breakpoint associated with this request message
+ */
+ public MokaBreakpoint getBreakpoint() {
+ return this.breakpoint ;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ibreakpointlistener/RemoveBreakpoint_Request.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ibreakpointlistener/RemoveBreakpoint_Request.java
new file mode 100644
index 00000000000..7a685509865
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ibreakpointlistener/RemoveBreakpoint_Request.java
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.request.ibreakpointlistener;
+
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.request.RequestMessage;
+import org.eclipse.papyrus.moka.debug.MokaBreakpoint;
+
+/**
+ * A message representing a request for removing a breakpoint.
+ * This is emitted from the debug target, to the execution engine.
+ *
+ */
+public class RemoveBreakpoint_Request extends RequestMessage {
+
+ /**
+ * The breakpoint associated with this request message
+ */
+ protected MokaBreakpoint breakpoint ;
+
+ /**
+ * Constructs a request message from the given breakpoint
+ *
+ * @param breakpoint The breakpoint associated with this request message
+ */
+ public RemoveBreakpoint_Request(MokaBreakpoint breakpoint) {
+ this.breakpoint = breakpoint ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.request.RequestMessage#marshall()
+ */
+ public String marshall() {
+ return Marshaller.getInstance().removeBreakpoint_request_marshal(this);
+ }
+
+ /**
+ * Returns the breakpoint associated with this request message
+ *
+ * @return The breakpoint associated with this request message
+ */
+ public MokaBreakpoint getBreakpoint() {
+ return this.breakpoint ;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/idisconnect/Disconnect_Request.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/idisconnect/Disconnect_Request.java
new file mode 100644
index 00000000000..fb2674e7976
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/idisconnect/Disconnect_Request.java
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.request.idisconnect;
+
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.request.RequestMessage;
+
+/**
+ * A message representing a request for disconnection.
+ * This is emitted from the debug target, to the execution engine.
+ *
+ */
+public class Disconnect_Request extends RequestMessage {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.request.RequestMessage#marshall()
+ */
+ public String marshall() {
+ return Marshaller.getInstance().disconnect_request_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/istackframe/GetVariables_Request.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/istackframe/GetVariables_Request.java
new file mode 100644
index 00000000000..fe53b3b05d3
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/istackframe/GetVariables_Request.java
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.request.istackframe;
+
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.request.RequestMessage;
+
+/**
+ * A message representing a request for variables.
+ * This is emitted from the debug target, to the execution engine.
+ *
+ */
+public class GetVariables_Request extends RequestMessage {
+
+ /**
+ * The debug element from which variables have to be retrieved.
+ * It can be a stack frame or a value
+ */
+ protected IDebugElement stackFrameOrValue ;
+
+ /**
+ * Constructs a request message from the given debug element.
+ * This debug element can be:
+ * - A stack frame
+ * - A value
+ *
+ * @param stackFrameOrValue The debug element from which variables have to be retrieved
+ */
+ public GetVariables_Request(IDebugElement stackFrameOrValue) {
+ this.stackFrameOrValue = stackFrameOrValue;
+ }
+
+ /**
+ * Returns the debug element from which variables have to be retrieved.
+ *
+ * @return The debug element from which variables have to be retrieved.
+ */
+ public IDebugElement getStackFrameOrValue() {
+ return stackFrameOrValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.request.RequestMessage#marshall()
+ */
+ public String marshall() {
+ return Marshaller.getInstance().getVariables_request_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/isuspendresume/Resume_Request.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/isuspendresume/Resume_Request.java
new file mode 100644
index 00000000000..0c8d5fd22cb
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/isuspendresume/Resume_Request.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.request.isuspendresume;
+
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.request.RequestMessage;
+
+/**
+ * A message representing a request for resuming execution.
+ * This is emitted from the debug target, to the execution engine.
+ *
+ */
+public class Resume_Request extends RequestMessage {
+
+ /**
+ * The element from which the execution engine shall resume execution
+ */
+ protected IDebugElement debugElement;
+
+ /**
+ * The reason for resuming (e.g. Resume, step over, step into, etc.)
+ */
+ protected int resumeDetail ;
+
+ /**
+ * Constructs a request message from the given debug element and resume details.
+ * debugElement represents the element from which the execution engine shall resume execution
+ * resumeDetail provides information about the reason for resuming (e.g. Resume, step over, step into, etc.)
+ *
+ * @param debugElement The element from which the execution engine shall resume execution
+ * @param resumeDetail The reason for resuming (e.g. Resume, step over, step into, etc.)
+ */
+ public Resume_Request(IDebugElement debugElement, int resumeDetail) {
+ this.debugElement = debugElement;
+ this.resumeDetail = resumeDetail;
+ }
+
+ /**
+ * Returns the element from which the execution engine shall resume execution
+ *
+ * @return The element from which the execution engine shall resume execution
+ */
+ public IDebugElement getDebugElement() {
+ return debugElement;
+ }
+
+ /**
+ * Returns the reason for resuming (e.g. Resume, step over, step into, etc.)
+ *
+ * @return The reason for resuming (e.g. Resume, step over, step into, etc.)
+ */
+ public int getResumeDetail() {
+ return resumeDetail;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.request.RequestMessage#marshall()
+ */
+ public String marshall() {
+ return Marshaller.getInstance().resume_request_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/isuspendresume/Suspend_Request.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/isuspendresume/Suspend_Request.java
new file mode 100644
index 00000000000..15c3164c3b5
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/isuspendresume/Suspend_Request.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.request.isuspendresume;
+
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.request.RequestMessage;
+
+/**
+ * A message representing a request for suspending execution.
+ * This is emitted from the debug target, to the execution engine.
+ *
+ */
+public class Suspend_Request extends RequestMessage {
+
+ /**
+ * The element from which the execution engine shall suspend execution
+ */
+ protected IDebugElement debugElement;
+
+ /**
+ * The reason for suspending. This is typically a Client Request
+ */
+ protected int suspendDetail ;
+
+ /**
+ * Constructs a request message from the given debug element and suspend details.
+ * debugElement represents the element from which the execution engine shall suspend execution
+ * resumeDetail provides information about the reason for suspending. This is typically a Client Request.
+ *
+ * @param debugElement The element from which the execution engine shall suspend execution
+ * @param resumeDetail The reason for suspending
+ */
+ public Suspend_Request(IDebugElement debugElement, int suspendDetail) {
+ this.debugElement = debugElement;
+ this.suspendDetail = suspendDetail;
+ }
+
+ /**
+ * Returns the element from which the execution engine shall suspend execution
+ *
+ * @return The element from which the execution engine shall suspend execution
+ */
+ public IDebugElement getDebugElement() {
+ return debugElement;
+ }
+
+ /**
+ * Returns the reason for suspending. This is typically a Client Request.
+ *
+ * @return The reason for suspending
+ */
+ public int getSuspendDetail() {
+ return suspendDetail;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.request.RequestMessage#marshall()
+ */
+ public String marshall() {
+ return Marshaller.getInstance().suspend_request_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/iterminate/Terminate_Request.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/iterminate/Terminate_Request.java
new file mode 100644
index 00000000000..d9f7db0aa47
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/iterminate/Terminate_Request.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.request.iterminate;
+
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.request.RequestMessage;
+
+/**
+ * A message representing a request for terminating execution.
+ * This is emitted from the debug target, to the execution engine.
+ *
+ */
+public class Terminate_Request extends RequestMessage {
+
+ /**
+ * The element from which the execution engine shall terminate execution
+ */
+ protected IDebugElement debugElement;
+
+ /**
+ * Constructs a request message from the given debug element.
+ *
+ * @param debugElement The element from which the execution engine shall terminate execution
+ */
+ public Terminate_Request(IDebugElement debugElement) {
+ this.debugElement = debugElement;
+ }
+
+ /**
+ * Returns the element from which the execution engine shall terminate execution
+ *
+ * @return The element from which the execution engine shall terminate execution
+ */
+ public IDebugElement getDebugElement() {
+ return debugElement;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.request.RequestMessage#marshall()
+ */
+ public String marshall() {
+ return Marshaller.getInstance().terminate_request_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ithread/GetStackFrames_Request.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ithread/GetStackFrames_Request.java
new file mode 100644
index 00000000000..ff689d98b7e
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ithread/GetStackFrames_Request.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.request.ithread;
+
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.request.RequestMessage;
+
+/**
+ * A message representing a request for stack frames, available for a specific thread.
+ * This is emitted from the debug target, to the execution engine.
+ *
+ */
+public class GetStackFrames_Request extends RequestMessage {
+
+ /**
+ * The thread for which available stack frames are requested
+ */
+ protected IThread thread ;
+
+ /**
+ * Constructs a request message from the given thread.
+ *
+ * @param thread The thread for which available stack frames are requested
+ */
+ public GetStackFrames_Request(IThread thread) {
+ this.thread = thread;
+ }
+
+ /**
+ * Returns the thread for which available stack frames are requested
+ *
+ * @return The thread for which available stack frames are requested
+ */
+ public IThread getThread() {
+ return thread;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.request.RequestMessage#marshall()
+ */
+ public String marshall() {
+ return Marshaller.getInstance().getStackFrames_request_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ivalue/GetValueString_Request.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ivalue/GetValueString_Request.java
new file mode 100644
index 00000000000..e441961e8f5
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ivalue/GetValueString_Request.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.request.ivalue;
+
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.request.RequestMessage;
+
+/**
+ * A message representing a request for the string representation of a given value
+ * This is emitted from the debug target, to the execution engine.
+ *
+ */
+public class GetValueString_Request extends RequestMessage {
+
+ /**
+ * The value for which a string representation is requested
+ */
+ protected IValue value ;
+
+ /**
+ * Constructs a request message from the given value.
+ *
+ * @param value The value for which a string representation is requested
+ */
+ public GetValueString_Request(IValue value) {
+ this.value = value ;
+ }
+
+ /**
+ * Returns the value for which a string representation is requested
+ *
+ * @return The value for which a string representation is requested
+ */
+ public IValue getValue() {
+ return value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.request.RequestMessage#marshall()
+ */
+ public String marshall() {
+ return Marshaller.getInstance().getValueString_request_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ivariable/GetReferenceTypeName_Request.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ivariable/GetReferenceTypeName_Request.java
new file mode 100644
index 00000000000..3b7c7ef336c
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ivariable/GetReferenceTypeName_Request.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.request.ivariable;
+
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.request.RequestMessage;
+
+/**
+ * A message representing a request for the reference type name of a given debug element.
+ * This is emitted from the debug target, to the execution engine.
+ *
+ */
+public class GetReferenceTypeName_Request extends RequestMessage {
+
+ /**
+ * The debug element from which the reference type name is requested.
+ * This can be a variable or a value.
+ */
+ protected IDebugElement debugElement ;
+
+ /**
+ * Constructs a request message from the given debug element.
+ * This debug element can be a variable or a value
+ *
+ * @param debugElement The debug element from which the reference type name is requested
+ */
+ public GetReferenceTypeName_Request(IDebugElement debugElement) {
+ this.debugElement = debugElement ;
+ }
+
+ /**
+ * Returns the debug element from which the reference type name is requested
+ *
+ * @return The debug element from which the reference type name is requested
+ */
+ public IDebugElement getVariableOrValue() {
+ return debugElement;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.request.RequestMessage#marshall()
+ */
+ public String marshall() {
+ return Marshaller.getInstance().getReferenceTypeName_request_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ivariable/GetValue_Request.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ivariable/GetValue_Request.java
new file mode 100644
index 00000000000..dbc7fe6cb4e
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/communication/request/ivariable/GetValue_Request.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.communication.request.ivariable;
+
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.request.RequestMessage;
+
+/**
+ * A message representing a request for retrieving the value associated with a variable.
+ * This is emitted from the debug target, to the execution engine.
+ *
+ */
+public class GetValue_Request extends RequestMessage {
+
+ /**
+ * The variable for which associated value is requested
+ */
+ protected IVariable variable ;
+
+ /**
+ * Constructs a request message from the given variable.
+ *
+ * @param variable The variable for which associated value is requested
+ */
+ public GetValue_Request(IVariable variable) {
+ this.variable = variable ;
+ }
+
+ /**
+ * Returns the variable for which associated value is requested
+ *
+ * @return The variable for which associated value is requested
+ */
+ public IVariable getVariable() {
+ return variable;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.communication.request.RequestMessage#marshall()
+ */
+ public String marshall() {
+ return Marshaller.getInstance().getValue_request_marshal(this);
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaBreakpoint.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaBreakpoint.java
new file mode 100644
index 00000000000..0510dbdbc8c
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaBreakpoint.java
@@ -0,0 +1,196 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.debug;
+
+import java.util.MissingResourceException;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.model.Breakpoint;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.launch.EditorUtils;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.uml2.uml.NamedElement;
+
+/**
+ * Implementation of IBreakpoint provided by Moka.
+ * MokaBreakpoint relies on markers of type MokaConstants.MOKA_BREAKPOINT_MARKER_ID,
+ * which extend both papyrus model marker and eclipse breakpoint marker.
+ *
+ */
+public class MokaBreakpoint extends Breakpoint {
+
+ /**
+ * The model element to which this breakpoint is attached
+ */
+ protected EObject modelElement ;
+
+ /**
+ * A default resource set which should, ideally, never be used
+ */
+ protected static ResourceSet defaultResourceSet ;
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier()
+ */
+ public String getModelIdentifier() {
+ return MokaConstants.MOKA_DEBUG_MODEL_ID ;
+ }
+
+ /**
+ * Return the model element to which this breakpoint is attached
+ *
+ * @return The model element to which this breakpoint is attached
+ */
+ public EObject getModelElement() {
+ return this.modelElement ;
+ }
+
+ /**
+ * Toggles a breakpoint on the given model element
+ *
+ * @param modelElement The model element to which a breakpoint has to be attached
+ */
+ public void toggleBreakpoint(EObject modelElement) {
+ String uri = modelElement.eResource().getURI().toString() ;
+ String fragment = modelElement.eResource().getURIFragment(modelElement) ;
+ IResource iresource = getIResource(modelElement.eResource()) ;
+ this.modelElement = modelElement ;
+ try {
+ if (iresource != null) {
+ IMarker marker = iresource.createMarker(MokaConstants.MOKA_BREAKPOINT_MARKER_ID);
+ marker.setAttribute(EValidator.URI_ATTRIBUTE, uri + "#" + fragment) ;
+ marker.setAttribute(IBreakpoint.ID, this.getModelIdentifier()) ;
+ this.setMarker(marker) ;
+ this.setEnabled(true) ;
+ this.setPersisted(true) ;
+ }
+ } catch (CoreException ce) {
+ ce.printStackTrace() ;
+ }
+ }
+
+ /**
+ * Convenience method returning the IResource corresponding to a Resource
+ *
+ * @param resource The Resource from which the corresponding IResource has to be retrieved
+ * @return the IResource corresponding to the Resource
+ */
+ public static IResource getIResource(Resource resource) {
+ if (resource == null)
+ return null ;
+ String uriPath = resource.getURI().toPlatformString(true);
+ if (uriPath == null) // FIXME this is not a Platform scheme
+ return null ;
+ IResource iresource = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uriPath));
+ if(iresource != null) {
+ if(iresource.exists()) {
+ return iresource;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Computes a label for this breakpoint
+ *
+ * @return A label for this breakpoint
+ */
+ public String getLabel() {
+ String label = "" ;
+ if (this.modelElement instanceof NamedElement) {
+ return ((NamedElement)this.modelElement).getQualifiedName() ;
+ }
+ return label ;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.Breakpoint#setMarker(org.eclipse.core.resources.IMarker)
+ */
+ public void setMarker(IMarker marker) throws CoreException {
+ if (this.modelElement == null)
+ this.modelElement = getEObjectOfMarker(marker) ;
+ super.setMarker(marker);
+ }
+
+ /**
+ * Convenience method returning the EObject of a given marker (provided that it is a marker with a URI)
+ *
+ * @param marker
+ * The marker from which eObject has to be retrieved
+ * @return The EObject associated with the given marker
+ */
+ public static EObject getEObjectOfMarker(IMarker marker) {
+ URI uriOfMarker = getURI(marker);
+ if(uriOfMarker != null) {
+ try {
+ EObject modelElement = null ;
+ IEditorPart part = EditorUtils.getEditorPart(uriOfMarker.trimFragment().toString()) ;
+ if (part != null) {
+ ServicesRegistry servicesRegistry = (ServicesRegistry)part.getAdapter(ServicesRegistry.class);
+ if (servicesRegistry != null) {
+ try {
+ ResourceSet resourceSet = servicesRegistry.getService(ModelSet.class) ;
+ modelElement = resourceSet.getEObject(uriOfMarker, true);
+ if (modelElement != null)
+ return modelElement ;
+ } catch (ServiceException e) {
+ Activator.log.error(e) ;
+ }
+ }
+ }
+
+ if (defaultResourceSet == null)
+ defaultResourceSet = new ResourceSetImpl();
+ defaultResourceSet.getResource(uriOfMarker.trimFragment(), true);
+ return defaultResourceSet.getEObject(uriOfMarker, true);
+ } catch (MissingResourceException e) {
+ Activator.log.error(e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Convenience method returning the URI corresponding to the value of the EValidator.URI_ATTRIBUTE of a marker
+ *
+ * @param marker
+ * The marker from which the URI corresponding to the value its EValidator.URI_ATTRIBUTE has to be constructed
+ * @return The URI corresponding to the value of the EValidator.URI_ATTRIBUTE of the given marker
+ */
+ public static URI getURI(IMarker marker) {
+ String uriOfMarkerStr = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
+ if(uriOfMarkerStr != null) {
+ return URI.createURI(uriOfMarkerStr);
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaDebugElement.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaDebugElement.java
new file mode 100644
index 00000000000..bc045c5aeb3
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaDebugElement.java
@@ -0,0 +1,109 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.debug;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.papyrus.moka.Activator;
+import org.eclipse.papyrus.moka.MokaConstants;
+
+/**
+ * An implementation of IDebugElement factorizing methods and properties for
+ * other debug classes provided by Moka.
+ *
+ */
+public abstract class MokaDebugElement extends PlatformObject implements IDebugElement {
+
+ /**
+ * The moka debug target associated with this debug element
+ */
+ protected MokaDebugTarget debugTarget;
+
+ /**
+ * Constructs a new debug element contained in the given moka debug target.
+ *
+ * @param target Moka debug target
+ */
+ public MokaDebugElement(MokaDebugTarget target) {
+ this.debugTarget = target;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
+ */
+ public String getModelIdentifier() {
+ return MokaConstants.MOKA_DEBUG_MODEL_ID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
+ */
+ public IDebugTarget getDebugTarget() {
+ return this.debugTarget;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
+ */
+ public ILaunch getLaunch() {
+ return this.debugTarget.getLaunch();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ if (adapter == IDebugElement.class) {
+ return this;
+ }
+ return super.getAdapter(adapter);
+ }
+
+ /**
+ * Convenience method for the setting the debug target of this debug element
+ *
+ * @param debugTarget The debug target for this debug element
+ */
+ public void setDebugTarget(MokaDebugTarget debugTarget) {
+ this.debugTarget = debugTarget ;
+ }
+
+ /**
+ * Convenience method for aborting execution
+ *
+ * @param message
+ * @param e
+ * @throws DebugException
+ */
+ protected void abort(String message, Throwable e) throws DebugException {
+ throw new DebugException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, DebugPlugin.INTERNAL_ERROR, message, e));
+ }
+
+ /**
+ * Convenience method for firing a debug event to the debug plugin
+ *
+ * @param event the event to be fired
+ */
+ protected void fireEvent(DebugEvent event) {
+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {event});
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaDebugTarget.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaDebugTarget.java
new file mode 100644
index 00000000000..47d5b33b083
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaDebugTarget.java
@@ -0,0 +1,741 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.debug;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IMemoryBlock;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IRegisterGroup;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.event.Start_Event;
+import org.eclipse.papyrus.moka.communication.event.isuspendresume.Resume_Event;
+import org.eclipse.papyrus.moka.communication.event.isuspendresume.Suspend_Event;
+import org.eclipse.papyrus.moka.communication.event.iterminate.Terminate_Event;
+import org.eclipse.papyrus.moka.communication.request.RequestMessage;
+import org.eclipse.papyrus.moka.communication.request.ibreakpointlistener.AddBreakpoint_Request;
+import org.eclipse.papyrus.moka.communication.request.ibreakpointlistener.RemoveBreakpoint_Request;
+import org.eclipse.papyrus.moka.communication.request.idisconnect.Disconnect_Request;
+import org.eclipse.papyrus.moka.communication.request.istackframe.GetVariables_Request;
+import org.eclipse.papyrus.moka.communication.request.isuspendresume.Resume_Request;
+import org.eclipse.papyrus.moka.communication.request.isuspendresume.Suspend_Request;
+import org.eclipse.papyrus.moka.communication.request.iterminate.Terminate_Request;
+import org.eclipse.papyrus.moka.communication.request.ithread.GetStackFrames_Request;
+import org.eclipse.papyrus.moka.communication.request.ivalue.GetValueString_Request;
+import org.eclipse.papyrus.moka.communication.request.ivariable.GetReferenceTypeName_Request;
+import org.eclipse.papyrus.moka.communication.request.ivariable.GetValue_Request;
+
+/**
+ * An implementation of IDebugTarget.
+ * More specifically, it implements a communication protocol which complies with AbstractExecutionEngine.
+ * Communication rely on sockets. The EventDispatchJob associated with this MokaDebugTarget listens to events
+ * emitted by the target program (i.e., through the eventSocket), and fires corresponding debug events to
+ * the Debug plugin.
+ * The requestSocket is used to emit requests to the execution engine.
+ * The replySocket is used to receive replies from the execution engine.
+ *
+ */
+public class MokaDebugTarget extends MokaDebugElement implements IDebugTarget {
+
+ /**
+ * The launch object containing this debug target
+ */
+ protected ILaunch launch;
+
+ // sockets to communicate with Execution engine
+ protected Socket requestSocket;
+ protected PrintWriter requestWriter;
+ protected Socket replySocket;
+ protected BufferedReader replyReader;
+ protected Socket eventSocket;
+ protected BufferedReader eventReader;
+
+ // event dispatch job
+ protected EventDispatchJob eventDispatchJob;
+
+ protected boolean isStarted = false ;
+
+ /**
+ * Constructs a new moka debug target in the given launch for the associated Execution Engine process.
+ *
+ * @param launch containing launch
+ * @param process The execution engine process
+ * @param requestPort port to send requests to the process
+ * @param eventPort port to read events from
+ * @exception CoreException if unable to connect to host
+ */
+ public MokaDebugTarget(ILaunch launch, IProcess process) throws CoreException {
+ super(null);
+ this.launch = launch;
+ this.debugTarget = this;
+ this.executionEngineProcess = process ;
+ DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
+ }
+
+ /**
+ * Connects this debug target to the execution engine, and starts the event dispatch job.
+ *
+ * @param requestPort The port for the request socket
+ * @param replyPort The port for the reply socket
+ * @param eventPort The port for the event socket
+ * @throws DebugException
+ */
+ public void connect(int requestPort, int replyPort, int eventPort) throws DebugException {
+ try {
+ this.requestSocket = new Socket("localhost", requestPort);
+ this.requestWriter = new PrintWriter(this.requestSocket.getOutputStream());
+ this.replySocket = new Socket("localhost", replyPort);
+ this.replyReader = new BufferedReader(new InputStreamReader(this.replySocket.getInputStream()));
+ this.eventSocket = new Socket("localhost", eventPort);
+ this.eventReader = new BufferedReader(new InputStreamReader(this.eventSocket.getInputStream()));
+ } catch (UnknownHostException e) {
+ abort("Unable to connect to Execution Engine", e);
+ } catch (IOException e) {
+ abort("Unable to connect to Execution Engine", e);
+ }
+ this.eventDispatchJob = new EventDispatchJob();
+ this.eventDispatchJob.schedule();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.debug.MokaDebugElement#getLaunch()
+ */
+ public ILaunch getLaunch() {
+ return this.launch ;
+ }
+
+ ///////////////////////////////////////////
+ // Implementation of interface IDebugTarget
+ ///////////////////////////////////////////
+
+ /**
+ * The name of this debug target.
+ */
+ protected String name = null ;
+
+ /**
+ * The threads for this debug target.
+ * This collection of threads is initialized with the first Start_Event received in the event dispatch loop
+ * This collection of threads is updated with reception of a Suspend_Event in the event dispatch loop
+ *
+ */
+ protected MokaThread[] threads = new MokaThread[]{} ;
+
+ /**
+ * The process associated with this debug target. Hosts the target program, i.e., the actual execution engine
+ */
+ protected IProcess executionEngineProcess;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
+ */
+ public IProcess getProcess() {
+ return this.executionEngineProcess;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#getThreads()
+ */
+ public IThread[] getThreads() throws DebugException {
+ return threads ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#hasThreads()
+ */
+ public boolean hasThreads() throws DebugException {
+ return this.isStarted && !this.isTerminated() && this.getThreads() != null && this.getThreads().length > 0 ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#getName()
+ */
+ public String getName() throws DebugException {
+ if (this.name != null) {
+ return this.name ;
+ }
+ return "" ;
+ }
+
+ /**
+ * Convenience method for setting the new name for this MokaDebugTarget
+ *
+ * @param name
+ */
+ public void setName(String name) {
+ this.name = name ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDebugTarget#supportsBreakpoint(org.eclipse.debug.core.model.IBreakpoint)
+ */
+ public boolean supportsBreakpoint(IBreakpoint breakpoint) {
+ // By default, a breakpoint is supported if it has MokaConstants.ID_MOKA_DEBUG_MODEL as a debug model identifier
+ if (breakpoint.getModelIdentifier().equals(MokaConstants.MOKA_DEBUG_MODEL_ID)) {
+ return true ;
+ }
+ return false;
+ }
+
+ //////////////////////////////////////////////////
+ // Implementation of interface IBreakpointListener
+ //////////////////////////////////////////////////
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(org.eclipse.debug.core.model.IBreakpoint)
+ */
+ public void breakpointAdded(IBreakpoint breakpoint) {
+ if (this.supportsBreakpoint(breakpoint)) {
+ try {
+ if (breakpoint.isEnabled()) {
+ try {
+ // If the breakpoint is supported, this is a MokaBreakpoint
+ MokaBreakpoint mokaBreakpoint = (MokaBreakpoint)breakpoint ;
+ AddBreakpoint_Request request = new AddBreakpoint_Request(mokaBreakpoint) ;
+ this.sendRequest(request) ;
+ // Waits for an acknowledge from the execution engine
+ @SuppressWarnings("unused")
+ String ack = replyReader.readLine() ;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ } catch (CoreException e) {
+ e.printStackTrace() ;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
+ */
+ public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
+ if (supportsBreakpoint(breakpoint)) {
+ try {
+ // If the breakpoint is supported, this is a MokaBreakpoint
+ MokaBreakpoint mokaBreakpoint = (MokaBreakpoint)breakpoint ;
+ RemoveBreakpoint_Request request = new RemoveBreakpoint_Request(mokaBreakpoint) ;
+ this.sendRequest(request) ;
+ // Waits for an acknowledge from the execution engine
+ @SuppressWarnings("unused")
+ String ack = replyReader.readLine() ;
+ } catch (CoreException e) {
+ e.printStackTrace() ;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
+ */
+ public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
+ if (this.supportsBreakpoint(breakpoint)) {
+ try {
+ if (breakpoint.isEnabled() && DebugPlugin.getDefault().getBreakpointManager().isEnabled()) {
+ this.breakpointAdded(breakpoint);
+ } else {
+ this.breakpointRemoved(breakpoint, delta);
+ }
+ } catch (CoreException e) {
+ e.printStackTrace() ;
+ }
+ }
+ }
+
+ //////////////////////////////////////////
+ // Implementation of interface IDisconnect
+ //////////////////////////////////////////
+
+ /**
+ * Determines whether the target program is disconnected or not from this debug target.
+ */
+ protected boolean isDisconnected = false ;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDisconnect#canDisconnect()
+ */
+ public boolean canDisconnect() {
+ // In this default implementation, disconnection can never occur. This can be overloaded by clients.
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDisconnect#disconnect()
+ */
+ public void disconnect() throws DebugException {
+ try {
+ Disconnect_Request request = new Disconnect_Request() ;
+ this.sendRequest(request) ;
+ // Waits for an acknowledge from the execution engine
+ @SuppressWarnings("unused")
+ String ack = replyReader.readLine() ;
+ this.isDisconnected = true ;
+ } catch (CoreException e) {
+ e.printStackTrace() ;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IDisconnect#isDisconnected()
+ */
+ public boolean isDisconnected() {
+ return this.isDisconnected ;
+ }
+
+ ////////////////////////////////////////////////////
+ // Implementation of interface IMemoryBlockRetrieval
+ ////////////////////////////////////////////////////
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#supportsStorageRetrieval()
+ */
+ public boolean supportsStorageRetrieval() {
+ // By default, this default implementation does not support memory block retrieval. This can be overloaded by clients
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long)
+ */
+ public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException {
+ return null ;
+ }
+
+ ///////////////////////////////////
+ // Implementation of ISuspendResume
+ ///////////////////////////////////
+
+ /**
+ * Determines whether this element is currently suspended.
+ */
+ protected boolean isSuspended = false ;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
+ */
+ public boolean canResume() {
+ // The debug target can be resumed if it is currently suspended
+ return this.isSuspended ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
+ */
+ public boolean canSuspend() {
+ // The debug target can be suspended if it is not already suspended and if it is not terminated
+ return !this.isSuspended && !this.isTerminated() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
+ */
+ public boolean isSuspended() {
+ return this.isSuspended;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#resume()
+ */
+ public void resume() throws DebugException {
+ // A call to resume() has no effect on an element that is not suspended.
+ // if (this.isSuspended)
+ this.resume(this, DebugEvent.CLIENT_REQUEST) ;
+ }
+
+ /**
+ * Handles occurrence of a resume event. The event is represented by the String message, and has been emitted by the target program.
+ * This method is called by the event dispatch job.
+ *
+ * @param message The String representation of the event
+ */
+ protected void handle_Resume_Event(String message) {
+ Resume_Event event = Marshaller.getInstance().resume_event_unmarshal(message) ;
+ this.isSuspended = false ;
+ this.fireEvent(event.getDebugEvent()) ;
+ }
+
+ /**
+ * Sends a request to the target program for resuming the given debugElement (which can be an IDebugTarget or an IThread) for the reason hold by resumeDetail.
+ * resumeDetail can be one of the following values:
+ * - DebugEvent.CLIENT_REQUEST: Execution is resumed due to a resume client request
+ * - DebugEvent.STEP_INTO: Execution is resumed due to a step into client request
+ * - DebugEvent.STEP_OVER: Execution is resumed due to a step over client request
+ * - DebugEvent.STEP_RETURN: Execution is resumed due to a step return client request
+ * In reply to this request, the target program will emit a Resume_Event.
+ * This Resume_Event is handled by the event dispatch job, so that the appropriate RESUME DebugEvent is emitted to the DebugPlugin.
+ *
+ * @param debugElement The debug element being resumed
+ * @param resumeDetail Details about the reason for resuming
+ */
+ public void resume(IDebugElement debugElement, int resumeDetail) throws DebugException{
+ Resume_Request request = new Resume_Request(debugElement, resumeDetail) ;
+ try {
+ this.sendRequest(request) ;
+ } catch (DebugException e) {
+ this.abort("Failed to resume execution of the given debug element", e) ;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
+ */
+ public void suspend() throws DebugException {
+ // A call to suspend() has no effect on an element that is already suspended.
+ if (!this.isSuspended)
+ this.suspend(this, DebugEvent.CLIENT_REQUEST) ;
+ }
+
+ /**
+ * Sends a request to the target program for suspending the given debugElement (which can be an IDebugTarget or an IThread) for the reason hold by suspendDetail.
+ * resumeDetail can be one of the following values:
+ * - DebugEvent.CLIENT_REQUEST: Execution was suspended due to a suspend client request
+ * - DebugEvent.STEP_END: Execution was suspended due to the completion of a step action
+ * - DebugEvent.BREAKPOINT: Execution was suspended due to a breakpoint
+ * In reply to this request, the target program will emit a Suspend_Event.
+ * This Suspend_Event is handled by the event dispatch job, so that the appropriate SUSPEND DebugEvent is emitted to the DebugPlugin.
+ *
+ * @param debugElement The debug element being resumed
+ * @param suspendDetail Details about the reason for resuming
+ */
+ public void suspend(IDebugElement debugElement, int suspendDetail) throws DebugException {
+ Suspend_Request request = new Suspend_Request(debugElement, suspendDetail) ;
+ try {
+ this.sendRequest(request) ;
+ } catch (DebugException e) {
+ this.abort("Failed to suspend execution of the given debug element", e) ;
+ }
+ }
+
+ /**
+ * Handles occurrence of a suspend event. The event is represented by the String message, and has been emitted by the target program.
+ * This method is called by the event dispatch job.
+ *
+ * @param message The String representation of the event
+ */
+ protected void handle_Suspend_Event(String message) {
+ Suspend_Event event = Marshaller.getInstance().suspend_event_unmarshal(message) ;
+ this.isSuspended = true ;
+ this.threads = event.getThreads() ;
+ int suspendEventDetail = event.getDebugEvent().getDetail() ;
+ // In the case where the suspend event occured due to a step end, the corresponding IThread must be explicitly stated that it is not stepping anymore.
+ // @see MokaThrea.stepEnded()
+ if (suspendEventDetail == DebugEvent.STEP_END || suspendEventDetail == DebugEvent.BREAKPOINT) {
+ // By construction, the source element associated with this debug event is a MokaThread
+ MokaThread thread = (MokaThread)event.getDebugEvent().getSource() ;
+ thread.stepEnded() ;
+ }
+ this.fireEvent(event.getDebugEvent()) ;
+ }
+
+ ///////////////////////////////
+ // Implementation of ITerminate
+ ///////////////////////////////
+
+ /**
+ * Determines whether this element is terminated
+ */
+ protected boolean isTerminated = false;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
+ */
+ public boolean canTerminate() {
+ // An element can terminate if it is not already terminated
+ return ! this.isTerminated ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
+ */
+ public boolean isTerminated() {
+ return this.isTerminated ;
+ }
+
+ /**
+ * Terminates execution by firing a terminate event for the debug plugin
+ */
+ protected void terminated() {
+ this.isTerminated = true;
+ this.isSuspended = false ;
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this) ;
+ this.fireEvent(new Terminate_Event(this).getDebugEvent()) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#terminate()
+ */
+ public void terminate() throws DebugException {
+ this.terminate(this) ;
+ }
+
+ /**
+ * Sends a request to the target program for terminating the given debugElement (which can be an IDebugTarget or an IThread).
+ * In reply to this request, the target program will emit a Terminate_Event.
+ * This Terminate_Event is handled by the event dispatch job, so that the appropriate TERMINATE DebugEvent is emitted to the DebugPlugin.
+ *
+ * @param debugElement The debug element being terminated
+ */
+ public void terminate(IDebugElement debugElement) throws DebugException {
+ Terminate_Request request = new Terminate_Request(debugElement) ;
+ try {
+ this.sendRequest(request) ;
+ } catch (DebugException e) {
+ this.abort("Failed to terminate execution of the given debug element", e) ;
+ }
+ }
+
+ /**
+ * Handles occurrence of a terminate event, emitted by the target program.
+ * This method is called by the event dispatch job.
+ *
+ */
+ protected void handle_Terminate_Event() {
+ this.isTerminated = true ;
+ }
+
+ /**
+ * Listens to events from the Execution engine and fires corresponding debug events to the debug plugin
+ */
+ class EventDispatchJob extends Job {
+
+ public EventDispatchJob() {
+ super("Moka Event Dispatch");
+ setSystem(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IStatus run(IProgressMonitor monitor) {
+ String event = "";
+
+ while (!isTerminated() && event != null) {
+ try {
+ event = eventReader.readLine();
+ if (event != null) {
+ isSuspended = false ;
+ if (event.startsWith(MokaConstants.event_start)) {
+ handle_Start_Event(event);
+ }
+ else if (event.startsWith(MokaConstants.event_resume)) {
+ handle_Resume_Event(event);
+ }
+ else if (event.startsWith(MokaConstants.event_suspend)) {
+ handle_Suspend_Event(event);
+ }
+ else if (event.startsWith(MokaConstants.event_terminate)) {
+ handle_Terminate_Event() ;
+ }
+ }
+ } catch (IOException e) {
+ terminated();
+ }
+ }
+ terminated() ;
+ return Status.OK_STATUS;
+ }
+ }
+
+ //////////////////////
+ // Convenience methods
+ //////////////////////
+
+ /**
+ * Handles occurrence of a start event, which means that the target program is ready to receive requests.
+ * This method is called by the event dispatch job.
+ *
+ */
+ protected void handle_Start_Event(String message) {
+ Start_Event event = Marshaller.getInstance().start_event_unmarshal(message) ;
+ this.threads = event.getThreads() ;
+ this.fireEvent(event.getDebugEvent());
+ // Installs deferred breakpoints only if the breakpoint manager is enabled
+ //if (DebugPlugin.getDefault().getBreakpointManager().isEnabled())
+ this.installDeferredBreakpoints();
+ try {
+ resume();
+ this.isStarted = true ;
+ } catch (DebugException e) {
+ e.printStackTrace() ;
+ }
+ }
+
+ /**
+ * Install breakpoints that are already registered with the breakpoint manager
+ */
+ protected void installDeferredBreakpoints() {
+ IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(MokaConstants.MOKA_DEBUG_MODEL_ID) ;
+ for (int i = 0; i < breakpoints.length; i++) {
+ this.breakpointAdded(breakpoints[i]);
+ }
+ }
+
+ /**
+ * Convenience methods for marshaling and sending a request to the target program, through the request socket
+ *
+ * @param request The Request object to be marshaled and sent to the target program
+ * @throws DebugException
+ */
+ protected void sendRequest(RequestMessage request) throws DebugException {
+ synchronized (requestSocket) {
+ requestWriter.println(request.marshall());
+ requestWriter.flush();
+ }
+ }
+
+ /**
+ * Emits a request to the target program to retrieve stack frames associated with a thread.
+ * The returned array is empty (but not null) if no stack frames are available, or if the thread is not suspended.
+ * This method is provided as a convenience for MokaThread, so that all requests (respectively replies) are emitted (respectively received) from (by) the debug target
+ *
+ * @param thread The thread for which stack frames have to be retrieved
+ * @return The (possibly empty) collection of stack frames associated with the given thread
+ * @throws DebugException
+ */
+ public IStackFrame[] getStackFrames(IThread thread) throws DebugException {
+ IStackFrame[] stackFrames = new IStackFrame[]{} ;
+ if (!thread.isSuspended())
+ return stackFrames ;
+ this.sendRequest(new GetStackFrames_Request(thread)) ;
+ try {
+ String reply = replyReader.readLine() ;
+ stackFrames = Marshaller.getInstance().getStackFrames_reply_unmarshal(reply).getStackFrames() ;
+ } catch (IOException e) {
+ this.abort("Failed to retrieve stack frames", e) ;
+ }
+ return stackFrames ;
+ }
+
+ /**
+ * Emits a request to the target program to retrieve variables associated with a stack frame or value.
+ * The returned array is empty (but not null) if no variables are visible.
+ * This method is provided as a convenience for MokaStackFrame and MokaValue, so that all requests (respectively replies) are emitted (respectively received) from (by) the debug target
+ * stackFrameOrValue must be an IStackFrame or an IValue
+ *
+ * @param stackFrameOrValue The stack frame or value for which variables have to be retrieved
+ * @return The (possibly empty) collection of variables associated with this stack frame or value
+ * @throws DebugException
+ */
+ public MokaVariable[] getVariables(IDebugElement stackFrameOrValue) throws DebugException {
+ MokaVariable[] variables = new MokaVariable[]{} ;
+ this.sendRequest(new GetVariables_Request(stackFrameOrValue)) ;
+ try {
+ String reply = replyReader.readLine() ;
+ variables = Marshaller.getInstance().getVariables_reply_unmarshal(reply).getVariables() ;
+ } catch (IOException e) {
+ this.abort("Failed to retrieve variables", e) ;
+ }
+ return variables ;
+ }
+
+ /**
+ * Not supported by this default implementation
+ *
+ * @param stackFrame The stack frame for which register groups have to be retrieved
+ * @return The (possibly empty) collection of register groups associated with this stack frame
+ * @throws DebugException
+ */
+ public IRegisterGroup[] getRegisterGroups(IStackFrame stackFrame) throws DebugException {
+ return new IRegisterGroup[]{} ;
+ }
+
+ /**
+ * Emits a request to the target program to retrieve the value associated with a variable.
+ * The returned value may be null.
+ * This method is provided as a convenience for MokaVariable, so that all requests (respectively replies) are emitted (respectively received) from (by) the debug target
+ *
+ * @param variable The variable for which value has to be retrieved
+ * @return The value of this variable, if any
+ * @throws DebugException
+ */
+ public MokaValue getValue(MokaVariable variable) throws DebugException {
+ MokaValue value = null ;
+ this.sendRequest(new GetValue_Request(variable)) ;
+ try {
+ String reply = replyReader.readLine() ;
+ value = Marshaller.getInstance().getValue_reply_unmarshal(reply).getValue() ;
+ } catch (IOException e) {
+ this.abort("Failed to retrieve variable value", e) ;
+ }
+ return value ;
+ }
+
+ /**
+ * Emits a request to the target program to retrieve the reference type name of a variable or value.
+ * The returned value may be null.
+ * This method is provided as a convenience for MokaVariable, so that all requests (respectively replies) are emitted (respectively received) from (by) the debug target
+ *
+ * @param debugElement The variable or value for which the reference type name has to be retrieved
+ * @return The reference type name of this variable or value, if any
+ * @throws DebugException
+ */
+ public String getReferenceTypeName(IDebugElement debugElement) throws DebugException {
+ String referenceTypeName = null ;
+ this.sendRequest(new GetReferenceTypeName_Request(debugElement)) ;
+ try {
+ String reply = replyReader.readLine() ;
+ referenceTypeName = Marshaller.getInstance().getReferenceTypeName_reply_unmarshal(reply).getReferenceTypeName() ;
+ } catch (IOException e) {
+ this.abort("Failed to retrieve variable value", e) ;
+ }
+ return referenceTypeName ;
+ }
+
+ /**
+ * Emits a request to the target program to retrieve the string representation of a value.
+ * The returned value may be null.
+ * This method is provided as a convenience for MokaVariable, so that all requests (respectively replies) are emitted (respectively received) from (by) the debug target
+ *
+ * @param value The value for which the string representation has to be retrieved
+ * @return The string representation of this value
+ * @throws DebugException
+ */
+ public String getValueString(IValue value) throws DebugException {
+ String textualRepresentation = null ;
+ this.sendRequest(new GetValueString_Request(value)) ;
+ try {
+ String reply = replyReader.readLine() ;
+ textualRepresentation = Marshaller.getInstance().getValueString_reply_unmarshal(reply).getValueString() ;
+ } catch (IOException e) {
+ this.abort("Failed to retrieve textual representation of value", e) ;
+ }
+ return textualRepresentation ;
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaJobChangeListener.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaJobChangeListener.java
new file mode 100644
index 00000000000..4deec8fa13d
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaJobChangeListener.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.debug;
+
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.IJobChangeListener;
+
+/**
+ * See MokaProcess
+ *
+ */
+public class MokaJobChangeListener implements IJobChangeListener {
+
+ protected MokaProcess process;
+
+ public MokaJobChangeListener(MokaProcess process) {
+ this.process = process;
+ }
+
+ public void sleeping(IJobChangeEvent event) {
+ // Not used
+ }
+
+ public void scheduled(IJobChangeEvent event) {
+ // Not used
+ }
+
+ public void running(IJobChangeEvent event) {
+ // Not used
+ }
+
+ public void done(IJobChangeEvent event) {
+ process.terminated();
+ }
+
+ public void awake(IJobChangeEvent event) {
+ // Not used
+ }
+
+ public void aboutToRun(IJobChangeEvent event) {
+ // Not used
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaProcess.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaProcess.java
new file mode 100644
index 00000000000..f1d5ce5b449
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaProcess.java
@@ -0,0 +1,305 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.debug;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IStreamsProxy;
+import org.eclipse.debug.core.model.ITerminate;
+
+/**
+ * An IProcess is an abstraction of a running program (in our case, the actual execution engine).
+ * The Eclipse debug plugin provides a default implementation for java.lang.Process.
+ * Such a Process can then be started by running a command line. In the case where the target
+ * program is itself implemented as an Eclipse plug-in, providing the appropriate command line
+ * is complex, especially regarding the appropriate class path.
+ * In order to simplify this, Moka provides MokaProcess, an implementation of IProcess
+ * simulating a process with a job. The job is provided as a parameter of the constructor,
+ * and encapsulates execution of an IExecutionEngine. When the constructor is called,
+ * a MokaJobChangeListener is added to the given Job, so that when the Job terminates
+ * (which means that Job.done() is called), the MokaProcess is notified of the termination
+ * and terminates itself (i.e., MokaJobChangeListener.done() calls MokaProcess.terminated()).
+ *
+ */
+public class MokaProcess extends PlatformObject implements IProcess {
+
+ private static final int MAX_WAIT_FOR_DEATH_ATTEMPTS = 10;
+ private static final int TIME_TO_WAIT_FOR_THREAD_DEATH = 500; // ms
+
+ /**
+ * The launch this process is contained in
+ */
+ protected ILaunch launch;
+
+ /**
+ * The Job used to run the execution engine
+ */
+ protected Job job;
+
+ /**
+ * This Job's exit value
+ */
+ protected int exitValue;
+
+ /**
+ * The label of the process
+ */
+ protected String label;
+
+ /**
+ * Whether this process is terminated
+ */
+ protected boolean isTerminated = false ;
+
+ /**
+ * Table of client defined attributes
+ */
+ protected Map<String, String> attributes;
+
+
+ /**
+ * Constructs a MokaRuntimeProcess on the given job, adding this process to the given launch.
+ *
+ * @param launch the parent launch of this process
+ * @param process underlying system process
+ * @param label the label used for this process
+ * @param attributes map of attributes used to initialize the attributes of this process, or null if none
+ */
+ public MokaProcess(ILaunch launch, Job job, String label, Map<String, String> attributes) {
+ this.launch = launch;
+ initializeAttributes(attributes);
+ this.job = job ;
+ this.job.addJobChangeListener(new MokaJobChangeListener(this)) ;
+ this.label = label;
+ isTerminated= false ;
+ launch.addProcess(this);
+ fireCreationEvent();
+ }
+
+ /**
+ * Initialize the attributes of this process to those in the given map.
+ *
+ * @param attributes attribute map or <code>null</code> if none
+ */
+ protected void initializeAttributes(Map<String, String> attributes) {
+ if (attributes != null) {
+ Iterator<String> keys = attributes.keySet().iterator();
+ while (keys.hasNext()) {
+ String key = (String)keys.next();
+ setAttribute(key, (String)attributes.get(key));
+ }
+ }
+ }
+
+ /**
+ * @see ITerminate#canTerminate()
+ */
+ public synchronized boolean canTerminate() {
+ return !isTerminated;
+ }
+
+ /**
+ * @see IProcess#getLabel()
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ * @see IProcess#getLaunch()
+ */
+ public ILaunch getLaunch() {
+ return launch;
+ }
+
+ /**
+ * @see ITerminate#isTerminated()
+ */
+ public synchronized boolean isTerminated() {
+ return isTerminated;
+ }
+
+ /**
+ * @see ITerminate#terminate()
+ */
+ public void terminate() throws DebugException {
+ if (!isTerminated()) {
+ //Job job = getExecutionEngineJob();
+ if (this.job != null) {
+ this.job.cancel();
+ }
+ int attempts = 0;
+ while (attempts < MAX_WAIT_FOR_DEATH_ATTEMPTS) {
+ try {
+ if (this.job != null) {
+ IStatus result = this.job.getResult() ;
+ if (result == null) // No result available. It means that cancellation is not yet effective.
+ throw new IllegalThreadStateException() ;
+ else
+ this.exitValue = this.job.getResult().getCode() ;
+ }
+ return;
+ } catch (IllegalThreadStateException ie) {
+ ie.printStackTrace() ;
+ }
+ try {
+ Thread.sleep(TIME_TO_WAIT_FOR_THREAD_DEATH);
+ } catch (InterruptedException e) {
+ }
+ attempts++;
+ }
+ IStatus status = new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugException.TARGET_REQUEST_FAILED, "Terminate failed", null);
+ throw new DebugException(status);
+ }
+ }
+
+ /**
+ * Notification that the system process associated with this process
+ * has terminated.
+ */
+ public void terminated() {
+ int exitValue = -1;
+ boolean running = false;
+ try {
+ exitValue = this.job.getResult().getCode();
+ } catch (IllegalThreadStateException ie) {
+ running = true;
+ }
+
+ synchronized (this) {
+ isTerminated= true;
+ if (!running) {
+ this.exitValue = exitValue;
+ }
+ this.job= null;
+ }
+ this.fireTerminateEvent();
+ }
+
+ /**
+ * @see IProcess#getStreamsProxy()
+ */
+ public IStreamsProxy getStreamsProxy() {
+ return null;
+ }
+
+ /**
+ * Fires a creation event.
+ */
+ protected void fireCreationEvent() {
+ fireEvent(new DebugEvent(this, DebugEvent.CREATE));
+ }
+
+ /**
+ * Fires the given debug event.
+ *
+ * @param event debug event to fire
+ */
+ protected void fireEvent(DebugEvent event) {
+ DebugPlugin manager= DebugPlugin.getDefault();
+ if (manager != null) {
+ manager.fireDebugEventSet(new DebugEvent[]{event});
+ }
+ }
+
+ /**
+ * Fires a terminate event.
+ */
+ protected void fireTerminateEvent() {
+ fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
+ }
+
+ /**
+ * Fires a change event.
+ */
+ protected void fireChangeEvent() {
+ fireEvent(new DebugEvent(this, DebugEvent.CHANGE));
+ }
+
+ /**
+ * @see IProcess#setAttribute(String, String)
+ */
+ public void setAttribute(String key, String value) {
+ if (attributes == null) {
+ attributes = new HashMap<String,String>();
+ }
+ Object origVal = attributes.get(key);
+ if (origVal != null && origVal.equals(value)) {
+ return; //nothing changed.
+ }
+
+ attributes.put(key, value);
+ fireChangeEvent();
+ }
+
+ /**
+ * @see IProcess#getAttribute(String)
+ */
+ public String getAttribute(String key) {
+ if (attributes == null) {
+ return null;
+ }
+ return (String)attributes.get(key);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ if (adapter.equals(IProcess.class)) {
+ return this;
+ }
+ if (adapter.equals(IDebugTarget.class)) {
+ ILaunch launch = getLaunch();
+ IDebugTarget[] targets = launch.getDebugTargets();
+ for (int i = 0; i < targets.length; i++) {
+ if (this.equals(targets[i].getProcess())) {
+ return targets[i];
+ }
+ }
+ return null;
+ }
+ if (adapter.equals(ILaunch.class)) {
+ return getLaunch();
+ }
+ //CONTEXTLAUNCHING
+ if(adapter.equals(ILaunchConfiguration.class)) {
+ return getLaunch().getLaunchConfiguration();
+ }
+ return super.getAdapter(adapter);
+ }
+ /**
+ * @see IProcess#getExitValue()
+ */
+ public synchronized int getExitValue() throws DebugException {
+ if (isTerminated()) {
+ return exitValue;
+ }
+ throw new DebugException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugException.TARGET_REQUEST_FAILED, "Exit value not available until process terminates.", null));
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaStackFrame.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaStackFrame.java
new file mode 100644
index 00000000000..882c64cf71a
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaStackFrame.java
@@ -0,0 +1,345 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.debug;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IRegisterGroup;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * An implementation of MokaStackFrame.
+ * A MokaStackFrame is associated with a model element.
+ *
+ */
+public class MokaStackFrame extends MokaDebugElement implements IStackFrame {
+
+ /**
+ * The model element represented by this moka stack frame.
+ * For example, this can be a node or edge in a UML Activity
+ *
+ */
+ protected EObject modelElement ;
+
+ public MokaStackFrame(MokaDebugTarget target) {
+ super(target);
+ }
+
+ /**
+ * Sets the model element represented by this stack frame
+ *
+ * @param modelElement the model element represented by this stack frame
+ */
+ public void setModelElement(EObject modelElement) {
+ this.modelElement = modelElement ;
+ }
+
+ /**
+ * Returns the model element represented by this stack frame
+ *
+ * @return the model element represented by this stack frame
+ */
+ public EObject getModelElement() {
+ return this.modelElement ;
+ }
+
+ ////////////////////////////////
+ // Implementation of IStackFrame
+ ////////////////////////////////
+
+ /**
+ * The thread this stack frame is contained in
+ */
+ protected MokaThread thread = null ;
+
+ /**
+ * The variables associated with this stack frame
+ */
+ protected MokaVariable[] variables = null ;
+
+ /**
+ * The name of this stack frame
+ */
+ protected String name = null ;
+
+ /**
+ * The register groups assigned to this stack frame
+ */
+ protected IRegisterGroup[] registerGroups = null ;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getThread()
+ */
+ public IThread getThread() {
+ return this.thread ;
+ }
+
+ /**
+ * A Convenience method for setting the thread containing this stack frame
+ *
+ * @param thread The thread containing this stack frame
+ */
+ public void setThread(MokaThread thread) {
+ this.thread = thread ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getVariables()
+ */
+ public IVariable[] getVariables() throws DebugException {
+ if (this.variables != null)
+ return this.variables ;
+ // Delegates retrieval of variables to the owning debug target
+ this.variables = this.debugTarget.getVariables(this) ;
+ return this.variables ;
+ }
+
+ /**
+ * A convenience method for setting the visible variables of this stack frame
+ *
+ * @param variables The visible variables of this stack frame
+ */
+ public void setVariables(MokaVariable[] variables) {
+ if (variables != null)
+ this.variables = variables ;
+ else
+ this.variables = new MokaVariable[]{} ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#hasVariables()
+ */
+ public boolean hasVariables() throws DebugException {
+ return this.getVariables().length > 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getLineNumber()
+ */
+ public int getLineNumber() throws DebugException {
+ // line number information is not available / does not make sense in the context of a model
+ return -1 ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getCharStart()
+ */
+ public int getCharStart() throws DebugException {
+ // char start information is not available / does not make sense in the context of a model
+ return -1;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getCharEnd()
+ */
+ public int getCharEnd() throws DebugException {
+ // char end information is not available / does not make sense in the context of a model
+ return -1;
+ }
+
+// /* (non-Javadoc)
+// * @see org.eclipse.debug.core.model.IStackFrame#getName()
+// */
+// public String getName() throws DebugException {
+// if (this.name != null)
+// return this.name ;
+// // Delegates to the owning debug target retrieval of this stack frame name
+// this.name = this.debugTarget.getName(this) ;
+// return this.name ;
+// }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getName()
+ */
+ public String getName() throws DebugException {
+ if (this.name != null)
+ return this.name ;
+ // Delegates to the owning debug target retrieval of this stack frame name
+ return "" ;
+ }
+
+ /**
+ * A convenience method for setting the name of this stack frame
+ *
+ * @param name The new name for this stack frame
+ */
+ public void setName(String name) {
+ this.name = name != null ? name : "" ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups()
+ */
+ public IRegisterGroup[] getRegisterGroups() throws DebugException {
+ if (this.registerGroups != null)
+ return this.registerGroups ;
+ // Delegates retrieval of register groups to the owning debug target
+ this.registerGroups = this.debugTarget.getRegisterGroups(this) ;
+ return this.registerGroups;
+ }
+
+ /**
+ * A convenience method for setting the register groups of a stack frame
+ *
+ * @param registerGroups The register groups of this stack frame
+ */
+ public void setRegisterGroups(IRegisterGroup[] registerGroups) {
+ if (registerGroups != null)
+ this.registerGroups = registerGroups ;
+ else
+ this.registerGroups = new IRegisterGroup[]{} ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups()
+ */
+ public boolean hasRegisterGroups() throws DebugException {
+ return this.getRegisterGroups().length > 0;
+ }
+
+ //////////////////////////
+ // Implementation of IStep
+ //////////////////////////
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#canStepInto()
+ */
+ public boolean canStepInto() {
+ // delegates to the owning thread
+ return this.getThread().canStepInto() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#canStepOver()
+ */
+ public boolean canStepOver() {
+ // delegates to the owning thread
+ return this.getThread().canStepOver() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#canStepReturn()
+ */
+ public boolean canStepReturn() {
+ // delegates to the owning thread
+ return this.getThread().canStepReturn() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#isStepping()
+ */
+ public boolean isStepping() {
+ // delegates to the owning thread
+ return this.getThread().isStepping() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepInto()
+ */
+ public void stepInto() throws DebugException {
+ // delegates to the owning thread
+ this.getThread().stepInto() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepOver()
+ */
+ public void stepOver() throws DebugException {
+ // delegates to the owning thread
+ this.getThread().stepOver() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepReturn()
+ */
+ public void stepReturn() throws DebugException {
+ // delegates to the owning thread
+ this.getThread().stepReturn() ;
+ }
+
+ ///////////////////////////////////
+ // Implementation of ISuspendResume
+ ///////////////////////////////////
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
+ */
+ public boolean canResume() {
+ // delegates to the owning thread
+ return this.getThread().canResume() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
+ */
+ public boolean canSuspend() {
+ // delegates to the owning thread
+ return this.getThread().canSuspend() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
+ */
+ public boolean isSuspended() {
+ // delegates to the owning thread
+ return this.getThread().isSuspended() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#resume()
+ */
+ public void resume() throws DebugException {
+ // delegates to the owning thread
+ this.getThread().resume() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
+ */
+ public void suspend() throws DebugException {
+ // delegates to the owning thread
+ this.getThread().suspend() ;
+ }
+
+ ///////////////////////////////
+ // Implementation of ITerminate
+ ///////////////////////////////
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
+ */
+ public boolean canTerminate() {
+ // delegates to the owning thread
+ return this.getThread().canTerminate() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
+ */
+ public boolean isTerminated() {
+ // delegates to the owning thread
+ return this.getThread().isTerminated() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#terminate()
+ */
+ public void terminate() throws DebugException {
+ // delegates to the owning thread
+ this.getThread().terminate() ;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaThread.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaThread.java
new file mode 100644
index 00000000000..d05d0816813
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaThread.java
@@ -0,0 +1,329 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.debug;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+
+
+/**
+ * An implementation of IThread
+ *
+ */
+public class MokaThread extends MokaDebugElement implements IThread {
+
+ public MokaThread(MokaDebugTarget debugTarget) {
+ super(debugTarget) ;
+ }
+
+ ////////////////////////////
+ // Implementation of IThread
+ ////////////////////////////
+
+ /**
+ * The stack frames contained in this thread.
+ */
+ protected IStackFrame[] stackFrames ;
+
+ /**
+ * The breakpoints this thread is suspended on.
+ * This can be empty if the thread is not suspended, or it is not suspended on a breakpoint (e.g., suspended due to a step end)
+ */
+ protected MokaBreakpoint[] breakpoints = new MokaBreakpoint[]{};
+
+ /**
+ * The priority of this thread
+ */
+ protected int priority = 0 ;
+
+ /**
+ * The name of this thread
+ */
+ protected String name = null ;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getStackFrames()
+ */
+ public IStackFrame[] getStackFrames() throws DebugException {
+ if (stackFrames != null) {
+ return this.stackFrames ;
+ }
+ // Delegates retrieval of stack frames to the owning debug target
+ this.stackFrames = this.debugTarget.getStackFrames(this) ;
+ return this.stackFrames ;
+ }
+
+ /**
+ * A convenience method for setting the stack frames of a MokaThread
+ *
+ * @param stackFrames The stack frames for this thread
+ */
+ public void setStackFrames(IStackFrame[] stackFrames) {
+ this.stackFrames = stackFrames ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#hasStackFrames()
+ */
+ public boolean hasStackFrames() throws DebugException {
+ return this.getStackFrames().length > 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getPriority()
+ */
+ public int getPriority() throws DebugException {
+ return this.priority ;
+ }
+
+ /**
+ * Convenience method for setting the priority of a MokaThread
+ *
+ * @param priority The priority of the thread
+ */
+ public void setPriority(int priority) {
+ this.priority = priority ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getTopStackFrame()
+ */
+ public IStackFrame getTopStackFrame() throws DebugException {
+ if (this.hasStackFrames())
+ return this.stackFrames[0] ;
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getName()
+ */
+ public String getName() throws DebugException {
+ if (this.name != null)
+ return this.name ;
+ return "" ;
+ }
+
+ /**
+ * Convenience method for setting the name of a thread
+ *
+ * @param name The new name for this thread
+ */
+ public void setName(String name) {
+ this.name = name ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IThread#getBreakpoints()
+ */
+ public IBreakpoint[] getBreakpoints() {
+ if (! this.isSuspended)
+ return new IBreakpoint[] {} ;
+ return this.breakpoints ;
+ }
+
+ /**
+ * Convenience method for setting the breakpoints where a thread is suspended
+ *
+ * @param breakpoints The breakpoints on which the thread is suspended
+ */
+ public void setBreakpoints(MokaBreakpoint[] breakpoints) {
+ if (breakpoints != null)
+ this.breakpoints = breakpoints ;
+ else
+ this.breakpoints = new MokaBreakpoint[]{} ;
+ }
+
+ ///////////////////////////////
+ // Implementation of ITerminate
+ ///////////////////////////////
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
+ */
+ public boolean canTerminate() {
+ // A thread can be terminated if its debug target can be terminated
+ return this.debugTarget.canTerminate() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
+ */
+ public boolean isTerminated() {
+ // A thread is terminated if its debug target is terminated
+ return this.debugTarget.isTerminated() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ITerminate#terminate()
+ */
+ public void terminate() throws DebugException {
+ this.isStepping = false ;
+ // Delegates termination to the owning debug target
+ this.debugTarget.terminate(this) ;
+ }
+
+ ///////////////////////////////////
+ // Implementation of ISuspendResume
+ ///////////////////////////////////
+
+ /**
+ * Determines whether this element is currently suspended.
+ */
+ protected boolean isSuspended = false ;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
+ */
+ public boolean canResume() {
+ // A thread can resume if it is suspended
+ return this.isSuspended() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
+ */
+ public boolean canSuspend() {
+ // A thread can suspend if it is not already suspended
+ return !this.isSuspended() ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
+ */
+ public boolean isSuspended() {
+ return this.isSuspended ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#resume()
+ */
+ public void resume() throws DebugException {
+ this.isSuspended = false ;
+ // Delegates resume to the owning debugTarget
+ this.debugTarget.resume(this, DebugEvent.CLIENT_REQUEST) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
+ */
+ public void suspend() throws DebugException {
+ this.isSuspended = true ;
+ // delegates suspend to the owning debugTarget
+ this.debugTarget.suspend(this, DebugEvent.CLIENT_REQUEST) ;
+ }
+
+ /**
+ * Convenience method for setting the value of the isSuspended attribute
+ *
+ * @param isSuspended
+ */
+ public void setSuspended(boolean isSuspended) {
+ this.isSuspended = isSuspended ;
+ }
+
+ //////////////////////////
+ // Implementation of IStep
+ //////////////////////////
+
+ /**
+ * A thread is considered to be stepping after the step is entered (resume event is emitted) and until the step is completed (suspend event is emitted)
+ */
+ protected boolean isStepping = false ;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#canStepInto()
+ */
+ public boolean canStepInto() {
+ // Step into is possible if the thread is suspended.
+ return this.isSuspended ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#canStepOver()
+ */
+ public boolean canStepOver() {
+ // Step over is possible if the thread is suspended.
+ return this.isSuspended ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#canStepReturn()
+ */
+ public boolean canStepReturn() {
+ // Step return is possible if the thread is suspended.
+ return this.isSuspended ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#isStepping()
+ */
+ public boolean isStepping() {
+ return this.isStepping ;
+ }
+
+ /**
+ * Convenience method to enable the MokaDebugTarget to state that a MokaThread is no more stepping.
+ * This is called by the debug target when suspend event occurs, with one of the following SUSPEND details:
+ * - DebugEvent.STEP_END
+ * - DebugEvent.BREAKPOINT
+ *
+ * @param isStepping
+ */
+ public void stepEnded() {
+ this.isStepping = false ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepInto()
+ */
+ public void stepInto() throws DebugException {
+ // This thread enters stepping state
+ this.isStepping = true ;
+ // Resuming is delegated to the owning debug target, with appropriate RESUME event details
+ // This will trigger a RESUME event for the target program.
+ // Stepping state will be exit when the target program generates a suspend event corresponding to a STEP_END or BREAKPOINT
+ // Exiting the stepping state is handled by the moka debug target, in reaction to the suspend event.
+ this.debugTarget.resume(this, DebugEvent.STEP_INTO) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepOver()
+ */
+ public void stepOver() throws DebugException {
+ // This thread enters stepping state.
+ this.isStepping = true ;
+ // Resuming is delegated to the owning debug target, with appropriate RESUME event details
+ // This will trigger a RESUME event for the target program.
+ // Stepping state will be exit when the target program generates a suspend event corresponding to a STEP_END or BREAKPOINT
+ // Exiting the stepping state is handled by the moka debug target, in reaction to the suspend event.
+ this.debugTarget.resume(this, DebugEvent.STEP_OVER) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IStep#stepReturn()
+ */
+ public void stepReturn() throws DebugException {
+ // This thread enters stepping state
+ this.isStepping = true ;
+ // Resuming is delegated to the owning debug target, with appropriate RESUME event details
+ // This will trigger a RESUME event for the target program.
+ // Stepping state will be exit when the target program generates a suspend event corresponding to a STEP_END or BREAKPOINT
+ // Exiting the stepping state is handled by the moka debug target, in reaction to the suspend event.
+ this.debugTarget.resume(this, DebugEvent.STEP_RETURN) ;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaValue.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaValue.java
new file mode 100644
index 00000000000..8cbd24001b7
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaValue.java
@@ -0,0 +1,124 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.debug;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+
+/**
+ * An implementation of IValue
+ *
+ */
+public class MokaValue extends MokaDebugElement implements IValue {
+
+ public MokaValue(MokaDebugTarget target) {
+ super(target);
+ }
+
+ ///////////////////////////
+ // Implementation of IValue
+ ///////////////////////////
+
+ /**
+ * The reference type name of this value
+ */
+ protected String referenceTypeName = null ;
+
+ /**
+ * The textual representation of this value
+ */
+ protected String textualRepresentation = null ;
+
+ /**
+ * The variables contained in this value
+ */
+ protected MokaVariable[] nestedVariables = null ;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
+ */
+ public String getReferenceTypeName() throws DebugException {
+ if (this.referenceTypeName != null)
+ return this.referenceTypeName ;
+ // Delegates retrieval of the reference type name to the owning debug target
+ this.referenceTypeName = this.debugTarget.getReferenceTypeName(this) ;
+ return this.referenceTypeName ;
+ }
+
+ /**
+ * Convenience method for setting the reference type name of this value
+ *
+ * @param referenceTypeName The new reference type name for this value
+ */
+ public void setReferenceTypeName(String referenceTypeName) {
+ this.referenceTypeName = referenceTypeName != null ? referenceTypeName : "" ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IValue#getValueString()
+ */
+ public String getValueString() throws DebugException {
+ if (this.textualRepresentation != null)
+ return this.textualRepresentation ;
+ // Delegates retrieval of the textual representation of this value to the owning debug target
+ this.textualRepresentation = this.debugTarget.getValueString(this) ;
+ return this.textualRepresentation ;
+ }
+
+ /**
+ * Convenience method for setting the textual representation of a MokaValue
+ *
+ * @param textualRepresentation The new textual representation for this value
+ */
+ public void setValueString(String textualRepresentation) {
+ this.textualRepresentation = textualRepresentation != null ? textualRepresentation : "" ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IValue#isAllocated()
+ */
+ public boolean isAllocated() throws DebugException {
+ // This default implementation return true
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IValue#getVariables()
+ */
+ public IVariable[] getVariables() throws DebugException {
+ if (this.nestedVariables != null)
+ return this.nestedVariables ;
+ // Delegates retrieval of variables to the owning debug target
+ this.nestedVariables = this.debugTarget.getVariables(this) ;
+ return this.nestedVariables ;
+ }
+
+ /**
+ * Convenience method for setting the nested variables of a MokaVariable
+ *
+ * @param nestedVariables The nested variables for this value
+ */
+ public void setVariables(MokaVariable[] nestedVariables) {
+ this.nestedVariables = (nestedVariables != null ? nestedVariables : new MokaVariable[]{}) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IValue#hasVariables()
+ */
+ public boolean hasVariables() throws DebugException {
+ return this.getVariables().length > 0 ;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaVariable.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaVariable.java
new file mode 100644
index 00000000000..52a819732cf
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/debug/MokaVariable.java
@@ -0,0 +1,138 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.debug;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+
+/**
+ * An implementation of IVariable
+ *
+ */
+public class MokaVariable extends MokaDebugElement implements IVariable {
+
+ public MokaVariable(MokaDebugTarget target) {
+ super(target);
+ }
+
+ //////////////////////////////
+ // Implementation of IVariable
+ //////////////////////////////
+
+ /**
+ * The value of this variable
+ */
+ protected MokaValue value = null ;
+
+ /**
+ * The name of this variable
+ */
+ protected String name = null ;
+
+ /**
+ * The reference type name for this variable
+ */
+ protected String referenceTypeName = null ;
+
+ /**
+ * Determines whether this variable's value has changed since the last suspend event
+ */
+ protected boolean hasValueChanged = false ;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IVariable#getValue()
+ */
+ public IValue getValue() throws DebugException {
+ if (this.value != null)
+ return this.value ;
+ // Delegates retrieval of the value to the owning debug target
+ this.value = this.debugTarget.getValue(this) ;
+ return this.value ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IVariable#getName()
+ */
+ public String getName() throws DebugException {
+ if (this.name != null)
+ return this.name ;
+ return "" ;
+ }
+
+ /**
+ * Convenience method for setting the name of variable
+ *
+ * @param name The new name for this variable
+ */
+ public void setName(String name) {
+ this.name = name != null ? name : "" ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
+ */
+ public String getReferenceTypeName() throws DebugException {
+ if (this.referenceTypeName != null)
+ return this.referenceTypeName ;
+ // Delegates retrieval of the reference type name to the owning debug target
+ this.referenceTypeName = this.debugTarget.getReferenceTypeName(this) ;
+ return this.referenceTypeName ;
+ }
+
+ /**
+ * Convenience method for setting the reference type name of a variable
+ *
+ * @param referenceTypeName The new reference type name for this variable
+ */
+ public void setReferenceTypeName(String referenceTypeName) {
+ this.referenceTypeName = referenceTypeName != null ? referenceTypeName : "" ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
+ */
+ public boolean hasValueChanged() throws DebugException {
+ return this.hasValueChanged ; // In this implementation, it means that it always returns false
+ }
+
+ ///////////////////////////////////////
+ // Implementation of IValueModification
+ ///////////////////////////////////////
+
+ public void setValue(String expression) throws DebugException {
+ // Do nothing
+ }
+
+ public void setValue(IValue value) throws DebugException {
+ if (value instanceof MokaValue)
+ this.value = (MokaValue)value ;
+ }
+
+ public boolean supportsValueModification() {
+ // By default, does not support value modification
+ return false;
+ }
+
+ public boolean verifyValue(String expression) throws DebugException {
+ // By default, does not support value modification
+ return false;
+ }
+
+ public boolean verifyValue(IValue value) throws DebugException {
+ // By default, does not support value modification
+ return false;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/engine/AbstractExecutionEngine.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/engine/AbstractExecutionEngine.java
new file mode 100644
index 00000000000..af7e761a998
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/engine/AbstractExecutionEngine.java
@@ -0,0 +1,536 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.engine;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IMemoryBlock;
+import org.eclipse.debug.core.model.IRegisterGroup;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.communication.Marshaller;
+import org.eclipse.papyrus.moka.communication.event.EventMessage;
+import org.eclipse.papyrus.moka.communication.event.Start_Event;
+import org.eclipse.papyrus.moka.communication.event.isuspendresume.Resume_Event;
+import org.eclipse.papyrus.moka.communication.event.isuspendresume.Suspend_Event;
+import org.eclipse.papyrus.moka.communication.event.iterminate.Terminate_Event;
+import org.eclipse.papyrus.moka.communication.reply.Ack;
+import org.eclipse.papyrus.moka.communication.reply.ReplyMessage;
+import org.eclipse.papyrus.moka.communication.reply.istackframe.GetVariables_Reply;
+import org.eclipse.papyrus.moka.communication.reply.ithread.GetStackFrames_Reply;
+import org.eclipse.papyrus.moka.communication.reply.ivalue.GetValueString_Reply;
+import org.eclipse.papyrus.moka.communication.reply.ivariable.GetReferenceTypeName_Reply;
+import org.eclipse.papyrus.moka.communication.reply.ivariable.GetValue_Reply;
+import org.eclipse.papyrus.moka.communication.request.ibreakpointlistener.AddBreakpoint_Request;
+import org.eclipse.papyrus.moka.communication.request.ibreakpointlistener.RemoveBreakpoint_Request;
+import org.eclipse.papyrus.moka.communication.request.istackframe.GetVariables_Request;
+import org.eclipse.papyrus.moka.communication.request.isuspendresume.Resume_Request;
+import org.eclipse.papyrus.moka.communication.request.isuspendresume.Suspend_Request;
+import org.eclipse.papyrus.moka.communication.request.iterminate.Terminate_Request;
+import org.eclipse.papyrus.moka.communication.request.ithread.GetStackFrames_Request;
+import org.eclipse.papyrus.moka.communication.request.ivalue.GetValueString_Request;
+import org.eclipse.papyrus.moka.communication.request.ivariable.GetReferenceTypeName_Request;
+import org.eclipse.papyrus.moka.communication.request.ivariable.GetValue_Request;
+import org.eclipse.papyrus.moka.debug.MokaBreakpoint;
+import org.eclipse.papyrus.moka.debug.MokaDebugTarget;
+import org.eclipse.papyrus.moka.debug.MokaValue;
+import org.eclipse.papyrus.moka.debug.MokaVariable;
+
+/**
+ * An abstract implementation of IExecutionEngine, consistent with the communication
+ * protocol implemented by MokaDebugTarget.
+ * This implementation encapsulates a request dispatch loop. This abstract class can
+ * be extended and used with the generic implementation of the Eclipse Debug Model
+ * provided by Moka. The proposed debug model is included in package debug.
+ * In particular, it includes class MokaDebugTarget, an implementation of IDebugTarget
+ * which encapsulates an event dispatch loop.
+ *
+ */
+public abstract class AbstractExecutionEngine implements IExecutionEngine {
+
+ /**
+ * The eObject being executed by this execution engine
+ */
+ protected EObject eObjectToExecute ;
+
+ /**
+ * The mode in which this execution is running. Values can be ILaunchManager.DEBUG_MODE or ILaunchManager.RUN_MODE
+ */
+ protected String mode = ILaunchManager.RUN_MODE ;
+
+ /**
+ * The debug target associated with this execution engine
+ */
+ protected MokaDebugTarget debugTarget ;
+
+ /**
+ * The server socket used to accept connection from the requestSocket (connection is done in Moka debug target)
+ */
+ protected ServerSocket requestServer ;
+
+ /**
+ * The server socket used to accept connection from the replySocket (connection is done in Moka debug target)
+ */
+ protected ServerSocket replyServer ;
+
+ /**
+ * The socket used to reply to request emitted by the debug target
+ */
+ protected Socket replySocket;
+
+ /**
+ * The server socket used to accept connection from the eventSocket (connection is done in Moka debug target)
+ */
+ protected ServerSocket eventServer ;
+
+ /**
+ * The socket used to receive request from the debug target
+ */
+ protected Socket requestSocket;
+
+ /**
+ * Writer for the request socket
+ */
+ protected PrintWriter replyWriter;
+
+ /**
+ * Reader for the request socket
+ */
+ protected BufferedReader requestReader;
+
+ /**
+ * This socket is used to raise events for the debug target
+ */
+ protected Socket eventSocket;
+
+ /**
+ * Writer for the event socket
+ */
+ protected PrintWriter eventWriter ;
+
+ /**
+ * Determines if the execution is terminated
+ */
+ protected boolean isTerminated = false ;
+
+ /**
+ * Inits the execution engine in Run mode
+ */
+ public void initRun(EObject eObjectToExecute, String[] args) {
+ this.eObjectToExecute = eObjectToExecute ;
+ this.initializeArguments(args) ;
+ }
+
+ /**
+ * Inits the execution engine in Debug mode.
+ * This includes the creation of server sockets, to enable connection of sockets in the moka debug target.
+ *
+ */
+ public void initDebug(EObject eObjectToExecute, String[] args, MokaDebugTarget debugTarget, int requestPort, int replyPort, int eventPort) throws UnknownHostException, IOException {
+ this.debugTarget = debugTarget ;
+ this.requestServer = new ServerSocket(requestPort) ;
+ this.replyServer = new ServerSocket(replyPort) ;
+ this.eventServer = new ServerSocket(eventPort) ;
+ this.mode = ILaunchManager.DEBUG_MODE ;
+ this.initRun(eObjectToExecute, args) ;
+ }
+
+ /**
+ * Returns the debug target associated with this execution engine
+ *
+ * @return the debug target associated with this execution engine
+ */
+ public MokaDebugTarget getDebugTarget() {
+ return this.debugTarget ;
+ }
+
+
+ /**
+ * Returns true if the execution is terminated, false otherwise
+ *
+ * @return true if the execution is terminated, false otherwise
+ */
+ public boolean isTerminated() {
+ return this.isTerminated ;
+ }
+
+ /**
+ * Initializes the execution engine with given arguments
+ */
+ public abstract void initializeArguments(String[] args) ;
+
+ /**
+ * Starts the execution and the request dispatch loop.
+ */
+ public void start() throws IOException {
+ if (eObjectToExecute != null) {
+ if (this.mode.equals(ILaunchManager.DEBUG_MODE)) {
+ String request = "";
+ // First accepts connection of the request socket (from the moka debug target) and initializes reader/writer
+ requestSocket = requestServer.accept() ;
+ requestReader = new BufferedReader(new InputStreamReader(requestSocket.getInputStream()));
+ // Then accepts connection of the reply socket
+ replySocket = replyServer.accept() ;
+ replyWriter = new PrintWriter(replySocket.getOutputStream());
+ // Then accepts connection of the event socket
+ eventSocket = eventServer.accept() ;
+ eventWriter = new PrintWriter(eventSocket.getOutputStream()) ;
+ // Communication protocol starts by notifying the moka debug target that execution has started
+ this.sendEvent(new Start_Event(this.debugTarget, this.getThreads())) ;
+ while (!this.isTerminated && request != null) {
+ try {
+ request = requestReader.readLine();
+ if (request != null) {
+ if (request.startsWith(MokaConstants.request_addBreakpoint)) {
+ // Add breakpoint request
+ this.addBreakpoint_reply(request);
+ }
+ else if (request.startsWith(MokaConstants.request_removeBreakpoint)) {
+ // Remove breakpoint request
+ this.removeBreakpoint_reply(request) ;
+ }
+ else if (request.startsWith(MokaConstants.request_disconnect)) {
+ // Disconnection requested
+ this.disconnect_reply() ;
+ }
+ else if (request.startsWith(MokaConstants.request_resume)) {
+ // Resume requested
+ this.resume_reply(request) ;
+ }
+ else if (request.startsWith(MokaConstants.request_suspend)) {
+ // Suspend requested
+ this.suspend_reply(request) ;
+ }
+ else if (request.startsWith(MokaConstants.request_terminate)) {
+ // Terminate requested
+ this.terminate_reply(request) ;
+ }
+ else if (request.startsWith(MokaConstants.request_getStackFrames)) {
+ // Stack frames requested
+ this.getStackFrames_reply(request) ;
+ }
+ else if (request.startsWith(MokaConstants.request_getVariables)) {
+ // Variables requested
+ this.getVariables_reply(request) ;
+ }
+ else if (request.startsWith(MokaConstants.request_getValue)) {
+ // Variable value requested
+ this.getValue_reply(request) ;
+ }
+ else if (request.startsWith(MokaConstants.request_getReferenceTypeName)) {
+ // Reference type name of a variable requested
+ this.getReferenceTypeName_reply(request) ;
+ }
+ else if (request.startsWith(MokaConstants.request_getValueString)) {
+ // String representation of a value requested
+ this.getValueString_reply(request) ;
+ }
+ }
+ } catch (IOException e) {
+ this.isTerminated = true ;
+ }
+ }
+ // Communication protocol ends by notifying the moka debug target that execution has terminated
+ this.sendEvent(new Terminate_Event(this.debugTarget)) ;
+ }
+ else {
+ // In Run mode, simply resumes the execution once.
+ this.resume() ;
+ }
+ }
+ }
+
+ // **************************************
+ // Management of a addBreakpoint request emitted from the debug target.
+ // @see IBreakpointListener.breakpointAdded() and IBreakpointListener.breakpointChanged()
+ // ***************************************
+ /**
+ * Manages reply to an addBreakpoint request emitted from the debug target
+ */
+ protected void addBreakpoint_reply(String request) {
+ AddBreakpoint_Request breakpointRequest = Marshaller.getInstance().addBreakpoint_request_unmarshal(request) ;
+ this.addBreakpoint(breakpointRequest.getBreakpoint()) ;
+ Ack reply = new Ack() ;
+ this.reply(reply) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#addBreakpoint()
+ */
+ public abstract void addBreakpoint(MokaBreakpoint breakpoint) ;
+
+ // **************************************
+ // Management of a removeBreakpoint request emitted from the debug target.
+ // @see IBreakpointListener.breakpointRemoved() and IBreakpointListener.breakpointChanged()
+ // ***************************************
+ /**
+ * Manages reply to an addBreakpoint request emitted from the debug target
+ */
+ protected void removeBreakpoint_reply(String request) {
+ RemoveBreakpoint_Request breakpointRequest = Marshaller.getInstance().removeBreakpoint_request_unmarshal(request) ;
+ this.removeBreakpoint(breakpointRequest.getBreakpoint()) ;
+ Ack reply = new Ack() ;
+ this.reply(reply) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#removeBreakpoint()
+ */
+ public abstract void removeBreakpoint(MokaBreakpoint breakpoint) ;
+
+ // **************************************
+ // Management of a disconnect request emitted from the debug target.
+ // @see IDisconnect.disconnect()
+ // ***************************************
+ /**
+ * Manages reply to an addBreakpoint request emitted from the debug target
+ */
+ protected void disconnect_reply() {
+ this.disconnect() ;
+ Ack reply = new Ack() ;
+ this.reply(reply) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#removeBreakpoint()
+ */
+ public abstract void disconnect() ;
+
+ // **************************************
+ // Management of a getMemoryBlock() request emitted from the debug target.
+ // @see IMemoryBlockRetrieval.getMemoryBlock()
+ // ***************************************
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#removeBreakpoint()
+ */
+ public IMemoryBlock getMemoryBlock(long startAddress, long length) {
+ // Not supported
+ return null ;
+ }
+
+ // **************************************
+ // Management of a resume() request emitted from the debug target.
+ // @see ISuspendResume.resume()
+ // ***************************************
+ /**
+ * Manages reply to a resume() request emitted from the debug target
+ */
+ protected void resume_reply(String message) {
+ Resume_Request request = Marshaller.getInstance().resume_request_unmarshal(message) ;
+ Resume_Event event = new Resume_Event(request.getDebugElement(), request.getResumeDetail()) ;
+ this.sendEvent(event) ;
+ this.resume(request) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#resume(Resume_Request request)
+ */
+ public abstract void resume(Resume_Request request) ;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#resume()
+ */
+ public abstract void resume() ;
+
+ // **************************************
+ // Management of a suspend() request emitted from the debug target.
+ // @see ISuspendResume.suspend()
+ // ***************************************
+ /**
+ * Manages reply to a suspend() request emitted from the debug target
+ */
+ protected void suspend_reply(String message) {
+ Suspend_Request request = Marshaller.getInstance().suspend_request_unmarshal(message) ;
+ this.suspend(request) ;
+ Suspend_Event event = new Suspend_Event(request.getDebugElement(), request.getSuspendDetail(), this.getThreads()) ;
+ this.sendEvent(event) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#suspend(Suspend_Request request)
+ */
+ public abstract void suspend(Suspend_Request request) ;
+
+ // **************************************
+ // Management of a suspend() request emitted from the debug target.
+ // @see ISuspendResume.suspend()
+ // ***************************************
+ /**
+ * Manages reply to a suspend() request emitted from the debug target
+ */
+ protected void terminate_reply(String message) {
+ Terminate_Request request = Marshaller.getInstance().terminate_request_unmarshal(message) ;
+ this.terminate(request) ;
+ }
+
+ /**
+ * Implementation of this operation should at least do the following: this.isTerminated = true ;
+ * Note that implementation should not fire a Terminate_Event, since this is managed at the exit of the request dispatch loop implemented by start()
+ *
+ * (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#terminate(org.eclipse.papyrus.moka.communication.request.iterminate.Terminate_Request)
+ */
+ public abstract void terminate(Terminate_Request request) ;
+
+ // **************************************
+ // Management of a getStackFrames() request emitted from the debug target.
+ // @see IThread.getStackFrames()
+ // ***************************************
+ /**
+ * Manages reply to a getStackFrames() request emitted from the debug target
+ */
+ protected void getStackFrames_reply(String message) {
+ GetStackFrames_Request request = Marshaller.getInstance().getStackFrames_request_unmarshal(message) ;
+ GetStackFrames_Reply reply = new GetStackFrames_Reply(this.getStackFrames(request.getThread())) ;
+ this.reply(reply) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#getStackFrames(IThread thread)
+ */
+ public abstract IStackFrame[] getStackFrames(IThread thread) ;
+
+ // **************************************
+ // Management of a getVariables() request emitted from the debug target.
+ // @see IStackFrame.getVariables()
+ // ***************************************
+ /**
+ * Manages reply to a getStackFrames() request emitted from the debug target
+ */
+ protected void getVariables_reply(String message) {
+ GetVariables_Request request = Marshaller.getInstance().getVariables_request_unmarshal(message) ;
+ GetVariables_Reply reply = new GetVariables_Reply((MokaVariable[])this.getVariables(request.getStackFrameOrValue())) ;
+ this.reply(reply) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#getVariables(IStackFrame stackFrame)
+ */
+ public IVariable[] getVariables(IDebugElement stackFrameOrValue) {
+ // By default, returns an empty array of variables
+ return new IVariable[]{} ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#getRegisterGroups(IStackFrame stackFrame)
+ */
+ public IRegisterGroup[] getRegisterGroups(IStackFrame stackFrame) {
+ // Not supported
+ return new IRegisterGroup[]{} ;
+ }
+
+ // **************************************
+ // Management of a getRegisterGroups() request emitted from the debug target.
+ // @see IVariable.getValue()
+ // ***************************************
+ /**
+ * Manages reply to a getRegisterGroups() request emitted from the debug target
+ */
+ protected void getValue_reply(String message) {
+ GetValue_Request request = Marshaller.getInstance().getValue_request_unmarshal(message) ;
+ GetValue_Reply reply = new GetValue_Reply((MokaValue)this.getValue(request.getVariable())) ;
+ this.reply(reply) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#getValue(IVariable variable)
+ */
+ public IValue getValue(IVariable variable) {
+ // The default implementation returns null
+ // It makes the hypothesis that when the debug target
+ // asks for variables, the IVariables which are returned
+ // embed corresponding values.
+ // It means that, by default, this method is never called.
+ return null ;
+ }
+
+ // **************************************
+ // Management of a getRegisterGroups() request emitted from the debug target.
+ // @see IVariable.getReferenceTypeName()
+ // ***************************************
+ /**
+ * Manages reply to a getRegisterGroups() request emitted from the debug target
+ */
+ protected void getReferenceTypeName_reply(String message) {
+ GetReferenceTypeName_Request request = Marshaller.getInstance().getReferenceTypeName_request_unmarshal(message) ;
+ GetReferenceTypeName_Reply reply = new GetReferenceTypeName_Reply(this.getReferenceTypeName(request.getVariableOrValue())) ;
+ this.reply(reply) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#getReferenceTypeName(IDebugElement debugElement)
+ */
+ public String getReferenceTypeName(IDebugElement debugElement) {
+ // By default, returns an empty string
+ return "" ;
+ }
+
+ // **************************************
+ // Management of a getValueString() request emitted from the debug target.
+ // @see IValue.getValueString()
+ // ***************************************
+ /**
+ * Manages reply to a getRegisterGroups() request emitted from the debug target
+ */
+ protected void getValueString_reply(String message) {
+ GetValueString_Request request = Marshaller.getInstance().getValueString_request_unmarshal(message) ;
+ GetValueString_Reply reply = new GetValueString_Reply(this.getValueString(request.getValue())) ;
+ this.reply(reply) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.papyrus.moka.engine.IExecutionEngine#getValueString(IValue value)
+ */
+ public String getValueString(IValue value) {
+ // By default, returns an empty string
+ return "" ;
+ }
+
+ /**
+ * Convenience method for marshalling a Reply, and writing it on the replySocket so that it can be accessed by the debug target
+ *
+ * @param reply The Reply object to be marshalled and written on the replySocket
+ */
+ protected void reply(ReplyMessage reply) {
+ synchronized (replySocket) {
+ replyWriter.println(reply.marshal());
+ replyWriter.flush();
+ }
+ }
+
+ /**
+ * Convenience method for marshalling an Event, and writing it on the eventSocket so that it can be accessed by the debug target
+ *
+ * @param reply The Event object to be marshalled and written on the eventSocket
+ */
+ public void sendEvent(EventMessage event) {
+ synchronized (eventSocket) {
+ eventWriter.println(event.marshal());
+ eventWriter.flush();
+ }
+ }
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/engine/IExecutionEngine.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/engine/IExecutionEngine.java
new file mode 100644
index 00000000000..f5dc08f2214
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/engine/IExecutionEngine.java
@@ -0,0 +1,198 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.engine;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IMemoryBlock;
+import org.eclipse.debug.core.model.IRegisterGroup;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.moka.communication.request.isuspendresume.Resume_Request;
+import org.eclipse.papyrus.moka.communication.request.isuspendresume.Suspend_Request;
+import org.eclipse.papyrus.moka.communication.request.iterminate.Terminate_Request;
+import org.eclipse.papyrus.moka.debug.MokaBreakpoint;
+import org.eclipse.papyrus.moka.debug.MokaDebugTarget;
+import org.eclipse.papyrus.moka.debug.MokaThread;
+
+/**
+ * The interface underlying the ExecutionEngine extension point provided by Moka.
+ *
+ */
+public interface IExecutionEngine {
+
+ /**
+ * Returns true if this execution engine supports the debug mode
+ *
+ * @return true if debug mode is supported, false otherwise
+ */
+ public boolean isDebugModeSupported() ;
+
+ /**
+ * Initializes the engine for an execution in "Run" mode
+ *
+ * @param eObjectToExecute The object to be executed by the engine
+ * @param args Optional arguments for the execution of the object
+ */
+ public void initRun(EObject eObjectToExecute, String[] args) ;
+
+ /**
+ * Resumes the execution of the target program, after initialization in "Run" mode
+ */
+ public void resume() ;
+
+ /**
+ * Initializes the engine for an execution in "Debug" mode.
+ * This requires to know the debugTarget which will communicate with this execution engine.
+ * Since the debugTarget and the execution engine must run asynchronously, they communicate through sockets.
+ * requestPort indicates the address of the socket through which requests emitted from the debug target flow.
+ * replyPort indicates the address of the socket through which replies emitted from the execution engine flow.
+ * eventPort indicates the address of the socket through which messages corresponding to debug events occurring in the execution engine flow.
+ *
+ * @param eObjectToExecute The object to be executed by the engine
+ * @param args Optional arguments for the execution of the object
+ * @param debugTarget the debugTarget communicating with this execution engine
+ * @param requestPort the address of the socket through which requests emitted from the debug target flow.
+ * @param replyPort the address of the socket through which replies (emitted from the execution engine) flow.
+ * @param eventPort indicates the address of the socket through which messages corresponding to debug events occurring in the execution engine flow.
+ * @throws UnknownHostException when problems occur while establishing connection with the sockets
+ * @throws IOException when problems occur while reading/writing on sockets
+ */
+ public void initDebug(EObject eObjectToExecute, String[] args, MokaDebugTarget debugTarget, int requestPort, int replyPort, int eventPort) throws UnknownHostException, IOException ;
+
+ /**
+ * Initialization of the execution engine with given arguments. This is supposed to be called in the implementation of initRun and/or initDebug methods
+ *
+ * @param args The arguments for the initialization of the execution engine, before starting execution
+ */
+ public void initializeArguments(String[] args) ;
+
+ /**
+ * Starts the execution. This is supposed to be called after initialization phases.
+ *
+ * @throws IOException
+ */
+ public void start() throws IOException ;
+
+ /**
+ * Returns the collection of MokaThread for this execution engine. If no threads are defined, the returned collection is empty, but not null.
+ *
+ * @return the collection of MokaThread for this execution engine
+ */
+ public MokaThread[] getThreads() ;
+
+ /**
+ * Registers the given breakpoint in the execution engine
+ *
+ * @param breakpoint the breakpoint to be registered
+ */
+ public void addBreakpoint(MokaBreakpoint breakpoint) ;
+
+ /**
+ * Unregister the given breakpoint in the execution engine
+ *
+ * @param breakpoint the breakpoint to be unregistered
+ */
+ public void removeBreakpoint(MokaBreakpoint breakpoint) ;
+
+ /**
+ * Disconnects this execution engine from the associated debug target.
+ */
+ public void disconnect() ;
+
+ /**
+ * Gets the memory block at the given startAddress, for the given length
+ *
+ * @param startAddress The startAddress for the memory block
+ * @param length The length of the memory block
+ * @return the memory block corresponding to the given startAddress and length
+ */
+ public IMemoryBlock getMemoryBlock(long startAddress, long length) ;
+
+ /**
+ * Resumes execution according to the given Resume_Request
+ *
+ * @param request The Resume_Request indicating how execution has to be resumed
+ */
+ public void resume(Resume_Request request) ;
+
+ /**
+ * Suspends execution according to the given Suspend_Request
+ *
+ * @param request The Suspend_Request indicating how execution has to be suspended
+ */
+ public void suspend(Suspend_Request request) ;
+
+ /**
+ * Terminates execution according to the given Terminate_Request
+ *
+ * @param request The Terminate_Request indicating how execution has to be terminated
+ */
+ public void terminate(Terminate_Request request) ;
+
+ /**
+ * Returns the stack frames of the given thread
+ *
+ * @param thread The thread for which stack frames have to be retrieved
+ * @return The stack frames of the given thread
+ */
+ public IStackFrame[] getStackFrames(IThread thread) ;
+
+ /**
+ * Return the visible variables of the given stack frame or value
+ * stackFrameOrValue must be an IStackFrame or an IValue
+ *
+ * @param stackFrameOrValue The stack frame or value for which variables have to be retrieved
+ * @return The visible variables of the given stack frame or value
+ */
+ public IVariable[] getVariables(IDebugElement stackFrameOrValue) ;
+
+ /**
+ * Returns the register groups of the given stack frame
+ *
+ * @param stackFrame The stack frame for which register groups have to be retrieved
+ * @return The register groups of the given stack frame
+ */
+ public IRegisterGroup[] getRegisterGroups(IStackFrame stackFrame) ;
+
+ /**
+ * Returns the value (if any) for the given variable
+ *
+ * @param variable The variable for which value has to be retrieved
+ * @return The value (if any) for the given variable
+ */
+ public IValue getValue(IVariable variable) ;
+
+ /**
+ * Returns the reference type name of the given variable
+ * debugElement must be a IVariable or IValue
+ *
+ * @param variable The variable or value for which the reference type name has to be retrieved
+ * @return The reference type name of the given variable or value
+ */
+ public String getReferenceTypeName(IDebugElement debugElement) ;
+
+ /**
+ * Returns the string representation of the given value
+ *
+ * @param value The value for which a textual representation has to be retrieved
+ * @return The string representation of the given value
+ */
+ public String getValueString(IValue value) ;
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/engine/MokaExecutionEngineJob.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/engine/MokaExecutionEngineJob.java
new file mode 100644
index 00000000000..a53334f3508
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/engine/MokaExecutionEngineJob.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.engine;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+
+/**
+ * A Job for hosting the execution of an engine
+ *
+ */
+public class MokaExecutionEngineJob extends Job {
+
+ /**
+ * The engine performing the execution
+ */
+ protected IExecutionEngine engine ;
+
+ public MokaExecutionEngineJob(String name, IExecutionEngine engine) {
+ super(name) ;
+ this.engine = engine ;
+ }
+
+ /**
+ * Calls the start method of the owned execution engine
+ *
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ this.engine.start() ;
+ } catch (IOException e) {
+ return new Status(IStatus.ERROR, "org.eclipse.papyrus.moka", e.getMessage());
+ }
+ return new Status(IStatus.OK, "org.eclipse.papyrus.moka", "Execution was successfull");
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/launch/EditorUtils.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/launch/EditorUtils.java
new file mode 100644
index 00000000000..66c49413548
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/launch/EditorUtils.java
@@ -0,0 +1,133 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.launch;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * Some utilities for dealing with IEditorParts and File editor inputs
+ *
+ */
+public class EditorUtils {
+
+ /**
+ * Returns the IEditorPart associated with the given model element.
+ * If no IEditorPart is available in the workbench, a new one is created.
+ *
+ * @param modelElement The modelElement for which an IEditorPart is requested
+ * @return The IEditorPart associated with the given model element.
+ */
+ public static IEditorPart getEditorPart(EObject modelElement) {
+ if (! modelElement.eIsProxy())
+ return getEditorPart(modelElement.eResource().getURI().toString()) ;
+ IEditorPart part = null ;
+ // Need to open a new editor
+ final FileEditorInput input = getFileEditorInput(modelElement) ;
+ OpenPapyrusEditorRunnable runnable = new OpenPapyrusEditorRunnable(input) ;
+ Display.getDefault().syncExec(runnable) ;
+ part = runnable.getEditorPart() ;
+
+ return part ;
+ }
+
+ /**
+ * Returns the IEditorPart associated with the Resource depicted by the given resourceURI string.
+ * If no IEditorPart is available in the workbench, a new one is created.
+ *
+ * @param resourceURI The string representation of the resource URI for which an IEditorPart is requested
+ * @return The IEditorPart associated with the given resource URI.
+ */
+ public static IEditorPart getEditorPart(String resourceURI) {
+ // FIXME this snippet of code is not robust
+ String[] splitted = resourceURI.split("/") ;
+ String resourceName = splitted[splitted.length - 1].replaceAll(".uml", ".di") ;
+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows() ;
+ IEditorPart part = null ;
+ for (int i = 0 ; i < windows.length && part == null ; i++) {
+ IWorkbenchPage[] pages = windows[i].getPages() ;
+ for (int j = 0 ; j < pages.length && part == null ; j++) {
+ IEditorReference[] editorReferences = pages[j].getEditorReferences() ;
+ for (int k = 0 ; k < editorReferences.length && part == null ; k++) {
+ IEditorReference ref = editorReferences[k] ;
+ IEditorPart cdd = ref.getEditor(true) ;
+ if (cdd instanceof IMultiDiagramEditor) {
+ String cddName = cdd.getEditorInput().getName() ;
+ if (cddName.equals(resourceName))
+ part = cdd ;
+ }
+ }
+ }
+ }
+ if (part == null) {
+ // Need to open a new editor
+ final FileEditorInput input = getFileEditorInput(resourceURI) ;
+ OpenPapyrusEditorRunnable runnable = new OpenPapyrusEditorRunnable(input) ;
+ Display.getDefault().syncExec(runnable) ;
+ part = runnable.getEditorPart() ;
+
+ }
+
+ return part ;
+ }
+
+ /**
+ * Returns a File Editor Input for the given model element.
+ * This shall be understood as "The FileEditorInput which shall be used
+ * to retrieve or construct the appropriate IEditorPart"
+ *
+ * @param modelElement The model element for which a File Editor Input is requested
+ * @return The FileEditorInput which shall be used to retrieve or construct the appropriate IEditorPart for editing this model element
+ */
+ public static FileEditorInput getFileEditorInput(EObject modelElement) {
+ EObject resolvedElement = modelElement ;
+ if (resolvedElement.eIsProxy()) {
+ // Tries to resolve in a new resource set
+ resolvedElement = EcoreUtil.resolve(modelElement, new ResourceSetImpl()) ;
+ }
+ return getFileEditorInput(resolvedElement.eResource().getURI().toString()) ;
+ }
+
+ /**
+ * Returns a File Editor Input for the given resource URI string.
+ *
+ * @param resourceURI The string representing the resource URI for which a FileEditorInput is requested
+ * @return a File Editor Input for the given resource URI string.
+ */
+ public static FileEditorInput getFileEditorInput(String resourceURI) {
+ Resource newResource = new ResourceSetImpl().createResource(URI.createURI(resourceURI.replaceAll(".uml", ".di"))) ;
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot workspaceRoot = workspace.getRoot();
+ IFile modelElementIFile = (IFile) workspaceRoot.findMember(newResource.getURI().toPlatformString(true));
+ if(modelElementIFile == null)
+ return null ;
+ return new FileEditorInput(modelElementIFile) ;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/launch/MokaLaunchDelegate.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/launch/MokaLaunchDelegate.java
new file mode 100644
index 00000000000..40b78450826
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/launch/MokaLaunchDelegate.java
@@ -0,0 +1,214 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.launch;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.moka.Activator;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.papyrus.moka.debug.MokaDebugTarget;
+import org.eclipse.papyrus.moka.debug.MokaProcess;
+import org.eclipse.papyrus.moka.engine.IExecutionEngine;
+import org.eclipse.papyrus.moka.engine.MokaExecutionEngineJob;
+import org.eclipse.ui.IEditorPart;
+
+
+/**
+ * An implementation of ILaunchConfigurationDelegate
+ *
+ */
+public class MokaLaunchDelegate extends LaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
+
+ /**
+ * The attribute name for the resource uri associated with a launch configuration
+ * The corresponding resource contains the EObject to be executed
+ */
+ public static String URI_ATTRIBUTE_NAME = "URI_ATTRIBUTE" ;
+
+ /**
+ * The attribute name for the uri fragment associated with a launch configuration
+ * This fragment is an id for the EObject to be executed
+ */
+ public static String FRAGMENT_ATTRIBUTE_NAME = "FRAGMENT_ATTRIBUTE" ;
+
+ /**
+ * The attribute name for the arguments associated with a launch configuration
+ * This arguments are given to the execution engine for initialization, before actually starting execution.
+ */
+ public static String ARGS_ATTRIBUTE_NAME = "ARGS_ATTRIBUTE" ;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+
+ // instantiates the actual execution engine
+ IExecutionEngine engine = this.instantiateExecutionEngine() ;
+ if (engine == null)
+ this.abort("Could not instantiate execution engine", null) ;
+
+ // Create a job for the execution of this engine
+ Job engineJob = new MokaExecutionEngineJob("Execution Engine Job", engine) ;
+
+ // retrieves values for the various attributes associated with the launch configuration
+ String resourceURI = configuration.getAttribute(URI_ATTRIBUTE_NAME, "") ;
+ String uriFragment = configuration.getAttribute(FRAGMENT_ATTRIBUTE_NAME, "") ;
+ String arguments = configuration.getAttribute(ARGS_ATTRIBUTE_NAME, "") ;
+ String[] args = arguments.split("\\s+");
+
+ IEditorPart part = EditorUtils.getEditorPart(resourceURI) ;
+
+ //IEditorPart part = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor() ;
+ ServicesRegistry servicesRegistry = (ServicesRegistry)part.getAdapter(ServicesRegistry.class);
+ ResourceSet resourceSet = null ;
+ try {
+ resourceSet = servicesRegistry.getService(ModelSet.class) ;
+ } catch (ServiceException e1) {
+ resourceSet = new ResourceSetImpl() ;
+ e1.printStackTrace();
+ }
+
+ // from the arguments, retrieves the EObject to be executed
+
+ //ResourceSet resourceSet = new ResourceSetImpl() ;
+ Resource resource = resourceSet.getResource(URI.createURI(resourceURI), true) ;
+ final EObject eObjectToExecute = resource.getEObject(uriFragment) ;
+
+ // Gets port addresses for sockets
+ int requestPort = -1;
+ int replyPort = -1;
+ int eventPort = -1;
+
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ requestPort = findFreePort();
+ eventPort = findFreePort();
+ replyPort = findFreePort();
+ if (requestPort == -1 || replyPort == -1 || eventPort == -1) {
+ this.abort("Unable to find free port", null);
+ }
+ }
+
+ // The resulting job is used for the creation of MokaRuntimeProcess, thereby simulating a real, physical process
+ IProcess process = new MokaProcess(launch, engineJob, "Moka runtime process", new HashMap<String,String>()) ;
+
+ // Initializes the engine, as well as the debug target if we are in DEBUG_MODE
+ if (mode.equals(ILaunchManager.DEBUG_MODE) && engine.isDebugModeSupported()) {
+ MokaDebugTarget target = new MokaDebugTarget(launch, process);
+ try {
+ engine.initDebug(eObjectToExecute, args, target, requestPort, replyPort, eventPort) ;
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ target.connect(requestPort, replyPort, eventPort) ;
+ launch.addDebugTarget(target);
+ }
+ else {
+ engine.initRun(eObjectToExecute, args) ;
+ }
+
+ // Schedules the job so that execution effectively starts
+ engineJob.schedule() ;
+ }
+
+ /**
+ * A convenience method for instantiating the actual execution engine.
+ * The class to be instantiated is determined in the Moka preference page (see MokaConstants.DEFAULT_EXECUTION_ENGINE)
+ * Any engine contributing to MokaConstants.ENGINE_EXTENSION_POINT_ID can be selected in this preference page.
+ *
+ * @return
+ */
+ protected IExecutionEngine instantiateExecutionEngine() {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] config = registry.getConfigurationElementsFor(MokaConstants.MOKA_ENGINE_EXTENSION_POINT_ID);
+ try {
+ IConfigurationElement e = null;
+ String selectedExecutionEngine = "" + Activator.getDefault().getPreferenceStore().getString(MokaConstants.MOKA_DEFAULT_EXECUTION_ENGINE_PREF);
+ for(int i = 0; i < config.length; i++) {
+ if(config[i].getNamespaceIdentifier().equals(selectedExecutionEngine))
+ e = config[i];
+ }
+ final Object o = e.createExecutableExtension("class");
+ return (IExecutionEngine)o ;
+ } catch (CoreException ex) {
+
+ } catch (Exception ex) {
+
+ }
+ // If null is returned, the calling method (launch) fires a CoreException
+ return null ;
+ }
+
+ /**
+ * Returns a free port number on localhost, or -1 if unable to find a free port.
+ * This code has been duplicated from the PDAExample. See http://www.eclipse.org/articles/Article-Debugger/how-to.html
+ *
+ * @return a free port number on localhost, or -1 if unable to find a free port
+ */
+ protected static int findFreePort() {
+ ServerSocket socket= null;
+ try {
+ socket= new ServerSocket(0);
+ return socket.getLocalPort();
+ } catch (IOException e) {
+ } finally {
+ if (socket != null) {
+ try {
+ socket.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * A convenience method for aborting launching.
+ * This code has been duplicated from the PDAExample. See http://www.eclipse.org/articles/Article-Debugger/how-to.html
+ *
+ * @param message
+ * @param e
+ * @throws CoreException
+ */
+ protected void abort(String message, Throwable e) throws CoreException {
+ throw new CoreException(new Status(IStatus.ERROR, MokaConstants.MOKA_DEBUG_MODEL_ID, 0, message, e));
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/launch/OpenPapyrusEditorRunnable.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/launch/OpenPapyrusEditorRunnable.java
new file mode 100644
index 00000000000..4e4087af2aa
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/launch/OpenPapyrusEditorRunnable.java
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.launch;
+
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.moka.MokaConstants;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * A runnable to open a new Papyrus editor from a file editor input
+ *
+ */
+public class OpenPapyrusEditorRunnable implements Runnable {
+
+ /**
+ * The file editor input from which an IEditorPart has to be constructed and added to the workbench
+ */
+ protected FileEditorInput input ;
+
+ protected IEditorPart part ;
+
+ public OpenPapyrusEditorRunnable(FileEditorInput input) {
+ this.input = input ;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ try {
+ this.part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, MokaConstants.PAPYRUS_EDITOR_ID) ;
+ } catch (PartInitException e) {
+ Activator.log.error(e) ;
+ }
+ }
+
+ /**
+ * Returns the created IEditorPart
+ * This method shall be called only after run() has been executed
+ *
+ * @return The created IEditorPart
+ */
+ public IEditorPart getEditorPart() {
+ return this.part ;
+ }
+
+}
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/locator/MokaSourceLocator.java b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/locator/MokaSourceLocator.java
new file mode 100644
index 00000000000..20e0fcce038
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka/src/org/eclipse/papyrus/moka/locator/MokaSourceLocator.java
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.locator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.moka.debug.MokaStackFrame;
+
+/**
+ * A simple implementation of ISourceLookupDirector.
+ * In this implementation, EObjects are considered as source elements.
+ *
+ */
+public class MokaSourceLocator extends AbstractSourceLookupDirector implements ISourceLookupDirector {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#initializeParticipants()
+ */
+ public void initializeParticipants() {
+ // This initialization step does not have any particular impact.
+ // All needed information comes from getSourceElement
+ // Nevertheless, this code is kept there since the MokaSourceLookupParticipant could be used to account for additional information in the launch configuration.
+ // For example, these information may include a list of di files where graphical representations have to be taken from a given semantic element.
+ // This may be removed if we confirm that this mechanism only makes sense for text file resources.
+ ISourceLookupParticipant[] participants = new ISourceLookupParticipant[] {new MokaSourceLookupParticipant()} ;
+ this.addParticipants(participants) ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#getSourceElement(java.lang.Object)
+ */
+ public Object getSourceElement(Object element) {
+ EObject sourceElement = null ;
+ MokaStackFrame stackFrame = (MokaStackFrame)element ;
+ sourceElement = stackFrame.getModelElement() ;
+ return sourceElement ;
+ }
+
+ /**
+ * An empty implementation of ISourceLookupParticipant.
+ * See comment on initializeParticipants.
+ *
+ */
+ protected class MokaSourceLookupParticipant implements ISourceLookupParticipant {
+
+ public void sourceContainersChanged(ISourceLookupDirector director) {
+ }
+
+ public void init(ISourceLookupDirector director) {
+ }
+
+ public String getSourceName(Object object) throws CoreException {
+ return null;
+ }
+
+ public Object[] findSourceElements(Object object) throws CoreException {
+ return null;
+ }
+
+ public void dispose() {
+ }
+ };
+
+}

Back to the top