Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2018-11-02 19:45:37 +0000
committerMichael Keppler2018-11-10 07:01:42 +0000
commitc7940ec94c58879eefe5e74d21e8621b09a438d6 (patch)
tree7bf4176a2a9e77dd7c74ec6a5f4becbbbfb03e56
parent31b6558aba3aeb04f1fd8a7593e6af97790e7c54 (diff)
downloadegit-c7940ec94c58879eefe5e74d21e8621b09a438d6.tar.gz
egit-c7940ec94c58879eefe5e74d21e8621b09a438d6.tar.xz
egit-c7940ec94c58879eefe5e74d21e8621b09a438d6.zip
Have an initially selected repository in Reflog
The reflog view already tracks the workbench selection to show the matching repository. Therefore it is reasonable to show the repository for the current selection when opening the view. This avoids that the user has to either first select the repository from the toolbar or to click somewhere to explicitly set the selection. Bug: 539799 Change-Id: I84d9ddeef9dda4867bbc359a1a399ff3508760d0 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java
index 738c5d01f4..b9bced1f37 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java
@@ -86,6 +86,7 @@ import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.OpenAndLinkWithEditorHelper;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
@@ -403,6 +404,31 @@ public class ReflogView extends ViewPart implements RefsChangedListener, IShowIn
menuManager.add(resetManager);
getSite().registerContextMenu(POPUP_MENU_ID, menuManager, refLogTableTreeViewer);
+
+ showInitialSelection();
+ }
+
+ /**
+ * try to automatically show a repository when opening the view
+ */
+ private void showInitialSelection() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow();
+ if (window == null) {
+ return;
+ }
+ IEditorPart editor = window.getActivePage().getActiveEditor();
+ if (editor != null) {
+ IEditorInput input = editor.getEditorInput();
+ Repository repository = AdapterUtils.adapt(input, Repository.class);
+ if (repository != null) {
+ reactOnSelection(new StructuredSelection(repository));
+ }
+ } else {
+ IStructuredSelection selection = (IStructuredSelection) window
+ .getSelectionService().getSelection();
+ reactOnSelection(selection);
+ }
}
@Override

Back to the top