summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorRemy Suen2010-04-30 18:30:20 (EDT)
committer Remy Suen2010-04-30 18:30:20 (EDT)
commite494ea152d0f0663d3004ab5638ff85ac2654671 (patch)
treea7c3624580d11cedd1eb65746ff06a8895fbc2b7
parentdc9549b6d29825839d1e94da612a414e1423aaa7 (diff)
downloadegit-e494ea152d0f0663d3004ab5638ff85ac2654671.zip
egit-e494ea152d0f0663d3004ab5638ff85ac2654671.tar.gz
egit-e494ea152d0f0663d3004ab5638ff85ac2654671.tar.bz2
Fix EGit history handling code to consider IAdaptablesrefs/changes/34/634/1
The history code naively assumes that all of its inputs are of type IResource. However, this is invalid as objects like an editor's input or JDT's handling of the model of a Java project are not represented by an IResource. The history code needs to be corrected to consider the case where an IAdaptable is handed to it. Bug: 311249 Change-Id: Ie1e20f68b9023bd98981f42d9b8fa14aae250614
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java14
1 files changed, 12 insertions, 2 deletions
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 1b02dc8..ed87e59 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
@@ -20,6 +20,7 @@ import org.eclipse.compare.ITypedElement;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
@@ -157,6 +158,12 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
}
+ if (object instanceof IAdaptable) {
+ IResource resource = (IResource) ((IAdaptable) object)
+ .getAdapter(IResource.class);
+ return resource == null ? false : typeOk(resource);
+ }
+
if (object instanceof IResource) {
return typeOk((IResource) object);
}
@@ -862,7 +869,10 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
in = new ResourceList(new IResource[] { (IResource) o });
else if (o instanceof ResourceList)
in = o;
- else
+ else if (o instanceof IAdaptable) {
+ IResource resource = (IResource) ((IAdaptable) o).getAdapter(IResource.class);
+ in = resource == null ? null : new ResourceList(new IResource[] { resource });
+ } else
in = null;
return super.setInput(in);
}
@@ -873,7 +883,7 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
revObjectSelectionProvider.setActiveRepository(null);
cancelRefreshJob();
- if (graph == null)
+ if (graph == null || super.getInput() == null)
return false;
final IResource[] in = ((ResourceList) super.getInput()).getItems();