Changeset 837 for trunk/quest-plugin-mfc/src/main/java/de/ugoe/cs/quest/plugin/mfc/guimodel/MFCGUIElementSpec.java
- Timestamp:
- 09/20/12 12:03:03 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-plugin-mfc/src/main/java/de/ugoe/cs/quest/plugin/mfc/guimodel/MFCGUIElementSpec.java
r832 r837 1 1 2 package de.ugoe.cs.quest.plugin.mfc.guimodel; 2 3 … … 99 100 * modality of the window 100 101 */ 101 protected MFCGUIElementSpec(long hwnd, 102 String name, 103 int resourceId, 104 String type, 105 boolean isModal) 102 protected MFCGUIElementSpec(long hwnd, String name, int resourceId, String type, boolean isModal) 106 103 { 107 104 this.hwnd = hwnd; … … 121 118 public String getName() { 122 119 StringBuffer names = new StringBuffer(); 123 120 124 121 if (name != null) { 125 122 names.append('"'); … … 130 127 names.append("NOT_SET"); 131 128 } 132 129 133 130 if (formerNames.size() > 0) { 134 131 135 132 names.append(" (aka "); 136 133 137 134 for (int i = 0; i < formerNames.size(); i++) { 138 135 if (i > 0) { … … 144 141 names.append('"'); 145 142 } 146 143 147 144 names.append(")"); 148 145 } 149 146 150 147 return names.toString(); 151 148 } … … 173 170 } 174 171 175 /* (non-Javadoc) 172 /* 173 * (non-Javadoc) 174 * 176 175 * @see de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec#getType() 177 176 */ … … 183 182 /** 184 183 * <p> 185 * TODO: comment186 * </p> 187 * 188 * @return 184 * Returns the modality of the specified GUI element. 185 * </p> 186 * 187 * @return the modality 189 188 */ 190 189 public boolean isModal() { … … 201 200 */ 202 201 public void setName(String newName) { 203 if ((this.name != null) && 204 (!this.name.equals(newName)) && 202 if ((this.name != null) && (!this.name.equals(newName)) && 205 203 (!this.formerNames.contains(this.name))) 206 204 { 207 205 this.formerNames.add(this.name); 208 206 } 209 207 210 208 this.name = newName; 211 209 } … … 223 221 this.formerHwnds.add(this.hwnd); 224 222 } 225 223 226 224 this.hwnd = newHwnd; 227 225 } 228 226 229 /* (non-Javadoc) 230 * @see de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec#getSimilarity(de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec) 227 /* 228 * (non-Javadoc) 229 * 230 * @see 231 * de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec#getSimilarity(de.ugoe.cs.quest.eventcore 232 * .guimodel.IGUIElementSpec) 231 233 */ 232 234 @Override 233 235 public boolean getSimilarity(IGUIElementSpec other) { 234 236 235 237 if (this == other) { 236 238 return true; 237 239 } 238 240 239 241 if (!(other instanceof MFCGUIElementSpec)) { 240 242 return false; 241 243 } 242 244 243 245 MFCGUIElementSpec otherSpec = (MFCGUIElementSpec) other; 244 246 … … 260 262 // and reopend, i.e. a new instance is created. If one of them stays the same, then 261 263 // similarity is given. Therefore these are the first two comparisons 262 264 263 265 if (hwnd == otherSpec.hwnd) { 264 266 return true; 265 267 } 266 268 267 269 if ((name != null) && (name.equals(otherSpec.name))) { 268 270 return true; 269 271 } 270 271 if ((((name == null) && (otherSpec.name == null)) || 272 (("".equals(name)) && ("".equals(otherSpec.name)))) && 273 (formerNames.size() == 0) && (otherSpec.formerNames.size() == 0)) 272 273 if ((((name == null) && (otherSpec.name == null)) || (("".equals(name)) && ("" 274 .equals(otherSpec.name)))) && 275 (formerNames.size() == 0) && 276 (otherSpec.formerNames.size() == 0)) 274 277 { 275 278 return true; 276 279 } 277 280 278 281 // if the hwnd and the name did not stay the same, then the name should be checked first. 279 282 // The current name of one of the specs must be contained in the former names of the … … 291 294 return true; 292 295 } 293 296 294 297 // ok. Even the names do not match. This is usually a clear indication, that the elements 295 298 // are distinct. However, we check, if the former handles matched. This is very unlikely … … 302 305 303 306 // now we can be really sure, that the GUI elements differ 304 307 305 308 return false; 306 309 } 307 310 308 /* (non-Javadoc) 311 /* 312 * (non-Javadoc) 313 * 309 314 * @see de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec#equals(IGUIElementSpec) 310 315 */ 311 316 @Override 312 317 public boolean equals(Object other) { 313 318 314 319 if (this == other) { 315 320 return true; 316 321 } 317 322 318 323 if (!(other instanceof MFCGUIElementSpec)) { 319 324 return false; 320 325 } 321 326 322 327 MFCGUIElementSpec otherSpec = (MFCGUIElementSpec) other; 323 324 return 325 (hwnd == otherSpec.hwnd) && (isModal == otherSpec.isModal) && 328 329 return (hwnd == otherSpec.hwnd) && (isModal == otherSpec.isModal) && 326 330 (resourceId == otherSpec.resourceId) && 327 331 ((type == otherSpec.type) || ((type != null) && (type.equals(otherSpec.type)))) && … … 329 333 } 330 334 331 /* (non-Javadoc) 335 /* 336 * (non-Javadoc) 337 * 332 338 * @see java.lang.Object#hashCode() 333 339 */ … … 340 346 /** 341 347 * <p> 342 * Returns a string ident fier of the window:<br>348 * Returns a string identifier of the window:<br> 343 349 * {@code [resourceId;"windowName";"className";modality]} 344 350 * </p> … … 348 354 @Override 349 355 public String toString() { 350 return "[" + resourceId + ";" + getName() + ";\"" + type + "\";" + isModal + ";" + 351 hwnd + "]"; 352 } 353 354 /** 355 * <p> 356 * TODO: comment 357 * </p> 356 return "[" + resourceId + ";" + getName() + ";\"" + type + "\";" + isModal + ";" + hwnd + 357 "]"; 358 } 359 360 /** 361 * <p> 362 * Returns the XML representation of this specification. 363 * </p> 364 * 365 * @return the XML representation 358 366 */ 359 367 String toXML() { 360 return 361 "<window name=\"" + (name != null ? StringTools.xmlEntityReplacement(name) : "") + 362 "\" class=\"" + StringTools.xmlEntityReplacement(type) + 363 "\" resourceId=\"" + resourceId + "\" isModal=\"" + 364 isModal + "\"/>"; 365 } 366 367 /** 368 * <p> 369 * TODO: comment 370 * </p> 371 * 368 return "<window name=\"" + (name != null ? StringTools.xmlEntityReplacement(name) : "") + 369 "\" class=\"" + StringTools.xmlEntityReplacement(type) + "\" resourceId=\"" + 370 resourceId + "\" isModal=\"" + isModal + "\"/>"; 371 } 372 373 /** 374 * <p> 375 * Updates the specification with another specification. 376 * </p> 377 * 372 378 * @param furtherSpec 379 * specification used to update the current specification 373 380 */ 374 381 void update(IGUIElementSpec furtherSpec) { 375 382 MFCGUIElementSpec other = (MFCGUIElementSpec) furtherSpec; 376 383 377 384 if (other != this) { 378 385 for (long formerHwnd : other.formerHwnds) { … … 388 395 } 389 396 390 if ((name != other.name) && (name != null) && (!name.equals(other.name))) 391 { 397 if ((name != other.name) && (name != null) && (!name.equals(other.name))) { 392 398 setName(other.name); 393 399 }
Note: See TracChangeset
for help on using the changeset viewer.