Skip to content

Commit 4d28260

Browse files
committed
Find/replace overlay: improve replace toggle button appearance
The button to toggle whether the replace bar in a find/replace overlay is shown currently appears to be a rather heavyweight button with a border. With this change, the button is replace with a lightweight toolbar item like used for all other buttons in the overlay. This improves the appearance as well as the implementation as the same implementation patterns can now be applied to all buttons in the overlay.
1 parent f35ef3a commit 4d28260

File tree

1 file changed

+15
-19
lines changed
  • bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay

1 file changed

+15
-19
lines changed

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

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
*******************************************************************************/
1414
package org.eclipse.ui.internal.findandreplace.overlay;
1515

16-
import static org.eclipse.ui.internal.findandreplace.overlay.FindReplaceShortcutUtil.registerActionShortcutsAtControl;
17-
1816
import java.util.List;
1917
import java.util.function.Consumer;
2018

@@ -28,7 +26,6 @@
2826
import org.eclipse.swt.events.FocusEvent;
2927
import org.eclipse.swt.events.FocusListener;
3028
import org.eclipse.swt.events.KeyListener;
31-
import org.eclipse.swt.events.SelectionListener;
3229
import org.eclipse.swt.events.ShellAdapter;
3330
import org.eclipse.swt.events.ShellEvent;
3431
import org.eclipse.swt.graphics.Color;
@@ -37,7 +34,6 @@
3734
import org.eclipse.swt.graphics.RGBA;
3835
import org.eclipse.swt.graphics.Rectangle;
3936
import org.eclipse.swt.layout.GridData;
40-
import org.eclipse.swt.widgets.Button;
4137
import org.eclipse.swt.widgets.Composite;
4238
import org.eclipse.swt.widgets.Control;
4339
import org.eclipse.swt.widgets.Display;
@@ -117,8 +113,8 @@ private final class KeyboardShortcuts {
117113
private boolean replaceBarOpen;
118114

119115
private Composite container;
120-
private Button replaceToggle;
121-
private FindReplaceOverlayAction replaceToggleShortcut;
116+
private AccessibleToolBar replaceToggleTools;
117+
private ToolItem replaceToggle;
122118

123119
private Composite contentGroup;
124120

@@ -474,7 +470,7 @@ private Control createDialog(final Composite parent) {
474470
private void initializeSearchShortcutHandlers() {
475471
searchTools.registerActionShortcutsAtControl(searchBar);
476472
closeTools.registerActionShortcutsAtControl(searchBar);
477-
registerActionShortcutsAtControl(replaceToggleShortcut, searchBar);
473+
replaceToggleTools.registerActionShortcutsAtControl(searchBar);
478474
}
479475

480476
/**
@@ -712,15 +708,15 @@ private void createMainContainer(final Composite parent) {
712708
}
713709

714710
private void createReplaceToggle() {
715-
replaceToggleShortcut = new FindReplaceOverlayAction(this::toggleReplace);
716-
replaceToggleShortcut.addShortcuts(KeyboardShortcuts.TOGGLE_REPLACE);
717-
replaceToggle = new Button(container, SWT.FLAT | SWT.PUSH);
718-
GridDataFactory.fillDefaults().grab(false, true).align(GridData.BEGINNING, GridData.FILL)
719-
.applyTo(replaceToggle);
720-
replaceToggle.setToolTipText(replaceToggleShortcut
721-
.addShortcutHintToTooltipText(FindReplaceMessages.FindReplaceOverlay_replaceToggle_toolTip));
722-
replaceToggle.setImage(FindReplaceOverlayImages.get(FindReplaceOverlayImages.KEY_OPEN_REPLACE_AREA));
723-
replaceToggle.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> toggleReplace()));
711+
replaceToggleTools = new AccessibleToolBar(container);
712+
GridDataFactory.fillDefaults().grab(false, true).align(GridData.CENTER, GridData.CENTER)
713+
.applyTo(replaceToggleTools);
714+
715+
replaceToggle = new AccessibleToolItemBuilder(replaceToggleTools)
716+
.withShortcuts(KeyboardShortcuts.TOGGLE_REPLACE)
717+
.withImage(FindReplaceOverlayImages.get(FindReplaceOverlayImages.KEY_OPEN_REPLACE_AREA))
718+
.withToolTipText(FindReplaceMessages.FindReplaceOverlay_replaceToggle_toolTip)
719+
.withOperation(this::toggleReplace).build();
724720
}
725721

726722
private void toggleReplace() {
@@ -765,7 +761,7 @@ private void createReplaceDialog() {
765761
private void initializeReplaceShortcutHandlers() {
766762
replaceTools.registerActionShortcutsAtControl(replaceBar);
767763
closeTools.registerActionShortcutsAtControl(replaceBar);
768-
registerActionShortcutsAtControl(replaceToggleShortcut, replaceBar);
764+
replaceToggleTools.registerActionShortcutsAtControl(replaceBar);
769765
}
770766

771767
private void enableSearchTools(boolean enable) {
@@ -778,8 +774,8 @@ private void enableReplaceToggle(boolean enable) {
778774
return;
779775
}
780776
boolean visible = enable && findReplaceLogic.getTarget().isEditable();
781-
((GridData) replaceToggle.getLayoutData()).exclude = !visible;
782-
replaceToggle.setVisible(visible);
777+
((GridData) replaceToggleTools.getLayoutData()).exclude = !visible;
778+
replaceToggleTools.setVisible(visible);
783779
}
784780

785781
private void enableReplaceTools(boolean enable) {

0 commit comments

Comments
 (0)