aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Kinzler2010-04-26 13:12:17 (EDT)
committerChris Aniszczyk2010-04-26 16:16:14 (EDT)
commit51a958c6c1640fe692960d3b0e25e33bc6f5a940 (patch)
treee578669c6dd4aff9fd281dee79a54ad23953570b
parent8a770e3e9eb25689949495f5cc08f2dacf89ad5c (diff)
downloadegit-51a958c6c1640fe692960d3b0e25e33bc6f5a940.zip
egit-51a958c6c1640fe692960d3b0e25e33bc6f5a940.tar.gz
egit-51a958c6c1640fe692960d3b0e25e33bc6f5a940.tar.bz2
Editor tab switch should update GitRepostoriesViewrefs/changes/08/608/2
When switching editors, the GitRepositoriesView should update the tree selection if the "Link WithSelection" toggle is on. Change-Id: I02adb324696e6bf454cce4ebfd7ffbeae65f5e48 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
index 3762f74..161cb13 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
@@ -77,6 +77,9 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISelectionService;
@@ -260,11 +263,21 @@ public class RepositoriesView extends ViewPart implements ISelectionProvider {
public void selectionChanged(IWorkbenchPart part,
ISelection selection) {
+ // if the "link with selection" toggle is off, we're done
if (linkWithSelectionAction == null
|| !linkWithSelectionAction.isChecked())
return;
- reactOnSelection(selection);
+ // this may happen if we switch between editors
+ if (part instanceof IEditorPart) {
+ IEditorInput input = ((IEditorPart) part).getEditorInput();
+ if (input instanceof IFileEditorInput)
+ reactOnSelection(new StructuredSelection(
+ ((IFileEditorInput) input).getFile()));
+
+ } else {
+ reactOnSelection(selection);
+ }
}
});