4242import org .eclipse .swt .widgets .Scrollable ;
4343import org .eclipse .swt .widgets .Shell ;
4444import org .eclipse .swt .widgets .Text ;
45- import org .eclipse .swt .widgets .ToolBar ;
4645import org .eclipse .swt .widgets .ToolItem ;
4746import org .eclipse .swt .widgets .Widget ;
4847
@@ -89,7 +88,7 @@ class FindReplaceOverlay extends Dialog {
8988 private Composite searchContainer ;
9089 private Composite searchBarContainer ;
9190 private Text searchBar ;
92- private ToolBar searchTools ;
91+ private AccessibleToolBar searchTools ;
9392
9493 private ToolItem searchInSelectionButton ;
9594 private ToolItem wholeWordSearchButton ;
@@ -102,7 +101,7 @@ class FindReplaceOverlay extends Dialog {
102101 private Composite replaceContainer ;
103102 private Composite replaceBarContainer ;
104103 private Text replaceBar ;
105- private ToolBar replaceTools ;
104+ private AccessibleToolBar replaceTools ;
106105 private ToolItem replaceButton ;
107106 private ToolItem replaceAllButton ;
108107
@@ -432,7 +431,7 @@ private void retrieveBackgroundColor() {
432431 }
433432
434433 private void createSearchTools () {
435- searchTools = new ToolBar (searchContainer , SWT . HORIZONTAL );
434+ searchTools = new AccessibleToolBar (searchContainer );
436435 GridDataFactory .fillDefaults ().grab (false , true ).align (GridData .CENTER , GridData .END ).applyTo (searchTools );
437436
438437 createWholeWordsButton ();
@@ -441,104 +440,106 @@ private void createSearchTools() {
441440 createAreaSearchButton ();
442441
443442 @ SuppressWarnings ("unused" )
444- ToolItem separator = new ToolItem (searchTools , SWT .SEPARATOR );
445-
446- searchUpButton = new ToolItem (searchTools , SWT .PUSH );
447- searchUpButton .setImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_FIND_PREV ));
448- searchUpButton .setToolTipText (FindReplaceMessages .FindReplaceOverlay_upSearchButton_toolTip );
449- searchUpButton .addSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
450- performSearch (false );
451- evaluateFindReplaceStatus ();
452- }));
453- searchDownButton = new ToolItem (searchTools , SWT .PUSH );
443+ ToolItem separator = searchTools .createToolItem (SWT .SEPARATOR );
444+
445+ searchUpButton = new AccessibleToolItemBuilder (searchTools ).withStyleBits (SWT .PUSH )
446+ .withImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_FIND_PREV ))
447+ .withToolTipText (FindReplaceMessages .FindReplaceOverlay_upSearchButton_toolTip )
448+ .withSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
449+ performSearch (false );
450+ evaluateFindReplaceStatus ();
451+ })).build ();
452+ searchDownButton = new AccessibleToolItemBuilder (searchTools ).withStyleBits (SWT .PUSH )
453+ .withImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_FIND_NEXT ))
454+ .withToolTipText (FindReplaceMessages .FindReplaceOverlay_downSearchButton_toolTip )
455+ .withSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
456+ performSearch (true );
457+ evaluateFindReplaceStatus ();
458+ })).build ();
454459 searchDownButton .setSelection (true ); // by default, search down
455- searchDownButton .setImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_FIND_NEXT ));
456- searchDownButton .setToolTipText (FindReplaceMessages .FindReplaceOverlay_downSearchButton_toolTip );
457- searchDownButton .addSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
458- performSearch (true );
459- evaluateFindReplaceStatus ();
460- }));
461- searchAllButton = new ToolItem (searchTools , SWT .PUSH );
462- searchAllButton .setImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_SEARCH_ALL ));
463- searchAllButton .setToolTipText (FindReplaceMessages .FindReplaceOverlay_searchAllButton_toolTip );
464- searchAllButton .addSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
465- performSelectAll ();
466- evaluateFindReplaceStatus ();
467- }));
460+
461+ searchAllButton = new AccessibleToolItemBuilder (searchTools ).withStyleBits (SWT .PUSH )
462+ .withImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_SEARCH_ALL ))
463+ .withToolTipText (FindReplaceMessages .FindReplaceOverlay_searchAllButton_toolTip )
464+ .withSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
465+ performSelectAll ();
466+ evaluateFindReplaceStatus ();
467+ })).build ();
468468 }
469469
470470 private void createAreaSearchButton () {
471- searchInSelectionButton = new ToolItem (searchTools , SWT .CHECK );
472- searchInSelectionButton .setImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_SEARCH_IN_AREA ));
473- searchInSelectionButton .setToolTipText (FindReplaceMessages .FindReplaceOverlay_searchInSelectionButton_toolTip );
471+ searchInSelectionButton = new AccessibleToolItemBuilder (searchTools ).withStyleBits (SWT .CHECK )
472+ .withImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_SEARCH_IN_AREA ))
473+ .withToolTipText (FindReplaceMessages .FindReplaceOverlay_searchInSelectionButton_toolTip )
474+ .withSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
475+ activateInFindReplacerIf (SearchOptions .GLOBAL , !searchInSelectionButton .getSelection ());
476+ updateIncrementalSearch ();
477+ })).build ();
474478 searchInSelectionButton .setSelection (findReplaceLogic .isActive (SearchOptions .WHOLE_WORD ));
475- searchInSelectionButton .addSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
476- activateInFindReplacerIf (SearchOptions .GLOBAL , !searchInSelectionButton .getSelection ());
477- updateIncrementalSearch ();
478- }));
479479 }
480480
481481 private void createRegexSearchButton () {
482- regexSearchButton = new ToolItem (searchTools , SWT .CHECK );
483- regexSearchButton .setImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_FIND_REGEX ));
484- regexSearchButton .setToolTipText (FindReplaceMessages .FindReplaceOverlay_regexSearchButton_toolTip );
482+ regexSearchButton = new AccessibleToolItemBuilder (searchTools ).withStyleBits (SWT .CHECK )
483+ .withImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_FIND_REGEX ))
484+ .withToolTipText (FindReplaceMessages .FindReplaceOverlay_regexSearchButton_toolTip )
485+ .withSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
486+ activateInFindReplacerIf (SearchOptions .REGEX , ((ToolItem ) e .widget ).getSelection ());
487+ wholeWordSearchButton .setEnabled (!findReplaceLogic .isActive (SearchOptions .REGEX ));
488+ updateIncrementalSearch ();
489+ })).build ();
485490 regexSearchButton .setSelection (findReplaceLogic .isActive (SearchOptions .REGEX ));
486- regexSearchButton .addSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
487- activateInFindReplacerIf (SearchOptions .REGEX , ((ToolItem ) e .widget ).getSelection ());
488- wholeWordSearchButton .setEnabled (!findReplaceLogic .isActive (SearchOptions .REGEX ));
489- updateIncrementalSearch ();
490- }));
491491 }
492492
493493 private void createCaseSensitiveButton () {
494- caseSensitiveSearchButton = new ToolItem (searchTools , SWT .CHECK );
495- caseSensitiveSearchButton .setImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_CASE_SENSITIVE ));
496- caseSensitiveSearchButton .setToolTipText (FindReplaceMessages .FindReplaceOverlay_caseSensitiveButton_toolTip );
494+ caseSensitiveSearchButton = new AccessibleToolItemBuilder (searchTools ).withStyleBits (SWT .CHECK )
495+ .withImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_CASE_SENSITIVE ))
496+ .withToolTipText (FindReplaceMessages .FindReplaceOverlay_caseSensitiveButton_toolTip )
497+ .withSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
498+ activateInFindReplacerIf (SearchOptions .CASE_SENSITIVE , caseSensitiveSearchButton .getSelection ());
499+ updateIncrementalSearch ();
500+ })).build ();
497501 caseSensitiveSearchButton .setSelection (findReplaceLogic .isActive (SearchOptions .CASE_SENSITIVE ));
498- caseSensitiveSearchButton .addSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
499- activateInFindReplacerIf (SearchOptions .CASE_SENSITIVE , caseSensitiveSearchButton .getSelection ());
500- updateIncrementalSearch ();
501- }));
502502 }
503503
504504 private void createWholeWordsButton () {
505- wholeWordSearchButton = new ToolItem (searchTools , SWT .CHECK );
506- wholeWordSearchButton .setImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_WHOLE_WORD ));
507- wholeWordSearchButton .setToolTipText (FindReplaceMessages .FindReplaceOverlay_wholeWordsButton_toolTip );
505+ wholeWordSearchButton = new AccessibleToolItemBuilder (searchTools ).withStyleBits (SWT .CHECK )
506+ .withImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_WHOLE_WORD ))
507+ .withToolTipText (FindReplaceMessages .FindReplaceOverlay_wholeWordsButton_toolTip )
508+ .withSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
509+ activateInFindReplacerIf (SearchOptions .WHOLE_WORD , wholeWordSearchButton .getSelection ());
510+ updateIncrementalSearch ();
511+ })).build ();
508512 wholeWordSearchButton .setSelection (findReplaceLogic .isActive (SearchOptions .WHOLE_WORD ));
509- wholeWordSearchButton .addSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
510- activateInFindReplacerIf (SearchOptions .WHOLE_WORD , wholeWordSearchButton .getSelection ());
511- updateIncrementalSearch ();
512- }));
513513 }
514514
515515 private void createReplaceTools () {
516516 Color warningColor = JFaceColors .getErrorText (getShell ().getDisplay ());
517517
518- replaceTools = new ToolBar (replaceContainer , SWT . HORIZONTAL );
518+ replaceTools = new AccessibleToolBar (replaceContainer );
519519 GridDataFactory .fillDefaults ().grab (false , true ).align (GridData .CENTER , GridData .END ).applyTo (replaceTools );
520- replaceButton = new ToolItem (replaceTools , SWT .PUSH );
521- replaceButton .setImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_REPLACE ));
522- replaceButton .setToolTipText (FindReplaceMessages .FindReplaceOverlay_replaceButton_toolTip );
523- replaceButton .addSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
524- if (getFindString ().isEmpty ()) {
525- showUserFeedback (warningColor , true );
526- return ;
527- }
528- performSingleReplace ();
529- evaluateFindReplaceStatus ();
530- }));
531- replaceAllButton = new ToolItem (replaceTools , SWT .PUSH );
532- replaceAllButton .setImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_REPLACE_ALL ));
533- replaceAllButton .setToolTipText (FindReplaceMessages .FindReplaceOverlay_replaceAllButton_toolTip );
534- replaceAllButton .addSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
535- if (getFindString ().isEmpty ()) {
536- showUserFeedback (warningColor , true );
537- return ;
538- }
539- performReplaceAll ();
540- evaluateFindReplaceStatus ();
541- }));
520+ replaceButton = new AccessibleToolItemBuilder (replaceTools ).withStyleBits (SWT .PUSH )
521+ .withImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_REPLACE ))
522+ .withToolTipText (FindReplaceMessages .FindReplaceOverlay_replaceButton_toolTip )
523+ .withSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
524+ if (getFindString ().isEmpty ()) {
525+ showUserFeedback (warningColor , true );
526+ return ;
527+ }
528+ performSingleReplace ();
529+ evaluateFindReplaceStatus ();
530+ })).build ();
531+
532+ replaceAllButton = new AccessibleToolItemBuilder (replaceTools ).withStyleBits (SWT .PUSH )
533+ .withImage (FindReplaceOverlayImages .get (FindReplaceOverlayImages .KEY_REPLACE_ALL ))
534+ .withToolTipText (FindReplaceMessages .FindReplaceOverlay_replaceAllButton_toolTip )
535+ .withSelectionListener (SelectionListener .widgetSelectedAdapter (e -> {
536+ if (getFindString ().isEmpty ()) {
537+ showUserFeedback (warningColor , true );
538+ return ;
539+ }
540+ performReplaceAll ();
541+ evaluateFindReplaceStatus ();
542+ })).build ();
542543 }
543544
544545 private void createSearchBar () {
0 commit comments