1313 *******************************************************************************/
1414package org .eclipse .ui .internal .findandreplace .overlay ;
1515
16- import static org .eclipse .ui .internal .findandreplace .overlay .FindReplaceShortcutUtil .registerActionShortcutsAtControl ;
17-
1816import java .util .List ;
1917import java .util .function .Consumer ;
2018
2826import org .eclipse .swt .events .FocusEvent ;
2927import org .eclipse .swt .events .FocusListener ;
3028import org .eclipse .swt .events .KeyListener ;
31- import org .eclipse .swt .events .SelectionListener ;
3229import org .eclipse .swt .events .ShellAdapter ;
3330import org .eclipse .swt .events .ShellEvent ;
3431import org .eclipse .swt .graphics .Color ;
3734import org .eclipse .swt .graphics .RGBA ;
3835import org .eclipse .swt .graphics .Rectangle ;
3936import org .eclipse .swt .layout .GridData ;
40- import org .eclipse .swt .widgets .Button ;
4137import org .eclipse .swt .widgets .Composite ;
4238import org .eclipse .swt .widgets .Control ;
4339import 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