View | Details | Raw Unified | Return to bug 197444 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/draw2d/FocusTraverseManager.java (-17 / +26 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.draw2d;
11
package org.eclipse.draw2d;
12
12
13
import java.util.ArrayList;
13
import java.util.List;
14
import java.util.List;
14
15
15
/**
16
/**
Lines 28-34 Link Here
28
/**
29
/**
29
 * Default constructor.
30
 * Default constructor.
30
 */
31
 */
31
public FocusTraverseManager() { }
32
public FocusTraverseManager() { 
33
	
34
}
32
35
33
private IFigure findDeepestRightmostChildOf(IFigure fig) {
36
private IFigure findDeepestRightmostChildOf(IFigure fig) {
34
	while (fig.getChildren().size() != 0) {
37
	while (fig.getChildren().size() != 0) {
Lines 60-69 Link Here
60
			return null;
63
			return null;
61
	}
64
	}
62
	
65
	
63
	int siblingPos = nextFocus.getParent().getChildren().indexOf(nextFocus);
66
	List siblingsPositions = new ArrayList();
67
	siblingsPositions.add(Integer.valueOf(nextFocus.getParent().getChildren().indexOf(nextFocus)));
64
	while (!found) {
68
	while (!found) {
65
		IFigure parent = nextFocus.getParent();
69
		IFigure parent = nextFocus.getParent();
66
		
70
67
		/*
71
		/*
68
		 * Figure traversal is implemented using the pre-order left to right
72
		 * Figure traversal is implemented using the pre-order left to right
69
		 * tree traversal algorithm.
73
		 * tree traversal algorithm.
Lines 77-105 Link Here
77
		List siblings = parent.getChildren();
81
		List siblings = parent.getChildren();
78
82
79
		if (nextFocus.getChildren().size() != 0) {
83
		if (nextFocus.getChildren().size() != 0) {
80
			nextFocus = (IFigure)nextFocus.getChildren().get(0);
84
			siblingsPositions.add(Integer.valueOf(0));
81
			siblingPos = 0;
85
			nextFocus = (IFigure) nextFocus.getChildren().get(0);
82
			if (isFocusEligible(nextFocus))
86
			if (isFocusEligible(nextFocus))
83
				found = true;	
87
				found = true;
84
		} else if (siblingPos < siblings.size() - 1) {
88
		} else if (((Integer)siblingsPositions.get(siblingsPositions.size() - 1)).intValue() < siblings.size() - 1) {
85
			nextFocus = ((IFigure)(siblings.get(++siblingPos)));
89
			int nextSiblingPos = ((Integer)siblingsPositions.remove(siblingsPositions.size() - 1)).intValue() + 1;
90
			siblingsPositions.add(Integer.valueOf(nextSiblingPos));
91
			nextFocus = ((IFigure) (siblings.get(nextSiblingPos)));
86
			if (isFocusEligible(nextFocus))
92
			if (isFocusEligible(nextFocus))
87
				found = true;
93
				found = true;
88
		} else {
94
		} else {
89
			boolean untraversedSiblingFound = false;			
95
			boolean untraversedSiblingFound = false;
90
			while (!untraversedSiblingFound) {
96
			while (!untraversedSiblingFound) {
91
				IFigure p = nextFocus.getParent();	
97
				IFigure p = nextFocus.getParent();
92
				IFigure gp = p.getParent();
98
				IFigure gp = p.getParent();
93
				
99
94
				if (gp != null) {
100
				if (gp != null) {
95
					int parentSiblingCount = gp.getChildren().size();
101
					int parentSiblingCount = gp.getChildren().size();
96
					int parentIndex = gp.getChildren().indexOf(p);
102
					int parentIndex = ((Integer)siblingsPositions.remove(siblingsPositions.size() - 2)).intValue();
97
					if (parentIndex < parentSiblingCount - 1) {
103
					if (parentIndex < parentSiblingCount - 1) {
98
						nextFocus = ((IFigure)p.getParent()
104
						nextFocus = ((IFigure) p.getParent().getChildren().get(
99
								.getChildren().get(parentIndex + 1));
105
								parentIndex + 1));
100
						siblingPos = parentIndex + 1;
106
						int nextSiblingPos = parentIndex + 1;
107
						siblingsPositions.remove(siblingsPositions.size() - 1);
108
						siblingsPositions.add(Integer.valueOf(nextSiblingPos));
101
						untraversedSiblingFound = true;
109
						untraversedSiblingFound = true;
102
						if (isFocusEligible(nextFocus))		
110
						if (isFocusEligible(nextFocus))
103
							found = true;
111
							found = true;
104
					} else
112
					} else
105
						nextFocus = p;
113
						nextFocus = p;
Lines 109-116 Link Here
109
					found = true;
117
					found = true;
110
				}
118
				}
111
			}
119
			}
112
		}		
120
		}
113
	}
121
	}
122
	
114
	return nextFocus;
123
	return nextFocus;
115
}
124
}
116
125

Return to bug 197444