Changeset 1436
- Timestamp:
- 03/06/14 10:30:03 (11 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-events-test/src/test/java/de/ugoe/cs/autoquest/eventcore/guimodel/AbstractDefaultGUIElementTest.java
r1396 r1436 69 69 assertFalse(guiElements[i].equals(guiElements[j])); 70 70 assertFalse(guiElements[j].equals(guiElements[i])); 71 assertNotSame(guiElements[i].hashCode(), guiElements[j].hashCode());72 71 } 73 72 } -
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 } -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLDocumentSpec.java
r1276 r1436 77 77 */ 78 78 public HTMLDocumentSpec(HTMLServerSpec server, String path, String query, String title) { 79 super("document"); 79 super("document", (server != null ? server.hashCode() : 0) + 80 (path != null ? path.hashCode() : 0) + (query != null ? query.hashCode() : 0) + 81 (title != null ? title.hashCode() : 0)); 80 82 81 83 if (server == null) { -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLGUIElementSpec.java
r1276 r1436 40 40 */ 41 41 private String type; 42 43 /** 44 * <p> 45 * the hashCode of this GUI element specification 46 * </p> 47 */ 48 private int hashCode; 42 49 43 50 /** … … 50 57 * @throws IllegalArgumentException if the provided type is null 51 58 */ 52 public HTMLGUIElementSpec(String type ) {59 public HTMLGUIElementSpec(String type, int hashCode) { 53 60 if (type == null) { 54 61 throw new IllegalArgumentException("type must not be null"); … … 56 63 57 64 this.type = type; 65 this.hashCode = hashCode; 58 66 } 59 67 … … 87 95 } 88 96 97 /* (non-Javadoc) 98 * @see java.lang.Object#hashCode() 99 */ 100 @Override 101 public int hashCode() { 102 return hashCode; 103 } 104 89 105 } -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLPageElementSpec.java
r1276 r1436 83 83 */ 84 84 public HTMLPageElementSpec(HTMLDocumentSpec page, String tagName, String htmlId, int index) { 85 super(tagName); 85 super(tagName, (page != null ? page.hashCode() : 0) + 86 (tagName != null ? tagName.hashCode() : 0) + 87 (htmlId != null ? htmlId.hashCode() : 0) + (index >= 0 ? index : 0)); 86 88 87 89 if (page == null) { -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLServerSpec.java
r1276 r1436 59 59 */ 60 60 public HTMLServerSpec(String host, int port) { 61 super("server" );61 super("server", (host != null ? host.hashCode() : 0) + port); 62 62 63 63 if (host == null) {
Note: See TracChangeset
for help on using the changeset viewer.