Index: src/org/eclipse/draw2d/FocusTraverseManager.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/FocusTraverseManager.java,v retrieving revision 1.11 diff -u -r1.11 FocusTraverseManager.java --- src/org/eclipse/draw2d/FocusTraverseManager.java 4 May 2005 15:48:36 -0000 1.11 +++ src/org/eclipse/draw2d/FocusTraverseManager.java 8 Apr 2009 14:25:14 -0000 @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.draw2d; +import java.util.ArrayList; import java.util.List; /** @@ -28,7 +29,9 @@ /** * Default constructor. */ -public FocusTraverseManager() { } +public FocusTraverseManager() { + +} private IFigure findDeepestRightmostChildOf(IFigure fig) { while (fig.getChildren().size() != 0) { @@ -60,10 +63,11 @@ return null; } - int siblingPos = nextFocus.getParent().getChildren().indexOf(nextFocus); + List siblingsPositions = new ArrayList(); + siblingsPositions.add(Integer.valueOf(nextFocus.getParent().getChildren().indexOf(nextFocus))); while (!found) { IFigure parent = nextFocus.getParent(); - + /* * Figure traversal is implemented using the pre-order left to right * tree traversal algorithm. @@ -77,29 +81,33 @@ List siblings = parent.getChildren(); if (nextFocus.getChildren().size() != 0) { - nextFocus = (IFigure)nextFocus.getChildren().get(0); - siblingPos = 0; + siblingsPositions.add(Integer.valueOf(0)); + nextFocus = (IFigure) nextFocus.getChildren().get(0); if (isFocusEligible(nextFocus)) - found = true; - } else if (siblingPos < siblings.size() - 1) { - nextFocus = ((IFigure)(siblings.get(++siblingPos))); + found = true; + } else if (((Integer)siblingsPositions.get(siblingsPositions.size() - 1)).intValue() < siblings.size() - 1) { + int nextSiblingPos = ((Integer)siblingsPositions.remove(siblingsPositions.size() - 1)).intValue() + 1; + siblingsPositions.add(Integer.valueOf(nextSiblingPos)); + nextFocus = ((IFigure) (siblings.get(nextSiblingPos))); if (isFocusEligible(nextFocus)) found = true; } else { - boolean untraversedSiblingFound = false; + boolean untraversedSiblingFound = false; while (!untraversedSiblingFound) { - IFigure p = nextFocus.getParent(); + IFigure p = nextFocus.getParent(); IFigure gp = p.getParent(); - + if (gp != null) { int parentSiblingCount = gp.getChildren().size(); - int parentIndex = gp.getChildren().indexOf(p); + int parentIndex = ((Integer)siblingsPositions.remove(siblingsPositions.size() - 2)).intValue(); if (parentIndex < parentSiblingCount - 1) { - nextFocus = ((IFigure)p.getParent() - .getChildren().get(parentIndex + 1)); - siblingPos = parentIndex + 1; + nextFocus = ((IFigure) p.getParent().getChildren().get( + parentIndex + 1)); + int nextSiblingPos = parentIndex + 1; + siblingsPositions.remove(siblingsPositions.size() - 1); + siblingsPositions.add(Integer.valueOf(nextSiblingPos)); untraversedSiblingFound = true; - if (isFocusEligible(nextFocus)) + if (isFocusEligible(nextFocus)) found = true; } else nextFocus = p; @@ -109,8 +117,9 @@ found = true; } } - } + } } + return nextFocus; }