Changeset 1004 for trunk/autoquest-core-events/src/main/java/de/ugoe
- Timestamp:
- 12/04/12 11:50:39 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/guimodel/GUIElementTree.java
r1002 r1004 39 39 */ 40 40 public class GUIElementTree { 41 /* Note that in the current version the id of a GUI element is assumed to be a n Integer. For future41 /* Note that in the current version the id of a GUI element is assumed to be a long. For future 42 42 versions it might be more suitable to change to some generic id type. */ 43 43 … … 45 45 * <p> 46 46 * Map of all GUI elements that are part of the tree for efficient searching. The keys of the 47 * map are the hash values of the GUI elements.48 * </p> 49 */ 50 private Map< Integer, IGUIElement> guiElements;47 * map are the ids of the GUI elements. 48 * </p> 49 */ 50 private Map<Long, IGUIElement> guiElements; 51 51 52 52 /** 53 53 * <p> 54 54 * Map of all GUI element specifications that are part of the tree for efficient searching. The 55 * keys of the map are the hash values of the GUI elements.56 * </p> 57 */ 58 private Map< Integer, IGUIElementSpec> guiElementSpecs;55 * keys of the map are the ids of the GUI elements. 56 * </p> 57 */ 58 private Map<Long, IGUIElementSpec> guiElementSpecs; 59 59 60 60 /** 61 61 * <p> 62 62 * Map of all children of GUI elements that are part of the tree. The keys of the map are the 63 * hash values of the parent GUI elements.64 * </p> 65 */ 66 private Map< Integer, List<Integer>> childRelations;63 * ids of the parent GUI elements. 64 * </p> 65 */ 66 private Map<Long, List<Long>> childRelations; 67 67 68 68 /** 69 69 * <p> 70 70 * Map of all parents of GUI elements that are part of the tree. The keys of the map are the 71 * hash values of the child GUI elements.72 * </p> 73 */ 74 private Map< Integer, Integer> parentRelations;71 * ids of the child GUI elements. 72 * </p> 73 */ 74 private Map<Long, Long> parentRelations; 75 75 76 76 /** … … 96 96 */ 97 97 public GUIElementTree() { 98 guiElementSpecs = new HashMap< Integer, IGUIElementSpec>();99 childRelations = new HashMap< Integer, List<Integer>>();100 parentRelations = new HashMap< Integer, Integer>();101 guiElements = new HashMap< Integer, IGUIElement>();98 guiElementSpecs = new HashMap<Long, IGUIElementSpec>(); 99 childRelations = new HashMap<Long, List<Long>>(); 100 parentRelations = new HashMap<Long, Long>(); 101 guiElements = new HashMap<Long, IGUIElement>(); 102 102 guiModel = new GUIModel(); 103 103 } … … 110 110 */ 111 111 public GUIElementTree(GUIModel guiModel){ 112 guiElementSpecs = new HashMap< Integer, IGUIElementSpec>();113 childRelations = new HashMap< Integer, List<Integer>>();114 parentRelations = new HashMap< Integer, Integer>();115 guiElements = new HashMap< Integer, IGUIElement>();112 guiElementSpecs = new HashMap<Long, IGUIElementSpec>(); 113 childRelations = new HashMap<Long, List<Long>>(); 114 parentRelations = new HashMap<Long, Long>(); 115 guiElements = new HashMap<Long, IGUIElement>(); 116 116 this.guiModel = guiModel; 117 117 } … … 129 129 * the GUI element specification 130 130 */ 131 public void add( IntegerguiElementID,132 IntegerparentID,131 public void add(Long guiElementID, 132 Long parentID, 133 133 IGUIElementSpec guiElementSpec) 134 134 { … … 138 138 IGUIElementSpec parent = guiElementSpecs.get(parentID); 139 139 if (parent != null) { 140 List< Integer> otherChildren = childRelations.get(parentID);140 List<Long> otherChildren = childRelations.get(parentID); 141 141 142 142 if (otherChildren == null) { 143 otherChildren = new ArrayList< Integer>();143 otherChildren = new ArrayList<Long>(); 144 144 childRelations.put(parentID, otherChildren); 145 145 } … … 153 153 List<IGUIElementSpec> guiElementPath = new ArrayList<IGUIElementSpec>(); 154 154 155 IntegercurrentElementID = guiElementID;155 Long currentElementID = guiElementID; 156 156 while (guiElementSpec != null) { 157 157 guiElementPath.add(0, guiElementSpec); … … 180 180 * @return {@link IGUIElementSpec} of the GUI element with the given id if found, null otherwise 181 181 */ 182 public IGUIElement find( intid) {182 public IGUIElement find(long id) { 183 183 IGUIElement guiElement = guiElements.get(id); 184 184 if (guiElement == null) { … … 191 191 } 192 192 193 IntegercurrentElementID = id;193 Long currentElementID = id; 194 194 while (elementSpec != null) { 195 195 guiElementPath.add(0, elementSpec); … … 219 219 * @return number of GUI elements that were removed 220 220 */ 221 public int remove( intid) {221 public int remove(long id) { 222 222 IGUIElementSpec node = guiElementSpecs.remove(id); 223 223 int removedCounter = 1; 224 224 225 225 if (node != null) { 226 List< Integer> nodesToBeRemoved = childRelations.remove(id);226 List<Long> nodesToBeRemoved = childRelations.remove(id); 227 227 228 228 // remove all children and sub-children, if any 229 229 if (nodesToBeRemoved != null) { 230 230 for (int i = 0; i < nodesToBeRemoved.size(); i++) { 231 IntegernodeToBeRemoved = nodesToBeRemoved.get(i);232 List< Integer> children =231 Long nodeToBeRemoved = nodesToBeRemoved.get(i); 232 List<Long> children = 233 233 childRelations.remove(nodeToBeRemoved); 234 234 … … 245 245 /* the node may be a child node of a parent. So search for it in the child relations 246 246 of the parent and remove it */ 247 Integerparent = parentRelations.remove(id);247 Long parent = parentRelations.remove(id); 248 248 if (parent != null) { 249 List< Integer> children = childRelations.get(parent);249 List<Long> children = childRelations.get(parent); 250 250 251 251 if (children != null) {
Note: See TracChangeset
for help on using the changeset viewer.