Changeset 1685
- Timestamp:
- 08/17/14 18:45:48 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDgenerateJacaretoReplay.java
r1684 r1685 31 31 import de.ugoe.cs.util.console.Command; 32 32 import de.ugoe.cs.autoquest.eventcore.Event; 33 import de.ugoe.cs.autoquest.eventcore.gui.*; 33 34 import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement; 34 35 import de.ugoe.cs.util.console.Console; … … 133 134 for (Iterator<Event> eventIter = sequence.iterator(); eventIter.hasNext();) { 134 135 Event event = eventIter.next(); 135 JFCGUIElement target = (JFCGUIElement) event.getTarget(); 136 137 switch (event.getType().getName()) 138 { 139 case "LeftMouseButtonDown": 140 structure.add("<StructureElement class=\"jacareto.struct.MouseClick\">"); 141 writeMouseClickEvent(writer, structure, event.getTimestamp(), target, 501); 142 break; 143 case "LeftMouseButtonUp": 144 writeMouseClickEvent(writer, structure, event.getTimestamp(), target, 502); 145 break; 146 case "LeftMouseClick": 147 writeMouseClickEvent(writer, structure, event.getTimestamp(), target, 500); 148 structure.add("</StructureElement>"); 149 // FIXME: don't always write an item action 150 writeItemActionEvent(writer, structure, target); 151 break; 136 137 if (event.getType() instanceof MouseButtonDown) { 138 structure.add("<StructureElement class=\"jacareto.struct.MouseClick\">"); 139 writeMouseClickEvent(writer, structure, event, 501); 152 140 } 153 141 else if (event.getType() instanceof MouseButtonUp) { 142 writeMouseClickEvent(writer, structure, event, 502); 143 } 144 else if (event.getType() instanceof MouseClick) { 145 writeMouseClickEvent(writer, structure, event, 500); 146 structure.add("</StructureElement>"); 147 // FIXME: don't always write an item action 148 writeItemActionEvent(writer, structure, event); 149 } 154 150 } 155 151 } … … 230 226 private void writeItemActionEvent(BufferedWriter writer, 231 227 ArrayList<String> structure, 232 JFCGUIElement target) throws IOException228 Event event) throws IOException 233 229 { 230 JFCGUIElement target = (JFCGUIElement) event.getTarget(); 231 MouseButtonInteraction info = (MouseButtonInteraction) event.getType(); 232 234 233 //@formatter:off 235 234 writeLine(writer, … … 253 252 + "ID=\"1001\" " 254 253 + "command=" + target.getName() + " " 255 + "modifiers=\" 16\" />"254 + "modifiers=\"" + getButtonModifier(info) + "\" />" 256 255 ); 257 256 //@formatter:on … … 264 263 private void writeMouseClickEvent(BufferedWriter writer, 265 264 ArrayList<String> structure, 266 long timestamp, 267 JFCGUIElement target, 265 Event event, 268 266 int jacId) throws IOException 269 267 { 270 // Note, that all position related attributes appear to be meaningless 271 // for our purposes. 268 MouseButtonInteraction info = (MouseButtonInteraction) event.getType(); 269 JFCGUIElement target = (JFCGUIElement) event.getTarget(); 270 int clickCount = event.getType() instanceof MouseDoubleClick ? 2 : 1; 271 272 272 // TODO: change procTime and duration to adequate values 273 273 //@formatter:off … … 286 286 + "width=\"0\" " 287 287 + "height=\"0\" " 288 + "when=\"" + timestamp+ "\" "288 + "when=\"" + event.getTimestamp() + "\" " 289 289 + "isConsumed=\"false\">" 290 290 ); 291 291 writeLine(writer, 292 292 "<MouseInfo " 293 + "xPosition=\" 0\" "294 + "yPosition=\" 0\" "293 + "xPosition=\"" + info.getX()+ "\" " 294 + "yPosition=\"" + info.getY()+ "\" " 295 295 + "rootX=\"0\" " 296 296 + "rootY=\"0\" " 297 + "clickCount=\" 1\" "298 + "modifiers=\" 16\" "297 + "clickCount=\"" + clickCount + "\" " 298 + "modifiers=\"" + getButtonModifier(info) + "\" " 299 299 + "isPopupTrigger=\"false\" />" 300 300 ); … … 304 304 structure.add("<Recordable ref=\"" + (nextRef++) + "\" />"); 305 305 } 306 307 private int getButtonModifier(MouseButtonInteraction info) { 308 switch (info.getButton()) 309 { 310 case LEFT: 311 return 16; 312 case MIDDLE: 313 return 8; 314 case RIGHT: 315 return 4; 316 default: 317 // TODO: handle unknown mouse button 318 return -1; 319 } 320 } 306 321 }
Note: See TracChangeset
for help on using the changeset viewer.