Bug 513920 - [Interoperability] Move and refactore code from plugin oep.m2m.qvto to the new git org.eclipse.papyrus-interoperability
Change-Id: Ia983d9efa9cb82ef593dd7a09b03044f194aacc0
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/META-INF/MANIFEST.MF
index d5c2eb9..3f1dd33 100644
--- a/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/META-INF/MANIFEST.MF
@@ -12,8 +12,12 @@
org.eclipse.emf.ecore;bundle-version="[2.13.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)",
org.eclipse.m2m.qvt.oml;bundle-version="[3.7.0,4.0.0)",
- org.eclipse.uml2.uml;bundle-version="[5.2.0,6.0.0)"
+ org.eclipse.uml2.uml;bundle-version="[5.2.0,6.0.0)",
+ org.eclipse.gmf.runtime.notation;bundle-version="[1.7.0,2.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.interoperability.common.blackboxes,
- org.eclipse.papyrus.interoperability.common.blackboxes.ecore
+ org.eclipse.papyrus.interoperability.common.blackboxes.ecore,
+ org.eclipse.papyrus.interoperability.common.blackboxes.emf,
+ org.eclipse.papyrus.interoperability.common.blackboxes.uml,
+ org.eclipse.papyrus.interoperability.common.blackboxes.utils
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/plugin.xml b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/plugin.xml
index f3d0d1d..d9201ab 100644
--- a/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/plugin.xml
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/plugin.xml
@@ -42,5 +42,27 @@
</metamodel>
</library>
</unit>
+ <unit
+ description="Provides some EMF Resource manipulation helpers"
+ name="EMFResource"
+ namespace="org.eclipse.papyrus.interoperability.common.blackboxes.emf">
+ <library
+ class="org.eclipse.papyrus.interoperability.common.blackboxes.emf.EMFResourceUtils">
+ <metamodel
+ nsURI="http://www.eclipse.org/emf/2002/Ecore">
+ </metamodel>
+ </library>
+ </unit>
+ <unit
+ description="Provides an access to Config Properties"
+ name="Properties"
+ namespace="org.eclipse.papyrus.interoperability.common.blackboxes.utils">
+ <library
+ class="org.eclipse.papyrus.interoperability.common.blackboxes.utils.PropertiesUtil">
+ <metamodel
+ nsURI="http://www.eclipse.org/emf/2002/Ecore">
+ </metamodel>
+ </library>
+ </unit>
</extension>
</plugin>
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/src/org/eclipse/papyrus/interoperability/common/blackboxes/emf/EMFResourceUtils.java b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/src/org/eclipse/papyrus/interoperability/common/blackboxes/emf/EMFResourceUtils.java
new file mode 100644
index 0000000..78c295d
--- /dev/null
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/src/org/eclipse/papyrus/interoperability/common/blackboxes/emf/EMFResourceUtils.java
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.interoperability.common.blackboxes.emf;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation.Kind;
+
+
+public class EMFResourceUtils {
+
+ /**
+ * Returns the URI of the selected element as a String
+ *
+ * @param target
+ * @return
+ */
+ @Operation(contextual = true, kind = Kind.QUERY)
+ public String getURI(EObject target) {
+ if (target == null) {
+ return "";
+ }
+ return EcoreUtil.getURI(target).toString();
+ }
+
+ /**
+ * Deletes the selected element, ensuring that it is also removed from the
+ * CrossReference (Especially useful for UML Models to avoid memory leaks)
+ *
+ * If delete incoming references is true, the operation may take a longer time
+ * to complete
+ *
+ * @param target
+ * @param deleteIncomingReferences
+ */
+ @Operation(contextual = true, kind = Kind.HELPER)
+ public void forceDelete(EObject target, boolean deleteIncomingReferences) {
+ if (target == null) {
+ return;
+ }
+
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(target);
+
+ if (deleteIncomingReferences) {
+ EcoreUtil.delete(target);
+ } else {
+ EcoreUtil.remove(target);
+ }
+
+ if (adapter != null) {
+ adapter.unsetTarget(target);
+ }
+ }
+}
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/src/org/eclipse/papyrus/interoperability/common/blackboxes/utils/PropertiesUtil.java b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/src/org/eclipse/papyrus/interoperability/common/blackboxes/utils/PropertiesUtil.java
new file mode 100644
index 0000000..386d379
--- /dev/null
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/src/org/eclipse/papyrus/interoperability/common/blackboxes/utils/PropertiesUtil.java
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.interoperability.common.blackboxes.utils;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation.Kind;
+import org.eclipse.m2m.qvt.oml.util.IContext;
+
+
+public class PropertiesUtil {
+
+ @Operation(withExecutionContext = true, kind = Kind.HELPER)
+ public String getStringProperty(IContext context, String property) {
+ return (String)context.getConfigProperty(property);
+ }
+
+ @Operation(withExecutionContext = true, kind = Kind.HELPER)
+ public boolean getBooleanProperty(IContext context, String property) {
+ return Boolean.parseBoolean(context.getConfigProperty(property).toString());
+ }
+
+ @Operation(withExecutionContext = true, kind = Kind.HELPER)
+ public int getIntegerProperty(IContext context, String property) {
+ return Integer.parseInt(context.getConfigProperty(property).toString());
+ }
+
+ @Operation(withExecutionContext = true, kind = Kind.HELPER)
+ public EObject getEObjectProperty(IContext context, String property) {
+ Object value = context.getConfigProperties().get(property);
+ if(value instanceof EObject) {
+ return (EObject)value;
+ }
+ return null;
+ }
+
+}
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.papyrus.interoperability.common/META-INF/MANIFEST.MF
index db7e41d..3995795 100644
--- a/common/plugins/org.eclipse.papyrus.interoperability.common/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common/META-INF/MANIFEST.MF
@@ -7,22 +7,21 @@
Bundle-Activator: org.eclipse.papyrus.interoperability.common.Activator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime;resolution:=optional;x-installation:=greedy,
- org.eclipse.emf.ecore;bundle-version="2.13.0";visibility:=reexport,
- org.eclipse.uml2.types;bundle-version="2.0.0";visibility:=reexport,
- org.eclipse.papyrus.infra.emf;bundle-version="2.2.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.widgets;bundle-version="3.0.0",
- org.eclipse.papyrus.infra.properties.ui;bundle-version="2.0.0",
- org.eclipse.ui.console;bundle-version="3.6.200",
- org.eclipse.uml2.uml;bundle-version="5.2.0",
- org.eclipse.papyrus.uml.tools;bundle-version="3.0.0",
- org.eclipse.gmf.runtime.notation;bundle-version="1.8.0",
- org.eclipse.m2m.qvt.oml;bundle-version="3.7.0",
- org.eclipse.papyrus.uml.extensionpoints;bundle-version="1.2.0",
- org.eclipse.papyrus.m2m.qvto;bundle-version="1.4.0",
- org.eclipse.papyrus.uml.modelrepair;bundle-version="2.0.0"
+Require-Bundle: org.eclipse.ui;bundle-version="[3.109.0,4.0.0)",
+ org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)";resolution:=optional;x-installation:=greedy,
+ org.eclipse.emf.ecore;bundle-version="[2.13.0,3.0.0)";visibility:=reexport,
+ org.eclipse.uml2.types;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.emf;bundle-version="[2.2.0,3.0.0)",
+ org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)",
+ org.eclipse.papyrus.infra.widgets;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.papyrus.infra.properties.ui;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.ui.console;bundle-version="[3.6.200,4.0.0)",
+ org.eclipse.uml2.uml;bundle-version="[5.2.0,6.0.0)",
+ org.eclipse.papyrus.uml.tools;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.gmf.runtime.notation;bundle-version="[1.7.0,2.0.0)",
+ org.eclipse.m2m.qvt.oml;bundle-version="[3.7.0,4.0.0)",
+ org.eclipse.papyrus.uml.extensionpoints;bundle-version="[1.2.0,2.0.0)",
+ org.eclipse.papyrus.uml.modelrepair;bundle-version="[2.0.0,3.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.interoperability.common,
@@ -34,5 +33,6 @@
org.eclipse.papyrus.interoperability.common.internal.extension,
org.eclipse.papyrus.interoperability.common.transformation,
org.eclipse.papyrus.interoperability.common.transformation.ui,
+ org.eclipse.papyrus.interoperability.common.utils,
org.eclipse.papyrus.interoperability.common.wizard,
org.eclipse.papyrus.interoperability.common.wizard.pages
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common/libraries/EclipseUI.qvto b/common/plugins/org.eclipse.papyrus.interoperability.common/libraries/EclipseUI.qvto
new file mode 100644
index 0000000..9184710
--- /dev/null
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common/libraries/EclipseUI.qvto
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+library EclipseUI;
+
+/** The IStatus#INFO code */
+query info() : Integer {
+ return 1
+}
+
+/** The IStatus#WARNING code */
+query warning() : Integer{
+ return 2
+}
+
+/** The IStatus#ERROR code */
+query error() : Integer {
+ return 4
+}
+
+query warning(message: String){
+ log(message, null, warning())
+}
+
+query error(message: String){
+ log(message, null, error())
+}
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common/plugin.xml b/common/plugins/org.eclipse.papyrus.interoperability.common/plugin.xml
index ee24097..8bdde82 100644
--- a/common/plugins/org.eclipse.papyrus.interoperability.common/plugin.xml
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common/plugin.xml
@@ -31,4 +31,47 @@
isCustomizable="false">
</context>
</extension>
+ <extension
+ point="org.eclipse.m2m.qvt.oml.runtime.qvtTransformation">
+ <library
+ file="libraries/EclipseUI.qvto"
+ id="libraries.EclipseUI">
+ </library>
+ </extension>
+ <extension
+ point="org.eclipse.m2m.qvt.oml.javaBlackboxUnits">
+ <unit
+ description="Provides an Eclipse UI/QVTo integration for transformations"
+ name="UI"
+ namespace="org.eclipse.papyrus.interoperability.common.utils">
+ <library
+ class="org.eclipse.papyrus.interoperability.common.utils.TransformationUI">
+ <metamodel
+ nsURI="http://www.eclipse.org/emf/2002/Ecore">
+ </metamodel>
+ </library>
+ </unit>
+ <unit
+ description="Java helpers to manipulate Notation DataTypes (Gradient, Bendpoints...)"
+ name="NotationTypes"
+ namespace="org.eclipse.papyrus.interoperability.common.utils">
+ <library
+ class="org.eclipse.papyrus.interoperability.common.utils.NotationTypes">
+ <metamodel
+ nsURI="http://www.eclipse.org/gmf/runtime/1.0.2/notation">
+ </metamodel>
+ </library>
+ </unit>
+ <unit
+ description="Provides access to the incremental trace model for ad hoc trace queries."
+ name="Traces"
+ namespace="org.eclipse.papyrus.interoperability.common.utils">
+ <library
+ class="org.eclipse.papyrus.interoperability.common.utils.TraceHelper">
+ <metamodel
+ nsURI="http://www.eclipse.org/emf/2002/Ecore">
+ </metamodel>
+ </library>
+ </unit>
+ </extension>
</plugin>
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/transformation/AbstractImportTransformation.java b/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/transformation/AbstractImportTransformation.java
index 332b6a4..f8578be 100644
--- a/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/transformation/AbstractImportTransformation.java
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/transformation/AbstractImportTransformation.java
@@ -67,8 +67,8 @@
import org.eclipse.papyrus.interoperability.common.MigrationParameters.ThreadConfig;
import org.eclipse.papyrus.interoperability.common.concurrent.ExecutorsPool;
import org.eclipse.papyrus.interoperability.common.internal.extension.TransformationExtension;
-import org.eclipse.papyrus.m2m.qvto.TraceHelper;
-import org.eclipse.papyrus.m2m.qvto.TransformationUI;
+import org.eclipse.papyrus.interoperability.common.utils.TraceHelper;
+import org.eclipse.papyrus.interoperability.common.utils.TransformationUI;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.statushandlers.StatusManager;
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/utils/NotationTypes.java b/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/utils/NotationTypes.java
new file mode 100644
index 0000000..4ed488f
--- /dev/null
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/utils/NotationTypes.java
@@ -0,0 +1,95 @@
+/*****************************************************************************
+ * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, 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
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 497841
+ *****************************************************************************/
+package org.eclipse.papyrus.interoperability.common.utils;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.gmf.runtime.notation.Anchor;
+import org.eclipse.gmf.runtime.notation.LayoutConstraint;
+import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation.Kind;
+
+
+public class NotationTypes {
+
+ private static final double HIMETRIC_UNITS_PER_INCH = 2540.0;
+
+ private static float pseudoHimetricDPI = 72.0f;
+ private static double pseudoHimetricScale = 1.0;
+
+ static {
+ pseudoHimetricScale = pseudoHimetricDPI / HIMETRIC_UNITS_PER_INCH;
+ }
+
+ @Operation(contextual = true, kind = Kind.QUERY)
+ public static int toPixels(LayoutConstraint self, Integer himetric) {
+ return (himetric == null) ? -1 : convertToPixels(himetric);
+ }
+
+ @Operation(contextual = true, kind = Kind.QUERY)
+ public static int toPixels(View self, Integer himetric) {
+ return (himetric == null) ? -1 : convertToPixels(himetric);
+ }
+
+ @Operation(contextual = true, kind = Kind.QUERY)
+ public static int toPixels(Anchor self, Integer himetric) {
+ return (himetric == null) ? -1 : convertToPixels(himetric);
+ }
+
+ @Operation(contextual = true, kind = Kind.HELPER)
+ public static void copyBendpoints(final RelativeBendpoints source, RelativeBendpoints target, boolean convertToPixels) {
+ List<RelativeBendpoint> result = new LinkedList<RelativeBendpoint>();
+
+ for (Object point : source.getPoints()) {
+ if (point instanceof RelativeBendpoint) {
+ RelativeBendpoint pointCopy = new RelativeBendpoint(((RelativeBendpoint) point).convertToString());
+ result.add(pointCopy);
+ }
+ }
+
+ if (convertToPixels) {
+ List<RelativeBendpoint> convertedResult = new LinkedList<RelativeBendpoint>();
+
+ for (RelativeBendpoint point : result) {
+ convertedResult.add(convertToPixels(point));
+ }
+
+ result = convertedResult;
+ }
+
+ target.setPoints(result);
+ }
+
+ private static RelativeBendpoint convertToPixels(RelativeBendpoint bendpoint) {
+ int newSourceX, newSourceY, newTargetX, newTargetY;
+
+ newSourceX = convertToPixels(bendpoint.getSourceX());
+ newSourceY = convertToPixels(bendpoint.getSourceY());
+ newTargetX = convertToPixels(bendpoint.getTargetX());
+ newTargetY = convertToPixels(bendpoint.getTargetY());
+
+ return new RelativeBendpoint(newSourceX, newSourceY, newTargetX, newTargetY);
+ }
+
+ private static int convertToPixels(int source) {
+ // TODO: Fix hard-coded pixel defaults in the QVTos and
+ // elsewhere that assume a 72-DPI display (cf. bug 497841).
+
+ // return MapModeTypes.HIMETRIC_MM.LPtoDP(source);
+ return (int) (source * pseudoHimetricScale);
+ }
+}
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/utils/TraceHelper.java b/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/utils/TraceHelper.java
new file mode 100644
index 0000000..2021057
--- /dev/null
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/utils/TraceHelper.java
@@ -0,0 +1,161 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus 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
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.interoperability.common.utils;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.m2m.internal.qvt.oml.trace.EValue;
+import org.eclipse.m2m.internal.qvt.oml.trace.Trace;
+import org.eclipse.m2m.internal.qvt.oml.trace.TraceRecord;
+import org.eclipse.m2m.internal.qvt.oml.trace.VarParameterValue;
+import org.eclipse.m2m.qvt.oml.ExecutionContext;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation.Kind;
+import org.eclipse.m2m.qvt.oml.util.IContext;
+import org.eclipse.m2m.qvt.oml.util.ISessionData;
+
+/**
+ * Query operations that introspect the trace model.
+ */
+@SuppressWarnings("restriction")
+public class TraceHelper {
+ /**
+ * QVTo {@link ExecutionContext} session data key for the cumulative trace history.
+ * This is distinct from the session data for incremental update traces because it
+ * is not used for incremental update, but as a "memory" of trace relationships
+ * established by past transformations.
+ */
+ public static ISessionData.SimpleEntry<org.eclipse.m2m.qvt.oml.util.Trace> TRACE_HISTORY = new ISessionData.SimpleEntry<org.eclipse.m2m.qvt.oml.util.Trace>();
+
+ private final Map<String, EClass> eclasses = new HashMap<String, EClass>();
+
+ /**
+ * Initializes me.
+ */
+ public TraceHelper() {
+ super();
+ }
+
+ /**
+ * Gets the source object from which a given {@code self} object traces.
+ *
+ * @param context
+ * the execution context
+ * @param self
+ * the object for which to trace its original in the source model
+ *
+ * @return
+ * the source object, or {@code null} if not found in the traces
+ */
+ @Operation(contextual = true, kind = Kind.QUERY, withExecutionContext = true)
+ public Object traceFrom(IContext context, Object self) {
+ return traceFrom(context, self, null);
+ }
+
+ /**
+ * Gets the source object from which a given {@code self} object traces.
+ *
+ * @param context
+ * the execution context
+ * @param self
+ * the object for which to trace its original in the source model
+ * @param type
+ * the type of source object to obtain, in case multiple sources
+ * map to the same target (may be {@code null} to get any source)
+ *
+ * @return
+ * the source object, or {@code null} if not found in the traces
+ */
+ @Operation(contextual = true, kind = Kind.QUERY, withExecutionContext = true)
+ public Object traceFrom(IContext context, Object self, String type) {
+ EObject result = null;
+
+ org.eclipse.m2m.qvt.oml.util.Trace history = context.getSessionData().getValue(TRACE_HISTORY);
+ List<EObject> traces = (history != null) ? history.getTraceContent() : Collections.<EObject> emptyList();
+
+ for (EObject next : traces) {
+ if (next instanceof Trace) {
+ Trace trace = (Trace) next;
+ EList<TraceRecord> inverse = trace.getTargetToTraceRecordMap().get(self);
+ if (inverse != null) {
+ for (TraceRecord record : inverse) {
+ VarParameterValue source = record.getContext().getContext();
+ EValue sourceValue = (source == null) ? null : source.getValue();
+ EObject sourceElement = (sourceValue == null) ? null : sourceValue.getModelElement();
+
+ if ((sourceElement != null) && ((type == null) || isA(sourceElement.eClass(), type))) {
+ result = sourceElement;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private boolean isA(EClass eclass, String type) {
+ boolean result;
+
+ EClass target = eclasses.get(type);
+ if (target != null) {
+ result = target.isSuperTypeOf(eclass);
+ } else {
+ result = __isA(eclass, type);
+ }
+
+ return result;
+ }
+
+ private boolean __isA(EClass eclass, String type) {
+ boolean result;
+
+ String qname = qname(eclass);
+ result = qname.equals(type);
+ if (!result) {
+ for (EClass next : eclass.getESuperTypes()) {
+ result = isA(next, type);
+ if (result) {
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private String qname(EClass eclass) {
+ StringBuilder buf = new StringBuilder();
+ buf.append(eclass.getEPackage().getName());
+ buf.append("::"); //$NON-NLS-1$
+ buf.append(eclass.getName());
+
+ for (EPackage nesting = eclass.getEPackage().getESuperPackage(); nesting != null; nesting = nesting.getESuperPackage()) {
+ buf.insert(0, "::"); //$NON-NLS-1$
+ buf.insert(0, nesting.getName());
+ }
+
+ String result = buf.toString();
+ eclasses.put(result, eclass);
+ return result;
+ }
+}
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/utils/TransformationUI.java b/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/utils/TransformationUI.java
new file mode 100644
index 0000000..9ae03fe
--- /dev/null
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common/src/org/eclipse/papyrus/interoperability/common/utils/TransformationUI.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.interoperability.common.utils;
+
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation.Kind;
+import org.eclipse.m2m.qvt.oml.util.IContext;
+
+
+public class TransformationUI {
+
+ public static final String MONITOR = "monitor";
+
+ @Operation(withExecutionContext = true, kind = Kind.HELPER)
+ public void beginTask(IContext context, String name, int totalWork) {
+ getMonitor(context).beginTask(name, totalWork);
+ }
+
+ @Operation(withExecutionContext = true, kind = Kind.HELPER)
+ public void worked(IContext context, int worked) {
+ getMonitor(context).worked(worked);
+ }
+
+ @Operation(withExecutionContext = true, kind = Kind.HELPER)
+ public boolean isCanceled(IContext context) {
+ return getMonitor(context).isCanceled();
+ }
+
+
+
+
+
+ private IProgressMonitor getMonitor(IContext context) {
+ Object monitor = context.getConfigProperty(MONITOR);
+
+ if(monitor instanceof IProgressMonitor) {
+ return (IProgressMonitor)monitor;
+ }
+
+ return new NullProgressMonitor();
+ }
+
+}
diff --git a/common/tests/org.eclipse.papyrus.interoperability.common.tests/META-INF/MANIFEST.MF b/common/tests/org.eclipse.papyrus.interoperability.common.tests/META-INF/MANIFEST.MF
index 7ed3f9b..cdc124e 100644
--- a/common/tests/org.eclipse.papyrus.interoperability.common.tests/META-INF/MANIFEST.MF
+++ b/common/tests/org.eclipse.papyrus.interoperability.common.tests/META-INF/MANIFEST.MF
@@ -12,7 +12,7 @@
org.eclipse.emf.ecore;bundle-version="[2.13.0,3.0.0)",
org.eclipse.uml2.uml;bundle-version="[5.2.0,6.0.0)",
org.eclipse.papyrus.junit.utils;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.emf.compare;bundle-version="[3.4.0,4.0.0)"
+ org.eclipse.emf.compare;bundle-version="[3.3.0,4.0.0)"
Bundle-Activator: org.eclipse.papyrus.interoperability.common.tests.Activator
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.interoperability.common.tests,
diff --git a/common/tests/org.eclipse.papyrus.interoperability.common.tests/build.properties b/common/tests/org.eclipse.papyrus.interoperability.common.tests/build.properties
index 27571f5..04fa2df 100644
--- a/common/tests/org.eclipse.papyrus.interoperability.common.tests/build.properties
+++ b/common/tests/org.eclipse.papyrus.interoperability.common.tests/build.properties
@@ -3,6 +3,5 @@
bin.includes = META-INF/,\
.,\
about.html,\
- OSGI-INF/l10n/bundle.properties,\
- plugin.xml
+ OSGI-INF/l10n/bundle.properties
src.includes = about.html