Changeset 1436 for trunk/autoquest-core-events/src/main/java/de/ugoe
- Timestamp:
- 03/06/14 10:30:03 (11 years ago)
- Location:
- trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/guimodel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/guimodel/AbstractDefaultGUIElement.java
r1433 r1436 69 69 */ 70 70 private GUIModel guiModel; 71 72 /** 73 * <p> 74 * the hash code of this object 75 * </p> 76 */ 77 private int hashCode; 71 78 72 79 /** … … 84 91 this.usageObserved = false; 85 92 setParent(parent); 93 94 if (specification != null) { 95 this.hashCode = specification.hashCode(); 96 } 97 else { 98 this.hashCode = 0; 99 } 86 100 } 87 101 … … 135 149 this.equalGUIElements.add(other); 136 150 other.equalGUIElements = this.equalGUIElements; 151 other.hashCode = this.hashCode; 137 152 } 138 153 else { 139 154 addIfNotContained(other.equalGUIElements, this); 140 155 this.equalGUIElements = other.equalGUIElements; 156 this.hashCode = other.hashCode; 141 157 } 142 158 } … … 145 161 addIfNotContained(this.equalGUIElements, other); 146 162 other.equalGUIElements = this.equalGUIElements; 163 other.hashCode = this.hashCode; 147 164 } 148 165 else if (this.equalGUIElements != other.equalGUIElements) { … … 153 170 for (AbstractDefaultGUIElement candidate : other.equalGUIElements) { 154 171 candidate.equalGUIElements = this.equalGUIElements; 172 candidate.hashCode = this.hashCode; 155 173 } 156 174 157 175 other.equalGUIElements = this.equalGUIElements; 176 other.hashCode = this.hashCode; 158 177 } 159 178 // else … … 219 238 // implement final, as GUI elements are all singletons and they equal only if they are the 220 239 // same object. If there are several GUI element objects that represent the same GUI element 221 // then they are stored in the list of equal elements. In this case, the hash code of the 222 // list is unique within the system 223 synchronized (AbstractDefaultGUIElement.class) { 224 if (this.equalGUIElements == null) { 225 this.equalGUIElements = new LinkedList<AbstractDefaultGUIElement>(); 226 this.equalGUIElements.add(this); 227 } 228 229 return System.identityHashCode(this.equalGUIElements); 230 } 240 // then they are stored in the list of equal elements. But at least their type is expected 241 // to be equal, so return the hash code of the type. 242 return hashCode; 231 243 } 232 244 -
trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/guimodel/GUIModel.java
r1433 r1436 167 167 result.add(child.guiElement); 168 168 } 169 } 170 } 171 else { 172 System.out.println("problem"); 173 boolean found = false; 174 for (Map.Entry<IGUIElement, TreeNode> entry : allNodes.entrySet()) { 175 if (entry.getKey().equals(guiElement)) { 176 if (!found) { 177 System.out.println(guiElement.hashCode() + " " + entry.getKey().hashCode()); 178 found = true; 179 } 180 else { 181 Console.traceln(Level.SEVERE, "Multiple nodes in the internal GUI model " + 182 "match the same GUI element. This should not be the case " + 183 "and the GUI model is probably invalid."); 184 } 185 } 186 } 187 188 if (!found) { 189 Console.traceln(Level.SEVERE, "GUI element belonging to model not found in model"); 169 190 } 170 191 } … … 322 343 323 344 TreeNode parent = findNode(guiElements.get(0).getParent()); 345 if (parent == null) { 346 throw new IllegalArgumentException("GUI elements to group must have a parent: parent " + 347 "of " + guiElements.get(0) + " is " + 348 guiElements.get(0).getParent() + " and not found " + 349 "in the model"); 350 } 324 351 325 352 List<TreeNode> nodesToGroup = new LinkedList<TreeNode>(); … … 450 477 451 478 if (node1 == null || node2 == null) { 452 throw new IllegalArgumentException (453 479 throw new IllegalArgumentException 480 ("Error while merging nodes: one element is not part of the GUI model!"); 454 481 } 455 482 … … 645 672 646 673 allNodes.put(replacement.guiElement, replacement); 647 674 648 675 return replacement; 649 676 }
Note: See TracChangeset
for help on using the changeset viewer.