Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Muskalla2011-01-21 20:13:59 +0000
committerChris Aniszczyk2011-01-25 23:19:53 +0000
commita2b585173cc6bb01e48f8bc99ea72b7b3fe277b1 (patch)
tree5d462b669f06d3ea7272bdceeb5f5a58123f214a
parent526e8486200877f79313f668a5d81889a41d0a8d (diff)
downloadegit-a2b585173cc6bb01e48f8bc99ea72b7b3fe277b1.tar.gz
egit-a2b585173cc6bb01e48f8bc99ea72b7b3fe277b1.tar.xz
egit-a2b585173cc6bb01e48f8bc99ea72b7b3fe277b1.zip
Support 'Open corresponding task' in History and Sync View
In order to quickly see a task for a commit, we need to provide an adapter between EGit and Mylyn. Change-Id: I2d265c8b894c1b45c2d4d9186f6696433acba95c Signed-off-by: Benjamin Muskalla <benjamin.muskalla@tasktop.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.egit.mylyn.ui/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.egit.mylyn.ui/plugin.xml11
-rw-r--r--org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java58
-rw-r--r--org.eclipse.egit.ui/META-INF/MANIFEST.MF1
4 files changed, 73 insertions, 1 deletions
diff --git a/org.eclipse.egit.mylyn.ui/META-INF/MANIFEST.MF b/org.eclipse.egit.mylyn.ui/META-INF/MANIFEST.MF
index f76d527e5e..913fb6eff1 100644
--- a/org.eclipse.egit.mylyn.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.mylyn.ui/META-INF/MANIFEST.MF
@@ -22,4 +22,6 @@ Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.eclipse.egit.internal.mylyn.ui;version="0.11.0";x-internal:=true,
org.eclipse.egit.internal.mylyn.ui.commit;version="0.11.0";x-internal:=true
-Import-Package: org.eclipse.egit.ui;version="[0.11.0,0.12.0)"
+Import-Package: org.eclipse.egit.ui;version="[0.11.0,0.12.0)",
+ org.eclipse.egit.ui.internal.synchronize.model;version="[0.11.0,0.12.0)",
+ org.eclipse.jgit.revwalk;version="[0.11.0,0.12.0)"
diff --git a/org.eclipse.egit.mylyn.ui/plugin.xml b/org.eclipse.egit.mylyn.ui/plugin.xml
index 18fa41622e..31a5d02c7c 100644
--- a/org.eclipse.egit.mylyn.ui/plugin.xml
+++ b/org.eclipse.egit.mylyn.ui/plugin.xml
@@ -7,4 +7,15 @@
class="org.eclipse.egit.internal.mylyn.ui.commit.MylynCommitMessageProvider">
</commitMessageProvider>
</extension>
+
+ <extension point="org.eclipse.core.runtime.adapters">
+ <factory adaptableType="org.eclipse.egit.ui.internal.history.SWTCommit"
+ class="org.eclipse.egit.internal.mylyn.ui.commit.TaskReferenceFactory">
+ <adapter type="org.eclipse.mylyn.team.ui.AbstractTaskReference"/>
+ </factory>
+ <factory adaptableType="org.eclipse.egit.ui.internal.synchronize.model.GitModelCommit"
+ class="org.eclipse.egit.internal.mylyn.ui.commit.TaskReferenceFactory">
+ <adapter type="org.eclipse.mylyn.team.ui.AbstractTaskReference"/>
+ </factory>
+ </extension>
</plugin>
diff --git a/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java
new file mode 100644
index 0000000000..517b419122
--- /dev/null
+++ b/org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Benjamin Muskalla 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:
+ * Benjamin Muskalla <benjamin.muskalla@tasktop.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.internal.mylyn.ui.commit;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.egit.ui.internal.synchronize.model.GitModelCommit;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.mylyn.internal.team.ui.LinkedTaskInfo;
+import org.eclipse.mylyn.team.ui.AbstractTaskReference;
+
+/**
+ * Adapter factory to bridge between Mylyn and EGit domain models.
+ */
+public class TaskReferenceFactory implements IAdapterFactory {
+ private static final Class<?>[] ADAPTER_TYPES = new Class[] { AbstractTaskReference.class };
+
+ @SuppressWarnings({ "rawtypes" })
+ public Class[] getAdapterList() {
+ return ADAPTER_TYPES;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (!AbstractTaskReference.class.equals(adapterType))
+ return null;
+
+ return adaptFromComment(adaptableObject);
+ }
+
+ private AbstractTaskReference adaptFromComment(Object element) {
+ String comment;
+ RevCommit commit = getCommitForElement(element);
+ if(commit != null)
+ comment = commit.getFullMessage();
+ else
+ return null;
+ return new LinkedTaskInfo(null, null, null, comment);
+ }
+
+ private static RevCommit getCommitForElement(Object element) {
+ RevCommit commit = null;
+ if (element instanceof RevCommit)
+ commit = (RevCommit) element;
+ else if (element instanceof GitModelCommit) {
+ GitModelCommit modelCommit = (GitModelCommit) element;
+ commit= modelCommit.getBaseCommit();
+ }
+ return commit;
+ }
+}
diff --git a/org.eclipse.egit.ui/META-INF/MANIFEST.MF b/org.eclipse.egit.ui/META-INF/MANIFEST.MF
index b7228bbf1a..00330844ad 100644
--- a/org.eclipse.egit.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.ui/META-INF/MANIFEST.MF
@@ -74,4 +74,5 @@ Export-Package: org.eclipse.egit.ui;version="0.11.0",
org.eclipse.egit.ui.internal.repository.tree.command;version="0.11.0";x-internal:=true,
org.eclipse.egit.ui.internal.sharing;version="0.11.0";x-internal:=true,
org.eclipse.egit.ui.internal.synchronize;version="0.11.0";x-internal:=true,
+ org.eclipse.egit.ui.internal.synchronize.model;version="0.11.0";x-friends:="org.eclipse.egit.mylyn.ui",
org.eclipse.egit.ui.internal.trace;version="0.11.0";x-internal:=true

Back to the top