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 /org.eclipse.egit.mylyn.ui/src/org
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>
Diffstat (limited to 'org.eclipse.egit.mylyn.ui/src/org')
-rw-r--r--org.eclipse.egit.mylyn.ui/src/org/eclipse/egit/internal/mylyn/ui/commit/TaskReferenceFactory.java58
1 files changed, 58 insertions, 0 deletions
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;
+ }
+}

Back to the top