Changeset 1088 for trunk/autoquest-core-events/src/main/java/de/ugoe
- Timestamp:
- 02/18/13 18:18:11 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/guimodel/GUIModel.java
r1086 r1088 163 163 164 164 for (TreeNode node : allNodes) { 165 for (TreeNode child : node.children) { 166 if (child.guiElement.equals(guiElement)) { 167 if (parent != null) { 168 parent = node.guiElement; 169 } 170 else { 171 Console 165 if (node.children != null) { 166 for (TreeNode child : node.children) { 167 if (child.guiElement.equals(guiElement)) { 168 if (parent != null) { 169 parent = node.guiElement; 170 } 171 else { 172 Console 172 173 .traceln(Level.SEVERE, 173 174 "Multiple nodes in the internal GUI model match the same GUI element. " 174 + "This should not be the case and the GUI model is probably invalid."); 175 + "This should not be the case and the GUI model is probably invalid."); 176 } 175 177 } 176 178 } … … 208 210 public Traverser getTraverser() { 209 211 return new Traverser(); 212 } 213 214 /** 215 * returns a traverser for the GUI model starting at the given GUI element. Returns null, if 216 * the GUI element is not part of the model. 217 * 218 * @return a traverser 219 */ 220 public Traverser getTraverser(IGUIElement startingAt) { 221 TreeNode node = findNode(startingAt); 222 223 if (node != null) { 224 Traverser traverser = new Traverser(); 225 traverser.navigateTo(node); 226 return traverser; 227 } 228 else { 229 return null; 230 } 210 231 } 211 232 … … 616 637 */ 617 638 public boolean hasNextSibling() { 618 StackEntry entry = nodeStack.pop(); 619 boolean result = nodeStack.peek().treeNode.children.size() > (entry.index + 1); 620 pushChild(entry.index); 639 boolean result = false; 640 if (nodeStack.size() > 1) { 641 StackEntry entry = nodeStack.pop(); 642 result = nodeStack.peek().treeNode.children.size() > (entry.index + 1); 643 pushChild(entry.index); 644 } 645 621 646 return result; 622 647 } … … 662 687 } 663 688 689 /** 690 * <p> 691 * navigates the traverser to the given node in the GUI model 692 * </p> 693 */ 694 private boolean navigateTo(TreeNode node) { 695 if (hasFirstChild()) { 696 IGUIElement childElement = firstChild(); 697 698 while (childElement != null) { 699 if (childElement.equals(node.guiElement)) { 700 return true; 701 } 702 else if (navigateTo(node)) { 703 return true; 704 } 705 else { 706 childElement = nextSibling(); 707 } 708 } 709 710 parent(); 711 } 712 713 return false; 714 } 715 664 716 /** 665 717 * <p>
Note: See TracChangeset
for help on using the changeset viewer.