Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2013-04-13 13:05:12 +0000
committerMatthias Sohn2013-04-15 21:39:21 +0000
commit4757472cb52c8914058e63fb50f3f4a4325db231 (patch)
tree38f73264b85dcd9632335ee91da701c838ac047c /org.eclipse.egit.ui
parent56eb69bcb21faa7cbaee03d363e110483c0b839f (diff)
downloadegit-4757472cb52c8914058e63fb50f3f4a4325db231.tar.gz
egit-4757472cb52c8914058e63fb50f3f4a4325db231.tar.xz
egit-4757472cb52c8914058e63fb50f3f4a4325db231.zip
Use ResourceUtil.getFileForLocation in StagingEntry.getFile
The util method now includes more logic for finding the right one, which should also apply e.g. for Show In actions. Additionally, selectionIncludesNonWorkspaceResources in StagingView now uses StagingEntry.getFile instead of implementing similar but not quite the same logic. This fixes some strange behavior with nested projects. Change-Id: Iff238b7e228044fe027538eefd81700bccef505e Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java15
2 files changed, 6 insertions, 18 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java
index 512e6b26ad..dd7c1ad5a2 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java
@@ -16,12 +16,11 @@ import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.egit.core.internal.util.ResourceUtil;
import org.eclipse.egit.ui.internal.decorators.IDecoratableResource;
import org.eclipse.egit.ui.internal.decorators.IProblemDecoratable;
import org.eclipse.jgit.lib.Repository;
@@ -147,12 +146,12 @@ public class StagingEntry implements IAdaptable, IProblemDecoratable, IDecoratab
}
/**
- * @return the file corresponding to the entry
+ * @return the file corresponding to the entry, if it exists in the
+ * workspace, null otherwise.
*/
public IFile getFile() {
IPath absolutePath = getLocation();
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile resource = root.getFileForLocation(absolutePath);
+ IFile resource = ResourceUtil.getFileForLocation(absolutePath);
return resource;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index 0e528ad39c..41b8c3a5f7 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -27,7 +27,6 @@ import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
@@ -1121,23 +1120,13 @@ public class StagingView extends ViewPart implements IShowInSource {
if (!(selectedObject instanceof StagingEntry))
return false;
StagingEntry stagingEntry = (StagingEntry) selectedObject;
- String path = currentRepository.getWorkTree() + "/" + stagingEntry.getPath(); //$NON-NLS-1$
- if (getResource(path) == null)
+ IFile file = stagingEntry.getFile();
+ if (file == null)
return true;
}
return false;
}
- private IFile getResource(String path) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile file = root.getFileForLocation(new Path(path));
- if (file == null)
- return null;
- if (file.getProject().isAccessible())
- return file;
- return null;
- }
-
private void openSelectionInEditor(ISelection s) {
if (s.isEmpty() || !(s instanceof IStructuredSelection))
return;

Back to the top