Bug 519909: Added handler to allow linking to markers
diff --git a/org.eclipse.capra.handler.marker/.classpath b/org.eclipse.capra.handler.marker/.classpath
new file mode 100644
index 0000000..22f3064
--- /dev/null
+++ b/org.eclipse.capra.handler.marker/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.capra.handler.marker/.project b/org.eclipse.capra.handler.marker/.project
new file mode 100644
index 0000000..05584ad
--- /dev/null
+++ b/org.eclipse.capra.handler.marker/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.capra.handler.marker</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.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.capra.handler.marker/META-INF/MANIFEST.MF b/org.eclipse.capra.handler.marker/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..24349cb
--- /dev/null
+++ b/org.eclipse.capra.handler.marker/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Capra Handler for Eclipse Markers
+Bundle-SymbolicName: org.eclipse.capra.handler.marker;singleton:=true
+Bundle-Version: 0.7.0.qualifier
+Require-Bundle: org.eclipse.capra.core,
+ org.eclipse.core.resources,
+ org.eclipse.core.runtime,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.ide
+Import-Package: org.eclipse.capra.ui.helpers
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-Vendor: Capra Development Team
diff --git a/org.eclipse.capra.handler.marker/build.properties b/org.eclipse.capra.handler.marker/build.properties
new file mode 100644
index 0000000..9fc85e9
--- /dev/null
+++ b/org.eclipse.capra.handler.marker/build.properties
@@ -0,0 +1,14 @@
+###############################################################################
+# Copyright (c) 2016 Chalmers | University of Gothenburg, rt-labs 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:
+# Chalmers | University of Gothenburg and rt-labs - initial API and implementation and/or initial documentation
+###############################################################################
+source.. = src/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/org.eclipse.capra.handler.marker/plugin.xml b/org.eclipse.capra.handler.marker/plugin.xml
new file mode 100644
index 0000000..0ca44c2
--- /dev/null
+++ b/org.eclipse.capra.handler.marker/plugin.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2016 Chalmers | University of Gothenburg, rt-labs 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:
+ Chalmers | University of Gothenburg and rt-labs - initial API and implementation and/or initial documentation
+ -->
+
+<plugin>
+ <extension
+ id="org.eclipse.capra.handler.marker.MarkerHandler"
+ point="org.eclipse.capra.configuration.artifactHandlers">
+ <artifactHandler
+ class="org.eclipse.capra.handler.marker.MarkerHandler">
+ </artifactHandler>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.capra.handler.marker/pom.xml b/org.eclipse.capra.handler.marker/pom.xml
new file mode 100644
index 0000000..9ec3fb7
--- /dev/null
+++ b/org.eclipse.capra.handler.marker/pom.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Chalmers | University of Gothenburg, rt-labs 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:
+ Chalmers | University of Gothenburg and rt-labs - initial API and implementation and/or initial documentation
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <relativePath>../pom.xml</relativePath>
+ <groupId>org.eclipse.capra</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.capra.handler.marker</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+</project>
diff --git a/org.eclipse.capra.handler.marker/src/org/eclipse/capra/handler/marker/MarkerHandler.java b/org.eclipse.capra.handler.marker/src/org/eclipse/capra/handler/marker/MarkerHandler.java
new file mode 100644
index 0000000..374d06d
--- /dev/null
+++ b/org.eclipse.capra.handler.marker/src/org/eclipse/capra/handler/marker/MarkerHandler.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Chalmers | University of Gothenburg, rt-labs 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:
+ * Chalmers | University of Gothenburg and rt-labs - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.capra.handler.marker;
+
+import org.eclipse.capra.core.adapters.ArtifactMetaModelAdapter;
+import org.eclipse.capra.core.handlers.AbstractArtifactHandler;
+import org.eclipse.capra.core.handlers.IArtifactUnpacker;
+import org.eclipse.capra.core.helpers.ExtensionPointHelper;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.ui.texteditor.MarkerUtilities;
+import org.eclipse.ui.views.markers.MarkerItem;
+
+/**
+ * Handler to allow tracing to and from IMarker instances as used by Eclipse to associate notes with resources.
+ */
+public class MarkerHandler extends AbstractArtifactHandler<IMarker> implements IArtifactUnpacker<MarkerItem, IMarker> {
+
+ @Override
+ public EObject createWrapper(IMarker artifact, EObject artifactModel) {
+ ArtifactMetaModelAdapter adapter = ExtensionPointHelper.getArtifactWrapperMetaModelAdapter().get();
+
+ IResource resource = artifact.getResource();
+
+ EObject wrapper = adapter.createArtifact(artifactModel, this.getClass().getName(),
+ resource.getLocationURI().toString(), Long.toString(artifact.getId()), this.getDisplayName(artifact),
+ resource.getFullPath().toString());
+
+ return wrapper;
+ }
+
+ @Override
+ public IMarker resolveWrapper(EObject wrapper) {
+ ArtifactMetaModelAdapter adapter = ExtensionPointHelper.getArtifactWrapperMetaModelAdapter().get();
+ IResource target = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(adapter.getArtifactPath(wrapper));
+ Long id = new Long(adapter.getArtifactIdentifier(wrapper));
+ IMarker marker = target.getMarker(id);
+ return marker;
+ }
+
+ @Override
+ public String getDisplayName(IMarker artifact) {
+ return MarkerUtilities.getMarkerType(artifact) + ": " + MarkerUtilities.getMessage(artifact);
+ }
+
+ @Override
+ public String generateMarkerMessage(IResourceDelta delta, String wrapperUri) {
+ return null;
+ }
+
+ @Override
+ public IMarker unpack(MarkerItem container) {
+ return container.getMarker();
+ }
+}