From 19ee7f3d45bdf482918850a39e4fc200325287c4 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Wed, 22 Apr 2026 20:31:34 +0200 Subject: [PATCH] PreferenceDialog: render filter as native search field Give the preference dialog's filter field the full set of search-related style bits (SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL) so it is rendered as a native search field with a magnifier and cancel icon. Also override setInitialText to expose the hint via Text#setMessage only, instead of stuffing it into the field's content. The dialog auto-focuses the filter field on open, so the old initial-text fallback was never actually shown as a placeholder and forced users to delete the hint before typing. --- .../internal/dialogs/FilteredPreferenceDialog.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java index ece0dac34d7..9c281e7d07d 100644 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java +++ b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java @@ -119,6 +119,18 @@ protected class PreferenceFilteredTree extends FilteredTree { super(parent, treeStyle, filter, true, true); } + @Override + protected Text doCreateFilterText(Composite parent) { + return new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); + } + + @Override + public void setInitialText(String text) { + if (filterText != null && !filterText.isDisposed()) { + filterText.setMessage(text != null ? text : ""); //$NON-NLS-1$ + } + } + /** * Add an additional, optional filter to the viewer. If the filter text is * cleared, this filter will be removed from the TreeViewer.