Changeset 1838 for trunk


Ignore:
Timestamp:
11/27/14 22:07:25 (10 years ago)
Author:
dmay
Message:

reintroduce mouse dragging (done right, this time)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDgenerateJacaretoReplay.java

    r1836 r1838  
    267267 
    268268                if (event.getType() instanceof MouseButtonDown) { 
    269                     commitFocusEvent(); 
    270                     lastKeySequenceEvent = null; 
    271  
    272                     lastMouseClickEvent = new StructureNode("MouseClick"); 
    273                     lastMouseDownTarget = event.getTarget(); 
    274                     writeMouseClickEvent(writer, event, (JFCGUIElement) event.getTarget(), 
    275                                          EVENT_DURATION, 501); 
     269                    handleMouseDown(writer, event, "MouseClick"); 
    276270                } 
    277271                else if (event.getType() instanceof MouseButtonUp) { 
    278                     lastKeySequenceEvent = null; 
    279  
    280                     writeMouseClickEvent(writer, event, (JFCGUIElement) event.getTarget(), 
    281                                          EVENT_DURATION, 502); 
     272                    handleMouseUp(writer, event); 
    282273                } 
    283274                else if (event.getType() instanceof MouseDoubleClick) { 
     
    379370                    writeFocusChangeEvent(writer, event); 
    380371                } 
     372                else if (event.getType() instanceof MouseDragAndDrop) { 
     373                    handleMouseDragAndDrop(writer, event); 
     374                } 
    381375                else if (event.getType() instanceof KeyPressed) { 
    382376                    handleKeyPressed(writer, event); 
     
    388382                    handleTextInput(writer, event); 
    389383                } 
    390             } 
    391         } 
     384                else { 
     385                    Console.traceln(Level.WARNING, "No handler for event \"" + event + 
     386                        "\". Skipped."); 
     387                } 
     388            } 
     389        } 
     390    } 
     391 
     392    private void handleMouseDown(BufferedWriter writer, Event event, String structureName) 
     393        throws IOException 
     394    { 
     395        commitFocusEvent(); 
     396        lastKeySequenceEvent = null; 
     397 
     398        lastMouseClickEvent = new StructureNode(structureName); 
     399        lastMouseDownTarget = event.getTarget(); 
     400        writeMouseClickEvent(writer, event, (JFCGUIElement) event.getTarget(), EVENT_DURATION, 501); 
     401    } 
     402 
     403    private void handleMouseUp(BufferedWriter writer, Event event) throws IOException { 
     404        lastKeySequenceEvent = null; 
     405 
     406        writeMouseClickEvent(writer, event, (JFCGUIElement) event.getTarget(), EVENT_DURATION, 502); 
     407    } 
     408 
     409    private void handleMouseDragAndDrop(BufferedWriter writer, Event event) throws IOException { 
     410        commitFocusEvent(); 
     411 
     412        MouseDragAndDrop dragEvent = (MouseDragAndDrop) event.getType(); 
     413        lastMouseClickEvent = new StructureNode("MouseDrag"); 
     414        lastMouseDownTarget = null; 
     415 
     416        writeMouseClickEvent(writer, event, (JFCGUIElement) event.getTarget(), EVENT_DURATION, 
     417                             dragEvent.getXStart(), dragEvent.getYStart(), 501); 
     418        writeMouseClickEvent(writer, event, (JFCGUIElement) event.getTarget(), EVENT_DURATION, 
     419                             dragEvent.getX(), dragEvent.getY(), 506); 
     420 
     421        structure.children.add(lastMouseClickEvent); 
    392422    } 
    393423 
     
    642672    { 
    643673        MouseButtonInteraction info = (MouseButtonInteraction) event.getType(); 
     674        writeMouseClickEvent(writer, event, target, duration, info.getX(), info.getY(), jacId); 
     675    } 
     676 
     677    private void writeMouseClickEvent(BufferedWriter writer, 
     678                                      Event event, 
     679                                      JFCGUIElement target, 
     680                                      int duration, 
     681                                      int x, 
     682                                      int y, 
     683                                      int jacId) throws IOException 
     684    { 
     685        MouseButtonInteraction info = (MouseButtonInteraction) event.getType(); 
    644686        int clickCount = event.getType() instanceof MouseDoubleClick ? 2 : 1; 
    645687 
     
    664706        writeLine(writer, 
    665707            "<MouseInfo " 
    666             + "xPosition=\"" + info.getX() + "\" " 
    667             + "yPosition=\"" + info.getY() + "\" " 
     708            + "xPosition=\"" + x + "\" " 
     709            + "yPosition=\"" + y + "\" " 
    668710            + "rootX=\"0\" " 
    669711            + "rootY=\"0\" " 
Note: See TracChangeset for help on using the changeset viewer.