@@ -540,8 +540,8 @@ private ToolItem showChevron() {
540540 */
541541private ToolItem getChevron (CTabFolder tabFolder ) {
542542 for (Control child : tabFolder .getChildren ()) {
543- if (child instanceof ToolBar ) {
544- for (ToolItem toolItem : (( ToolBar ) child ) .getItems ()) {
543+ if (child instanceof ToolBar toolBar ) {
544+ for (ToolItem toolItem : toolBar .getItems ()) {
545545 if ((toolItem .getStyle () & SWT .PUSH ) != 0
546546 && toolItem .getText ().isEmpty ()
547547 && SWT .getMessage ("SWT_ShowList" ).equals (toolItem .getToolTipText ())
@@ -561,25 +561,25 @@ private void checkElementOverlap(CTabFolder tabFolder) {
561561 subControls .addAll (Arrays .asList (tabFolder .getItems ()));
562562 for (int i = 0 ; i < subControls .size (); i ++) {
563563 Rectangle boundsA = null ;
564- if (subControls .get (i ) instanceof Control ) {
565- if (!(( Control ) subControls . get ( i )) .isVisible ())
564+ if (subControls .get (i ) instanceof Control c ) {
565+ if (!c .isVisible ())
566566 continue ;
567- boundsA = (( Control ) subControls . get ( i )) .getBounds ();
568- } else if (subControls .get (i ) instanceof CTabItem ) {
569- if (!(( CTabItem ) subControls . get ( i )) .isShowing ())
567+ boundsA = c .getBounds ();
568+ } else if (subControls .get (i ) instanceof CTabItem cTab ) {
569+ if (!cTab .isShowing ())
570570 continue ;
571- boundsA = (( CTabItem ) subControls . get ( i )) .getBounds ();
571+ boundsA = cTab .getBounds ();
572572 }
573573 for (int j = i + 1 ; j < subControls .size (); j ++) {
574574 Rectangle boundsB = null ;
575- if (subControls .get (j ) instanceof Control ) {
576- if (!(( Control ) subControls . get ( j )) .isVisible ())
575+ if (subControls .get (j ) instanceof Control c ) {
576+ if (!c .isVisible ())
577577 continue ;
578- boundsB = (( Control ) subControls . get ( j )) .getBounds ();
579- } else if (subControls .get (j ) instanceof CTabItem ) {
580- if (!(( CTabItem ) subControls . get ( j )) .isShowing ())
578+ boundsB = c .getBounds ();
579+ } else if (subControls .get (j ) instanceof CTabItem cTab ) {
580+ if (!cTab .isShowing ())
581581 continue ;
582- boundsB = (( CTabItem ) subControls . get ( j )) .getBounds ();
582+ boundsB = cTab .getBounds ();
583583 }
584584 assertFalse ("Overlap between <" + subControls .get (i ) + "> and <" + subControls .get (j ) + ">\n " + boundsA
585585 + " overlaps " + boundsB , boundsA .intersects (boundsB ));
@@ -608,8 +608,8 @@ private void assertTabElementsInLine() {
608608 List <Rectangle > tabBarElementBounds = new ArrayList <>();
609609 Arrays .stream (ctabFolder .getItems ()).filter (CTabItem ::isShowing ).map (this ::getBoundsInShell ).forEach (tabBarElementBounds ::add );
610610 for (Control child : ctabFolder .getChildren ()) {
611- if (child instanceof ToolBar ) {
612- for (ToolItem toolItem : (( ToolBar ) child ) .getItems ()) {
611+ if (child instanceof ToolBar toolBarChild ) {
612+ for (ToolItem toolItem : toolBarChild .getItems ()) {
613613 if (toolItem .getImage () != null ) {
614614 tabBarElementBounds .add (getBoundsInShell (toolItem ));
615615 }
@@ -632,15 +632,15 @@ private void assertTabElementsInLine() {
632632private Rectangle getBoundsInShell (Widget control ) {
633633 Control parent ;
634634 Rectangle bounds ;
635- if (control instanceof Control ) {
636- parent = (( Control ) control ) .getParent ();
637- bounds = (( Control ) control ) .getBounds ();
638- } else if (control instanceof CTabItem ) {
639- parent = (( CTabItem ) control ) .getParent ();
640- bounds = (( CTabItem ) control ) .getBounds ();
641- } else if (control instanceof ToolItem ) {
642- parent = (( ToolItem ) control ) .getParent ();
643- bounds = (( ToolItem ) control ) .getBounds ();
635+ if (control instanceof Control c ) {
636+ parent = c .getParent ();
637+ bounds = c .getBounds ();
638+ } else if (control instanceof CTabItem cTab ) {
639+ parent = cTab .getParent ();
640+ bounds = cTab .getBounds ();
641+ } else if (control instanceof ToolItem toolItem ) {
642+ parent = toolItem .getParent ();
643+ bounds = toolItem .getBounds ();
644644 } else {
645645 throw new UnsupportedOperationException ("Widget must provide bounds and parent" );
646646 }
0 commit comments