Skip to content

Commit 19ee7f3

Browse files
committed
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.
1 parent fc4799a commit 19ee7f3

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ protected class PreferenceFilteredTree extends FilteredTree {
119119
super(parent, treeStyle, filter, true, true);
120120
}
121121

122+
@Override
123+
protected Text doCreateFilterText(Composite parent) {
124+
return new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
125+
}
126+
127+
@Override
128+
public void setInitialText(String text) {
129+
if (filterText != null && !filterText.isDisposed()) {
130+
filterText.setMessage(text != null ? text : ""); //$NON-NLS-1$
131+
}
132+
}
133+
122134
/**
123135
* Add an additional, optional filter to the viewer. If the filter text is
124136
* cleared, this filter will be removed from the TreeViewer.

0 commit comments

Comments
 (0)