diff options
author | aradermache | 2013-01-28 13:37:38 +0000 |
---|---|---|
committer | aradermache | 2013-01-28 13:37:38 +0000 |
commit | ebd5809581875b8c12cb622ae81c8067d668b945 (patch) | |
tree | f854e1f8841efea14d48498360f65cbb9926e202 /extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/TraceUtils.java | |
parent | 2744195194144042bef2c17eda5e1ef35d009933 (diff) | |
download | org.eclipse.papyrus-ebd5809581875b8c12cb622ae81c8067d668b945.tar.gz org.eclipse.papyrus-ebd5809581875b8c12cb622ae81c8067d668b945.tar.xz org.eclipse.papyrus-ebd5809581875b8c12cb622ae81c8067d668b945.zip |
Initial version for migration of Qompass designer from 0.9.2 to the trunk (0.10)
Diffstat (limited to 'extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/TraceUtils.java')
-rw-r--r-- | extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/TraceUtils.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/TraceUtils.java b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/TraceUtils.java new file mode 100644 index 00000000000..e8b0e395785 --- /dev/null +++ b/extraplugins/qompass-designer/tracing/org.eclipse.papyrus.qompass.modellibs.tracing/src/org/eclipse/papyrus/qompass/modellibs/tracing/acceleo/TraceUtils.java @@ -0,0 +1,45 @@ +package org.eclipse.papyrus.qompass.modellibs.tracing.acceleo; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; +import org.eclipse.papyrus.infra.services.tracepoints.MarkerUtils; +import org.eclipse.papyrus.infra.services.tracepoints.TracepointConstants; +import org.eclipse.papyrus.qompass.designer.core.transformations.TransformationContext; +import org.eclipse.uml2.uml.Element; + +public class TraceUtils { + + public static IMarker[] getMarkersForEObject(EObject eObject, String markerType) { + Resource resource = eObject.eResource(); + IFile file = WorkspaceSynchronizer.getFile(resource); + if(file != null) { + try { + return file.findMarkers(markerType, true, IResource.DEPTH_INFINITE); + } catch (CoreException e) { + } + } + return new IMarker[0]; + } + + public static boolean hasTrace(Element eObject) { + IMarker markers[] = getMarkersForEObject(eObject, TracepointConstants.tpOrbpMarker); + for(IMarker marker : markers) { + // explicitly pass resourceSet of eObject we want to compare. Otherwise, the marker utils would + // load resources into its own resource set (leading to non-comparable eObjects) + EObject eObjOfMarker = MarkerUtils.getEObjectOfMarker(eObject.eResource().getResourceSet(), marker); + if(eObjOfMarker == eObject) { + return true; + } + } + // TODO: testing workaround (always return true for port based transformations) + if(TransformationContext.getPort() != null) { + return true; + } + return false; + } +} |