Ignore:
Timestamp:
08/14/14 17:07:17 (10 years ago)
Author:
dmay
Message:

current progress: generate valid jacareto xml files and start replaying mouse clicks

File:
1 edited

Legend:

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

    r1673 r1678  
    2424import java.util.Iterator; 
    2525import java.util.List; 
     26import java.util.UUID; 
    2627import java.util.logging.Level; 
    2728 
     
    3031import de.ugoe.cs.util.console.Command; 
    3132import de.ugoe.cs.autoquest.eventcore.Event; 
     33import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
    3234import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement; 
    3335import de.ugoe.cs.util.console.Console; 
     
    4345 */ 
    4446public class CMDgenerateJacaretoReplay implements Command { 
     47 
     48    private int nextRef; 
    4549 
    4650    /* 
     
    108112        writeLine(writer, 
    109113                  "<KeyboardState procTime=\"0\" duration=\"0\" isNumLockOn=\"false\" isScrollLockOn=\"false\" isCapsLockOn=\"false\" applyIsNumLockOn=\"true\" applyIsScrollLockOn=\"true\" applyIsCapsLockOn=\"true\" uuid=\"28146f79-9fc7-49f9-b4a8-5866a7625683\" />"); 
    110         writeLine(writer, "ComponentMode numberPopupMenues=\"true\" />"); 
     114        writeLine(writer, "<ComponentMode numberPopupMenues=\"true\" />"); 
    111115        writeLine(writer, 
    112116                  "<ApplicationStarter procTime=\"5\" duration=\"5\" name=\"HelloWorldSwing\" class=\"HelloWorldSwing\" initclass=\"\" basepath=\"/home/daniel/project/autoquest-jfcmonitor\" classpathext=\"${basepath}/helloswing.jar;${basepath}/.;\" detectDuration=\"false\" captureparams=\"\" replayparams=\"\" uuid=\"a7b7d7b9-caa9-4d6d-b052-cf74d353275e\" />"); 
     
    120124        structure.add("<StructureElement class=\"jacareto.struct.RootElement\">"); 
    121125        // reference the elements that we included in the header 
    122         structure.add("<Recordable ref=\"1\" />"); // Calendar 
    123         structure.add("<Recordable ref=\"2\" />"); // SystemInfo 
    124         structure.add("<Recordable ref=\"3\" />"); // KeyboardState 
     126        structure.add("<Recordable ref=\"0\" />"); // Calendar 
     127        structure.add("<Recordable ref=\"1\" />"); // SystemInfo 
     128        structure.add("<Recordable ref=\"2\" />"); // KeyboardState 
     129        structure.add("<Recordable ref=\"3\" />"); // ComponentMode 
    125130        structure.add("<Recordable ref=\"4\" />"); // ApplicationStarter 
     131        nextRef = 5; 
    126132 
    127133        for (List<Event> sequence : sequences) { 
     
    131137                // TODO: do a mapping file or something to map 
    132138                // from autoquest events to jacareto events 
    133                 if (event.getType().getName().equals("KeyboardFocusChange")) { 
    134                     /* 
    135                     writeLine( 
    136                         "<FocusEvent procTime=\"0\" duration=\"0\" source="JFrame_(1).JRootPane_(1).JLayeredPane_(1).JPanel_(1).JPanel_(1).JCheckBox_(1)" +" + 
    137                         "       class="javax.swing.JCheckBox" uuid="061bee8f-d8a3-477f-ab8d-bab02f614916" ID="1004" component="null" root="JFrame_(1)" xPos="0" yPos="0" width="0" height="0" isTemporary="false" />"); 
    138                     */ 
    139                     System.out.println(((JFCGUIElement)event.getTarget()).getJacaretoHierarchy()); 
    140                 } 
    141                 else { 
    142                     System.out.println(event.getType()); 
    143                     System.out.println(event.getTarget()); 
     139                if (event.getType().getName().equals("LeftMouseClick")) { 
     140                    JFCGUIElement target = (JFCGUIElement) event.getTarget(); 
     141 
     142                    // FIXME: assume that the target is a checkbox for now =) 
     143                    // this is an item event and an action event in jacareto 
     144                    //@formatter:off 
     145                    writeLine(writer, 
     146                        "<ItemEvent " 
     147                        + "procTime=\"1\" " 
     148                        + "duration=\"8\" " 
     149                        + "source=\"" + target.getJacaretoHierarchy() + "\" " 
     150                        + "class=\"" + target.getSpecification().getType() + "\" " 
     151                        + "uuid=\"" + UUID.randomUUID() + "\" " 
     152                        + "ID=\"701\" " 
     153                        + "item=\"\" " 
     154                        + "stateChange=\"1\" />" 
     155                    ); 
     156                    writeLine(writer, 
     157                        "<ActionEvent " 
     158                        + "procTime=\"1\" " 
     159                        + "duration=\"0\" " 
     160                        + "source=\"" + target.getJacaretoHierarchy() + "\" " 
     161                        + "class=\"" + target.getSpecification().getType() + "\" " 
     162                        + "uuid=\"" + UUID.randomUUID() + "\" " 
     163                        + "ID=\"1001\" " 
     164                        + "command=" + target.getName() + " " 
     165                        + "modifiers=\"16\" />" 
     166                    ); 
     167                    //@formatter:on 
     168                    structure.add("<StructureElement class=\"jacareto.struct.ItemStateChange\">"); 
     169                    structure.add("<Recordable ref=\"" + (nextRef++) + "\" />"); 
     170                    structure.add("<Recordable ref=\"" + (nextRef++) + "\" />"); 
     171                    structure.add("</StructureElement>"); 
    144172                } 
    145173            } 
     
    159187            writeLine(writer, element); 
    160188        } 
     189        // close root element 
     190        writeLine(writer, "</StructureElement>"); 
    161191        writeLine(writer, "</Structure>"); 
    162192    } 
     
    169199            ArrayList<String> structure = writeJacaretoEvents(writer, sequences); 
    170200            writeJacaretoTail(writer, structure); 
    171             writeLine(writer, "<JacaretoStructure>"); 
     201            writeLine(writer, "</JacaretoStructure>"); 
    172202 
    173203            writer.flush(); 
Note: See TracChangeset for help on using the changeset viewer.