Allow overriding texts and images of unified diff toolbar actions - #2978
Open
tobiasmelcher wants to merge 1 commit into
Open
tobiasmelcher wants to merge 1 commit into
tobiasmelcher wants to merge 1 commit into
Conversation
The unified diff toolbars label their built-in actions with generic wording such as "Apply" or "Revert". That wording assumes the diff is shown against another revision of the same file, and it becomes misleading when a client shows a diff between two unrelated sources, because it does not say what taking over a change actually does. Callers can now override the text and the image of each built-in action through the builder, keyed by the new ToolbarAction enum. Overriding an image with null removes it, so the action shows its text instead. Text and image overrides are independent, and an absent entry keeps the default, so a caller only adapts the actions it cares about.
Contributor
Author
|
Closing: opened against the wrong remote by mistake. Reopening on the correct repository. |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The unified diff toolbars label their built-in actions with generic wording
such as "Apply", "Revert" or "Keep". That wording carries an implicit
assumption: that the diff is shown between two revisions of the same file,
where "apply" unambiguously means "take over this change into my file".
That assumption does not hold for every client. We want to use the unified
diff in the ABAP Development Tools (ADT) for Eclipse to compare an ABAP
source against the same object in a different system. In that scenario the
two sides are not revisions of one file but the same development object in two
separate backends, and the generic labels no longer say what accepting a change
actually does or which system it affects. A client needs to be able to phrase
the actions in its own domain language to make the consequence of taking over a
change unambiguous to the user.
There was no way to do that: the texts and images of the built-in toolbar
actions were hard-coded in
UnifiedDiffManager, and the only extension point,additionalActions, appends further actions rather than adapting the existingones.
What this changes
UnifiedDiff.Buildergains two methods that let a caller override thepresentation of any built-in toolbar action, keyed by the new
UnifiedDiff.ToolbarActionenum:The enum covers all built-in actions of both toolbars, the one shown for all
diffs and the one shown for the hovered diff:
ACCEPT_ALL,HIDE_ALL,REVERT_ALL,KEEP_ALL,UNDO_ALL,PREVIOUS,NEXT,ACCEPT,HIDE,REVERT,KEEPandUNDO. Which of them appear depends on theUnifiedDiffMode; overrides for actions the current mode does not show aresimply ignored.
Semantics are intentionally narrow, so the default behaviour is untouched for
every existing caller:
cares about.
default image in place.
nullremoves it, which makes the action render itstext instead of an icon.
OpenCode was used to help review and refine this change.