diff options
Diffstat (limited to 'extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints')
46 files changed, 2747 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.papyrus.infra.services.tracepoints</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/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 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>November 14, 2008</p>
+<h3>License</h3>
+
+<p>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 <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("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 <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
\ 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 Binary files differnew file mode 100644 index 00000000000..a831fe72782 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_16x16.gif 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 Binary files differnew file mode 100644 index 00000000000..3678b09c6bf --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_9x9.gif 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 Binary files differnew file mode 100644 index 00000000000..173661c5df7 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_grp.gif 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 Binary files differnew file mode 100644 index 00000000000..5ea466bcb2a --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkp_grp_disabled.gif 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 Binary files differnew file mode 100644 index 00000000000..74b26c31a4d --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkpd_16x16.gif 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 Binary files differnew file mode 100644 index 00000000000..d6d8d31b06f --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/brkpd_9x9.gif 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 Binary files differnew file mode 100644 index 00000000000..d90a29fead8 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/debug.gif 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 Binary files differnew file mode 100644 index 00000000000..1dc19a31a0f --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/properties.gif 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 Binary files differnew file mode 100644 index 00000000000..c04edf8e83e --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcp_11x12.gif 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 Binary files differnew file mode 100644 index 00000000000..29ec606076f --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcp_16x16.gif 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 Binary files differnew file mode 100644 index 00000000000..f3e7b3d6791 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcpd_11x12.gif 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 Binary files differnew file mode 100644 index 00000000000..76c65b6196f --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.infra.services.tracepoints/icons/etool16/trcpd_16x16.gif 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> + +<plugin> + <extension-point id="traceMechanism" name="traceMechanism" schema="schema/traceMechanism.exsd"/> + + <extension + point="org.eclipse.ui.menus"> + <menuContribution + allPopups="true" + locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup"> + <menu + icon="icons/etool16/debug.gif" + id="org.eclipse.papyrus.views.modelexplorer.popup.tracing" + label="Tracing"> + </menu> + </menuContribution> + <menuContribution + allPopups="true" + locationURI="popup:org.eclipse.papyrus.views.modelexplorer.popup.tracing"> + <command + commandId="org.eclipse.papyrus.tracepoints.togglebreakpoint" + icon="icons/etool16/brkp_16x16.gif" + id="org.eclipse.papyrus.tracepoints.togglebreakpoint" + label="Toggle breakpoint"> + </command> + <command + commandId="org.eclipse.papyrus.tracepoints.togglebreakpointactivation" + icon="icons/etool16/brkpd_16x16.gif" + id="org.eclipse.papyrus.tracepoints.togglebreakpointactivation" + label="Toggle breakpoint activation"> + </command> + <command + commandId="org.eclipse.papyrus.tracepoints.toggletracepoint" + icon="icons/etool16/trcp_16x16.gif" + id="org.eclipse.papyrus.tracepoints.toggletracepoint" + label="Toggle tracepoint"> + </command> + <command + commandId="org.eclipse.papyrus.tracepoints.toggletracepointactivation" + icon="icons/etool16/trcpd_16x16.gif" + id="org.eclipse.papyrus.tracepoints.toggletracepointactivation" + label="Toggle tracepoint activation"> + </command> + <command + commandId="org.eclipse.papyrus.tracepoints.tracepointproperties" + icon="icons/etool16/properties.gif" + id="org.eclipse.papyrus.tracepoints.tracepointproperties" + label="Tracepoint properties"> + </command> + </menuContribution> + </extension> + + <extension + point="org.eclipse.ui.menus"> + <menuContribution + allPopups="true" + locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu?after=filtersMenu"> + <menu + icon="icons/etool16/debug.gif" + id="org.eclipse.papyrus.views.gmf.popup.tracing" + label="Tracing"> + </menu> + </menuContribution> + <menuContribution + allPopups="true" + locationURI="popup:org.eclipse.papyrus.views.gmf.popup.tracing"> + <command + commandId="org.eclipse.papyrus.tracepoints.togglebreakpoint" + icon="icons/etool16/brkp_16x16.gif" + id="org.eclipse.papyrus.tracepoints.toggletracepoint" + label="Toggle breakpoint"> + </command> + <command + commandId="org.eclipse.papyrus.tracepoints.togglebreakpointactivation" + icon="icons/etool16/brkpd_16x16.gif" + id="org.eclipse.papyrus.tracepoints.togglebreakpointactivation" + label="Toggle breakpoint activation"> + </command> + <command + commandId="org.eclipse.papyrus.tracepoints.toggletracepoint" + icon="icons/etool16/trcp_16x16.gif" + id="org.eclipse.papyrus.tracepoints.toggletracepoint" + label="Toggle tracepoint"> + </command> + <command + commandId="org.eclipse.papyrus.tracepoints.toggletracepointactivation" + icon="icons/etool16/trcpd_16x16.gif" + id="org.eclipse.papyrus.tracepoints.toggletracepointactivation" + label="Toggle tracepoint activation"> + </command> + <command + commandId="org.eclipse.papyrus.tracepoints.tracepointproperties" + icon="icons/etool16/properties.gif" + id="org.eclipse.papyrus.tracepoints.tracepointproperties" + label="Tracepoint properties"> + </command> + </menuContribution> + </extension> + + <extension + point="org.eclipse.ui.commands"> + <command + categoryId="org.eclipse.papyrus.editor.category" + defaultHandler="org.eclipse.papyrus.infra.services.tracepoints.handler.ToggleBreakpointHandler" + description="ToggleBreakpoint" + id="org.eclipse.papyrus.tracepoints.togglebreakpoint" + name="ToggleBreakpoint"> + </command> + <command + categoryId="org.eclipse.papyrus.editor.category" + defaultHandler="org.eclipse.papyrus.infra.services.tracepoints.handler.ToggleBreakpointActivationHandler" + description="ToggleBreakpointActivation" + id="org.eclipse.papyrus.tracepoints.togglebreakpointactivation" + name="ToggleBreakpointActivation"> + </command> + <command + categoryId="org.eclipse.papyrus.editor.category" + defaultHandler="org.eclipse.papyrus.infra.services.tracepoints.handler.ToggleTracepointHandler" + description="ToggleTracepoint" + id="org.eclipse.papyrus.tracepoints.toggletracepoint" + name="ToggleTracepoint"> + </command> + <command + categoryId="org.eclipse.papyrus.editor.category" + defaultHandler="org.eclipse.papyrus.infra.services.tracepoints.handler.ToggleTracepointActivationHandler" + description="ToggleTracepointActivation" + id="org.eclipse.papyrus.tracepoints.toggletracepointactivation" + name="ToggleTracepointActivation"> + </command> + <command + categoryId="org.eclipse.papyrus.editor.category" + defaultHandler="org.eclipse.papyrus.infra.services.tracepoints.handler.TracepointPropertiesHandler" + description="TracepointPropertoes" + id="org.eclipse.papyrus.tracepoints.tracepointproperties" + name="TracepointProperties"> + </command> + </extension> + + <extension + point="org.eclipse.papyrus.infra.services.decoration.decorationSpecificFunctions"> + <client + class="org.eclipse.papyrus.infra.services.tracepoints.TraceFunctions" + decorationType="org.eclipse.papyrus.tporbpmarker"> + </client> + </extension> + + <extension + id="org.eclipse.papyrus.tporbpmarker" + name="tracepoint or breakpoint marker" + point="org.eclipse.core.resources.markers"> + <super + type="org.eclipse.papyrus.modelmarker"> + </super> + <attribute + name="isActive"> + </attribute> + <attribute + name="isTracepoint"> + </attribute> + <persistent + value="true"> + </persistent> + </extension> + + <extension + id="org.eclipse.papyrus.tpmarker" + name="tracepoint marker" + point="org.eclipse.core.resources.markers"> + <super + type="org.eclipse.papyrus.tporbpmarker"> + </super> + <attribute + name="traceAction"> + </attribute> + <attribute + name="traceMechanism"> + </attribute> + <persistent + value="true"> + </persistent> + </extension> + + <extension + point="org.eclipse.ui.preferencePages"> + <page + category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory" + class="org.eclipse.papyrus.infra.services.tracepoints.preferences.TPPreferencePage" + id="org.eclipse.papyrus.infra.services.tracepoints.preferences.TPPreferencePage_ID" + name="Tracepoint preferences"> + </page> + </extension> +</plugin> 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.papyrus.infra.services.tracepoints" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.eclipse.papyrus.infra.services.tracepoints" id="traceMechanism" name="traceMechanism"/> + </appinfo> + <documentation> + Possibility to add implementations of a trace mechanism + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <choice minOccurs="0" maxOccurs="unbounded"> + <element ref="client"/> + </choice> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute translatable="true"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="client"> + <complexType> + <attribute name="traceMechID" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.services.tracepoints.ITraceMechanism"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="examples"/> + </appinfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="apiinfo"/> + </appinfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="implementation"/> + </appinfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> 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<String> 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<IPapyrusDecoration> 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<ITraceMechanism> getTraceMechanisms() + { + EList<ITraceMechanism> mechanisms = new BasicEList<ITraceMechanism>(); + 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<ITraceMechanism> 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<ITraceMechanism> mechanisms = TraceMechanism.getTraceMechanisms(); + if(mechanisms.size() == 0) { + items = new String[]{ "no plugins provide trace extension mechanism" }; + } + else { + EList<String> idList = new BasicEList<String>(); + 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<ITraceMechanism> 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("<not available>"); + } + } + } + } + }); + + 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;
+
+/**
+ * <pre>
+ *
+ * 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).
+ *
+ * </pre>
+ */
+public abstract class AbstractCommandHandler extends AbstractHandler {
+
+ /**
+ * <pre>
+ *
+ * Returns the command to execute (to be implemented
+ * in children implementing this class)
+ *
+ * @return the command to execute
+ *
+ * </pre>
+ */
+ protected abstract Command getCommand();
+
+ /**
+ * <pre>
+ * Get the selected element, the first selected element if several are selected or null
+ * if no selection or the selection is not an {@link EObject}.
+ *
+ * @return selected {@link EObject} or null
+ * </pre>
+ *
+ */
+ protected EObject getSelectedElement() {
+ EObject eObject = null;
+ Object selection = null;
+
+ // Get current selection
+ selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+
+ // Get first element if the selection is an IStructuredSelection
+ if(selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+ selection = structuredSelection.getFirstElement();
+ }
+
+ // Treat non-null selected object (try to adapt and return EObject)
+ if(selection != null) {
+ Object businessObject = BusinessModelResolver.getInstance().getBusinessModel(selection);
+ if(businessObject instanceof EObject) {
+ eObject = (EObject)businessObject;
+ }
+ }
+ return eObject;
+ }
+
+ /**
+ * <pre>
+ * 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}
+ * </pre>
+ *
+ */
+ protected List<EObject> getSelectedElements() {
+
+ List<EObject> selectedEObjects = new ArrayList<EObject>();
+
+ // 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<ITraceMechanism> mechanisms = TraceMechanism.getTraceMechanisms(); + String mechanismID = ""; + if(mechanisms.size() > 0) { + ITraceMechanism mechanism = mechanisms.get(0); + // TODO: function need to support null object + EList<String> 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 + * <p> + * 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<ITraceMechanism> mechanisms = TraceMechanism.getTraceMechanisms(); + int elements = 0; + for(ITraceMechanism mechanism : mechanisms) { + // TODO: function need to support null object + EList<String> 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<String> 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) { + } +} |