Skip to content

Allow overriding texts and images of unified diff toolbar actions - #2978

Open
tobiasmelcher wants to merge 1 commit into
eclipse-platform:masterfrom
tobiasmelcher:d031119/unified-diff-toolbar-action-labels
Open

tobiasmelcher wants to merge 1 commit into
eclipse-platform:masterfrom
tobiasmelcher:d031119/unified-diff-toolbar-action-labels

Conversation

@tobiasmelcher

@tobiasmelcher tobiasmelcher commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

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 existing
ones.

What this changes

UnifiedDiff.Builder gains two methods that let a caller override the
presentation of any built-in toolbar action, keyed by the new
UnifiedDiff.ToolbarAction enum:

UnifiedDiff.create(editor, source, UnifiedDiffMode.OVERLAY_MODE)
    .toolbarActionText(ToolbarAction.ACCEPT_ALL, "Take over all changes from QAS")
    .toolbarActionText(ToolbarAction.ACCEPT, "Take over this change from QAS")
    .open();

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, KEEP and UNDO. Which of them appear depends on the
UnifiedDiffMode; overrides for actions the current mode does not show are
simply ignored.

Semantics are intentionally narrow, so the default behaviour is untouched for
every existing caller:

  • An absent entry keeps the default, so a client only adapts the actions it
    cares about.
  • Text and image overrides are independent: overriding only the text leaves the
    default image in place.
  • Overriding an image with null removes it, which makes the action render its
    text instead of an icon.

OpenCode was used to help review and refine this change.

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.
@tobiasmelcher

Copy link
Copy Markdown
Contributor Author

Closing: opened against the wrong remote by mistake. Reopening on the correct repository.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ± 0      54 suites  ±0   58m 10s ⏱️ + 1m 49s
 4 852 tests + 8   4 830 ✅ + 8   22 💤 ±0  0 ❌ ±0 
12 447 runs  +24  12 293 ✅ +24  154 💤 ±0  0 ❌ ±0 

Results for commit cf77eed. ± Comparison against base commit 196685d.

♻️ This comment has been updated with latest results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant