Changeset 1712


Ignore:
Timestamp:
09/02/14 14:53:55 (10 years ago)
Author:
dmay
Message:

it is now possible to replay arbitrary jfc programs (not recommended though because of ID problem)

File:
1 edited

Legend:

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

    r1704 r1712  
    9898 
    9999    private HashMap<VirtualKey, Integer> modifiers; 
    100      
     100 
    101101    private StructureNode lastMouseClickEvent; 
    102102    private StructureNode lastFocusChangeEvent; 
     
    110110    @Override 
    111111    public String help() { 
    112         return "generateJacaretoReplay <filename> <sequences>"; 
     112        return "generateJacaretoReplay <filename> <sequences> <class> <basepath> <classpathext> {<initclass>}"; 
    113113    } 
    114114 
     
    123123        String filename; 
    124124        String sequencesName; 
     125        String classpath; 
     126        String basepath; 
     127        String classpathext; 
     128        String initclass = ""; 
    125129        try { 
    126130            filename = (String) parameters.get(0); 
    127131            sequencesName = (String) parameters.get(1); 
     132            classpath = (String) parameters.get(2); 
     133            basepath = (String) parameters.get(3); 
     134            classpathext = (String) parameters.get(4); 
    128135        } 
    129136        catch (Exception e) { 
    130137            throw new IllegalArgumentException(); 
     138        } 
     139 
     140        if (parameters.size() > 5) { 
     141            initclass = (String) parameters.get(5); 
    131142        } 
    132143 
     
    151162        modifiers.put(VirtualKey.ALT_GRAPH, 32); 
    152163        currentKeyModifiers = 0; 
    153          
    154         writeJacaretoXML(sequences, filename); 
     164 
     165        writeJacaretoXML(sequences, filename, classpath, initclass, basepath, classpathext); 
    155166    } 
    156167 
     
    160171    } 
    161172 
    162     private void writeJacaretoHead(BufferedWriter writer) throws IOException { 
     173    private void writeJacaretoHead(BufferedWriter writer, 
     174                                   String classname, 
     175                                   String initclass, 
     176                                   String basepath, 
     177                                   String classpathext) throws IOException 
     178    { 
    163179        writeLine(writer, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"); 
    164180        writeLine(writer, "<JacaretoStructure>"); 
     
    170186        // application starter details need to be changed for general cases. 
    171187        writeLine(writer, 
    172                   "<Calendar procTime=\"0\" duration=\"0\" year=\"2014\" month=\"8\" date=\"11\" hour=\"14\" min=\"43\" sec=\"41\" uuid=\"06831ba1-f28a-4e05-b46e-ce9d8f9ffa0f\" />"); 
     188                  "<Calendar procTime=\"0\" duration=\"0\" year=\"2000\" month=\"1\" date=\"11\" hour=\"1\" min=\"1\" sec=\"1\" uuid=\"06831ba1-f28a-4e05-b46e-ce9d8f9ffa0f\" />"); 
    173189        writeLine(writer, 
    174190                  "<SystemInfo procTime=\"0\" duration=\"0\" screenWidth=\"2646\" screenHeight=\"1024\" javaVersion=\"1.7.0_65\" lookAndFeel=\"javax.swing.plaf.metal.MetalLookAndFeel\" uuid=\"720f430f-52cf-4d8b-9fbe-58434f766efe\" />"); 
     
    176192                  "<KeyboardState procTime=\"0\" duration=\"0\" isNumLockOn=\"false\" isScrollLockOn=\"false\" isCapsLockOn=\"false\" applyIsNumLockOn=\"true\" applyIsScrollLockOn=\"true\" applyIsCapsLockOn=\"true\" uuid=\"28146f79-9fc7-49f9-b4a8-5866a7625683\" />"); 
    177193        writeLine(writer, "<ComponentMode numberPopupMenues=\"true\" />"); 
    178         writeLine(writer, 
    179                   "<ApplicationStarter procTime=\"0\" duration=\"0\" 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\" />"); 
     194        //@formatter:off 
     195        writeLine(writer, "<ApplicationStarter " 
     196            + "procTime=\"0\" " 
     197            + "duration=\"0\" " 
     198            + "name=\"Autoquest Replay\" " 
     199            + "class=\"" + classname + "\" " 
     200            + "initclass=\"" + initclass + "\" "  
     201            + "basepath=\"" + basepath + "\" " 
     202            + "classpathext=\"" + classpathext + "\" " 
     203            + "detectDuration=\"false\" " 
     204            + "captureparams=\"\" " 
     205            + "replayparams=\"\" " 
     206            + "uuid=\"a7b7d7b9-caa9-4d6d-b052-cf74d353275e\" />" 
     207        ); 
     208        //@formatter:on 
    180209    } 
    181210 
     
    257286    } 
    258287 
    259     private void writeJacaretoXML(Collection<List<Event>> sequences, String filename) { 
     288    private void writeJacaretoXML(Collection<List<Event>> sequences, 
     289                                  String filename, 
     290                                  String classpath, 
     291                                  String initclass, 
     292                                  String basepath, 
     293                                  String classpathext) 
     294    { 
    260295        BufferedWriter writer = new BufferedWriter(openReplayFile(filename + ".xml")); 
    261296 
    262297        try { 
    263             writeJacaretoHead(writer); 
     298            writeJacaretoHead(writer, classpath, initclass, basepath, classpathext); 
    264299            writeJacaretoEvents(writer, sequences); 
    265300            writeJacaretoTail(writer); 
     
    455490 
    456491        applyKeyModifier(info.getKey(), jacId == 401); 
    457          
     492 
    458493        //@formatter:off 
    459494        writeLine(writer, 
     
    490525            return String.valueOf((char)keyCode); 
    491526        } 
    492         else { 
    493             return "_NO_LEGAL_XML_CHAR"; 
    494         } 
     527 
     528        return "_NO_LEGAL_XML_CHAR"; 
    495529    } 
    496530     
Note: See TracChangeset for help on using the changeset viewer.