Changeset 1061
- Timestamp:
- 02/12/13 16:05:41 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/GUIEventTaskComparisonRule.java
r1057 r1061 1 1 package de.ugoe.cs.autoquest.tasktrees.nodeequality; 2 2 3 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 3 4 import de.ugoe.cs.autoquest.eventcore.gui.IInteraction; 4 5 import de.ugoe.cs.autoquest.eventcore.gui.MouseClick; … … 7 8 import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 8 9 import de.ugoe.cs.autoquest.eventcore.gui.ValueSelection; 10 import de.ugoe.cs.autoquest.eventcore.guimodel.IButton; 11 import de.ugoe.cs.autoquest.eventcore.guimodel.ICheckBox; 12 import de.ugoe.cs.autoquest.eventcore.guimodel.IComboBox; 13 import de.ugoe.cs.autoquest.eventcore.guimodel.IImage; 14 import de.ugoe.cs.autoquest.eventcore.guimodel.IListBox; 15 import de.ugoe.cs.autoquest.eventcore.guimodel.IMenuButton; 16 import de.ugoe.cs.autoquest.eventcore.guimodel.IRadioButton; 17 import de.ugoe.cs.autoquest.eventcore.guimodel.IShape; 18 import de.ugoe.cs.autoquest.eventcore.guimodel.IText; 19 import de.ugoe.cs.autoquest.eventcore.guimodel.IToolTip; 9 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 10 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; … … 57 68 IInteraction interaction2 = (IInteraction) task2.getEventType(); 58 69 59 return compareInteractions(interaction1, interaction2 );60 } 61 62 /** 63 * <p> 64 * compares two interactions. The method delegates t wo70 return compareInteractions(interaction1, interaction2, task1.getEventTarget()); 71 } 72 73 /** 74 * <p> 75 * compares two interactions. The method delegates to other, more specific compare method, e.g., 65 76 * {@link #compareTextInputs(TextInput, TextInput)} and 66 * {@link #compareValueSelections(ValueSelection, ValueSelection)} for text inputs and value 67 * selections. Otherwise it uses the equal method of the interactions for comparison. In this 68 * case, if the interactions equal method returns true, this method returns lexical equality. 77 * {@link #compareValueSelections(ValueSelection, ValueSelection)}, if any exist for the 78 * concrete interaction types. Otherwise it uses the equals method of the interactions for 79 * comparison. In this case, if the interactions equals method returns true, this method 80 * returns lexical equality. 69 81 * </p> 70 82 * 71 83 * @param interaction1 the first interaction to compare 72 84 * @param interaction2 the second interaction to compare 73 * 74 * @return as described 75 */ 76 private NodeEquality compareInteractions(IInteraction interaction1, IInteraction interaction2) { 85 * @param eventTarget the event target on which the interactions happened (used within 86 * special comparisons like mouse clicks on buttons, where the coordinates 87 * can be ignored) 88 * 89 * @return as described 90 */ 91 private NodeEquality compareInteractions(IInteraction interaction1, 92 IInteraction interaction2, 93 IEventTarget eventTarget) 94 { 77 95 if (interaction1 == interaction2) { 78 96 return NodeEquality.LEXICALLY_EQUAL; … … 90 108 (interaction2 instanceof MouseClick)) 91 109 { 92 return compareMouseClicks((MouseClick) interaction1, (MouseClick) interaction2); 110 return compareMouseClicks 111 ((MouseClick) interaction1, (MouseClick) interaction2, eventTarget); 93 112 } 94 113 else if ((interaction1 instanceof MouseDoubleClick) && … … 96 115 { 97 116 return compareMouseDoubleClicks 98 ((MouseDoubleClick) interaction1, (MouseDoubleClick) interaction2 );117 ((MouseDoubleClick) interaction1, (MouseDoubleClick) interaction2, eventTarget); 99 118 } 100 119 else if ((interaction1 instanceof MouseDragAndDrop) && … … 168 187 * <p> 169 188 * compares two mouse clicks. If both clicks have the same coordinates, they are lexically 170 * equal. Otherwise, they are semantically equal. 189 * equal. Otherwise, they are semantically equal. Mouse clicks for which the coordinates make 190 * no lexical difference (see {@link #clickCoordinatesMakeLexicalDifference(IEventTarget)}) 191 * are treated as lexically equal. 171 192 * </p> 172 193 * 173 194 * @param interaction1 the first mouse click to compare 174 195 * @param interaction2 the second mouse click to compare 175 * 176 * @return as described 177 */ 178 private NodeEquality compareMouseClicks(MouseClick interaction1, 179 MouseClick interaction2) 196 * @param eventTarget the event target on which the interactions happened (used within 197 * special comparisons like mouse clicks on buttons, where the coordinates 198 * can be ignored) 199 * 200 * @return as described 201 */ 202 private NodeEquality compareMouseClicks(MouseClick interaction1, 203 MouseClick interaction2, 204 IEventTarget eventTarget) 180 205 { 181 206 if (interaction1.getButton() != interaction2.getButton()) { 182 207 return NodeEquality.UNEQUAL; 208 } 209 210 if (!clickCoordinatesMakeLexicalDifference(eventTarget)) { 211 return NodeEquality.LEXICALLY_EQUAL; 183 212 } 184 213 … … 199 228 * <p> 200 229 * compares two mouse double clicks. If both double clicks have the same coordinates, they are 201 * lexically equal. Otherwise, they are semantically equal. 230 * lexically equal. Otherwise, they are semantically equal. Double clicks for which the 231 * coordinates make no lexical difference 232 * (see {@link #clickCoordinatesMakeLexicalDifference(IEventTarget)}) are treated as lexically 233 * equal. 202 234 * </p> 203 235 * 204 236 * @param interaction1 the first mouse double click to compare 205 237 * @param interaction2 the second mouse double click to compare 238 * @param eventTarget the event target on which the interactions happened (used within 239 * special comparisons like mouse clicks on buttons, where the coordinates 240 * can be ignored) 206 241 * 207 242 * @return as described 208 243 */ 209 244 private NodeEquality compareMouseDoubleClicks(MouseDoubleClick interaction1, 210 MouseDoubleClick interaction2) 245 MouseDoubleClick interaction2, 246 IEventTarget eventTarget) 211 247 { 212 248 if (interaction1.getButton() != interaction2.getButton()) { 213 249 return NodeEquality.UNEQUAL; 250 } 251 252 if (!clickCoordinatesMakeLexicalDifference(eventTarget)) { 253 return NodeEquality.LEXICALLY_EQUAL; 214 254 } 215 255 … … 262 302 } 263 303 304 /** 305 * <p> 306 * Checks, if the coordinates of a click or double click on the provided event target makes 307 * a lexical difference. Mouse clicks and double clicks on buttons, check boxes, 308 * combo boxes, images, list boxes, menu buttons, radio buttons, shapes, uneditable text, 309 * and tool tips have no lexical difference as long as they happen on the same event target. 310 * The concrete coordinates are not relevant. 311 * </p> 312 * 313 * @param eventTarget the event target on which the interaction occurred 314 * 315 * @return if the coordinates are important to be considered for clicks and double clicks, 316 * false else 317 */ 318 private boolean clickCoordinatesMakeLexicalDifference(IEventTarget eventTarget) { 319 if ((eventTarget instanceof IButton) || 320 (eventTarget instanceof ICheckBox) || 321 (eventTarget instanceof IComboBox) || 322 (eventTarget instanceof IImage) || 323 (eventTarget instanceof IListBox) || 324 (eventTarget instanceof IMenuButton) || 325 (eventTarget instanceof IRadioButton) || 326 (eventTarget instanceof IShape) || 327 (eventTarget instanceof IText) || 328 (eventTarget instanceof IToolTip)) 329 { 330 return false; 331 } 332 else { 333 return true; 334 } 335 } 336 264 337 }
Note: See TracChangeset
for help on using the changeset viewer.