Skip to content

Commit 3a2e413

Browse files
Maximilian Wittmervogella
authored andcommitted
Implement a Modern Find/Replace-Overlay
This PR implements and tests a find/replace dialog which can be overlayed on top of the editor. The overlay uses the FindReplaceLogic which is also used by the existing find/replace dialog. The overlay can be enabled and disabled in the preferences. eclipse-platform#1090
1 parent 9e05ee3 commit 3a2e413

34 files changed

+1796
-10
lines changed

bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.ui.editors; singleton:=true
5-
Bundle-Version: 3.17.300.qualifier
5+
Bundle-Version: 3.18.0.qualifier
66
Bundle-Activator: org.eclipse.ui.internal.editors.text.EditorsPlugin
77
Bundle-ActivationPolicy: lazy
88
Bundle-Vendor: %providerName

bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ private OverlayPreferenceStore createDialogOverlayStore() {
428428
ArrayList<OverlayKey> overlayKeys= new ArrayList<>();
429429

430430
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_SPACES));
431+
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_FIND_REPLACE_OVERLAY));
432+
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_FIND_REPLACE_OVERLAY_AT_BOTTOM));
431433
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_ENCLOSED_SPACES));
432434
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TRAILING_SPACES));
433435
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_IDEOGRAPHIC_SPACES));
@@ -729,6 +731,8 @@ private OverlayPreferenceStore createOverlayStore() {
729731
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractTextEditor.PREFERENCE_COLOR_FIND_SCOPE));
730732

731733
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
734+
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_FIND_REPLACE_OVERLAY));
735+
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_FIND_REPLACE_OVERLAY_AT_BOTTOM));
732736
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
733737

734738
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH));
@@ -859,6 +863,15 @@ public void widgetSelected(SelectionEvent e) {
859863
IntegerDomain lineSpaceDomain= new IntegerDomain(0, 1000);
860864
addTextField(appearanceComposite, lineSpacing, lineSpaceDomain, 15, 0);
861865

866+
label= TextEditorMessages.TextEditorPreferencePage_useFindReplaceOverlay;
867+
Preference useFindReplaceOverlay= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_FIND_REPLACE_OVERLAY, label, null);
868+
final Button useOverlay= addCheckBox(appearanceComposite, useFindReplaceOverlay, new BooleanDomain(), 0);
869+
870+
label= TextEditorMessages.TextEditorPreferencePage_showFindReplaceOverlayAtBottom;
871+
Preference findReplaceOverlayAtBottom= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_FIND_REPLACE_OVERLAY_AT_BOTTOM, label, null);
872+
final Button overlayAtBottom= addCheckBox(appearanceComposite, findReplaceOverlayAtBottom, new BooleanDomain(), 0);
873+
createDependency(useOverlay, useFindReplaceOverlay, new Control[] { overlayAtBottom });
874+
862875
label= TextEditorMessages.TextEditorPreferencePage_enableWordWrap;
863876
Preference enableWordWrap= new Preference(AbstractTextEditor.PREFERENCE_WORD_WRAP_ENABLED, label, null);
864877
addCheckBox(appearanceComposite, enableWordWrap, new BooleanDomain(), 0);

bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ private TextEditorMessages() {
3535
public static String LinkedModeConfigurationBlock_DASHED_BOX;
3636
public static String TextEditorPreferencePage_displayedTabWidth;
3737
public static String TextEditorPreferencePage_lineSpacing;
38+
public static String TextEditorPreferencePage_useFindReplaceOverlay;
39+
public static String TextEditorPreferencePage_showFindReplaceOverlayAtBottom;
3840
public static String TextEditorPreferencePage_enableWordWrap;
3941
public static String TextEditorPreferencePage_convertTabsToSpaces;
4042
public static String TextEditorPreferencePage_undoHistorySize;

bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ EditorsPlugin_internal_error=Internal Error
1717

1818
TextEditorPreferencePage_displayedTabWidth=Displayed &tab width:
1919
TextEditorPreferencePage_lineSpacing=Line &spacing (extra % of font height):
20+
TextEditorPreferencePage_useFindReplaceOverlay=Use find/replace overla&y
21+
TextEditorPreferencePage_showFindReplaceOverlayAtBottom=&Display find/replace overlay at bottom of editor
2022
TextEditorPreferencePage_enableWordWrap=&Enable word wrap when opening an editor
2123
TextEditorPreferencePage_convertTabsToSpaces=&Insert spaces for tabs
2224
TextEditorPreferencePage_undoHistorySize=&Undo history size:

bundles/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,30 @@ private AbstractDecoratedTextEditorPreferenceConstants() {
220220
* </p>
221221
*/
222222
public final static String EDITOR_LINE_NUMBER_RULER= "lineNumberRuler"; //$NON-NLS-1$
223+
224+
/**
225+
* A named preference that controls whether the find/replace overlay is used in place of the
226+
* dialog.
227+
*
228+
* <p>
229+
* The preference value is of type <code>Boolean</code>
230+
* </p>
231+
*
232+
* @since 3.18
233+
*/
234+
public final static String EDITOR_USE_FIND_REPLACE_OVERLAY= "useFindReplaceOverlay"; //$NON-NLS-1$
235+
236+
/**
237+
* A named preference that controls whether the editor overlay to access find and replace
238+
* functionality should be aligned to the bottom of the editor page instead of to the top.
239+
*
240+
* <p>
241+
* The preference value is of type <code>Boolean</code>
242+
* </p>
243+
*
244+
* @since 3.18
245+
*/
246+
public final static String EDITOR_FIND_REPLACE_OVERLAY_AT_BOTTOM= "findReplaceOverlayAtBottom"; //$NON-NLS-1$
223247

224248
/**
225249
* A named preference that controls if the caret offset is shown in the status line.
@@ -723,6 +747,8 @@ private AbstractDecoratedTextEditorPreferenceConstants() {
723747
* @param store the preference store to be initialized
724748
*/
725749
public static void initializeDefaultValues(IPreferenceStore store) {
750+
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_FIND_REPLACE_OVERLAY, true);
751+
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_FIND_REPLACE_OVERLAY_AT_BOTTOM, false);
726752
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.USE_ANNOTATIONS_PREFERENCE_PAGE, false);
727753
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE, false);
728754

bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Require-Bundle:
3131
org.eclipse.core.expressions;bundle-version="[3.4.100,4.0.0)",
3232
org.eclipse.jface.text;bundle-version="[3.19.0,4.0.0)",
3333
org.eclipse.swt;bundle-version="[3.107.0,4.0.0)",
34-
org.eclipse.ui;bundle-version="[3.5.0,4.0.0)"
34+
org.eclipse.ui;bundle-version="[3.5.0,4.0.0)",
35+
org.eclipse.jface.notifications
3536
Bundle-RequiredExecutionEnvironment: JavaSE-17
3637
Automatic-Module-Name: org.eclipse.ui.workbench.texteditor
418 Bytes
Loading
870 Bytes
Loading
315 Bytes
Loading
524 Bytes
Loading

0 commit comments

Comments
 (0)