Find/replace: centralize UI state notifications in FindReplaceLogic#4176
Merged
HeikoKlare merged 1 commit intoJul 12, 2026
Merged
Conversation
Contributor
f3d2fd0 to
1d5a79b
Compare
1d5a79b to
c78c0df
Compare
There was a problem hiding this comment.
Pull request overview
This PR continues the Find/Replace overlay refactor by moving UI enablement/selection updates out of FindReplaceOverlay and into FindReplaceLogic notifications, so widgets can react to logic state changes instead of being updated imperatively by the overlay.
Changes:
- Replaced the single “option changed” listener with an explicit activation-change listener API on
IFindReplaceLogic/FindReplaceLogic. - Introduced an availability-change listener API and used it to drive tool item enablement from
isAvailable(...). - Updated overlay wiring (notably REGEX) and expanded tests to cover availability notifications (currently for
WHOLE_WORD).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/internal/findandreplace/FindReplaceLogicTest.java | Updates activation listener tests and adds availability listener tests (for whole-word scenarios). |
| bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java | Removes ad-hoc UI updates and relies more on logic-driven notifications for REGEX-related UI refresh. |
| bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/AccessibleToolItemBuilder.java | Binds tool item selection to activation notifications and enablement to availability notifications. |
| bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/IFindReplaceLogic.java | Splits listener API into activation-change vs availability-change channels with documentation. |
| bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceLogic.java | Implements the new listener channels and emits availability notifications (currently limited in scope). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Previously, the overlay managed button enablement imperatively: toggle lambdas and search-bar listeners scattered setEnabled() calls across FindReplaceOverlay, replicating logic that FindReplaceLogic already encapsulates internally. FindReplaceLogic now exposes two notification channels - addSearchOptionActivationChangedListener and addSearchOptionAvailabilityChangedListener - so that UI components can subscribe to state changes rather than polling after each mutation. AccessibleToolItemBuilder registers both listeners for every button bound to a SearchOption, removing the need for the overlay to know which widgets to update when logic state changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c78c0df to
81cbd7d
Compare
This was referenced Jul 12, 2026
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.
Motivation
Button enablement in the Find/Replace overlay was managed imperatively: toggle lambdas and search-bar listeners scattered
setEnabled()calls acrossFindReplaceOverlay, replicating logic thatFindReplaceLogicalready encapsulates internally. This made it easy to miss update sites, apply updates in the wrong order, or have the UI diverge from the actual logic state.This is part of the ongoing effort to separate UI setup from controller logic in the Find/Replace overlay, tracked in issue #1912.
Change
FindReplaceLogicnow exposes two notification channels:addSearchOptionActivationChangedListener— fires when an option is toggled on or offaddSearchOptionAvailabilityChangedListener— fires when the result ofisAvailable()changes for an optionUI components subscribe to these channels and update themselves reactively.
AccessibleToolItemBuilderregisters both listeners for every button bound to aSearchOption, soFindReplaceOverlayno longer needs to know which widgets to update when logic state changes.Towards proper Eclipse key binding handlers
Having the logic state drive UI state reactively through well-defined listener channels is a prerequisite for introducing proper Eclipse command-framework handlers for the overlay actions: the handler enablement state must be kept in sync with
FindReplaceLogicavailability without the overlay manually orchestrating updates. This change prepares that future migration. It follows:This change was created with the help of GitHub Copilot.