- Timestamp:
- 02/18/13 18:18:11 (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 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> -
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ShowGuiModelDialog.java
r1086 r1088 14 14 15 15 package de.ugoe.cs.autoquest.ui.swt; 16 17 import java.util.List;18 16 19 17 import org.eclipse.swt.SWT; … … 148 146 } 149 147 150 private void buildGuiTree(TreeItem currentParent, List<IGUIElement> elements) {151 for (IGUIElement element : elements) {152 TreeItem child = new TreeItem(currentParent, SWT.NULL);153 child.setText(element.toString());154 child.setData(element);155 buildGuiTree(child, model.getChildren(element));156 }157 }158 159 148 private void expandAll(Tree tree, boolean expanded) { 160 149 for (TreeItem item : tree.getItems()) { … … 203 192 // update visualization of the model 204 193 firstParent.removeAll(); 205 buildGuiTree(firstParent, model.get Children((IGUIElement) firstParent.getData()));194 buildGuiTree(firstParent, model.getTraverser((IGUIElement) firstParent.getData())); 206 195 firstParent.setExpanded(true); 207 196 }
Note: See TracChangeset
for help on using the changeset viewer.