Skip to content

Find/replace: centralize UI state notifications in FindReplaceLogic#4176

Merged
HeikoKlare merged 1 commit into
eclipse-platform:masterfrom
HeikoKlare:findreplace-overlay-logic-listeners
Jul 12, 2026
Merged

Find/replace: centralize UI state notifications in FindReplaceLogic#4176
HeikoKlare merged 1 commit into
eclipse-platform:masterfrom
HeikoKlare:findreplace-overlay-logic-listeners

Conversation

@HeikoKlare

@HeikoKlare HeikoKlare commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Motivation

Button enablement in the Find/Replace overlay was managed imperatively: toggle lambdas and search-bar listeners scattered setEnabled() calls across FindReplaceOverlay, replicating logic that FindReplaceLogic already 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

FindReplaceLogic now exposes two notification channels:

  • addSearchOptionActivationChangedListener — fires when an option is toggled on or off
  • addSearchOptionAvailabilityChangedListener — fires when the result of isAvailable() changes for an option

UI components subscribe to these channels and update themselves reactively. AccessibleToolItemBuilder registers both listeners for every button bound to a SearchOption, so FindReplaceOverlay no 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 FindReplaceLogic availability without the overlay manually orchestrating updates. This change prepares that future migration. It follows:


This change was created with the help of GitHub Copilot.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Test Results

   855 files  ± 0     855 suites  ±0   52m 5s ⏱️ + 1m 12s
 8 116 tests + 5   7 873 ✅ + 5  243 💤 ±0  0 ❌ ±0 
20 250 runs  +15  19 596 ✅ +15  654 💤 ±0  0 ❌ ±0 

Results for commit 81cbd7d. ± Comparison against base commit f4db045.

♻️ This comment has been updated with latest results.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@HeikoKlare HeikoKlare force-pushed the findreplace-overlay-logic-listeners branch from c78c0df to 81cbd7d Compare July 10, 2026 14:41
@HeikoKlare HeikoKlare marked this pull request as ready for review July 10, 2026 15:14
@HeikoKlare HeikoKlare merged commit 51109dc into eclipse-platform:master Jul 12, 2026
18 checks passed
@HeikoKlare HeikoKlare deleted the findreplace-overlay-logic-listeners branch July 12, 2026 07:42
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.

2 participants