Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2012-01-26 00:13:04 +0000
committerMatthias Sohn2012-01-26 00:13:04 +0000
commit933ff93918bff14d86355270e1dba2f3c8fad493 (patch)
treeb0f27b2468f392c9540016c0b70721f618a8a3ca
parent95981aca30a59b6e560e2e82d7b74d3bd0f8874b (diff)
downloadegit-933ff93918bff14d86355270e1dba2f3c8fad493.tar.gz
egit-933ff93918bff14d86355270e1dba2f3c8fad493.tar.xz
egit-933ff93918bff14d86355270e1dba2f3c8fad493.zip
[historyView] Support linking with commit editor
Opening the commit editor with the history view in link mode will now set the input of the view to be the commit's repository and the current commit being viewed will be selected once the view loads Bug: 368346 Change-Id: Icccc2d7032ba11b1ead5c993995efaca36251bf0 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/plugin.xml7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java21
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java6
3 files changed, 28 insertions, 6 deletions
diff --git a/org.eclipse.egit.ui/plugin.xml b/org.eclipse.egit.ui/plugin.xml
index c5e8f6d5c8..9642e79a59 100644
--- a/org.eclipse.egit.ui/plugin.xml
+++ b/org.eclipse.egit.ui/plugin.xml
@@ -280,6 +280,13 @@
</adapter>
</factory>
<factory
+ adaptableType="org.eclipse.egit.ui.internal.commit.RepositoryCommit"
+ class="org.eclipse.egit.ui.internal.factories.GitAdapterFactory">
+ <adapter
+ type="org.eclipse.team.ui.history.IHistoryPageSource">
+ </adapter>
+ </factory>
+ <factory
adaptableType="org.eclipse.egit.ui.internal.history.HistoryPageInput"
class="org.eclipse.egit.ui.internal.factories.GitAdapterFactory">
<adapter
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
index 80bd007337..0eeac9622e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
@@ -27,6 +27,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIIcons;
@@ -649,13 +650,11 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
if (object instanceof RepositoryTreeNode)
return true;
- if (object instanceof IAdaptable) {
- IResource resource = (IResource) ((IAdaptable) object)
- .getAdapter(IResource.class);
- return resource == null ? false : typeOk(resource);
- }
+ IResource resource = AdapterUtils.adapt(object, IResource.class);
+ if (resource != null && typeOk(resource))
+ return true;
- return false;
+ return AdapterUtils.adapt(object, Repository.class) != null;
}
private static boolean typeOk(final IResource object) {
@@ -1092,6 +1091,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
boolean showRef = false;
boolean showTag = false;
Repository repo = null;
+ RevCommit selection = null;
Ref ref = null;
if (o instanceof IResource) {
RepositoryMapping mapping = RepositoryMapping
@@ -1149,6 +1149,13 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
new IResource[] { resource });
}
}
+ if (repo == null) {
+ repo = AdapterUtils.adapt(o, Repository.class);
+ if (repo != null)
+ input = new HistoryPageInput(repo);
+ }
+ selection = AdapterUtils.adapt(o, RevCommit.class);
+
if (input == null) {
this.name = ""; //$NON-NLS-1$
setErrorMessage(UIText.GitHistoryPage_NoInputMessage);
@@ -1193,6 +1200,8 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
showRef(ref, repo);
if (showTag)
showTag(ref, repo);
+ if (selection != null)
+ graph.selectCommitStored(selection);
return true;
} finally {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
index b95e1b7991..72aaa65595 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommandHandler.java
@@ -23,6 +23,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.internal.CompareUtils;
@@ -97,6 +98,11 @@ abstract class AbstractHistoryCommandHandler extends AbstractHandler {
}
}
+
+ Repository repo = AdapterUtils.adapt(input, Repository.class);
+ if (repo != null)
+ return repo;
+
throw new ExecutionException(
UIText.AbstractHistoryCommanndHandler_CouldNotGetRepositoryMessage);
}

Back to the top