@@ -39,27 +39,27 @@ public class TraversePageHandler extends WidgetMethodHandler {
3939 @ Override
4040 public final Object execute (final ExecutionEvent event ) {
4141 Control focusControl = Display .getCurrent ().getFocusControl ();
42- System .out .println (1 );
4342 if (focusControl != null ) {
4443 boolean forward = "next" .equals (methodName ); //$NON-NLS-1$
45- System .out .println (methodName );
44+ // System.out.println(methodName);
4645 int traversal = "next" .equals (methodName ) ? SWT .TRAVERSE_PAGE_NEXT : SWT .TRAVERSE_PAGE_PREVIOUS ; //$NON-NLS-1$
4746// int traversal = getTraversalDirection(forward);
4847 Control control = focusControl ;
4948 do {
50- if (control instanceof CTabFolder folder && isFinalItemInCTabFolder (folder , forward )) {
51- System .out .println (isFinalItemInCTabFolder (folder , forward ));
49+ if (control instanceof CTabFolder folder && isFinalItemInCTabFolder (folder , forward )
50+ && !areHiddenItems (folder )) {
51+ // System.out.println(isFinalItemInCTabFolder(folder, forward));
5252
5353 loopToSecondToFirstItemInCTabFolder (folder , forward );
5454 traversal = getTraversalDirection (!forward ); // we are in the second-to-last item in the given
5555 // direction. Now, use the Traverse-event to move back by one
5656 }
5757 if (control .traverse (traversal )) {
58- System .out .println ("here" ); //$NON-NLS-1$
58+ // System.out.println("here"); //$NON-NLS-1$
5959 return null ;
6060 }
6161 if (control instanceof Shell ) {
62- System .out .println ("there" ); //$NON-NLS-1$
62+ // System.out.println("there"); //$NON-NLS-1$
6363 return null ;
6464 }
6565 control = control .getParent ();
@@ -97,17 +97,41 @@ private void loopToSecondToFirstItemInCTabFolder(CTabFolder folder, boolean forw
9797 * @param forward whether we want to traverse forwards of backwards
9898 */
9999 private boolean isFinalItemInCTabFolder (CTabFolder folder , boolean forward ) {
100+ folder .update ();
101+
102+ // System.out.println("Amount of Items: " + items); //$NON-NLS-1$
100103 CTabItem currentFolder = folder .getSelection ();
101104 CTabItem lastFolder = null ;
102105 if (forward ) {
103106 int itemCount = folder .getItemCount ();
107+ currentFolder .isShowing ();
108+ // System.out.println("Item Count: " + itemCount); //$NON-NLS-1$
109+ // System.out.println("Current folder: " + currentFolder.getText()); //$NON-NLS-1$
110+
104111 lastFolder = folder .getItem (itemCount - 1 );
112+ // System.out.println("Last folder: " + lastFolder.getText()); //$NON-NLS-1$
113+ // for (CTabItem i : folder.getItems()) {
114+ // System.out.println(i.getText() + " is shown: " + i.isShowing()); //$NON-NLS-1$
115+
116+ // }
117+
105118 } else {
106119 lastFolder = folder .getItem (0 );
107120 }
121+ // System.out.println("Current == Last: " + currentFolder.equals(lastFolder)); //$NON-NLS-1$
122+
108123 return currentFolder .equals (lastFolder );
109124 }
110125
126+ private boolean areHiddenItems (CTabFolder folder ) {
127+ for (CTabItem i : folder .getItems ()) {
128+ if (!i .isShowing ()) {
129+ return true ;
130+ }
131+ }
132+ return false ;
133+ }
134+
111135 /**
112136 * Looks up the traverse(int) method on the given focus control.
113137 *
0 commit comments