Toolbar button to switch repositories in git views
commit56991ad4ed5b8977a641307802743601fc215e5f
authorThomas Wolf <thomas.wolf@paranor.ch>
Thu, 13 Jul 2017 08:30:53 +0000 (13 10:30 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Thu, 13 Jul 2017 21:00:42 +0000 (13 23:00 +0200)
treec6c8a1757dd622cd29d4cf50e5c1a6022f97337b
parent500d12d02986d3deb206d21975ccc6e87e7e7d73
Toolbar button to switch repositories in git views

Enable the user to quickly switch the staging view, the reflog
view, the rebase interactive view, or the history view from one
repository to another via a toolbar button with a drop-down menu
listing all currently configured git repositories. Switching in
one view makes all other EGit views that are linked to the current
selection also switch. The current repository of a view, if any,
is marked by a check mark in the menu.

Use the "repository" image for the new button. Change the icon
for "no filter" in history view to avoid a clash: instead of the
repository icon, use a struck-out filter icon.

Make sure all Git views provide selections that do adapt to
Repository. This was already the case for the repositories view,
the history view, and partly the staging view. For the reflog
view, add an adaptable DTO wrapper around ReflogEntry for the tree.
In staging view, add a MultiViewerSelectionProvider modeled after
the JDT's SelectionProviderMediator that can provide the selection
from whichever viewer has the focus. In the rebase interactive view,
make PlanElement adapt to Repository, and fix some other minor bugs:
don't clear when the linked selection is empty, don't show "No
Repository Selected" briefly when a bare repo is selected, react on
the initial selection in createControl() instead of remembering the
selection when the view was created. (If the view is hidden, the
selection may have changed by the time it is activated and its
control is created.)

Make the repositories view react on selection changes not only for
IResource or File but also for Repository.

Add special-purpose selection providers (RepositorySelectionProvider)
to the staging view, the reflog view, the history view, and the
rebase interactive view that provide a selection that identifies the
current repository in those views if it is otherwise empty. Use a
RepositoryNode for this to avoid multiple entries in the history
view's navigation history. Since all views' selection listener
mechanisms do handle a selection that adapts to Repository, this
makes all EGit views nicely switch in sync when the "current"
repository is changed in one of them.

Includes initial UI tests. However, for some unknown reason I cannot
get the test for the new button and the selection handling to work,
so it is ignored. Somehow the selection in the other views does not
get updated when run as a SWTBot test. Testing this is tricky anyway
because most of our views load asynchronously one way or another. To
be able to detect that for the staging view, I have made it use a
WorkbenchJob instead of a plain Display.asyncExec(). Alas, that didn't
help for that test.

Bug: 518607
Change-Id: I976df6e3bf0363c27b877d995344487bb622f037
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
23 files changed:
icons/org.eclipse.egit.ui/icons/elcl16/filter_none.svg [new file with mode: 0644]
org.eclipse.egit.core/src/org/eclipse/egit/core/RepositoryUtil.java
org.eclipse.egit.core/src/org/eclipse/egit/core/internal/rebase/RebaseInteractivePlan.java
org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/selection/SelectionForViewsTest.java [new file with mode: 0644]
org.eclipse.egit.ui/icons/elcl16/filter_none.png [new file with mode: 0644]
org.eclipse.egit.ui/icons/elcl16/filter_none@2x.png [new file with mode: 0644]
org.eclipse.egit.ui/plugin.xml
org.eclipse.egit.ui/src/org/eclipse/egit/ui/JobFamilies.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIIcons.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositoryMenuUtil.java [new file with mode: 0644]
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseInteractiveView.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogItem.java [new file with mode: 0644]
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogViewContentProvider.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/AbstractSelectionProvider.java [new file with mode: 0644]
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/MultiViewerSelectionProvider.java [new file with mode: 0644]
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/selection/RepositorySelectionProvider.java [new file with mode: 0644]
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties