Clean up "Compare With" actions
commitf9bf65864c70e585bf1bcfa0149195714e4441a4
authorThomas Wolf <thomas.wolf@paranor.ch>
Thu, 13 Oct 2016 21:47:53 +0000 (13 23:47 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 18 Oct 2016 22:04:11 +0000 (19 00:04 +0200)
treec9a3d18932027f7d3945d871245fa851e2d42e8e
parent0e3aece4717f76664cbcdfa00444675e8bff5a80
Clean up "Compare With" actions

Replace the old-style <objectContribution> to org.eclipse.ui.popupMenus
by command/handler combos. Remove the defaultHandlers for those
commands, and the now unused legacy actions. Re-order the commands as
they were.

Prevent the "Compare With" menu from appearing in the context menus of
the left or right ruler in editors: apply the same work-around as for
the "Team" menu, i.e., suppress the menu for #OverviewRulerContext and
for #AbstractTextEditorRulerContext.

There should be no functional or visual change except that the commands
are hidden completely when not enabled (as opposed to being visible but
disabled).

The four commands had to be handled in one change to preserve the order
in which they appear in the sub-menu. Doing this one by one would lead
to intermediary states where the order was different.

* CompareIndexWithHead: activate the handler on a single selection for
  which hasStagedChanges() is true. Hide it when not enabled. Make the
  ResourceStatePropertyTester also work for items that adapt
  only to IPath but not to IResource, like StagingEntry, otherwise
  the new <handler> definition would not be active for those, which
  would have broken the comparison on a staged file (double click) in
  the staging view. Remove the now unused CompareIndexWithHeadAction,
  and the alwaysCheckEnabled() work-around.

* CompareWithPrevious: activate handler only if the selection indeed
  has tracked resources. Formerly, the command was enabled for
  untracked resources, but then presented a dialog that it couldn't
  find any previous version. Add a new property "hasTrackedResources"
  to the ResourceStatePropertyTester.

* CompareWithIndex: de-activate the handler if there are only ignored
  resources in the selection. The command works in that case, too, but
  simply presented an empty comparison in that case, which is a bit
  pointless.

  Prevent NPE in CompareTreeView if the comparison is empty.

* CompareWithHead: disable if there are no non-ignored resources in
  the selection.

Bug: 495064
Change-Id: Ia9fd7768f417f2d2ac08fd271a04da9da15cc7c7
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
org.eclipse.egit.ui/plugin.xml
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareIndexWithHeadAction.java [deleted file]
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareIndexWithHeadActionHandler.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareWithHeadAction.java [deleted file]
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareWithIndexAction.java [deleted file]
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareWithPreviousAction.java [deleted file]
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CompareTreeView.java
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/resources/ResourceStatePropertyTester.java