From ebd5809581875b8c12cb622ae81c8067d668b945 Mon Sep 17 00:00:00 2001 From: aradermache Date: Mon, 28 Jan 2013 13:37:38 +0000 Subject: Initial version for migration of Qompass designer from 0.9.2 to the trunk (0.10) --- .../.classpath | 7 + .../.project | 28 + .../META-INF/MANIFEST.MF | 29 + .../about.html | 28 + .../build.properties | 13 + .../icons/etool16/brkp_16x16.gif | Bin 0 -> 197 bytes .../icons/etool16/brkp_9x9.gif | Bin 0 -> 179 bytes .../icons/etool16/brkp_grp.gif | Bin 0 -> 361 bytes .../icons/etool16/brkp_grp_disabled.gif | Bin 0 -> 173 bytes .../icons/etool16/brkpd_16x16.gif | Bin 0 -> 139 bytes .../icons/etool16/brkpd_9x9.gif | Bin 0 -> 123 bytes .../icons/etool16/debug.gif | Bin 0 -> 348 bytes .../icons/etool16/properties.gif | Bin 0 -> 577 bytes .../icons/etool16/trcp_11x12.gif | Bin 0 -> 313 bytes .../icons/etool16/trcp_16x16.gif | Bin 0 -> 348 bytes .../icons/etool16/trcpd_11x12.gif | Bin 0 -> 302 bytes .../icons/etool16/trcpd_16x16.gif | Bin 0 -> 316 bytes .../plugin.properties | 12 + .../plugin.xml | 193 +++ .../schema/traceMechanism.exsd | 109 ++ .../infra/services/tracepoints/Activator.java | 90 ++ .../services/tracepoints/ITraceMechanism.java | 74 ++ .../infra/services/tracepoints/MarkerUtils.java | 84 ++ .../infra/services/tracepoints/TraceActions.java | 206 +++ .../infra/services/tracepoints/TraceFunctions.java | 112 ++ .../infra/services/tracepoints/TraceMechanism.java | 88 ++ .../infra/services/tracepoints/TraceState.java | 20 + .../services/tracepoints/TracepointConstants.java | 32 + .../commands/AbstractTracepointCommand.java | 168 +++ .../ToggleBreakpointActivationCommand.java | 40 + .../commands/ToggleBreakpointCommand.java | 41 + .../ToggleTracepointActivationCommand.java | 41 + .../commands/ToggleTracepointCommand.java | 52 + .../commands/TracepointPropertiesCommand.java | 81 ++ .../tracepoints/dialogs/TraceActionSelection.java | 293 +++++ .../handler/AbstractCommandHandler.java | 165 +++ .../handler/ToggleBreakpointActivationHandler.java | 33 + .../handler/ToggleBreakpointHandler.java | 33 + .../handler/ToggleTracepointActivationHandler.java | 33 + .../handler/ToggleTracepointHandler.java | 33 + .../handler/TracepointPropertiesHandler.java | 33 + .../BinaryEncodedMChoiceFieldEditor.java | 132 ++ .../preferences/MultipleChoiceFieldEditor.java | 234 ++++ .../preferences/TPPreferenceConstants.java | 51 + .../preferences/TPPreferenceInitializer.java | 53 + .../tracepoints/preferences/TPPreferencePage.java | 106 ++ .../.classpath | 7 + .../.project | 34 + .../META-INF/MANIFEST.MF | 19 + .../about.html | 28 + .../build.acceleo | 26 + .../build.properties | 13 + .../help/tocconcepts.xml | 7 + .../html/images/image001.gif | Bin 0 -> 2182 bytes .../html/images/image002.gif | Bin 0 -> 2123 bytes .../html/images/image003.gif | Bin 0 -> 1323 bytes .../html/images/image004.jpg | Bin 0 -> 3340 bytes .../html/images/image005.jpg | Bin 0 -> 36908 bytes .../html/images/image006.jpg | Bin 0 -> 4937 bytes .../html/images/image007.gif | Bin 0 -> 21539 bytes .../html/images/image008.jpg | Bin 0 -> 44181 bytes .../html/images/image009.jpg | Bin 0 -> 43754 bytes .../html/userguide.htm | 213 ++++ .../models/examples/ClientServerTraceTest.di | 76 ++ .../models/examples/ClientServerTraceTest.notation | 1315 ++++++++++++++++++++ .../models/examples/ClientServerTraceTest.uml | 428 +++++++ .../models/examples/ProducerConsumer.di | 53 + .../models/examples/ProducerConsumer.notation | 1090 ++++++++++++++++ .../models/examples/ProducerConsumer.uml | 457 +++++++ .../models/library/tracing.di | 52 + .../models/library/tracing.notation | 1078 ++++++++++++++++ .../models/library/tracing.uml | 771 ++++++++++++ .../plugin.properties | 12 + .../plugin.xml | 54 + .../qompass/modellibs/tracing/Activator.java | 51 + .../tracing/ClientServerTraceTestModelWizard.java | 11 + .../modellibs/tracing/IConfiguratorOTF.java | 53 + .../modellibs/tracing/IConfiguratorTrace.java | 40 + .../modellibs/tracing/QompassTraceMechanism.java | 181 +++ .../modellibs/tracing/acceleo/TraceUtils.java | 45 + .../modellibs/tracing/acceleo/traceCout.mtl | 14 + .../modellibs/tracing/acceleo/traceLTTng.mtl | 172 +++ .../qompass/modellibs/tracing/acceleo/traceOTF.mtl | 28 + .../.classpath | 7 + .../org.eclipse.papyrus.views.tracepoints/.project | 28 + .../META-INF/MANIFEST.MF | 22 + .../about.html | 28 + .../build.properties | 10 + .../contexts.xml | 13 + .../icons/breakpoint_view.gif | Bin 0 -> 204 bytes .../icons/gotoobj_tsk.gif | Bin 0 -> 372 bytes .../icons/skip_brkp.gif | Bin 0 -> 204 bytes .../plugin.properties | 12 + .../plugin.xml | 34 + .../papyrus/views/tracepoints/Activator.java | 78 ++ .../views/tracepoints/views/TraceViewImages.java | 44 + .../views/tracepoints/views/TracepointView.java | 521 ++++++++ 97 files changed, 9872 insertions(+) create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/.classpath create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/.project create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/META-INF/MANIFEST.MF create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/about.html create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/build.properties create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_16x16.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_9x9.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_grp.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_grp_disabled.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkpd_16x16.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkpd_9x9.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/debug.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/properties.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcp_11x12.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcp_16x16.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcpd_11x12.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcpd_16x16.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/plugin.properties create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/plugin.xml create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/schema/traceMechanism.exsd create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/Activator.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/ITraceMechanism.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/MarkerUtils.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceActions.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceFunctions.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceMechanism.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceState.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TracepointConstants.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/AbstractTracepointCommand.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleBreakpointActivationCommand.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleBreakpointCommand.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleTracepointActivationCommand.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleTracepointCommand.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/TracepointPropertiesCommand.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/dialogs/TraceActionSelection.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/AbstractCommandHandler.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleBreakpointActivationHandler.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleBreakpointHandler.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleTracepointActivationHandler.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleTracepointHandler.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/TracepointPropertiesHandler.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/BinaryEncodedMChoiceFieldEditor.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/MultipleChoiceFieldEditor.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/TPPreferenceConstants.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/TPPreferenceInitializer.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/TPPreferencePage.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/.classpath create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/.project create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/META-INF/MANIFEST.MF create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/about.html create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/build.acceleo create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/build.properties create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/help/tocconcepts.xml create mode 100755 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image001.gif create mode 100755 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image002.gif create mode 100755 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image003.gif create mode 100755 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image004.jpg create mode 100755 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image005.jpg create mode 100755 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image006.jpg create mode 100755 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image007.gif create mode 100755 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image008.jpg create mode 100755 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image009.jpg create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/userguide.htm create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ClientServerTraceTest.di create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ClientServerTraceTest.notation create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ClientServerTraceTest.uml create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ProducerConsumer.di create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ProducerConsumer.notation create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ProducerConsumer.uml create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/library/tracing.di create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/library/tracing.notation create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/library/tracing.uml create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/plugin.properties create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/plugin.xml create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/Activator.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/ClientServerTraceTestModelWizard.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/IConfiguratorOTF.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/IConfiguratorTrace.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/QompassTraceMechanism.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/TraceUtils.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/traceCout.mtl create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/traceLTTng.mtl create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/traceOTF.mtl create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/.classpath create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/.project create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/META-INF/MANIFEST.MF create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/about.html create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/build.properties create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/contexts.xml create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/icons/breakpoint_view.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/icons/gotoobj_tsk.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/icons/skip_brkp.gif create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/plugin.properties create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/plugin.xml create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/src/org/eclipse/papyrus/views/tracepoints/Activator.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/src/org/eclipse/papyrus/views/tracepoints/views/TraceViewImages.java create mode 100644 extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/src/org/eclipse/papyrus/views/tracepoints/views/TracepointView.java (limited to 'extraplugins/qompass-designer/tracing') diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/.classpath b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/.classpath new file mode 100644 index 00000000000..9d5026e8ffd --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/.project b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/.project new file mode 100644 index 00000000000..07350fea43f --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/.project @@ -0,0 +1,28 @@ + + + org.eclipse.papyrus.infra.services.tracepoints + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/META-INF/MANIFEST.MF b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..ee75c7c3f8c --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/META-INF/MANIFEST.MF @@ -0,0 +1,29 @@ +Manifest-Version: 1.0 +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.emf;bundle-version="2.6.0", + org.eclipse.emf.ecore;bundle-version="2.6.1", + org.eclipse.core.resources;bundle-version="3.6.0", + org.apache.commons.lang;bundle-version="2.3.0", + org.eclipse.emf.edit.ui;bundle-version="2.6.0", + org.eclipse.gmf.runtime.emf.commands.core;bundle-version="1.0.100", + org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.1.0", + org.eclipse.papyrus.infra.core;bundle-version="0.9.2", + org.eclipse.papyrus.infra.widgets;bundle-version="0.9.2", + org.eclipse.papyrus.infra.services.decoration;bundle-version="0.9.2", + org.eclipse.gef;bundle-version="3.8.1", + org.eclipse.gmf.runtime.notation;bundle-version="1.5.0", + org.eclipse.uml2.uml;bundle-version="4.0.0" +Export-Package: org.eclipse.papyrus.infra.services.tracepoints, + org.eclipse.papyrus.infra.services.tracepoints.commands, + org.eclipse.papyrus.infra.services.tracepoints.dialogs, + org.eclipse.papyrus.infra.services.tracepoints.preferences +Bundle-Vendor: %pluginProvider +Bundle-ActivationPolicy: lazy +Bundle-Version: 0.9.2.qualifier +Bundle-Name: %pluginName +Bundle-ManifestVersion: 2 +Bundle-Activator: org.eclipse.papyrus.infra.services.tracepoints.Activator +Bundle-SymbolicName: org.eclipse.papyrus.infra.services.tracepoints;singleton:=true +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-Localization: plugin diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/about.html b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/about.html new file mode 100644 index 00000000000..209103075a7 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

