Skip to content

Commit 8a48723

Browse files
committed
FindReplaceOverlay: Add "skip replace" button
support the workflow in which a user selectively wants to replace multiple occurrences but needs to check first which to replace. Adds a button associated to a shortcut which - when triggered - simply jumps to the next occurrence of the search term.
1 parent c5928bb commit 8a48723

File tree

6 files changed

+14
-0
lines changed

6 files changed

+14
-0
lines changed
496 Bytes
Loading
991 Bytes
Loading

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceMessages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ private FindReplaceMessages() {
5353
public static String FindReplace_WholeWordCheckBox_label;
5454
public static String FindReplace_IncrementalCheckBox_label;
5555
public static String FindReplace_RegExCheckbox_label;
56+
public static String FindReplaceOverlay_skipReplaceButton_toolTip;
5657
public static String FindReplace_FindNextButton_label;
5758
public static String FindReplace_ReplaceFindButton_label;
5859
public static String FindReplace_ReplaceSelectionButton_label;

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/FindReplaceMessages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ FindReplaceOverlay_regexSearchButton_toolTip=Match regular expression pattern
5555
FindReplaceOverlay_caseSensitiveButton_toolTip=Match case
5656
FindReplaceOverlay_wholeWordsButton_toolTip=Match whole word
5757
FindReplaceOverlay_replaceButton_toolTip=Replace
58+
FindReplaceOverlay_skipReplaceButton_toolTip=Don't replace this occurrence and jump to the next
5859
FindReplaceOverlay_replaceAllButton_toolTip=Replace all
5960
FindReplaceOverlay_searchBar_message=Find (\u2195 for history)
6061
FindReplaceOverlay_replaceBar_message=Replace (\u2195 for history)

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ private final class KeyboardShortcuts {
9797
KeyStroke.getInstance(SWT.MOD1, 'f'));
9898
private static final List<KeyStroke> TOGGLE_REPLACE = List.of( //
9999
KeyStroke.getInstance(SWT.MOD1, 'R'), KeyStroke.getInstance(SWT.MOD1, 'r'));
100+
public static final List<KeyStroke> SKIP_REPLACE = List.of( //
101+
KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'O'), KeyStroke.getInstance(SWT.MOD1 | SWT.SHIFT, 'o'));
100102
}
101103

102104
public static final String ID_DATA_KEY = "org.eclipse.ui.internal.findreplace.overlay.FindReplaceOverlay.id"; //$NON-NLS-1$
@@ -136,6 +138,7 @@ private final class KeyboardShortcuts {
136138
private Composite replaceBarContainer;
137139
private HistoryTextWrapper replaceBar;
138140
private AccessibleToolBar replaceTools;
141+
private ToolItem skipReplaceButton;
139142
private ToolItem replaceButton;
140143
private ToolItem replaceAllButton;
141144

@@ -291,6 +294,7 @@ private void assignIDs() {
291294

292295
if (replaceBarOpen) {
293296
replaceBar.setData(ID_DATA_KEY, "replaceInput");
297+
skipReplaceButton.setData(ID_DATA_KEY, "skipReplace");
294298
replaceButton.setData(ID_DATA_KEY, "replaceOne");
295299
replaceAllButton.setData(ID_DATA_KEY, "replaceAll");
296300
}
@@ -511,6 +515,12 @@ private void createReplaceTools() {
511515
replaceTools.createToolItem(SWT.SEPARATOR);
512516

513517
GridDataFactory.fillDefaults().grab(false, true).align(GridData.CENTER, GridData.END).applyTo(replaceTools);
518+
519+
skipReplaceButton = new AccessibleToolItemBuilder(replaceTools).withStyleBits(SWT.PUSH)
520+
.withImage(FindReplaceOverlayImages.get(FindReplaceOverlayImages.KEY_SKIP_REPLACE))
521+
.withToolTipText(FindReplaceMessages.FindReplaceOverlay_skipReplaceButton_toolTip)
522+
.withOperation(() -> performSearch(true)).withShortcuts(KeyboardShortcuts.SKIP_REPLACE).build();
523+
514524
replaceButton = new AccessibleToolItemBuilder(replaceTools).withStyleBits(SWT.PUSH)
515525
.withImage(FindReplaceOverlayImages.get(FindReplaceOverlayImages.KEY_REPLACE))
516526
.withToolTipText(FindReplaceMessages.FindReplaceOverlay_replaceButton_toolTip)

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlayImages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class FindReplaceOverlayImages {
4747
static final String KEY_OPEN_REPLACE_AREA = PREFIX_ELCL + "open_replace"; //$NON-NLS-1$
4848
static final String KEY_CLOSE_REPLACE_AREA = PREFIX_ELCL + "close_replace"; //$NON-NLS-1$
4949
static final String KEY_OPEN_HISTORY = "open_history"; //$NON-NLS-1$
50+
public static final String KEY_SKIP_REPLACE = PREFIX_ELCL + "skip_replace"; //$NON-NLS-1$
5051

5152
/**
5253
* The image registry containing {@link Image images}.
@@ -74,6 +75,7 @@ private static void declareImages() {
7475
declareRegistryImage(KEY_OPEN_REPLACE_AREA, ELCL + "open_replace.png"); //$NON-NLS-1$
7576
declareRegistryImage(KEY_CLOSE_REPLACE_AREA, ELCL + "close_replace.png"); //$NON-NLS-1$
7677
declareRegistryImage(KEY_OPEN_HISTORY, ELCL + "open_history.png"); //$NON-NLS-1$
78+
declareRegistryImage(KEY_SKIP_REPLACE, ELCL + "skip_replace.png"); //$NON-NLS-1$
7779
}
7880

7981
/**

0 commit comments

Comments
 (0)