November 14, 2008

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") 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 http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/build.properties b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/build.properties new file mode 100644 index 00000000000..8e1f07ccf86 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/build.properties @@ -0,0 +1,13 @@ +# +#Mon Sep 12 09:30:24 CEST 2011 +bin.includes = META-INF/,\ + .,\ + about.html,\ + plugin.properties,\ + plugin.xml,\ + icons/,\ + schema/ +output..=bin/ +src.includes = about.html +source..=src/ +bin..=bin/ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_16x16.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_16x16.gif new file mode 100644 index 00000000000..a831fe72782 Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_16x16.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_9x9.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_9x9.gif new file mode 100644 index 00000000000..3678b09c6bf Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_9x9.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_grp.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_grp.gif new file mode 100644 index 00000000000..173661c5df7 Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_grp.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_grp_disabled.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_grp_disabled.gif new file mode 100644 index 00000000000..5ea466bcb2a Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_grp_disabled.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkpd_16x16.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkpd_16x16.gif new file mode 100644 index 00000000000..74b26c31a4d Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkpd_16x16.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkpd_9x9.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkpd_9x9.gif new file mode 100644 index 00000000000..d6d8d31b06f Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkpd_9x9.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/debug.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/debug.gif new file mode 100644 index 00000000000..d90a29fead8 Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/debug.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/properties.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/properties.gif new file mode 100644 index 00000000000..1dc19a31a0f Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/properties.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcp_11x12.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcp_11x12.gif new file mode 100644 index 00000000000..c04edf8e83e Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcp_11x12.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcp_16x16.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcp_16x16.gif new file mode 100644 index 00000000000..29ec606076f Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcp_16x16.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcpd_11x12.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcpd_11x12.gif new file mode 100644 index 00000000000..f3e7b3d6791 Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcpd_11x12.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcpd_16x16.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcpd_16x16.gif new file mode 100644 index 00000000000..76c65b6196f Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcpd_16x16.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/plugin.properties b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/plugin.properties new file mode 100644 index 00000000000..3cabfa42274 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/plugin.properties @@ -0,0 +1,12 @@ +############################################################################### +# Copyright (c) 2010 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 +############################################################################### +pluginName=Papyrus Tracepoint Integration (Incubation) +pluginProvider=Eclipse Modeling Project diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/plugin.xml b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/plugin.xml new file mode 100644 index 00000000000..80dceda93de --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/plugin.xml @@ -0,0 +1,193 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/schema/traceMechanism.exsd b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/schema/traceMechanism.exsd new file mode 100644 index 00000000000..ba8ed1aca6d --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/schema/traceMechanism.exsd @@ -0,0 +1,109 @@ + + + + + + + + + Possibility to add implementations of a trace mechanism + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/Activator.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/Activator.java new file mode 100644 index 00000000000..9cba95d5b41 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/Activator.java @@ -0,0 +1,90 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints; + +import org.eclipse.papyrus.infra.core.log.LogHelper; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +// TODO: Auto-generated Javadoc +/** + * The activator class controls the plug-in life cycle. + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + /** The Constant PLUGIN_ID. */ + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.services.tracepoints"; //$NON-NLS-1$ + + // The shared instance + /** The plugin. */ + private static Activator plugin; + + /** The log service. */ + public static LogHelper log; + + /** + * The constructor. + */ + public Activator() { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + /** + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + * + * @param context + * @throws Exception + */ + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + log = new LogHelper(plugin); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + /** + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + * + * @param context + * @throws Exception + */ + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + log = null; + super.stop(context); + } + + /** + * Returns the shared instance. + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/ITraceMechanism.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/ITraceMechanism.java new file mode 100644 index 00000000000..0bfdb027b35 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/ITraceMechanism.java @@ -0,0 +1,74 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; + + +/** + * The trace mechanism itself is not specific for specific implementations such + * as instrumenting code generators. Thus, the following interface may be defined + * by extensions that provide an implementation of a trace point. + * The first operation gets a set of available trace implementations that are supplied + * by the extension (in conjunction with other mechanisms). + * This interface is used for mechanisms that have a way of implementing trace point + * + * @author ansgar + * + */ +public interface ITraceMechanism { + + /** + * @param eObj + * the element on which tracing is applied. It is passed, since the + * list of available trace mechanisms may depend on this object + * @return a list of IDs corresponding to available trace mechanisms + */ + EList getTraceMechanismIDs(EObject eObj); + + /** + * Provide a description of the trace mechanism + * + * @param id + * the id of the trace mechanism + * @return its description + */ + String getTraceMechanismDescription(EObject eObj, String id); + + /** + * Apply the tracing. This usually means that an implementation specific + * mechanism will add additional information to the EObject, for instance + * in form of additional markings or stereotypes (there is no assumption + * how this is actually done). The idea is that these markings will be + * evaluated during code generation to produce the right result. + * + * @param id + * the ID of a trace mechanism + * @param element + * the element that should be trace + * @param traceOption + * an encoded trace option. e.g. that only the called operation + * should be trace and not the values of the passed parameters. + */ + boolean applyTraceMechanism(EObject eObj, String id, int traceOption); + + /** + * Configure the trace mechanisms for runtime, in particular evaluate activate/inactive + * tracepoint settings to obtain a suitable runtime configuration. + * + * @return + */ + boolean configureTraceMechanisms(); +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/MarkerUtils.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/MarkerUtils.java new file mode 100644 index 00000000000..536728ff1ff --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/MarkerUtils.java @@ -0,0 +1,84 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.services.tracepoints; + +import java.util.MissingResourceException; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.papyrus.infra.core.markers.MarkerConstants; + +/** + * Utilities for Markers (TODO: some of these are generic marker services (move to infra core markers) and not specific to tracepoints). + * + * @author ansgar + * + */ +public class MarkerUtils { + + public static URI getURI(IMarker marker) { + String uriOfMarkerStr = marker.getAttribute(MarkerConstants.uri, null); + if(uriOfMarkerStr != null) { + return URI.createURI(uriOfMarkerStr); + } + return null; + } + + /** + * return the EObject of a marker (provided that it is a marker with a URI) + * + * @param marker + * @return the associated EObject + */ + public static EObject getEObjectOfMarker(IMarker marker) { + return getEObjectOfMarker(resourceSet, marker); + } + + /** + * return the EObject of a marker (provided that it is a marker with a URI) + * + * @param pResourceSet + * : the resourceSet into which the model associated with the eObject should + * be loaded + * @param marker + * @return the associated EObject + */ + public static EObject getEObjectOfMarker(ResourceSet pResourceSet, IMarker marker) { + URI uriOfMarker = getURI(marker); + if(uriOfMarker != null) { + try { + pResourceSet.getResource(uriOfMarker.trimFragment(), true); + return pResourceSet.getEObject(uriOfMarker, true); + } catch (MissingResourceException e) { + System.err.println("Missing resource"); + } + } + return null; + } + + public static boolean isActive(IMarker marker) { + return marker.getAttribute(TracepointConstants.isActive, false); + } + + /** + * our own copy of resource set + * we do not use the Papyrus resourceSet, since every editor keeps his own copy of the resource set (which is probably + * quite bad) and thus no resourceSet would be available, if Papyrus is not open. + */ + public static ResourceSet resourceSet = new ResourceSetImpl(); +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceActions.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceActions.java new file mode 100644 index 00000000000..6eaf7a25518 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceActions.java @@ -0,0 +1,206 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.papyrus.infra.services.tracepoints.preferences.TPPreferenceConstants; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.State; + +/** + * Set of enumerations that indicates what we want to trace. + * + * @author ansgar + * + */ +public class TraceActions { + + public enum TraceScope { + clazz, + operation, + state, + activity, + }; + + /** + * Options for tracing a class. Note that some options need additional information, e.g. "all operations" + * needs additional information how operations are traced + */ + public enum TAClass { + Creation, + Destruction, + AllOperations, + AllPorts, + AllStates + // +(?) all properties/all operations + // +(all ports?) + // +all state changes? (hierarchical propagation?) + + }; + + /** + * Different ways to trace operations: put only the call itself or the values of the parameters into + * a trace event. + */ + public enum TAOperation { + OnlyCall, + ParameterValues, // here exclusive (parameter values and OnlyCall may not be selected at the same time) + }; + + /** + * Not used for the moment + */ + public enum TAAttribute { + PropertyRead, + PropertyWrite; // write old and new value + }; + + /** + * Options to trace state + */ + public enum TAState { + StateEnter, // add incoming transition to trace? + StateLeave, // add outgoing transition to trace? + Transition // nothing (?) (triggers are known? - no, could be one out of many triggers) + }; + + /** + * Not used for the moment + */ + public enum TAActivity { + activity // (i.e. call operation action) explicit choice of (named attribute?) + }; + + public static String[][] getStringFields(Enum[] enumValues) { + int i = 0; + String[][] taOptions = new String[enumValues.length][2]; + for(Enum tLiteral : enumValues) { + taOptions[i][1] = tLiteral.name(); + taOptions[i][0] = tLiteral.name(); + i++; + } + return taOptions; + } + + public enum TraceFeature { + Class, + Port, + State, + Operation + }; + + /** + * Obtain the definition of a trace option in case of traces on classes + * + * @param traceAction + * @param subFeature + * the trace feature which we want to obtain, i.e. class, state or operation + * from a composite action string in case of class trace points + * @return + */ + public static String getOptions(String traceAction, TraceFeature subFeature) { + String prefix = getStringPrefix(subFeature); + int pos = traceAction.indexOf(prefix); + if(pos == -1) + return null; + else { + // comma is used as separation character. + pos += prefix.length(); + int endPos = traceAction.indexOf(',', pos); + if(endPos == -1) { + return traceAction.substring(pos); + } + return traceAction.substring(pos, endPos); + } + } + + /** + * Get the prefix that is used in each case of a class action to distinguish class, state and operation actions. + * + * @param feature + * The trace feature for which we set an action + * @return + */ + public static String getStringPrefix(TraceFeature feature) { + if(feature == TraceFeature.Class) { + return "C:"; + } + if(feature == TraceFeature.Port) { + return "P:"; + } + else if(feature == TraceFeature.State) { + return "S:"; + } + else if(feature == TraceFeature.Operation) { + return "O:"; + } + return null; + } + + /** + * Initialize an action string that will be stored in the trace marker from the configured actions + * in the preferences. In case of a class, the value is a combination of different options + * that are prefixed to enable a unique classification + * + * @param feature + * The trace feature for which we set an action + * @return + */ + public static String actionFromPreferences(TraceFeature feature) { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + if(feature == TraceFeature.Class) { + return compositeClassOption(store.getInt(TPPreferenceConstants.P_TRACE_OPTION_CLASS), + store.getInt(TPPreferenceConstants.P_TRACE_OPTION_STATE), + store.getInt(TPPreferenceConstants.P_TRACE_OPTION_OP)); + } + else if(feature == TraceFeature.State) { + return store.getString(TPPreferenceConstants.P_TRACE_OPTION_STATE); + } + else if(feature == TraceFeature.Operation) { + return store.getString(TPPreferenceConstants.P_TRACE_OPTION_OP); + } + return ""; + } + + public static String compositeClassOption(int classOption, int stateOption, int operationOption) { + return getStringPrefix(TraceFeature.Class) + classOption + "," + + getStringPrefix(TraceFeature.State) + stateOption + "," + + getStringPrefix(TraceFeature.Operation) + operationOption; + } + + /** + * Convenience function, return the action defined in the preferences in function of the model element + * + * @param element + * @return + */ + public static String actionFromPreferences(EObject element) { + return actionFromPreferences(getTraceFeature(element)); + } + + + public static TraceFeature getTraceFeature(EObject element) { + if(element instanceof State) { + return TraceFeature.State; + } + else if(element instanceof Operation) { + return TraceFeature.Operation; + } + else if(element instanceof org.eclipse.uml2.uml.Class) { + return TraceFeature.Class; + } + return null; + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceFunctions.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceFunctions.java new file mode 100644 index 00000000000..e18394590f3 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceFunctions.java @@ -0,0 +1,112 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints; + +import org.eclipse.core.resources.IMarker; +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; + + +public class TraceFunctions implements IDecorationSpecificFunctions { + + public static final String activeBreakpoint16 = "icons/etool16/brkp_16x16.gif"; + + public static final String inActiveBreakpoint16 = "icons/etool16/brkpd_16x16.gif"; + + public static final String activeTracepoint16 = "icons/etool16/trcp_16x16.gif"; + + public static final String inActiveTracepoint16 = "icons/etool16/trcpd_16x16.gif"; + + public static final String activeBreakpoint9 = "icons/etool16/brkp_9x9.gif"; + + public static final String inActiveBreakpoint9 = "icons/etool16/brkpd_9x9.gif"; + + public static final String activeTracepoint11 = "icons/etool16/trcp_11x12.gif"; + + public static final String inActiveTracepoint11 = "icons/etool16/trcp_11x12.gif"; + + /** + * Return the image descriptor associated with a trace or breakpoint marker + */ + public ImageDescriptor getImageDescriptorForGE(IMarker marker) { + + + org.eclipse.papyrus.infra.widgets.Activator widgetsActivator = + org.eclipse.papyrus.infra.widgets.Activator.getDefault(); + ImageDescriptor overlay = null; + boolean isActive = marker.getAttribute(TracepointConstants.isActive, false); + boolean isTracepoint = marker.getAttribute(TracepointConstants.isTracepoint, false); + if(isTracepoint) { + overlay = isActive ? + widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, activeTracepoint16) : + widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, inActiveTracepoint16); + } + else { + overlay = isActive ? + widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, activeBreakpoint16) : + widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, inActiveBreakpoint16); + } + + return overlay; + } + + /** + * Return the image descriptor associated with a trace or breakpoint marker + */ + public ImageDescriptor getImageDescriptorForME(IMarker marker) { + org.eclipse.papyrus.infra.widgets.Activator widgetsActivator = + org.eclipse.papyrus.infra.widgets.Activator.getDefault(); + ImageDescriptor overlay = null; + boolean isActive = marker.getAttribute(TracepointConstants.isActive, false); + boolean isTracepoint = marker.getAttribute(TracepointConstants.isTracepoint, false); + if(isTracepoint) { + overlay = isActive ? + widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, activeTracepoint11) : + widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, inActiveTracepoint11); + } + else { + overlay = isActive ? + widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, activeBreakpoint9) : + widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, inActiveBreakpoint9); + } + + return overlay; + } + + public PreferedPosition getPreferedPosition(IMarker marker) { + return PreferedPosition.SOUTH_EAST; + } + + public String getMessage(IMarker marker) { + boolean isActive = marker.getAttribute(TracepointConstants.isActive, false); + boolean isTracepoint = marker.getAttribute(TracepointConstants.isTracepoint, false); + return (isActive ? "active" : "inactive") + " " + + (isTracepoint ? "trace point" : "break point"); + } + + public int getPriority(IMarker marker) { + return 0; // all markers have same priority (and we should not have multiple markers on the same model element). + } + + public IPapyrusDecoration markerPropagation(EList childDecorations) { + return null; + } + + public MarkChildren supportsMarkerPropagation() { + return MarkChildren.NO; + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceMechanism.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceMechanism.java new file mode 100644 index 00000000000..3edea4d3717 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceMechanism.java @@ -0,0 +1,88 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.papyrus.infra.services.tracepoints.TraceActions.TraceFeature; +import org.eclipse.papyrus.infra.services.tracepoints.preferences.TPPreferenceConstants; + + +/** + * Support for multiple trace mechanisms via the Eclipse extension mechanism + */ + +public class TraceMechanism { + + public static final String ITRACE_MECHANISM_ID = Activator.PLUGIN_ID + ".traceMechanism"; + + public static EList getTraceMechanisms() + { + EList mechanisms = new BasicEList(); + IExtensionRegistry reg = Platform.getExtensionRegistry(); + IConfigurationElement[] configElements = reg.getConfigurationElementsFor(ITRACE_MECHANISM_ID); + for(IConfigurationElement configElement : configElements) { + try { + // TODO: cache returned instance (avoid creating a new instance each time => more efficient, no need for static attributes) + final Object obj = configElement.createExecutableExtension("class"); + if(obj instanceof ITraceMechanism) { + mechanisms.add((ITraceMechanism)obj); + } + } catch (CoreException exception) { + exception.printStackTrace(); + } + } + return mechanisms; + } + + /** + * get the ID of the default realization mechanism. In case of classes, need to store multiple mechanisms (how to trace states, how to trace + * operations) + * + * @return + */ + public static String getMechanismFromPreferences(TraceFeature feature) { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + if(store != null) { + if(feature == TraceFeature.Class) { + return TraceActions.getStringPrefix(TraceFeature.Port) + store.getInt(TPPreferenceConstants.P_TRACE_IMPLEMENTATION_PORT) + "," + + TraceActions.getStringPrefix(TraceFeature.State) + store.getInt(TPPreferenceConstants.P_TRACE_IMPLEMENTATION_SM) + "," + + TraceActions.getStringPrefix(TraceFeature.Operation) + store.getInt(TPPreferenceConstants.P_TRACE_IMPLEMENTATION_OP); + } + else if(feature == TraceFeature.State) { + return store.getString(TPPreferenceConstants.P_TRACE_IMPLEMENTATION_SM); + } + else if(feature == TraceFeature.Operation) { + return store.getString(TPPreferenceConstants.P_TRACE_IMPLEMENTATION_OP); + } + } + return ""; + } + + /** + * Convenience function. Return defaultTraceMechanisms in function of the element being traced. + * + * @param element + * @return + */ + public static String getDefaultMechanism(EObject element) { + return getMechanismFromPreferences(TraceActions.getTraceFeature(element)); + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceState.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceState.java new file mode 100644 index 00000000000..275d277cd68 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TraceState.java @@ -0,0 +1,20 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints; + + +public class TraceState { + + public static boolean skipAllTracepoints = false; +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TracepointConstants.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TracepointConstants.java new file mode 100644 index 00000000000..f4d617c6e7c --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/TracepointConstants.java @@ -0,0 +1,32 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints; + + + +public class TracepointConstants { + + /** + * The id of the marker used for tracepoints and breakpoints + */ + public static final String tpOrbpMarker = "org.eclipse.papyrus.tporbpmarker"; + + public static final String isActive = "isActive"; + + public static final String isTracepoint = "isTracepoint"; + + public static final String traceAction = "traceAction"; + + public static final String traceMechanism = "traceMechanism"; +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/AbstractTracepointCommand.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/AbstractTracepointCommand.java new file mode 100644 index 00000000000..1aaf94e276c --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/AbstractTracepointCommand.java @@ -0,0 +1,168 @@ +/***************************************************************************** + * 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: + * Ansgar Radermarcher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints.commands; + +import java.util.Collections; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.papyrus.infra.core.markers.MarkerConstants; +import org.eclipse.papyrus.infra.services.tracepoints.Activator; +import org.eclipse.papyrus.infra.services.tracepoints.ITraceMechanism; +import org.eclipse.papyrus.infra.services.tracepoints.TraceMechanism; +import org.eclipse.papyrus.infra.services.tracepoints.TracepointConstants; +import org.eclipse.papyrus.infra.services.tracepoints.preferences.TPPreferenceConstants; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.Port; +import org.eclipse.uml2.uml.State; + +/** + * Action used for pasting either a model element or a shape (i.e. the model element represented + * by the shape). Delegates to PasteShapeOrElementCommand + * + * @author Ansgar Radermacher (CEA LIST) + */ +abstract public class AbstractTracepointCommand extends AbstractTransactionalCommand { + + protected TransactionalEditingDomain domain; + + protected EObject selectedElement; + + /** + * Creates a new ImportLibraryFromRepositoryCommand + * + * @param editingDomain + * editing domain that manages the changed objects + * @param runnable + * process that executes the modifications + * @param label + * the label of the command + * @param description + * description of the command + */ + + public AbstractTracepointCommand(String label, TransactionalEditingDomain domain, EObject selectedElement) { + super(domain, label, Collections.EMPTY_LIST); + this.domain = domain; + this.selectedElement = selectedElement; + } + + protected void updateResourceAndURI() { + resource = selectedElement.eResource(); + uri = resource.getURI() + "#" + resource.getURIFragment(selectedElement); + iresource = WorkspaceSynchronizer.getFile(selectedElement.eResource()); + } + + protected IMarker findMarker(String type) { + + if(iresource != null) { + try { + for(IMarker marker : iresource.findMarkers(type, false, IResource.DEPTH_INFINITE)) { + String markerURI = marker.getAttribute(MarkerConstants.uri, ""); + if((markerURI != null) && markerURI.equals(uri)) { + return marker; + } + } + } catch (CoreException ce) { + } + } + return null; + } + + protected IMarker toggleMarker() { + try { + if(iresource != null) { + IMarker marker = findMarker(TracepointConstants.tpOrbpMarker); + if(marker == null) { // marker does not exist => create + marker = iresource.createMarker(TracepointConstants.tpOrbpMarker); + marker.setAttribute(MarkerConstants.uri, uri); + marker.setAttribute(TracepointConstants.isActive, true); + return marker; + } + else { + // marker exists => delete + marker.delete(); + } + } + } catch (CoreException ce) { + } + return null; + } + + protected void toggleMarkerActivation() { + try { + if(iresource != null) { + IMarker marker = findMarker(TracepointConstants.tpOrbpMarker); + if(marker == null) { // marker does not exist => create + marker = iresource.createMarker(TracepointConstants.tpOrbpMarker); + marker.setAttribute(MarkerConstants.uri, uri); + marker.setAttribute(TracepointConstants.isActive, true); + + // apply trace mechanism according to default in preferences + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + String id = null; + if(selectedElement instanceof Operation) { + id = store.getDefaultString(TPPreferenceConstants.P_TRACE_IMPLEMENTATION_OP); + } + else if(selectedElement instanceof Port) { + id = store.getDefaultString(TPPreferenceConstants.P_TRACE_IMPLEMENTATION_OP); + } + else if(selectedElement instanceof State) { + id = store.getDefaultString(TPPreferenceConstants.P_TRACE_IMPLEMENTATION_SM); + } + if(id != null) { + EList mechanisms = TraceMechanism.getTraceMechanisms(); + for(ITraceMechanism mechanism : mechanisms) { + for(String providedID : mechanism.getTraceMechanismIDs(selectedElement)) { + if(id.equals(providedID)) { + mechanism.applyTraceMechanism(selectedElement, id, 0); + } + } + } + } + } + else { + // marker exists => change activation status + boolean isSet = marker.getAttribute(TracepointConstants.isActive, false); + marker.setAttribute(TracepointConstants.isActive, !isSet); + } + } + } catch (CoreException ce) { + System.err.println(ce); + } + + } + + /** + * {@inheritDoc} + */ + @Override + public boolean canExecute() { + return (selectedElement != null); + } + + protected Resource resource; + + protected IResource iresource; + + protected String uri; +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleBreakpointActivationCommand.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleBreakpointActivationCommand.java new file mode 100644 index 00000000000..aac91107a20 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleBreakpointActivationCommand.java @@ -0,0 +1,40 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.services.tracepoints.commands; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; + + +public class ToggleBreakpointActivationCommand extends AbstractTracepointCommand { + + public ToggleBreakpointActivationCommand(EObject selectedElement) { + super("Toggle Breakpoint activation", TransactionUtil.getEditingDomain(selectedElement), selectedElement); + } + + /** + * {@inheritDoc} + */ + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + updateResourceAndURI(); + toggleMarkerActivation(); + return null; + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleBreakpointCommand.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleBreakpointCommand.java new file mode 100644 index 00000000000..2a3dcc3d415 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleBreakpointCommand.java @@ -0,0 +1,41 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.services.tracepoints.commands; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; + + +public class ToggleBreakpointCommand extends AbstractTracepointCommand { + + public ToggleBreakpointCommand(EObject selectedElement) { + super("Toggle Breakpoint", TransactionUtil.getEditingDomain(selectedElement), selectedElement); + } + + /** + * {@inheritDoc} + */ + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException + { + updateResourceAndURI(); + toggleMarker(); + return null; + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleTracepointActivationCommand.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleTracepointActivationCommand.java new file mode 100644 index 00000000000..0b636e0b2cc --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleTracepointActivationCommand.java @@ -0,0 +1,41 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.services.tracepoints.commands; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; + + +public class ToggleTracepointActivationCommand extends AbstractTracepointCommand { + + public ToggleTracepointActivationCommand(EObject selectedElement) { + super("Toggle tracepoint activation", TransactionUtil.getEditingDomain(selectedElement), selectedElement); + } + + /** + * {@inheritDoc} + */ + @Override + public CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + + updateResourceAndURI(); + toggleMarkerActivation(); + return null; + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleTracepointCommand.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleTracepointCommand.java new file mode 100644 index 00000000000..143ab6d7a50 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/ToggleTracepointCommand.java @@ -0,0 +1,52 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints.commands; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.papyrus.infra.services.tracepoints.TraceActions; +import org.eclipse.papyrus.infra.services.tracepoints.TraceMechanism; +import org.eclipse.papyrus.infra.services.tracepoints.TracepointConstants; + + +public class ToggleTracepointCommand extends AbstractTracepointCommand { + + public ToggleTracepointCommand(EObject selectedElement) { + super("Toggle tracepoint", TransactionUtil.getEditingDomain(selectedElement), selectedElement); + } + + /** + * {@inheritDoc} + */ + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + updateResourceAndURI(); + try { + IMarker marker = toggleMarker(); + marker.setAttribute(TracepointConstants.isTracepoint, true); + // set default options from preferences + marker.setAttribute(TracepointConstants.traceAction, TraceActions.actionFromPreferences(selectedElement)); + marker.setAttribute(TracepointConstants.traceMechanism, TraceMechanism.getDefaultMechanism(selectedElement)); + } catch (CoreException e) { + + } + return null; + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/TracepointPropertiesCommand.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/TracepointPropertiesCommand.java new file mode 100644 index 00000000000..c082c2a4c30 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/commands/TracepointPropertiesCommand.java @@ -0,0 +1,81 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.services.tracepoints.commands; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.papyrus.infra.services.tracepoints.TracepointConstants; +import org.eclipse.papyrus.infra.services.tracepoints.dialogs.TraceActionSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.uml2.uml.Element; + + +public class TracepointPropertiesCommand extends AbstractTracepointCommand { + + public TracepointPropertiesCommand(EObject selectedElement) { + super("Tracepoint properties", TransactionUtil.getEditingDomain(selectedElement), selectedElement); + } + + /** + * {@inheritDoc} + */ + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException + { + updateResourceAndURI(); + selectTraceActions(); + return null; + } + + protected void selectTraceActions() { + IMarker marker = findMarker(TracepointConstants.tpOrbpMarker); + if(marker != null) { + // should normally always hold, since this is checked in canExecute + TraceActionSelection tad = new TraceActionSelection(new Shell(), marker, (Element)selectedElement); + tad.open(); + if(tad.getReturnCode() == IDialogConstants.OK_ID) { + Object[] result = tad.getResult(); + String traceAction = (String)result[0]; + String traceMechanism = (String)result[1]; + try { + marker.setAttribute(TracepointConstants.traceAction, traceAction); + marker.setAttribute(TracepointConstants.traceMechanism, traceMechanism); + } catch (CoreException e) { + } + } + } + } + + /** + * {@inheritDoc} + */ + @Override + public boolean canExecute() { + if(selectedElement != null) { + updateResourceAndURI(); + IMarker marker = findMarker(TracepointConstants.tpOrbpMarker); + System.err.println("Hallo: " + marker); + return marker.getAttribute(TracepointConstants.isTracepoint, false); + } + return false; + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/dialogs/TraceActionSelection.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/dialogs/TraceActionSelection.java new file mode 100644 index 00000000000..b1258f9f19e --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/dialogs/TraceActionSelection.java @@ -0,0 +1,293 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.services.tracepoints.dialogs; + +import java.util.Arrays; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.papyrus.infra.services.tracepoints.ITraceMechanism; +import org.eclipse.papyrus.infra.services.tracepoints.TraceActions; +import org.eclipse.papyrus.infra.services.tracepoints.TraceActions.TAClass; +import org.eclipse.papyrus.infra.services.tracepoints.TraceActions.TAOperation; +import org.eclipse.papyrus.infra.services.tracepoints.TraceActions.TAState; +import org.eclipse.papyrus.infra.services.tracepoints.TraceActions.TraceFeature; +import org.eclipse.papyrus.infra.services.tracepoints.TraceMechanism; +import org.eclipse.papyrus.infra.services.tracepoints.TracepointConstants; +import org.eclipse.papyrus.infra.services.tracepoints.preferences.BinaryEncodedMChoiceFieldEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.ui.dialogs.SelectionStatusDialog; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.InstanceSpecification; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.State; + +public class TraceActionSelection extends SelectionStatusDialog { + + protected CheckboxTableViewer fTraceImplementations; + + protected Text fDescription; + + IMarker m_marker; + + BinaryEncodedMChoiceFieldEditor classOptions; + + BinaryEncodedMChoiceFieldEditor operationOptions; + + BinaryEncodedMChoiceFieldEditor stateOptions; + + /** + * The model element that has a trace marker + */ + private Element m_me; + + public TraceActionSelection(Shell parent, IMarker marker, Element me) { + super(parent); + m_me = me; + m_marker = marker; + // int traceAction = marker.getAttribute(TracepointConstants.traceAction, 0); + } + + + /** + * @see SelectionStatusDialog#computeResult() + * need to return two values: trace action & mechanism + */ + protected void computeResult() { + // nothing to do + String traceActionValue = null; + if(m_me instanceof State) { + traceActionValue = stateOptions.getResult(); + } + else if(m_me instanceof Class) { + traceActionValue = TraceActions.compositeClassOption( + classOptions.getIntResult(), + stateOptions.getIntResult(), + operationOptions.getIntResult()); + } + else if(m_me instanceof State) { + traceActionValue = stateOptions.getResult(); + } + else if(m_me instanceof Operation) { + traceActionValue = operationOptions.getResult(); + } + String traceMechanism = ""; + for(Object tableElement : fTraceImplementations.getCheckedElements()) { + traceMechanism = (String)tableElement; + }; + + Object[] result = new Object[]{ + traceActionValue, + traceMechanism + }; + setResult(Arrays.asList(result)); + } + + class EnumLabelProvider extends LabelProvider implements ITableLabelProvider { + + public String getColumnText(Object obj, int index) { + if(obj instanceof Enum) { + return ((Enum)obj).name(); + } + return obj.toString(); + } + + public Image getColumnImage(Object obj, int index) { + return null; + } + } + + class TraceMechanismsCP implements IStructuredContentProvider { + + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + } + + public void dispose() { + } + + public Object[] getElements(Object parent) { + Object items[] = null; + // + // Implementations of a tracing mechanism are depending on the injection mechanism and (likely) on the + // programming language. Therefore, they are not part of this plugin shipped with Papyrus, but use an + // extension mechanism. + + EList mechanisms = TraceMechanism.getTraceMechanisms(); + if(mechanisms.size() == 0) { + items = new String[]{ "no plugins provide trace extension mechanism" }; + } + else { + EList idList = new BasicEList(); + for(ITraceMechanism mechanism : mechanisms) { + for(String id : mechanism.getTraceMechanismIDs(m_me)) { + idList.add(id); + } + } + items = idList.toArray(new String[0]); + } + return items; + } + } + + public Control createDialogArea(Composite parent) { + Composite contents = (Composite)super.createDialogArea(parent); + + Label label = new Label(contents, SWT.NONE); + label.setText("Select trace action for this element"); + + // need context dependent dialogs on options + // we may need more than one options (e.g. AllOperations + OperationsWithParameters + (begin/end or both?)) + // clean way: accumulate all options, distribute them automatically accordingly. Better (even if less efficient, if strings) + + String[][] taClassOptions = TraceActions.getStringFields(TAClass.values()); + String[][] taStateOptions = TraceActions.getStringFields(TAState.values()); + String[][] taOperationOptions = TraceActions.getStringFields(TAOperation.values()); + String actionString = m_marker.getAttribute(TracepointConstants.traceAction, ""); + String mechanismID = m_marker.getAttribute(TracepointConstants.traceMechanism, ""); + + if(m_me instanceof State) { + stateOptions = new BinaryEncodedMChoiceFieldEditor("State options", 3, taStateOptions, contents, true); + stateOptions.setupViaString(actionString); + } + else if(m_me instanceof Class) { + classOptions = new BinaryEncodedMChoiceFieldEditor("Class options", 3, taClassOptions, contents, true); + stateOptions = new BinaryEncodedMChoiceFieldEditor("State options", 3, taStateOptions, contents, true); + operationOptions = new BinaryEncodedMChoiceFieldEditor("Operation options", 3, taOperationOptions, contents, true); + classOptions.setupViaString(TraceActions.getOptions(actionString, TraceFeature.Class)); + stateOptions.setupViaString(TraceActions.getOptions(actionString, TraceFeature.State)); + operationOptions.setupViaString(TraceActions.getOptions(actionString, TraceFeature.Operation)); + } + else if(m_me instanceof Operation) { + operationOptions = new BinaryEncodedMChoiceFieldEditor("Operation options", 3, taOperationOptions, contents, true); + operationOptions.setupViaString(actionString); + } + + Group implementationGroup = new Group(parent, SWT.NONE); + implementationGroup.setText("Implementation options"); + + // need additional item how the trace mechanism should be realized, i.e. available tracing mechanisms + fTraceImplementations = CheckboxTableViewer.newCheckList(implementationGroup, SWT.H_SCROLL | SWT.V_SCROLL); + + fTraceImplementations.setContentProvider(new TraceMechanismsCP()); + fTraceImplementations.setInput(this); + fTraceImplementations.setChecked(mechanismID, true); // TODO: likely not to work + + fTraceImplementations.addCheckStateListener(new ICheckStateListener() { + + public void checkStateChanged(CheckStateChangedEvent event) { + Object element = event.getElement(); + boolean isChecked = event.getChecked(); + // assure radio button functionality + if(isChecked) { + for(Object checkedElement : fTraceImplementations.getCheckedElements()) { + if(checkedElement != element) { + fTraceImplementations.setChecked(checkedElement, false); + } + } + } + } + }); + + fTraceImplementations.addSelectionChangedListener(new ISelectionChangedListener() { + + public void selectionChanged(SelectionChangedEvent event) { + ISelection selection = event.getSelection(); + if(selection instanceof IStructuredSelection) { + Object first = ((IStructuredSelection)selection).getFirstElement(); + if(first instanceof String) { + EList mechanisms = TraceMechanism.getTraceMechanisms(); + boolean noDesc = true; + for(ITraceMechanism mechanism : mechanisms) { + String description = mechanism.getTraceMechanismDescription(m_me, (String)first); + if(description != null) { + fDescription.setText(description); + noDesc = false; + break; + } + } + if(noDesc) { + fDescription.setText(""); + } + } + } + } + }); + + fDescription = new Text(implementationGroup, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY); + + GridData span = new GridData(); + span.horizontalAlignment = GridData.FILL; + span.grabExcessHorizontalSpace = true; + span.grabExcessVerticalSpace = true; + span.verticalAlignment = GridData.FILL; + span.heightHint = 250; + + // fTraceActions.getTable().setLayoutData(span); + implementationGroup.setLayout(new GridLayout()); + implementationGroup.setLayoutData(span); + + GridData span2 = new GridData(); + span2.horizontalAlignment = GridData.FILL; + span2.grabExcessHorizontalSpace = true; + span2.grabExcessVerticalSpace = true; + span2.verticalAlignment = GridData.FILL; + span2.heightHint = 80; + fDescription.setLayoutData(span2); + fTraceImplementations.getTable().setLayoutData(span2); + + // ruleGroup.setLayout(new RowLayout (SWT.VERTICAL)); + parent.setLayout(new GridLayout(1, false)); + // parent.setLayoutData(groupGridData); + return contents; + } + + // obtain name and explicit/implicit node Allocation + protected void setTextFromData(TreeItem ti) { + Object data = ti.getData(); + if(data instanceof InstanceSpecification) { + // ti.setText(new String[]{ name, nodeName, "[" + list + "]" }); + } + } + + protected void refreshTree(TreeItem ti) { + setTextFromData(ti); + for(TreeItem subItem : ti.getItems()) { + refreshTree(subItem); + } + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/AbstractCommandHandler.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/AbstractCommandHandler.java new file mode 100644 index 00000000000..83b15f4686c --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/AbstractCommandHandler.java @@ -0,0 +1,165 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints.handler; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.utils.BusinessModelResolver; +import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers; +import org.eclipse.papyrus.infra.services.tracepoints.Activator; +import org.eclipse.ui.PlatformUI; + +/** + *
+ * 
+ * This abstract command handler manages:
+ * - current selection in order to build a list of the selected {@link EObject}
+ * - execute the command (returned by children) in Papyrus {@link TransactionalEditingDomain}
+ * - calculate the command enablement and visibility regarding the command executability
+ * (the command is now shown in menu if not executable).
+ * 
+ * 
+ */ +public abstract class AbstractCommandHandler extends AbstractHandler { + + /** + *
+	 * 
+	 * Returns the command to execute (to be implemented 
+	 * in children implementing this class)
+	 * 
+	 * @return the command to execute
+	 * 
+	 * 
+ */ + protected abstract Command getCommand(); + + /** + *
+	 * 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
+	 * 
+ * + */ + 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) { + Object businessObject = BusinessModelResolver.getInstance().getBusinessModel(selection); + if(businessObject instanceof EObject) { + eObject = (EObject)businessObject; + } + } + return eObject; + } + + /** + *
+	 * Parse current selection and extract the list of {@link EObject} from
+	 * this selection.
+	 * 
+	 * This also tries to adapt selected element into {@link EObject}
+	 * (for example to get the {@link EObject} from a selection in the ModelExplorer).
+	 * 
+	 * @return a list of currently selected {@link EObject}
+	 * 
+ * + */ + protected List getSelectedElements() { + + List selectedEObjects = new ArrayList(); + + // Parse current selection + ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); + if(selection instanceof IStructuredSelection) { + IStructuredSelection structuredSelection = (IStructuredSelection)selection; + for(Object current : structuredSelection.toArray()) { + // Adapt current selection to EObject + if(current instanceof IAdaptable) { + selectedEObjects.add((EObject)((IAdaptable)current).getAdapter(EObject.class)); + } + } + } else { // Not a IStructuredSelection + if(selection != null) { + // Adapt current selection to EObject + if(selection instanceof IAdaptable) { + selectedEObjects.add((EObject)((IAdaptable)selection).getAdapter(EObject.class)); + } + } + } + + return selectedEObjects; + } + + /** + * + * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) + * + * @param event + * @return null + * @throws ExecutionException + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + try { + ServiceUtilsForActionHandlers util = new ServiceUtilsForActionHandlers(); + util.getTransactionalEditingDomain().getCommandStack().execute(getCommand()); + } catch (ServiceException e) { + Activator.log.error("Unexpected error while executing command.", e); //$NON-NLS-1$ + } + + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isEnabled() { + return getCommand().canExecute(); + } + + /** + * + * @return true (visible) when the command can be executed. + */ + public boolean isVisible() { + return getCommand().canExecute(); + } + + +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleBreakpointActivationHandler.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleBreakpointActivationHandler.java new file mode 100644 index 00000000000..e2d03274ea0 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleBreakpointActivationHandler.java @@ -0,0 +1,33 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.services.tracepoints.handler; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.services.tracepoints.commands.ToggleBreakpointActivationCommand; + +/** + * Handler for toggling breakpoint activation. Delegates to associated command + * + * @author Ansgar Radermacher (CEA LIST) + */ +public class ToggleBreakpointActivationHandler extends AbstractCommandHandler { + + @Override + protected Command getCommand() { + // not useful to cache command, since selected element may change + return new GMFtoEMFCommandWrapper(new ToggleBreakpointActivationCommand(getSelectedElement())); + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleBreakpointHandler.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleBreakpointHandler.java new file mode 100644 index 00000000000..2e840dcb595 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleBreakpointHandler.java @@ -0,0 +1,33 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.services.tracepoints.handler; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.services.tracepoints.commands.ToggleBreakpointCommand; + +/** + * Handler for toggling a break point. Delegates to associated command + * + * @author Ansgar Radermacher (CEA LIST) + */ +public class ToggleBreakpointHandler extends AbstractCommandHandler { + + @Override + protected Command getCommand() { + // not useful to cache command, since selected element may change + return new GMFtoEMFCommandWrapper(new ToggleBreakpointCommand(getSelectedElement())); + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleTracepointActivationHandler.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleTracepointActivationHandler.java new file mode 100644 index 00000000000..cd131c93831 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleTracepointActivationHandler.java @@ -0,0 +1,33 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.services.tracepoints.handler; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.services.tracepoints.commands.ToggleTracepointActivationCommand; + +/** + * Handler for toggling tracepoint activation. Delegates to associated command + * + * @author Ansgar Radermacher (CEA LIST) + */ +public class ToggleTracepointActivationHandler extends AbstractCommandHandler { + + @Override + protected Command getCommand() { + // not useful to cache command, since selected element may change + return new GMFtoEMFCommandWrapper(new ToggleTracepointActivationCommand(getSelectedElement())); + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleTracepointHandler.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleTracepointHandler.java new file mode 100644 index 00000000000..8045157a878 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/ToggleTracepointHandler.java @@ -0,0 +1,33 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.services.tracepoints.handler; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.services.tracepoints.commands.ToggleTracepointCommand; + +/** + * Handler for toggling a tracepoint. Delegates to associated command + * + * @author Ansgar Radermacher (CEA LIST) + */ +public class ToggleTracepointHandler extends AbstractCommandHandler { + + @Override + protected Command getCommand() { + // not useful to cache command, since selected element may change + return new GMFtoEMFCommandWrapper(new ToggleTracepointCommand(getSelectedElement())); + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/TracepointPropertiesHandler.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/TracepointPropertiesHandler.java new file mode 100644 index 00000000000..c1565dc9bea --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/handler/TracepointPropertiesHandler.java @@ -0,0 +1,33 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.services.tracepoints.handler; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.services.tracepoints.commands.TracepointPropertiesCommand; + +/** + * Handler for changing the properties of a tracepoint. Delegates to associated command + * + * @author Ansgar Radermacher (CEA LIST) + */ +public class TracepointPropertiesHandler extends AbstractCommandHandler { + + @Override + protected Command getCommand() { + // not useful to cache command, since selected element may change + return new GMFtoEMFCommandWrapper(new TracepointPropertiesCommand(getSelectedElement())); + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/BinaryEncodedMChoiceFieldEditor.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/BinaryEncodedMChoiceFieldEditor.java new file mode 100644 index 00000000000..b8db97671e8 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/BinaryEncodedMChoiceFieldEditor.java @@ -0,0 +1,132 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.services.tracepoints.preferences; + +import org.eclipse.swt.widgets.Composite; + + +/** + * A class derived from the MultipleChoiceFieldEditor. + * It encodes a multiple choice value in a binary way, i.e. bit I is set in the result, if the i-th choice is active. + * This class can also be used outside a preference page + * + * @author ansgar + * + */ +public class BinaryEncodedMChoiceFieldEditor extends MultipleChoiceFieldEditor { + + /** + * @param name + * The preference ID + * @param labeltext + * the label text + * @param numColumns + * the number of columns + * @param labelsAndValues + * a two dimensional array containing the labels and values + * @param parent + * the parent SWT composite (field editor parent) + * @param useGroup + * display contents within a group + */ + public BinaryEncodedMChoiceFieldEditor(String name, String labeltext, int numColumns, String[][] labelsAndValues, Composite parent, boolean useGroup) { + super(name, labeltext, numColumns, labelsAndValues, parent, useGroup); + } + + + /** + * Convenience constructor, if used outside a preference page + * + * @param labeltext + * the label text + * @param numColumns + * the number of columns + * @param labelsAndValues + * a two dimensional array containing the labels and values + * @param parent + * the parent SWT composite (field editor parent) + * @param useGroup + * display contents within a group + */ + public BinaryEncodedMChoiceFieldEditor(String labeltext, int numColumns, String[][] labelsAndValues, Composite parent, boolean useGroup) { + super("", labeltext, numColumns, labelsAndValues, parent, useGroup); + } + + /** + * Use this function to initialize the set/non-set flags within the dialog from a binary encoded value, + * if you use the dialog outside a preference page + * + * @param currentValue + */ + public void setupViaString(String currentValue) { + setupControls(currentValue); + } + + /** + * Use this function to get the results, + * if you use the dialog outside a preference page + * + * @return the result + */ + public String getResult() { + result = gatherSettings(); + return result; + } + + /** + * Convenience function returning an integer result instead of a String result + * (requires double conversion that is difficult to avoid, since calculateResults needs to return + * a string); + * + * @return + */ + public int getIntResult() { + if(getResult() == null) { + return 0; + } + return Integer.parseInt(getResult()); + } + + @Override + protected String calculateResult(String[][] settings) { + int traceActionValue = 0; + int index = 0; + for(String setting[] : settings) { + // [0] = name, [1] = value [2] = checked + if(setting[2].equals("true")) { + traceActionValue += 1 << index; + } + index++; + }; + return String.valueOf(traceActionValue); + } + + @Override + protected boolean isSelected(String fieldName, String valueToSet) { + try { + int value = new Integer(valueToSet); + int index = 0; + for(String setting[] : labelsAndValues) { + // [0] = name, [1] = value [2] = checked + if(setting[0].equals(fieldName)) { + return (value & (1 << index)) > 0; + } + index++; + }; + } catch (NumberFormatException e) { + } + return false; + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/MultipleChoiceFieldEditor.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/MultipleChoiceFieldEditor.java new file mode 100644 index 00000000000..0ef922e2b9e --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/MultipleChoiceFieldEditor.java @@ -0,0 +1,234 @@ +/******************************************************************************* + * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others. + * 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 + * + *******************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints.preferences; + +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +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.Control; +import org.eclipse.swt.widgets.Group; + + +/** + * @author Dennis Hübner - Initial contribution and API + * [used within Papyrus to avoid dependency to Xtext, minor visibility modification] + * + */ +public abstract class MultipleChoiceFieldEditor extends FieldEditor { + + private Composite checkBoxBox; + + private final boolean useGroup; + + protected final String[][] labelsAndValues; + + private final int numColumns; + + private Button[] checkBoxButtons; + + protected String result; + + public MultipleChoiceFieldEditor(String name, String labeltext, int numColumns, String[][] labelsAndValues, + Composite fieldEditorParent, boolean useGroup) { + init(name, labeltext); + this.numColumns = numColumns; + this.labelsAndValues = labelsAndValues.clone(); + this.useGroup = useGroup; + createControl(fieldEditorParent); + } + + /** + * @param settings + * String[][fieldName,fieldValue,isChecked] + * @return value as String + */ + protected abstract String calculateResult(String[][] settings); + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.preference.FieldEditor#adjustForNumColumns(int) + */ + @Override + protected void adjustForNumColumns(int numColumns) { + Control control = getLabelControl(); + if(control != null) { + ((GridData)control.getLayoutData()).horizontalSpan = numColumns; + } + ((GridData)checkBoxBox.getLayoutData()).horizontalSpan = numColumns; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.preference.FieldEditor#doFillIntoGrid(org.eclipse.swt + * .widgets.Composite, int) + */ + @Override + protected void doFillIntoGrid(Composite parent, int numColumns) { + if(useGroup) { + Control control = getCheckBoxControl(parent); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + control.setLayoutData(gd); + } + else { + Control control = getLabelControl(parent); + GridData gd = new GridData(); + gd.horizontalSpan = numColumns; + control.setLayoutData(gd); + control = getCheckBoxControl(parent); + gd = new GridData(); + gd.horizontalSpan = numColumns; + control.setLayoutData(gd); + } + } + + private Control getCheckBoxControl(Composite parent) { + if(checkBoxBox == null) { + Font font = parent.getFont(); + if(useGroup) { + Group group = new Group(parent, SWT.NONE); + group.setFont(font); + String text = getLabelText(); + if(text != null) { + group.setText(text); + } + checkBoxBox = group; + GridLayout layout = new GridLayout(); + layout.horizontalSpacing = HORIZONTAL_GAP; + layout.numColumns = numColumns; + checkBoxBox.setLayout(layout); + } + else { + checkBoxBox = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginWidth = 0; + layout.marginHeight = 0; + layout.horizontalSpacing = HORIZONTAL_GAP; + layout.numColumns = numColumns; + checkBoxBox.setLayout(layout); + checkBoxBox.setFont(font); + } + + checkBoxButtons = new Button[labelsAndValues.length]; + for(int i = 0; i < labelsAndValues.length; i++) { + Button checkBox = new Button(checkBoxBox, SWT.CHECK | SWT.LEFT); + checkBoxButtons[i] = checkBox; + String[] labelAndValue = labelsAndValues[i]; + checkBox.setText(labelAndValue[0]); + checkBox.setData(labelAndValue[1]); + checkBox.setFont(font); + checkBox.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent event) { + setPresentsDefaultValue(false); + String oldResult = result; + result = gatherSettings(); + fireValueChanged(VALUE, oldResult, result); + } + }); + } + checkBoxBox.addDisposeListener(new DisposeListener() { + + public void widgetDisposed(DisposeEvent event) { + checkBoxBox = null; + checkBoxButtons = null; + } + }); + } + else { + checkParent(checkBoxBox, parent); + } + return checkBoxBox; + } + + protected String gatherSettings() { + String[][] settings = new String[checkBoxButtons.length][3]; + for(int i = 0; i < checkBoxButtons.length; i++) { + Button currentCheckBox = checkBoxButtons[i]; + String name = currentCheckBox.getText(); + String value = (String)currentCheckBox.getData(); + String checked = String.valueOf(currentCheckBox.getSelection()); + settings[i] = new String[]{ name, value, checked }; + } + return calculateResult(settings); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.preference.FieldEditor#doLoad() + */ + @Override + public void doLoad() { + setupControls(getPreferenceStore().getString(getPreferenceName())); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.preference.FieldEditor#doLoadDefault() + */ + @Override + protected void doLoadDefault() { + setupControls(getPreferenceStore().getDefaultString(getPreferenceName())); + } + + protected void setupControls(String valueToSet) { + for(int i = 0; i < checkBoxButtons.length; i++) { + Button currentCheckBox = checkBoxButtons[i]; + currentCheckBox.setSelection(isSelected(currentCheckBox.getText(), valueToSet)); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.preference.FieldEditor#doStore() + */ + @Override + protected void doStore() { + if(result == null) { + return; + } + getPreferenceStore().setValue(getPreferenceName(), result); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls() + */ + @Override + public int getNumberOfControls() { + return 1; + } + + @Override + public void setEnabled(boolean enabled, Composite parent) { + if(!useGroup) { + super.setEnabled(enabled, parent); + } + for(Button button : checkBoxButtons) { + button.setEnabled(enabled); + } + } + + abstract protected boolean isSelected(String fieldName, String valueToSet); +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/TPPreferenceConstants.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/TPPreferenceConstants.java new file mode 100644 index 00000000000..2a0845bb849 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/TPPreferenceConstants.java @@ -0,0 +1,51 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints.preferences; + +/** + * Constant definitions for plug-in preferences + */ +public class TPPreferenceConstants { + + /** + * The trace mechanism that should be used by default + */ + public static final String P_TRACE_IMPLEMENTATION_PORT = "papyrus.trace.implementation.port"; + + /** + * The trace mechanism that should be used by default + */ + public static final String P_TRACE_IMPLEMENTATION_OP = "papyrus.trace.implementation.op"; + + /** + * The trace mechanism that should be used by default + */ + public static final String P_TRACE_IMPLEMENTATION_SM = "papyrus.trace.implementation.sm"; + + + /** + * Options for trace implementation via state machines + */ + public static final String P_TRACE_OPTION_CLASS = "papyrus.trace.option.class"; + + /** + * Options for trace implementation for operations + */ + public static final String P_TRACE_OPTION_STATE = "papyrus.trace.option.state"; + + /** + * Options for trace implementation via state machines + */ + public static final String P_TRACE_OPTION_OP = "papyrus.trace.option.op"; +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/TPPreferenceInitializer.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/TPPreferenceInitializer.java new file mode 100644 index 00000000000..096d661169d --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/TPPreferenceInitializer.java @@ -0,0 +1,53 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.emf.common.util.EList; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.papyrus.infra.services.tracepoints.Activator; +import org.eclipse.papyrus.infra.services.tracepoints.ITraceMechanism; +import org.eclipse.papyrus.infra.services.tracepoints.TraceMechanism; + +/** + * Class used to initialize default preference values. + */ +public class TPPreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + EList mechanisms = TraceMechanism.getTraceMechanisms(); + String mechanismID = ""; + if(mechanisms.size() > 0) { + ITraceMechanism mechanism = mechanisms.get(0); + // TODO: function need to support null object + EList mechanismIDs = mechanism.getTraceMechanismIDs(null); + if(mechanismIDs.size() > 0) { + mechanismID = mechanismIDs.get(0); + } + } + store.setDefault(TPPreferenceConstants.P_TRACE_IMPLEMENTATION_PORT, mechanismID); + store.setDefault(TPPreferenceConstants.P_TRACE_IMPLEMENTATION_OP, mechanismID); + store.setDefault(TPPreferenceConstants.P_TRACE_IMPLEMENTATION_SM, mechanismID); + + store.setDefault(TPPreferenceConstants.P_TRACE_OPTION_CLASS, 3); + store.setDefault(TPPreferenceConstants.P_TRACE_OPTION_STATE, 0); + store.setDefault(TPPreferenceConstants.P_TRACE_OPTION_OP, 0); + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/TPPreferencePage.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/TPPreferencePage.java new file mode 100644 index 00000000000..773c30a6ee1 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/src/org/eclipse/papyrus/infra/services/tracepoints/preferences/TPPreferencePage.java @@ -0,0 +1,106 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.services.tracepoints.preferences; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.jface.preference.ComboFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.RadioGroupFieldEditor; +import org.eclipse.papyrus.infra.services.tracepoints.Activator; +import org.eclipse.papyrus.infra.services.tracepoints.ITraceMechanism; +import org.eclipse.papyrus.infra.services.tracepoints.TraceActions; +import org.eclipse.papyrus.infra.services.tracepoints.TraceActions.TAClass; +import org.eclipse.papyrus.infra.services.tracepoints.TraceActions.TAOperation; +import org.eclipse.papyrus.infra.services.tracepoints.TraceActions.TAState; +import org.eclipse.papyrus.infra.services.tracepoints.TraceMechanism; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +/** + * This class represents the TracePoint preference page + *

+ * This page is used to modify preferences only. They are stored in the preference store that belongs to the main plug-in class. That way, preferences + * can be accessed directly via the preference store. + */ + +public class TPPreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + + public TPPreferencePage() { + super(GRID); + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + setDescription("Trace options"); + } + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + public void createFieldEditors() { + EList mechanisms = TraceMechanism.getTraceMechanisms(); + int elements = 0; + for(ITraceMechanism mechanism : mechanisms) { + // TODO: function need to support null object + EList mechanismIDs = mechanism.getTraceMechanismIDs(null); + elements += mechanismIDs.size(); + } + String[][] mechList = new String[elements][2]; + elements = 0; + for(ITraceMechanism mechanism : mechanisms) { + // TODO: function need to support null object + EList mechanismIDs = mechanism.getTraceMechanismIDs(null); + for(String id : mechanismIDs) { + mechList[elements][1] = id; + mechList[elements][0] = mechanism.getTraceMechanismDescription(null, id); + elements++; + } + } + + String[][] taClassOptions = TraceActions.getStringFields(TAClass.values()); + String[][] taStateOptions = TraceActions.getStringFields(TAState.values()); + String[][] taOperationOptions = TraceActions.getStringFields(TAOperation.values()); + + addField(new BinaryEncodedMChoiceFieldEditor(TPPreferenceConstants.P_TRACE_OPTION_CLASS, "Class options", 3, taClassOptions, getFieldEditorParent(), true)); + + addField(new BinaryEncodedMChoiceFieldEditor(TPPreferenceConstants.P_TRACE_OPTION_STATE, "State options", 3, taStateOptions, getFieldEditorParent(), true)); + + addField(new RadioGroupFieldEditor( + TPPreferenceConstants.P_TRACE_OPTION_OP, + "Operations options", 3, taOperationOptions, getFieldEditorParent(), true)); + + addField(new ComboFieldEditor( + TPPreferenceConstants.P_TRACE_IMPLEMENTATION_PORT, + "Trace Mechanism for ports", mechList, getFieldEditorParent())); + + addField(new ComboFieldEditor( + TPPreferenceConstants.P_TRACE_IMPLEMENTATION_OP, + "Trace Mechanism for operations (+construction/destruction)", mechList, getFieldEditorParent())); + + addField(new ComboFieldEditor( + TPPreferenceConstants.P_TRACE_IMPLEMENTATION_SM, + "Trace Mechanism for state machines", mechList, getFieldEditorParent())); + + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/.classpath b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/.classpath new file mode 100644 index 00000000000..64c5e31b7a2 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/.project b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/.project new file mode 100644 index 00000000000..7de3375ec19 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/.project @@ -0,0 +1,34 @@ + + + org.eclipse.papyrus.qompass.modellibs.tracing + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.acceleo.ide.ui.acceleoBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.acceleo.ide.ui.acceleoNature + org.eclipse.jdt.core.javanature + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/META-INF/MANIFEST.MF b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..796cbadf16f --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/META-INF/MANIFEST.MF @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.papyrus.qompass.modellibs.tracing;singleton:=true +Bundle-Version: 0.9.2.qualifier +Bundle-Activator: org.eclipse.papyrus.qompass.modellibs.tracing.Activator +Bundle-Vendor: %providerName +Require-Bundle: org.eclipse.papyrus.fcm.profile;bundle-version="0.9.2", + org.eclipse.papyrus.qompass.modellibs.core;bundle-version="0.9.2", + org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.papyrus.qompass.designer.core;bundle-version="0.9.2", + org.eclipse.papyrus.infra.services.tracepoints;bundle-version="0.9.2", + org.eclipse.papyrus.infra.core;bundle-version="0.9.2", + org.eclipse.emf.workspace;bundle-version="1.5.0", + org.eclipse.uml2.uml;bundle-version="4.0.0" +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-ActivationPolicy: lazy +Bundle-Localization: plugin diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/about.html b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/about.html new file mode 100644 index 00000000000..209103075a7 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

November 14, 2008

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") 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 http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/build.acceleo b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/build.acceleo new file mode 100644 index 00000000000..67c8b63b209 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/build.acceleo @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/build.properties b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/build.properties new file mode 100644 index 00000000000..2ff04c5cff9 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/build.properties @@ -0,0 +1,13 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + models/,\ + build.properties,\ + help/,\ + html/,\ + about.html,\ + plugin.properties +customBuildCallbacks = build.acceleo +src.includes = about.html diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/help/tocconcepts.xml b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/help/tocconcepts.xml new file mode 100644 index 00000000000..0344ca208f3 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/help/tocconcepts.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image001.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image001.gif new file mode 100755 index 00000000000..5271b605b82 Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image001.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image002.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image002.gif new file mode 100755 index 00000000000..d82c319e550 Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image002.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image003.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image003.gif new file mode 100755 index 00000000000..fae2ca8952f Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image003.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image004.jpg b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image004.jpg new file mode 100755 index 00000000000..864120f480a Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image004.jpg differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image005.jpg b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image005.jpg new file mode 100755 index 00000000000..9c9d1935d00 Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image005.jpg differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image006.jpg b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image006.jpg new file mode 100755 index 00000000000..d732917a0fc Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image006.jpg differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image007.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image007.gif new file mode 100755 index 00000000000..2a26c4ddaa7 Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image007.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image008.jpg b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image008.jpg new file mode 100755 index 00000000000..a332638c7e5 Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image008.jpg differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image009.jpg b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image009.jpg new file mode 100755 index 00000000000..bb1eed8a3b3 Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/images/image009.jpg differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/userguide.htm b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/userguide.htm new file mode 100644 index 00000000000..b2f52da6ea1 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/html/userguide.htm @@ -0,0 +1,213 @@ + + +Model-Based Tracing of UML models in Papyrus + + +

Model-Based Tracing of UML models in Papyrus

+

+
+

1. Introduction

+

+The Papyrus Trace Framework allows +annotating UML model elements with a trace annotation. Different kind of model +elements can be annotated, such as operations or ports. These annotations are +shown by means of a decoration icon. When the code of the application is +generated, the trace declaration must lead to an instrumentation of the +generated code for a specific trace implementation, in our case primarily +LTTng.

+

2. Annotating Model elements

+

Several model elements can be annotated +with trace information. In the sequel, we list these and outline the different +trace options.

+

1. Class/component itself. When a class is annotated, by default its +creation and destruction is traced. In addition, a class has several features +(such as operations and attributes). These can be traced without having to +place a tracepoint on the feature itself. The user can choose whether he wants +to trace in addition all attributes, all operations or all states. This choice +is available in the tracing context menu, after the tracepoint has been +applied.

+

2. Port of a component

+

+If a port of a component is traced, an interceptor is placed within the components container. The +interceptor traces the operations that are associated with a port. For +instance, a data-flow port is associated with push or pull operations that take +the concerned data type as parameter.

+

+

3. Operation of a class

+

A tracepoint may +be placed on an operation of a class. This means that an interceptor (on class +level) will create a trace event before and/or after the operation has been +called. In addition, there is the option to add the operation name and the +model reference into the trace point, or ' in addition ' all of the operations +parameters. If the trace event is produced before the application invocation, +out parameters and return values are not part of the trace event.

+

+

4. Property of a class

+

Properties +(attributes) of a class can be traced, if the attribute's type is itself a +class. In this case, the tracepoint is interpreted as a trace on the instance. +It implies activating tracing on the attributes type, but restricting the +production of a trace to the role (instance) that the type plays within the class +declaring the attribute. This mechanism can be realized within the framework, +but is not implemented at the moment.

+

5. +Trace +an instance specification

+

Putting a trace +point on an instance specification is quite similar to putting a trace point to +an attribute: the classifier referenced by the instance specification will have +trace support but actual tracing is restricted to concrete instance. Not implemented (planned for 2013)

+

+

6. +State +(within a statechart)

+

If a class defines a state-chart, the +states can be annotated with a trace marker. A trace event is produced, if the +state is entered and/or left (configurable via option). Not implemented +(planned for 2013)

+

7. +Transition: +A transition can be annotated. A trace event is produced, when the transition +is fired.

+

+

+

Code produced for a trace +annotation

+

2.1 +Trace declaration

+

In LTTng, a trace events need to have a +declaration. We distinguish events that have a generic declaration and those +requiring a specific declaration. For instance, a call event for an operation +has a generic declaration, if parameters are not included: all that is needed +is the operation name (or identifier). Although we could always use a generic +declaration with the operation name as parameter, we declare the name (and URI +reference) in the events declaration, i.e. in its meta-data. Thus, an event +instance does not include the model URI and is therefore quite lcompact on the +expense of a potentially large number of different events.

+

In general, the event declaration includes +a model reference, e.g. ref. to port or operation and event data. In case of an +operation call, the event data corresponds to the values of parameter and an +identification of the associated instance. The following code fragment shows, +how a tracepoint is declared in case of a port interception. Here, the port 'p', +typed with interface ICompute is traced, these are the actual of a package +template with the two formal parameters interface and port.

+

We use a canonical name for the event type +which is composed of the model name, the name of a package template and the +actual variables for the template. In our example, the model is called +ClientServerTraceTest, the package methodCall_port_ICompute_p (the underlying package +template is called methodCall_port, the actual for the two formals Interface +and port are 'ICompute' and 'p', respectively). The second parameter for the +event declaration is the elements name, e.g. the operation name ('add' in the +example) in case of a traced operation.

+
+

TRACEPOINT_EVENT(ClientServerTraceTest_methodCall_port_ICompute_p, +add,

+

+TP_ARGS(const char *, instanceName, int, a, int, b),

+

+TP_FIELDS(

+

+ctf_string(instanceName, instanceName)

+

+ctf_integer(int, a, a)

+

+ctf_integer(int, b, b)

+

)

+

)

+

TRACEPOINT_MODEL_EMF_URI(ClientServerTraceTest_methodCall_port_ICompute_p, +add, "platform:/resource/org.eclipse.papyrus.qompass.designer.examples/model/ClientServerTraceTest.uml#_4KiE8DLbEd2qeKRLMdIx_A")

+
+

+

For each trace event, the added +instrumentation code with invoke the tracepoint, in case of the example above +by

+
+

tracepoint(ClientServerTraceTest_methodCall_port_ICompute_p, add, instanceName, a, b);

+
+

Note that instanceName is an attribute of the interception +class, i.e. not a fixed string, a and b are the actual parameters of an +operation.

+

3. Example

+

This section demonstrates the use of the trace +mechanism by means of a very simple application, called client/server trace +test. The model is available via the 'new example' menu. Select the example +from the 'Qompass examples' folder.

+

trace4.png

+

Figure 1: Tracepoint on operation, shown in model +explorer, diagram and trace view

+

Figure 1 shows a +small test application. A tracepoint is placed on an operation testOp. The +tracepoint is also visible in the tracepoint view (first selected entry) and in +the model explorer and the left. The tracepoint view is an additional view that +can be shown via the Eclipse standard 'show view' dialog, appearing in the +Papyrus category.

+

+

+

trace9.png

+

Figure 2: Set trace points via context menu

+

Figure 2 shows a +part of the context menu of a model element in the model explorer or a diagram. +It contains a sub-menu called 'Tracing' that contains trace related functions. +In particular, it is possible to toggle a tracepoint, i.e. add or remove a +tracepoint. A tracepoint can be active or inactive. While the instrumentation +is always added, i.e. also when the tracepoint is inactive, trace events should +only be produced for an active tracepoint. This sould be done via the LTTng +runtime control mechanisms.

+

+

+

Figure 4: Preference dialog for tracing

+

Figure 4 shows the +preference dialog for tracing within the Papyrus category. The dialog captures +the different options how a tracepoint of a class, a state and on an operation +should be interpreted, e.g. whether an operation is be trace with or without +parameter values.

+

In addition to these options, the +instrumentation has a modular realization mechanism and the default +implementation among available implementations can be chosen. The Qompass model +library contains for instance not only an LTTng based trace implementation, but +also one based on OTF (open trace format).

+

+

+

+

Figure 5: Trace event view via TMF

+

Once the tracepoints are set, an +application can be compiled and executed. Currently, the runtime trace options +must be set manually (e.g. enable all events). The generated trace can be +imported by means of the TMF (trace monitoring framework) which is part of the +LTTng linux-tools. Figure 5 +shows the event view of this framework (note that the view will be replaced by +an editor from version 2.0 on) displaying the trace of the client/server trace +test model. The screenshot shows the event timestamp, type and content. It +depicts that the type corresponds to a qualified name in the model element and +that the contents contains parameter values.

+

+

+

Figure 6: Trace event view, filtered (only 'testOp' +is shown)

+

In Figure 6, the event view has been restricted +to the operation 'testOp' by means of a context operation of an element in the +model explorer or diagram. In this case, only events for the operation testOp +are shown.

+
+ + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ClientServerTraceTest.di b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ClientServerTraceTest.di new file mode 100644 index 00000000000..3e57bb9a61b --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ClientServerTraceTest.di @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ClientServerTraceTest.notation b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ClientServerTraceTest.notation new file mode 100644 index 00000000000..50b938b975e --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ClientServerTraceTest.notation @@ -0,0 +1,1315 @@ + + + + + +
+ + +
+ + +
+ + + + + + + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+
+
+ + + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+
+
+
+
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+
+
+
+
+ + + + + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + +
+ + +
+ + +
+ + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + +
+ + + + +
+ + +
+ + +
+ + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ClientServerTraceTest.uml b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ClientServerTraceTest.uml new file mode 100644 index 00000000000..d18b4fe9680 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ClientServerTraceTest.uml @@ -0,0 +1,428 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + C/C++ + cout << "a=" << a << " b=" << b << " a+b=" << a+b << endl; +return a+b; + + + C/C++ + cout << "a*b=" << a*b; +return a*b; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This interface contains services that are used by the client and provided by the server component + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The client component inherits a specific port from the Cstart componen type: the port "start" which provides interface IRunnable containing a single operation "run". By implementing this operation, the client gets initial control, comparable to a function "main" in classificla programming languages. + + + This realization relationship has been added automatically by Qompass, it is derived from the fact that class CClient_impl implements the port "start" which provides the interface "IStart" + + + The operation "run" (not the associated behavior) has been added automatically by Qompass in order to implement the operations of interfaces provided by ports, in this case of the operations of the "IStart" interface. It would be tedious to manually copy operations from an interface, as it would imply copying the complete signature with all parameters. The component developper has to provide a suitable behavior. A validation rule verifies if operations without behavior exist. + + + + + These two interface are part of the "BasicCalls" Qompass model library. The IStart interface is "special", since the Qompass model transformations check for it existance in order to pass the "main" control to this component. A validation rule checks, if exactly one component instance provides this interface via the "start" port. + + + + + + + + + + + + C/C++ + cout << "call via port q: add (2, 3);" << endl; +for (int i=0; i<20; i++) { + cout << "result: " << q->add (2, (i+3)) << endl; + usleep((i+10)*5*1000); + cout << "result: " << q->mult (3.0, 7.0) << endl; + usleep(20*1000); + testOp(i*2); + usleep(30*1000); +} + + + C/C++ + cout << "This is a test operation" << endl; + + + + + + + + + + + + A composite class in which two attributes represent the component instances client and server, respectively. The assembly between ports is done on this level. +A single class represents the complete application, typically called "System" or "System_impl". Such a class provides the information to calculate a tree of instance specifications, a so-called deployment plan. Check out the context menu. can be generated from the + + + This connection between ports is stereotyped. The "connector" provides information which specific interaction component is responsible for realising this connection. The interaction component is part of an Qompass model library. Select the connection and check out the Qompass pop "Show/choose connector type or implementation". In this case an group of implementations has been chosen, which contains a socket connection in case of distribution and a direct connection, if co-localized + + + + + + + + + + + + + + + + + + + + The hardware architecture is also defined by means of a composite class (comparable to the software architecture). The types (NodeA and NodeB) can be stereotyped with information about the used target platform (FCM stereotype target). As for software architecture, instances specification for nodes are derived from this class. Use "Qompass: create platform definition" in the context menu. + + + The physical connection between two nodes is represented by a UML connector. Currently, this information is not evaluated by Qompass, but it is planned to analyze for instance whether the throughput (specified by means of MARTE) is sufficient with requirements of the software + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A deployment configuration that activates the tracing container rule which will provide OTF tracing. The deployment configuration is linked with the "monolithic" deployment plan + + + deployment plan (= set of instances along with their configuration and allocation) "monolithic". All instances are allocated to node instance "monoNode". Check out the node allocation with the pop-up "Qompass: allocate to node". +Initiate the deployment and code generation with the pop-up "Qompass: generate deployment model and code from plan". + + + In this case, the deployment plan forsees allocating the client to nodeA and the server to nodeB. Note that the deployment transformations will automatically detect that a distributed connector is required, in this case a socket (see composite diagram System) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ProducerConsumer.di b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ProducerConsumer.di new file mode 100644 index 00000000000..8ead0589857 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ProducerConsumer.di @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ProducerConsumer.notation b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ProducerConsumer.notation new file mode 100644 index 00000000000..afa79ec196e --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ProducerConsumer.notation @@ -0,0 +1,1090 @@ + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + +
+
+
+
+
+ + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+ + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+ + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + +
+ + +
+ + +
+ + + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+ + + + + + + + + + + + + + +
+ + +
+ + +
+ + + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+ + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + +
+ + +
+ + +
+ + + + + + + + +
+ + +
+ + +
+ + + + + + + + +
+ + +
+ + +
+ + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+ + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+ + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+ + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + +
+ + +
+ + +
+ + + +
+ + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + +
+ + +
+ + +
+ + + +
+ + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+ + + + + + + + + + + + + + +
+ + +
+ + +
+ + + +
+ + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+ + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ProducerConsumer.uml b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ProducerConsumer.uml new file mode 100644 index 00000000000..08f377275a1 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/examples/ProducerConsumer.uml @@ -0,0 +1,457 @@ + + + + + + + + + + + + + + + + + + + + + + Variant of the consumper component that uses a "pull style", i.e. actively demands whether new data is available. Since the component is active, it needs to have its own thread. This is realized by the combination of the lifecycle port with a container rule that intercepts the lifecycle operations and executes the activation operation in its own thread. +Use the context menu to find out that the PullConsumer supports the "runStartThread" interceptor which intercepts the lifecycle port. + + + + Part of the Qompass model library. Provides the specific port "lc" (short for lifecycle). The "activate" operation of this port is called by generated boot-code after instantiation and configuration of a component. The deactivation is called before disposing a component + + + + + + + + + + + + C/C++ + cout << "wait for data on port p" << endl; +for (int i = 0; i<25; i++) { + if (p->hasData ()) { + ComponentModel::interfaces::PubData data = p->pull (); + cout << "received data: x = " << data.x << " y = " << data.y << endl; + } + usleep (100*1000); +} +cout << "finished waiting" << endl; + + + + + + + + + Push variant of a consumer, i.e. the consumer is called whenever new data is availble. It is not itself active. + + + A MARTE flow port. The synchronisation between MARTE and FCM stereotype is automatic, yet it is possible to refine on FCM level, whether the port uses a push or pull style. In this case, the port uses a push style by setting the port kind to "PushConsumer". + + + + + + + + + + + + + C/C++ + cout << "initialization of push consumer" << endl; + + + + C/C++ + cout << "received data: x = " << data.x << " y = " << data.y << endl; + + + + + + + + + + + + + + + + + + + + + + + + + Let the producer instance execute by the main thread by realising the specific port "start", inherited from CStart (part of the Qompass "core" model library). + + + + + + + + + + + + + C/C++ + cout << "publish a value via port q;" << endl; +ComponentModel::interfaces::PubData data; +data.x = 2; +data.y = 3; +for (int i = 0; i<20; i++) { + q->push (data); + cout << "." << flush; + // wait 200ms + usleep (200*1000); +} + + + + + + + + + Pull consumer is executed by its own thread. This is specified via a container service (runStartThread) + + + Since producer and consumer call operations (the latter to actively retrieve data), the two ports would be incompatible without using a specific interaction component, in this case. a FIFO. +Use the context menu on a selected connector to specify the interaction component. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The push consumer provides the interface that the producer uses (requires), no specific connector is required + + + + + + + + + + + + + + + + + + + + + + + + + Simple single node configuration. TargetOS is set to Linux, but will work on other OS (supporting POSIX threads) + + + + + + + + + + + + + + + + + + + + + + + + This configuration requires the installation of the OTF trace library.<br /> + + + Cross references to diagrams + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + false + + + + false + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/library/tracing.di b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/library/tracing.di new file mode 100644 index 00000000000..606e074c54d --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/library/tracing.di @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/library/tracing.notation b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/library/tracing.notation new file mode 100644 index 00000000000..bea3f251dce --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/library/tracing.notation @@ -0,0 +1,1078 @@ + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+
+
+
+
+ + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + +
+
+
+
+
+ + + + + +
+ + +
+ + +
+ + + +
+ + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+
+
+
+ + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + + + +
+
+
+
+
+ + + + + + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/library/tracing.uml b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/library/tracing.uml new file mode 100644 index 00000000000..79c61f1b245 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/models/library/tracing.uml @@ -0,0 +1,771 @@ + + + + + + + + + + + + + + + + + + + + + + Variant of OTF trace that only reports values that change. + + + A prior variant had a link with the methodCall_comp signature, since the operationIDs should be different, depending on the called component. This leads to a large number of generated classes. Current solution: configure the IDs on an instance level via ths InstanceConfigurator + + + + Trace implementation based on OTF trace library. Aggregates singleton TraceInit + + + + + + + + + + + + + + + + + + + + C/C++ + [import org::eclipse::papyrus::qompass::designer::core::acceleo::UMLTool/] +[import org::eclipse::papyrus::qompass::designer::core::acceleo::utils_cpp/] + +[template public traceOp(operation: Operation)] + +// <instance>_<port>_<operation> +// easier: <component>_<port>_<operation> +updateTimestamp (); +if (!hasDeclaredFunctions) { + declareFunctions(); + hasDeclaredFunctions = true; +} +Tracing::TraceInit::wait(); +int processID = Tracing::TraceInit::getProcessID(); +OTF_Writer * writer = Tracing::TraceInit::getWriter(); +OTF_Writer_writeEnter (writer, timestamp.ticks(), <%enumSvcPrefix%>::id_<%owner.varName%>_<%varName%>, processID, 0); +OTF_Writer_writeEventComment (writer, timestamp.ticks(), processID, portName); +OTF_Writer_writeEventComment (writer, timestamp.ticks(), processID, instanceName); +Tracing::TraceInit::post(); +[if not (type = null)] [type.cppType()/] ret = [/if]rconn->[operation.cppCall()/]; +updateTimestamp (); +Tracing::TraceInit::wait(); +OTF_Writer_writeLeave (writer, timestamp.ticks(), <%enumSvcPrefix%>::id_<%owner.varName%>_<%varName%>, processID, 0); +Tracing::TraceInit::post(); +[if not (type = null)] return ret;[/if] +[/template] + + + C/C++ + timestamp = OS_AL::Time::TimeVal::current (); +// gettimeofday (&currentTime, NULL); +// timestamp = ... + + + C/C++ + // function groups are badly supported in OTF, since writeEnter/Leave do not support them +// thus intial plan that each interface corresponds to a function group has not been implemented +int fctGroupID = 0; +int streamNr = 0; +OTF_Writer * writer = Tracing::TraceInit::getWriter(); +<%for (getAllOperations) {%> +OTF_Writer_writeDefFunction (writer, streamNr, <%enumSvcPrefix%>::id_<%owner.varName%>_<%varName%>, <%quoteLiteral("InterfaceEnum", "id_<%owner.varName%>_<%varName%>")%>, fctGroupID, 0); +<%}%> + + + + <<TextualRepresentation>>public '<%name%>' () { } + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + C/C++ + // <instance>_<port>_<operation> +// easier: <component>_<port>_<operation> +OTF_Writer * writer = Tracing::Trace::TraceInit::getWriter(); +int processID = Tracing::Trace::TraceInit::getProcessID(); +updateTimestamp (); +// need to store parameter values, but that is not simple, as we are not in the data-flow context +// => need specific data-flow trace +// (costly) solution? string comparison? [string has which size?] howto get string representation of each parameter?? (in particular for structs) +// too complicated... +// three specific data_flow trace, offering identical (but conjugated ports). PushP/PushP, PullC/PullC, PushC/PushC => three interceptors, howto select? + +/* +if (m_first) { + m_first = false; + doTrace = true; +} +else +*/ +bool doTrace = true; +OS_AL::Util::BString200 parameters; +parameters << "port=" << portName << " "; +if (doTrace) { + Tracing::Trace::TraceInit::wait(); + <%for (parametersInInout) {%> + <%if (filter("DataType")) {%> + <%for (ownedAttribute) {%> + parameters << <%name%> << "#"; + <%}%> + <%} else {%> + parameters << <%name%> << "#"; + <%}%> + <%}%> + OTF_Writer_writeEnter (writer, timestamp.ticks(), Tracing::Trace::ID_<%args(0).varName%>_<%varName%>, processID, 0); + Tracing::Trace::TraceInit::post(); +} +<%if (type != null) {%><%type.cppType%> ret = <%}%>rconn-><%cppCall%>; +<%if (type != null) {%>parameters << "r=" + <%if (type.filter("DataType")) {%> + <%for (type.ownedAttribute) {%> + << ret.<%name%> << "#" + <%}%>; + <%}else{%> + << ret; + <%}%> +<%}%> +updateTimestamp (); +if (doTrace) { + Tracing::Trace::TraceInit::wait(); + OTF_Writer_writeEventComment (writer, timestamp.ticks(), processID, parameters.data()); + OTF_Writer_writeLeave (writer, timestamp.ticks(), Tracing::Trace::ID_<%args(0).varName%>_<%varName%>, processID, 0); + Tracing::Trace::TraceInit::post(); +} +<%if (type != null) {%>return ret;<%}%> + + + C/C++ + m_first = true; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OTF (Open trace format) tracing mechanism + + + An OTF based trace mechanism that tracks value changes + + + LTTng based trace mechanism for port interception + + + LTTng LW mechanism for operations + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + C/C++ + [import org::eclipse::papyrus::qompass::modellibs::tracing::acceleo::traceLTTng/] + +[template public anOperation(operation : Operation)] +[operation.invokeTP()/] +[/template] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + C/C++ + const char *filename= "trace.otf"; + +//OTF_FileManager* manager; + +uint32_t streams= 1; + +/* file handles available */ +uint32_t files= 10; + +/* per-stream buffer size */ +uint32_t buffersize= 10*1024; + +/* compression on/off, test without compression to look at ASCII trace files */ +// int compression= 0; + +/************************************* +* INIT * +*************************************/ +manager= OTF_FileManager_open( files ); +// assert( NULL != manager ); + +writer = OTF_Writer_open( filename, streams, manager ); +OTF_Writer_setBufferSizes( writer, buffersize ); + +streamNr = 1; + +OTF_Writer_writeDefTimerResolution( writer, + streamNr /* uint32_t stream */, + 1e3 /* uint64_t ticksPerSecond */ ); + +// initial post +sema.post(); + + + C/C++ + return writer; + + + C/C++ + + + + C/C++ + // do not close in deactivate, since additional calls to OTF_write may occur later. +OTF_Writer_close(writer); + + + + C/C++ + int id = OS_AL::ProcessingResources::Thread::getId (); +for (int i = 0; i < processSet.size (); i++) { + if (processSet.get(i) == id) { + return i+1; + } +} +// not known yet => add +processSet.append(id); +int processID = processSet.size(); +char name[16]; +sprintf(name, "id: %x", id); +OTF_Writer_writeDefProcess(writer, streamNr, processID, name, 0); +// OS_AL name only valid for threads created with OS_AL +// OTF_Writer_writeDefProcess(writer, streamNr, processID, OS_AL::ProcessingResources::Thread::getName().data(), 0); +// not required +// OTF_Writer_assignProcess(writer, processID, streamNr); +// OTF_Writer_mapProcess(writer, processID); +OTF_Writer_writeBeginProcess (writer, 0, processID); +return processID; + + + C/C++ + sema.wait(); + + + C/C++ + sema.post(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + C/C++ + OTF_Writer_writeDefFunctionGroup (writer, 0, "application functions"); +<%for (ownedLiteral) {%> + OTF_Writer_writeDefFunction (writer, 0, <%name%>, "<%name%>", 0, 0); +<%}%> + + + + + + + + + + + + + C/C++ + TRACEPOINT_EVENT([tpName/], createClass, [clazz.qualifiedName /]) + + + C/C++ + TRACEPOINT_EVENT([tpName/], destroyClass, [clazz.qualifiedName /]) + + + + + + + + + + + + + + Interceptor + + + Trace Provider + + + + + + C/C++ + [import org::eclipse::papyrus::qompass::designer::core::acceleo::utils_cpp/] +[import org::eclipse::papyrus::qompass::designer::core::acceleo::UMLTool/] +[import org::eclipse::papyrus::qompass::modellibs::tracing::acceleo::traceLTTng/] + +[template public anOperation(operation : Operation)] + +// create event with operationID/portID and pass call +[operation.invokeTP()/] +[if not (type = null)]return [/if]rconn->[operation.cppCall()/]; +[/template] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + otf + /OTF-1.5/otflib/.libs + /OTF-1.5 + otflib/includes.h + + + + + + + + + + + + + + + + + + + + + + + + + + lttng-ust + dl + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/plugin.properties b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/plugin.properties new file mode 100644 index 00000000000..3909dafe6fc --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/plugin.properties @@ -0,0 +1,12 @@ +############################################################################### +# 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 +############################################################################### +pluginName=Papyrus extra: Qompass model library for tracing (Incubation) +providerName=Eclipse Modeling Project diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/plugin.xml b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/plugin.xml new file mode 100644 index 00000000000..59fc39dabaa --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/plugin.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/Activator.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/Activator.java new file mode 100644 index 00000000000..a9e29bfc7a2 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/Activator.java @@ -0,0 +1,51 @@ +package org.eclipse.papyrus.qompass.modellibs.tracing; + +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.qompass.modellibs.tracing"; //$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/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/ClientServerTraceTestModelWizard.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/ClientServerTraceTestModelWizard.java new file mode 100644 index 00000000000..44b716be54a --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/ClientServerTraceTestModelWizard.java @@ -0,0 +1,11 @@ +package org.eclipse.papyrus.qompass.modellibs.tracing; + +import org.eclipse.papyrus.qompass.modellibs.core.ModelCopyWizard; + + +public class ClientServerTraceTestModelWizard extends ModelCopyWizard { + + public ClientServerTraceTestModelWizard () { + modelName = "ClientServerTraceTest"; + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/IConfiguratorOTF.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/IConfiguratorOTF.java new file mode 100644 index 00000000000..6dae4aa1244 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/IConfiguratorOTF.java @@ -0,0 +1,53 @@ +package org.eclipse.papyrus.qompass.modellibs.tracing; + +import org.eclipse.papyrus.qompass.designer.core.PortUtils; +import org.eclipse.papyrus.qompass.designer.core.Utils; +import org.eclipse.papyrus.qompass.designer.core.deployment.DepPlanUtils; +import org.eclipse.papyrus.qompass.designer.core.extensions.IInstanceConfigurator; +import org.eclipse.papyrus.qompass.designer.core.transformations.ContainerContext; +import org.eclipse.uml2.uml.InstanceSpecification; +import org.eclipse.uml2.uml.Interface; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.Property; + + +public class IConfiguratorOTF implements IInstanceConfigurator { + + static final String PROP_PORT_NAME = "portName"; + + static final String PROP_INSTANCE_NAME = "instanceName"; + + /** + * Configure the passed trace instance + * + * @see org.eclipse.papyrus.qompass.designer.gentools.core.extensions.IInstanceConfigurator + */ + public void configureInstance(InstanceSpecification instance, Property componentPart, ContainerContext context) { + // The tracing code needs informations about the component instance and port. + + DepPlanUtils.configureProperty(instance, PROP_INSTANCE_NAME, "\"" + instance.getName() + "\""); + + // port in context => interception of port => provide information about port and interface + if(context.port != null) { + // obtain required or provided interface (TODO: will fail, if both are provided!) + Interface intf = PortUtils.getProvided(context.port); + if(intf == null) { + intf = PortUtils.getRequired(context.port); + } + + DepPlanUtils.configureProperty(instance, PROP_PORT_NAME, "\"" + context.port.getName() + "\""); + if(intf != null) { + // this is specific for OTF: + // each container contains an attribute (id_) for each operation. This is configured here, + // since we add instance information to the trace (is that useful??, seems like a hack) + for(Operation op : intf.getOperations()) { + String id = Utils.getTop(context.executorIS).getName() + "::Tracing::Trace::ID_" + + context.executorIS.getName().replace(".", "_") + "_" + op.getName(); + DepPlanUtils.configureProperty(instance, "id_" + op.getName(), id); + } + } + } + + + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/IConfiguratorTrace.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/IConfiguratorTrace.java new file mode 100644 index 00000000000..9e33f4bda66 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/IConfiguratorTrace.java @@ -0,0 +1,40 @@ +package org.eclipse.papyrus.qompass.modellibs.tracing; + +import org.eclipse.papyrus.qompass.designer.core.deployment.DepPlanUtils; +import org.eclipse.papyrus.qompass.designer.core.extensions.IInstanceConfigurator; +import org.eclipse.papyrus.qompass.designer.core.transformations.ContainerContext; +import org.eclipse.papyrus.qompass.designer.core.transformations.ContainerTrafo; +import org.eclipse.uml2.uml.InstanceSpecification; +import org.eclipse.uml2.uml.Property; + +public class IConfiguratorTrace implements IInstanceConfigurator { + + static final String PROP_PORT_NAME = "portName"; + + static final String PROP_INSTANCE_NAME = "instanceName"; + + /** + * Configure the passed trace instance + * + * @see org.eclipse.papyrus.qompass.designer.gentools.core.extensions.IInstanceConfigurator + */ + public void configureInstance(InstanceSpecification instance, Property componentPart, ContainerContext context) { + // The tracing code needs informations about the component instance and port. + + String instanceName = instance.getName(); + int index = instanceName.lastIndexOf("."); + if(index != -1) { + String lastSegment = instanceName.substring(index + 1); + if(lastSegment.startsWith(ContainerTrafo.interceptorName)) { + instanceName = instanceName.substring(0, index); + } + } + + DepPlanUtils.configureProperty(instance, PROP_INSTANCE_NAME, "\"" + instanceName + "\""); + + // port in context => interception of port => provide information about port and interface + if(context.port != null) { + DepPlanUtils.configureProperty(instance, PROP_PORT_NAME, "\"" + context.port.getName() + "\""); + } + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/QompassTraceMechanism.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/QompassTraceMechanism.java new file mode 100644 index 00000000000..0f0979541f7 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/QompassTraceMechanism.java @@ -0,0 +1,181 @@ +package org.eclipse.papyrus.qompass.modellibs.tracing; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers; +import org.eclipse.papyrus.infra.services.tracepoints.ITraceMechanism; +import org.eclipse.papyrus.infra.services.tracepoints.MarkerUtils; +import org.eclipse.papyrus.infra.services.tracepoints.TraceActions.TAOperation; +import org.eclipse.papyrus.infra.services.tracepoints.TracepointConstants; +import org.eclipse.papyrus.qompass.designer.core.Description; +import org.eclipse.papyrus.qompass.designer.core.StUtils; +import org.eclipse.papyrus.qompass.designer.core.Utils; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.Property; + +import FCM.ConfigOption; +import FCM.ContainerRule; +import FCM.RuleApplication; + +public class QompassTraceMechanism implements ITraceMechanism { + + public static final String EC3M_TRACING_URI = "pathmap://QML_TRACE/tracing.uml"; + + public static final URI tracingURI = URI.createURI(EC3M_TRACING_URI); + + public EList getTraceMechanismIDs(EObject eObj) { + EList ids = new BasicEList(); + // obtain list of all available container rules via Utils. Restrict to those doing tracing. + EList containerRules = getContainerRules(eObj); + for(ContainerRule containerRule : containerRules) { + if(isForTracing(containerRule)) { + Class clazz = containerRule.getBase_Class(); + ids.add(clazz.getName()); + } + } + if(ids.size() == 0) { + ids.add("dummy qompass rule"); + } + return ids; + } + + public String getTraceMechanismDescription(EObject eObj, String id) { + EList containerRules = getContainerRules(eObj); + for(ContainerRule containerRule : containerRules) { + if(isForTracing(containerRule)) { + Class clazz = containerRule.getBase_Class(); + if(clazz.getName().equals(id)) { + return Description.getDescription(clazz); + } + } + } + return null; + } + + /** + * Apply the trace mechanism, i.e. set or unset the appropriate ContainerRule for tracing. + * Currently handles trace on class. + * + * Basic idea: always apply same container rule. But container rule expansion is different in function of set tracepoints. + * Need to unapply, if there is no longer a trace needing it. + */ + public boolean applyTraceMechanism(EObject eObj, String id, int traceOption) { + Class clazzContext = getClassContext(eObj); + if(clazzContext == null) { + return false; + } + EList containerRules = getContainerRules(eObj); + for(ContainerRule containerRule : containerRules) { + if(isForTracing(containerRule)) { + Class clazz = containerRule.getBase_Class(); + + if(clazz.getName().equals(id)) { + if(traceOption == TAOperation.OnlyCall.ordinal()) { + // yes => what do we then (i.e. how is mapping done??) + } + RuleApplication ruleApplication = StUtils.applyApp(clazzContext, RuleApplication.class); + if((ruleApplication != null) && !ruleApplication.getContainerRule().contains(containerRule)) { + ruleApplication.getContainerRule().add(containerRule); + return true; + } + } + } + } + return false; + } + + // QompassTraceMechanism + + public boolean isForTracing(ContainerRule rule) { + for(ConfigOption co : rule.getForConfig()) { + // TODO: not very clean to used fixed string + if(co.getBase_Class().getName().equals("Trace")) { + return true; + } + } + return false; + } + + /** + * Return the class (component) for which we need to apply a container rule + * to enable the tracing of the passed eObject. This eObject may be + * (1) A class, in this case it could be returned directly + * (2) An operation. In this case, the owning class is returned (caveat: operation might belong to an interface) + * (3) A property of the class (including ports). + * + * @param eObj + * see description above + * @return the class to a container rule may be applied + */ + public Class getClassContext(EObject eObj) { + if(eObj instanceof Class) { + return (Class)eObj; + } else if(eObj instanceof Operation) { + return ((Operation)eObj).getClass_(); + } else if(eObj instanceof Property) { + return ((Property)eObj).getClass_(); + } else { + return null; + } + } + + public EList getContainerRules(EObject eObj) { + if(eObj == null) { + // load rules of registered Tracing model library + try { + ModelSet ms = ServiceUtilsForActionHandlers.getInstance().getModelSet(); + Resource rs = ms.getResource(tracingURI, true); + EList contents = rs.getContents(); + if((contents.size() > 0) && (contents.get(0) instanceof Package)) { + return Utils.getAllRules((Package)contents.get(0)); + } + } catch (ServiceException e) { + System.err.println(e); + } + return new BasicEList(); + } else { + Package top = Utils.getTop((Element)eObj); + return Utils.getAllRules(top); + } + } + + public boolean configureTraceMechanisms() { + String config = ""; + try { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + + if(root != null) { + Object tracePoints[] = root.findMarkers(TracepointConstants.tpOrbpMarker, true, IResource.DEPTH_INFINITE); + for(Object tracePointObj : tracePoints) { + if(tracePointObj instanceof IMarker) { + IMarker tracePoint = (IMarker)tracePointObj; + EObject eobj = MarkerUtils.getEObjectOfMarker(tracePoint); + if(MarkerUtils.isActive(tracePoint)) { + if(eobj instanceof NamedElement) { + config += ((NamedElement)eobj).getQualifiedName(); + } + } + } + } + } + } catch (CoreException e) { + } + System.err.println(config); + return true; + } + +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/TraceUtils.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/TraceUtils.java new file mode 100644 index 00000000000..e8b0e395785 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/TraceUtils.java @@ -0,0 +1,45 @@ +package org.eclipse.papyrus.qompass.modellibs.tracing.acceleo; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; +import org.eclipse.papyrus.infra.services.tracepoints.MarkerUtils; +import org.eclipse.papyrus.infra.services.tracepoints.TracepointConstants; +import org.eclipse.papyrus.qompass.designer.core.transformations.TransformationContext; +import org.eclipse.uml2.uml.Element; + +public class TraceUtils { + + public static IMarker[] getMarkersForEObject(EObject eObject, String markerType) { + Resource resource = eObject.eResource(); + IFile file = WorkspaceSynchronizer.getFile(resource); + if(file != null) { + try { + return file.findMarkers(markerType, true, IResource.DEPTH_INFINITE); + } catch (CoreException e) { + } + } + return new IMarker[0]; + } + + public static boolean hasTrace(Element eObject) { + IMarker markers[] = getMarkersForEObject(eObject, TracepointConstants.tpOrbpMarker); + for(IMarker marker : markers) { + // explicitly pass resourceSet of eObject we want to compare. Otherwise, the marker utils would + // load resources into its own resource set (leading to non-comparable eObjects) + EObject eObjOfMarker = MarkerUtils.getEObjectOfMarker(eObject.eResource().getResourceSet(), marker); + if(eObjOfMarker == eObject) { + return true; + } + } + // TODO: testing workaround (always return true for port based transformations) + if(TransformationContext.getPort() != null) { + return true; + } + return false; + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/traceCout.mtl b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/traceCout.mtl new file mode 100644 index 00000000000..540bd60fa85 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/traceCout.mtl @@ -0,0 +1,14 @@ +[module traceCout('http://www.eclipse.org/uml2/4.0.0/UML')] + +[import org::eclipse::papyrus::qompass::designer::core::acceleo::UMLTool/] +[import org::eclipse::papyrus::qompass::designer::core::acceleo::utils_cpp/] + +[template public traceOp(operation: Operation)] +// declare operation & use directly. Problem: declaration can not be within the scope of an operation +updateTimestamp (); +cout "enter operation: " << [operation.name/] << " at " << timestamp.ticks() << " parameters: " << + [for (parameter : Parameter | operation.ownedParameter)] "[parameter.name/] (of type [parameter.type.name/]): " << [parameter.name/] [/for] << endl; +) +[if not (type = null)] [type.cppType()/] ret = [/if]rconn->[operation.cppCall()/]; +[if not (type = null)] return ret; [/if] +[/template] diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/traceLTTng.mtl b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/traceLTTng.mtl new file mode 100644 index 00000000000..af7a3358147 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/traceLTTng.mtl @@ -0,0 +1,172 @@ +[module traceLTTng('http://www.eclipse.org/uml2/4.0.0/UML')/] + +[import org::eclipse::papyrus::qompass::designer::core::acceleo::UMLTool/] +[import org::eclipse::papyrus::qompass::designer::core::acceleo::TransformationContext/] +[import org::eclipse::papyrus::qompass::designer::core::acceleo::utils_cpp/] + +[query public hasTrace(element : Element) : Boolean = + invoke('org.eclipse.papyrus.qompass.modellibs.tracing.acceleo.TraceUtils', + 'hasTrace(org.eclipse.uml2.uml.Element)', + Sequence{element}) /] + +[template public declareTP(cl: Classifier)] +#if !defined(HFILENAME_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define HFILENAME_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +[for (operation : Operation | cl.getAllOperations())] +[if hasTrace()] +[declareTPop(tpName1(), operation)/] +[/if] +[/for] + +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER [tpName1() /] + +#undef TRACEPOINT_INCLUDE_FILE +#define TRACEPOINT_INCLUDE_FILE [trafoContextClassifier().getQualifiedName().replaceAll('::', '/') /].h + +#include + +#ifdef __cplusplus +} +#endif + +#endif +[/template] + +[template public declareTPop(tpName : String, operation : Operation)] +#include + +// declare trace point +TRACEPOINT_EVENT([tpName1()/], [operation.tpName2()/], + TP_ARGS(const char *, instanceName[if (operation.parametersInInout()->size() > 0)], [/if][for (parameter : Parameter | operation.parametersInInout()) separator(', ')][flattenParNameAndType()/][/for]), + TP_FIELDS( + ctf_string(instanceName, instanceName) + [for (parameter : Parameter | operation.parametersInInout())] + [trafoContextClassifier().declareDependency(parameter.type)/][flattenCtfType(parameter.type, parameter.name)/] + [/for] + ) +) +TRACEPOINT_MODEL_EMF_URI([tpName1()/], [operation.tpName2()/], "[operation.modelRef()/]") + +[/template] + +[template public declareCreateDestroy(tpName : String)] +TRACEPOINT_EVENT([tpName/], createClass, + TP_ARGS(const char *, classURI), + TP_FIELDS( + ctf_string(classURI, classURI) + ) +) +TRACEPOINT_EVENT([tpName/], destroyClass, + TP_ARGS(const char *, className), + TP_FIELDS( + ctf_string(xmdID, className) + ) +) +[/template] + + +[comment + The name that is used for the trace provider +/] +[template public tpName1()] +[templateBinding().getNearestPackage().getQualifiedName().varName()/] +[/template] + + +[comment + The name that is used for the type +/] +[template public tpName2(operation : Operation)] +[operation.name/] +[/template] + + +[comment + Reference either the port (if available in the context) or the operation that is traced +/] +[template public modelRef(operation : Operation) post(trim())] +[if (trafoContextPort() = null)] + [operation.getSourceRoot().getURI()/]#[operation.xmlID()/] +[else] + [operation.getSourceRoot().getURI()/]#[trafoContextPort().xmlID()/] +[/if] +[/template] + +[comment +/] +[template public declareTraceOp(operation : Operation)] +[/template] + +[template public invokeTP(operation : Operation)] +[if hasTrace()] +// use (call) tracepoint +tracepoint([tpName1()/], [operation.tpName2()/], instanceName[if (operation.parametersInInout()->size() > 0)], [/if][for (parameter : Parameter | operation.parametersInInout()) separator(', ')][flattenParName()/][/for]); +[/if] +[/template] + + +[template flattenParNameAndType(parameter : Parameter) post(trim())] +[if (type.oclIsTypeOf(DataType))] + [for (attribute : Property | type.oclAsType(DataType).attribute) separator(', ')][attribute.type.cppTypeWB()/], [parameter.name + '_' + attribute.name/][/for] +[else] + [parameter.type.cppTypeWB()/], [parameter.name/] +[/if] +[/template] + +[template flattenParName(parameter : Parameter) post(trim())] +[if (type.oclIsTypeOf(DataType))] + [for (attribute : Property | type.oclAsType(DataType).attribute) separator(', ')][parameter.name + '.' + attribute.name/][/for] +[else] + [parameter.name/] +[/if] +[/template] + + +[template flattenCtfType(type : Type, name : String) post(trim())] +[if (type.oclIsTypeOf(DataType))] + [for (attribute : Property | type.oclAsType(DataType).attribute) separator('\n')][ctfType(attribute.type, name + '_' + attribute.name)/][/for] +[else] + [ctfType(type, name)/] +[/if] +[/template] + + +[template cppTypeWB(type : Type) post(trim())] +[if + (type.qualifiedName = 'UMLPrimitiveTypes::Boolean') or + (type.qualifiedName = 'PrimitiveTypes::Boolean') or + (type.qualifiedName = 'CORBA::Boolean')] + /* bool */ unsigned char +[else] + [cppType()/] +[/if] +[/template] + + +[comment + Calculate the typename, defaulting to ctf_integer + TODO: treat pointer & ref stereotypes (can only evaulate on parameter or attribute, not on Type) +/] +[template public ctfType(type : Type, name : String) post(trim())] +[if + (type.qualifiedName = 'CORBA::String') or + (type.qualifiedName = 'PrimitiveTypes::String') or + (type.qualifiedName = 'UMLPrimitiveTypes::String')] + ctf_string([name/], [name/]) +[elseif + (type.qualifiedName = 'CORBA::Float') or + (type.qualifiedName = 'CORBA::Double') or + (type.qualifiedName = 'AnsiCLibrary::float') or + (type.qualifiedName = 'AnsiCLibrary::double')] + ctf_float([type.cppType()/], [name/], [name/]) +[else] + ctf_integer([type.cppTypeWB()/], [name/], [name/]) +[/if] +[/template] diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/traceOTF.mtl b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/traceOTF.mtl new file mode 100644 index 00000000000..dbf20923f40 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/traceOTF.mtl @@ -0,0 +1,28 @@ +[module traceOTF('http://www.eclipse.org/uml2/4.0.0/UML')/] + +[import org::eclipse::papyrus::qompass::designer::core::acceleo::UMLTool/] +[import org::eclipse::papyrus::qompass::designer::core::acceleo::utils_cpp/] + +[template public traceOp(operation: Operation)] + +// __ +// easier: __ +updateTimestamp (); +if (!hasDeclaredFunctions) { + declareFunctions(); + hasDeclaredFunctions = true; +} +Tracing::TraceInit::wait(); +int processID = Tracing::TraceInit::getProcessID(); +OTF_Writer * writer = Tracing::TraceInit::getWriter(); +OTF_Writer_writeEnter (writer, timestamp.ticks(), <%enumSvcPrefix%>::id_<%owner.varName%>_<%varName%>, processID, 0); +OTF_Writer_writeEventComment (writer, timestamp.ticks(), processID, portName); +OTF_Writer_writeEventComment (writer, timestamp.ticks(), processID, instanceName); +Tracing::TraceInit::post(); +[if not (type = null)] [type.cppType()/] ret = [/if]rconn->[operation.cppCall()/]; +updateTimestamp (); +Tracing::TraceInit::wait(); +OTF_Writer_writeLeave (writer, timestamp.ticks(), <%enumSvcPrefix%>::id_<%owner.varName%>_<%varName%>, processID, 0); +Tracing::TraceInit::post(); +[if not (type = null)] return ret;[/if] +[/template] \ No newline at end of file diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/.classpath b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/.classpath new file mode 100644 index 00000000000..64c5e31b7a2 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/.project b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/.project new file mode 100644 index 00000000000..657d2f7a65c --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/.project @@ -0,0 +1,28 @@ + + + org.eclipse.papyrus.views.tracepoints + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/META-INF/MANIFEST.MF b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..ccd7816299a --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.papyrus.views.tracepoints; singleton:=true +Bundle-Version: 0.9.2.qualifier +Bundle-Activator: org.eclipse.papyrus.views.tracepoints.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.papyrus.infra.services.tracepoints;bundle-version="0.9.2", + org.eclipse.core.resources;bundle-version="3.7.0", + org.eclipse.emf.ecore;bundle-version="2.8.0", + org.eclipse.gef;bundle-version="3.8.0", + org.eclipse.uml2.uml;bundle-version="4.0.0", + org.eclipse.papyrus.infra.core;bundle-version="0.9.2", + org.eclipse.papyrus.infra.widgets;bundle-version="0.9.2", + org.eclipse.emf.transaction;bundle-version="1.4.0", + org.eclipse.gmf.runtime.common.core;bundle-version="1.4.1", + org.eclipse.gmf.runtime.common.ui;bundle-version="1.5.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-Vendor: %pluginProvider +Bundle-Localization: plugin diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/about.html b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/about.html new file mode 100644 index 00000000000..209103075a7 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

November 14, 2008

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") 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 http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/build.properties b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/build.properties new file mode 100644 index 00000000000..8c05b0ac6b9 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/build.properties @@ -0,0 +1,10 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + contexts.xml,\ + about.html,\ + plugin.properties +src.includes = about.html diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/contexts.xml b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/contexts.xml new file mode 100644 index 00000000000..b3b18ae3d68 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/contexts.xml @@ -0,0 +1,13 @@ + + + + This is the context help for the sample view with a table viewer. It was generated by a PDE template. + + + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/icons/breakpoint_view.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/icons/breakpoint_view.gif new file mode 100644 index 00000000000..f529c5a4225 Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/icons/breakpoint_view.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/icons/gotoobj_tsk.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/icons/gotoobj_tsk.gif new file mode 100644 index 00000000000..cf62b63ae3e Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/icons/gotoobj_tsk.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/icons/skip_brkp.gif b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/icons/skip_brkp.gif new file mode 100644 index 00000000000..c1751c3ff4f Binary files /dev/null and b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/icons/skip_brkp.gif differ diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/plugin.properties b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/plugin.properties new file mode 100644 index 00000000000..b02f21505bc --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/plugin.properties @@ -0,0 +1,12 @@ +############################################################################### +# 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 +############################################################################### +pluginName=Papyrus Tracepoint View (Incubation) +pluginProvider=Eclipse Modeling Project diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/plugin.xml b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/plugin.xml new file mode 100644 index 00000000000..43cfbf7e29e --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/plugin.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/src/org/eclipse/papyrus/views/tracepoints/Activator.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/src/org/eclipse/papyrus/views/tracepoints/Activator.java new file mode 100644 index 00000000000..e12d420e77b --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/src/org/eclipse/papyrus/views/tracepoints/Activator.java @@ -0,0 +1,78 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.views.tracepoints; + +import org.eclipse.jface.resource.ImageDescriptor; +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.views.tracepoints"; //$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; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path + * the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/src/org/eclipse/papyrus/views/tracepoints/views/TraceViewImages.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/src/org/eclipse/papyrus/views/tracepoints/views/TraceViewImages.java new file mode 100644 index 00000000000..d1dc6b933aa --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/src/org/eclipse/papyrus/views/tracepoints/views/TraceViewImages.java @@ -0,0 +1,44 @@ +/***************************************************************************** +* 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: +* Ansgar Radermacher (CEA LIST) - Initial API and implementation +* +*****************************************************************************/ + +package org.eclipse.papyrus.views.tracepoints.views; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.papyrus.views.tracepoints.Activator; +import org.eclipse.swt.graphics.Image; + + +public class TraceViewImages { + + public static ImageDescriptor getGotoObjID() { + org.eclipse.papyrus.infra.widgets.Activator widgetsActivator = + org.eclipse.papyrus.infra.widgets.Activator.getDefault(); + return widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, "icons/gotoobj_tsk.gif"); + } + + public static ImageDescriptor getSkipAllID() { + org.eclipse.papyrus.infra.widgets.Activator widgetsActivator = + org.eclipse.papyrus.infra.widgets.Activator.getDefault(); + return widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, "icons/skip_brkp.gif"); + } + + public static Image getSkipAllImage() { + if(skipAllImage == null) { + skipAllImage = getSkipAllID().createImage(); + } + return skipAllImage; + } + + protected static Image skipAllImage = null; +} diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/src/org/eclipse/papyrus/views/tracepoints/views/TracepointView.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/src/org/eclipse/papyrus/views/tracepoints/views/TracepointView.java new file mode 100644 index 00000000000..ace3d79213b --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.views.tracepoints/src/org/eclipse/papyrus/views/tracepoints/views/TracepointView.java @@ -0,0 +1,521 @@ +/***************************************************************************** + * 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: + * Ansgar Radermacher (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.views.tracepoints.views; + + +import java.util.Map; + +import javax.swing.text.View; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gmf.runtime.common.ui.resources.FileChangeManager; +import org.eclipse.gmf.runtime.common.ui.resources.IFileObserver; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.util.OpenStrategy; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.ICheckStateProvider; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.papyrus.infra.services.tracepoints.MarkerUtils; +import org.eclipse.papyrus.infra.services.tracepoints.TraceFunctions; +import org.eclipse.papyrus.infra.services.tracepoints.TraceState; +import org.eclipse.papyrus.infra.services.tracepoints.TracepointConstants; +import org.eclipse.papyrus.infra.services.tracepoints.dialogs.TraceActionSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.ide.IGotoMarker; +import org.eclipse.ui.part.ViewPart; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.NamedElement; + + +/** + * This sample class demonstrates how to plug-in a new + * workbench view. The view shows data obtained from the + * model. The sample creates a dummy model on the fly, + * but a real implementation would connect to the model + * available either in this or another plug-in (e.g. the workspace). + * The view is connected to the model using a content provider. + *

+ * The view uses a label provider to define how model objects should be presented in the view. Each view can present the same model objects using + * different labels and icons, if needed. Alternatively, a single label provider can be shared between views in order to ensure that objects of the + * same type are presented in the same way everywhere. + *

+ */ + +public class TracepointView extends ViewPart implements ISelectionListener { + + /** + * The ID of the view as specified by the extension. + */ + public static final String ID = "org.eclipse.papyrus.views.tracepoints.views.Tracepoints"; + + + private CheckboxTableViewer viewer; + + protected Action actionDelete; + + protected Action actionDeleteAll; + + protected Action actionGoto; + + protected Action actionSkip; + + protected Action actionTraceSelect; + + private Action doubleClickAction; + + private IFileObserver fileObserver = null; + + protected TraceActionSelection tas; + + /** + * The content provider class is responsible for + * providing objects to the view. It can wrap + * existing objects in adapters or simply return + * objects as-is. These objects may be sensitive + * to the current input of the view, or ignore + * it and always show the same content + * (like Task List, for example). + */ + class ViewContentProvider implements IStructuredContentProvider { + + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + } + + public void dispose() { + } + + public Object[] getElements(Object parent) { + try { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + if(root != null) { + return root.findMarkers(TracepointConstants.tpOrbpMarker, true, IResource.DEPTH_INFINITE); + } + } catch (CoreException e) { + } + return new String[]{}; + } + } + + + + class ViewLabelProvider extends LabelProvider implements ITableLabelProvider { + + public ViewLabelProvider() { + this.traceImage = new TraceFunctions(); + } + + public String getColumnText(Object obj, int index) { + if(obj instanceof IMarker) { + EObject eobj = MarkerUtils.getEObjectOfMarker((IMarker)obj); + if(eobj instanceof NamedElement) { + return ((NamedElement)eobj).getQualifiedName(); + } else if(eobj != null) { + return eobj.toString(); + } + } + return getText(obj); + + } + + public Image getColumnImage(Object obj, int index) { + if(TraceState.skipAllTracepoints) { + return TraceViewImages.getSkipAllImage(); + } + if(obj instanceof IMarker) { + IMarker marker = (IMarker)obj; + ImageDescriptor id = traceImage.getImageDescriptorForGE(marker); + if(id != null) { + // TODO: leaks! + return id.createImage(); + } + } + return null; + } + + private TraceFunctions traceImage; + } + + class NameSorter extends ViewerSorter { + } + + /** + * The constructor. + */ + public TracepointView() { + } + + /** + * This is a callback that will allow us + * to create the viewer and initialize it. + */ + @Override + public void createPartControl(Composite parent) { + viewer = CheckboxTableViewer.newCheckList(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + viewer.setContentProvider(new ViewContentProvider()); + viewer.setLabelProvider(new ViewLabelProvider()); + viewer.setCheckStateProvider(new ICheckStateProvider() { + + public boolean isGrayed(Object element) { + return false; + } + + public boolean isChecked(Object element) { + if(element instanceof IMarker) { + IMarker marker = (IMarker)element; + return marker.getAttribute(TracepointConstants.isActive, false); + } + return false; + } + }); + + viewer.setSorter(new NameSorter()); + viewer.setInput(getViewSite()); + + getViewSite().getPage().addSelectionListener(this); + + + // Create the help context id for the viewer's control + PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.eclipse.papyrus.views.tracepoints.viewer"); + makeActions(); + hookContextMenu(); + hookDoubleClickAction(); + contributeToActionBars(); + viewer.addCheckStateListener(new ICheckStateListener() { + + public void checkStateChanged(CheckStateChangedEvent event) { + Object element = event.getElement(); + boolean isChecked = event.getChecked(); + if(element instanceof IMarker) { + IMarker marker = (IMarker)element; + try { + marker.setAttribute(TracepointConstants.isActive, isChecked); + switchUI(); + } catch (CoreException e) { + } + } + } + }); + + fileObserver = new IFileObserver() { + + public void handleMarkerDeleted(IMarker marker, @SuppressWarnings("rawtypes") Map attributes) { + switchUI(); + } + + public void handleMarkerChanged(IMarker marker) { + switchUI(); + } + + public void handleMarkerAdded(IMarker marker) { + switchUI(); + } + + // TODO need to handle? + public void handleFileRenamed(IFile oldFile, IFile file) { + } + + public void handleFileMoved(IFile oldFile, IFile file) { + } + + public void handleFileDeleted(IFile file) { + } + + public void handleFileChanged(IFile file) { + } + }; + + FileChangeManager.getInstance().addFileObserver(fileObserver); + } + + @Override + public void dispose() { + if(fileObserver != null) { + FileChangeManager.getInstance().addFileObserver(fileObserver); + } + super.dispose(); + } + + public void switchUI() { + Display.getDefault().asyncExec(new Runnable() { + + public void run() { + // ... do any work that updates the screen ... + viewer.refresh(); + } + }); + } + + private void hookContextMenu() { + MenuManager menuMgr = new MenuManager("#PopupMenu"); + menuMgr.setRemoveAllWhenShown(true); + menuMgr.addMenuListener(new IMenuListener() { + + public void menuAboutToShow(IMenuManager manager) { + TracepointView.this.fillContextMenu(manager); + } + }); + Menu menu = menuMgr.createContextMenu(viewer.getControl()); + viewer.getControl().setMenu(menu); + getSite().registerContextMenu(menuMgr, viewer); + } + + private void contributeToActionBars() { + IActionBars bars = getViewSite().getActionBars(); + fillLocalPullDown(bars.getMenuManager()); + fillLocalToolBar(bars.getToolBarManager()); + } + + protected void fillLocalPullDown(IMenuManager manager) { + manager.add(actionDelete); + manager.add(new Separator()); + manager.add(actionGoto); + } + + protected void fillContextMenu(IMenuManager manager) { + manager.add(actionDelete); + manager.add(actionGoto); + // Other plug-ins can contribute there actions here + manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + } + + protected void fillLocalToolBar(IToolBarManager manager) { + manager.add(actionDelete); + manager.add(actionDeleteAll); + manager.add(actionGoto); + manager.add(actionSkip); + manager.add(actionTraceSelect); + } + + protected void makeActions() { + actionSkip = new Action("Skip all", Action.AS_CHECK_BOX) { + + @Override + public void run() { + TraceState.skipAllTracepoints = !TraceState.skipAllTracepoints; + switchUI(); + } + }; + actionSkip.setChecked(TraceState.skipAllTracepoints); + + actionSkip.setImageDescriptor(TraceViewImages.getSkipAllID()); + actionSkip.setToolTipText("Toggle skipping all trace/break points"); + + actionDelete = new Action("Delete") { + + @Override + public void run() { + ISelection selection = viewer.getSelection(); + Object obj = ((IStructuredSelection)selection).getFirstElement(); + if(obj instanceof IMarker) { + IMarker marker = (IMarker)obj; + try { + marker.delete(); + } catch (CoreException e) { + } + } + } + }; + actionDelete.setToolTipText("Delete trace/breakpoint"); + actionDelete.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE)); + + actionDeleteAll = new Action() { + + @Override + public void run() { + + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + if(root != null) { + try { + root.deleteMarkers(TracepointConstants.tpOrbpMarker, true, 0); + } catch (CoreException e) { + } + } + } + }; + actionDeleteAll.setText("Delete all"); + actionDeleteAll.setToolTipText("Delete all trace/breakpoint"); + actionDeleteAll.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_REMOVEALL)); + + actionGoto = new Action() { + + @Override + public void run() { + ISelection selection = viewer.getSelection(); + Object obj = ((IStructuredSelection)selection).getFirstElement(); + if(obj instanceof IMarker) { + IMarker marker = (IMarker)obj; + boolean onlyNavigatoToActiveEditor = false; + IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + if(onlyNavigatoToActiveEditor) { + IEditorPart part = activePage.getActiveEditor(); + if(part instanceof IGotoMarker) { + ((IGotoMarker)part).gotoMarker(marker); + } + } else { + try { + IDE.openEditor(activePage, marker, OpenStrategy.activateOnOpen()); + } catch (PartInitException e) { + + } + } + } + } + }; + actionGoto.setText("Goto"); + actionGoto.setToolTipText("Navigate to trace/breakpoint"); + actionGoto.setImageDescriptor(TraceViewImages.getGotoObjID()); + doubleClickAction = actionGoto; + + actionTraceSelect = new Action() { + + @Override + public void run() { + ISelection selection = viewer.getSelection(); + Object obj = ((IStructuredSelection)selection).getFirstElement(); + if(obj instanceof IMarker) { + // EditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, null); + IMarker marker = (IMarker)obj; + EObject eobj = MarkerUtils.getEObjectOfMarker(marker); + if(eobj instanceof Element) { + TraceActionSelection tad = new TraceActionSelection(new Shell(), (IMarker)obj, (Element)eobj); + tad.open(); + if(tad.getReturnCode() == IDialogConstants.OK_ID) { + Object[] result = tad.getResult(); + int traceAction = (Integer)result[0]; + String traceMechanism = (String)result[1]; + try { + marker.setAttribute(TracepointConstants.traceAction, traceAction); + marker.setAttribute(TracepointConstants.traceMechanism, traceMechanism); + } catch (CoreException e) { + } + } + } + } + } + + }; + actionTraceSelect.setText("trace action"); + actionTraceSelect.setToolTipText("Select trace action"); + actionTraceSelect.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD)); + } + + protected void hookDoubleClickAction() { + viewer.addDoubleClickListener(new IDoubleClickListener() { + + public void doubleClick(DoubleClickEvent event) { + doubleClickAction.run(); + } + }); + } + + /** + * Passing the focus request to the viewer's control. + */ + @Override + public void setFocus() { + viewer.getControl().setFocus(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, + * org.eclipse.jface.viewers.ISelection) + */ + // TODO: function not used currently + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + + IStructuredSelection sSelection = null; + if(selection instanceof IStructuredSelection) { + sSelection = (IStructuredSelection)selection; + } + + // exclude case of an empty selection which is not a Tree selection, since changing views provokes an + // empty selection (selection gets lost, although same element remains selected) + if((selection != null) && (sSelection != null) && sSelection.isEmpty()) { + return; + } + currentElement = null; + + // No available selection: switch to default panel + if((sSelection == null) || (sSelection.size() != 1)) { + switchUI(); + return; + } + + // Retrieve selected object + Object currentObject = sSelection.getFirstElement(); + // If the object is an edit part, try to get semantic bridge + if(currentObject instanceof GraphicalEditPart) { + GraphicalEditPart editPart = (GraphicalEditPart)currentObject; + if(editPart.getModel() instanceof View) { + View view = (View)editPart.getModel(); + if(view.getElement() instanceof Element) { + currentObject = view.getElement(); + } + } + } else if(currentObject instanceof IAdaptable) { + // modisco ModelElementItem supports IAdaptable (cleaner than cast / dependency with modisco) + currentObject = ((IAdaptable)currentObject).getAdapter(EObject.class); + } + + if(currentObject instanceof Element) { + currentElement = (Element)currentObject; + // switchUI(); + } + } + + protected Element currentElement; +} -- cgit v1.2.3