Changeset 1670


Ignore:
Timestamp:
08/13/14 14:56:12 (10 years ago)
Author:
dmay
Message:

extract Jacareto replay file generation out of generateReplayfile again,
the minor changes to openReplayFile still persist though

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/sequences/CMDgenerateReplayfile.java

    r1663 r1670  
    1515package de.ugoe.cs.autoquest.commands.sequences; 
    1616 
    17 import java.io.BufferedWriter; 
    1817import java.io.File; 
    1918import java.io.FileOutputStream; 
     
    2120import java.io.OutputStreamWriter; 
    2221import java.util.Collection; 
    23 import java.util.Iterator; 
    2422import java.util.List; 
    2523import java.util.logging.Level; 
     
    8886        sequences = (Collection<List<Event>>) dataObject; 
    8987        createLogfileMultipleSessions(sequences, filename); 
    90  
    91         writeJacaretoXML(sequences, filename); 
    92     } 
    93  
    94     private void writeLine(BufferedWriter writer, String line) throws IOException { 
    95         writer.write(line); 
    96         writer.newLine(); 
    97     } 
    98  
    99     private void writeJacaretoHead(BufferedWriter writer) throws IOException { 
    100         writeLine(writer, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"); 
    101         writeLine(writer, "<JacaretoStructure>"); 
    102         writeLine(writer, "<Record>"); 
    103  
    104         // TODO: This header content is basically copy+paste from a 
    105         // specific jacareto replay file right now. 
    106         // Some things such as screen resolution and especially the 
    107         // application starter details need to be changed for general cases. 
    108         writeLine(writer, 
    109                   "<Calendar procTime=\"0\" duration=\"0\" year=\"2014\" month=\"8\" date=\"11\" hour=\"14\" min=\"43\" sec=\"41\" uuid=\"06831ba1-f28a-4e05-b46e-ce9d8f9ffa0f\" />"); 
    110         writeLine(writer, 
    111                   "<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\" />"); 
    112         writeLine(writer, 
    113                   "<KeyboardState procTime=\"0\" duration=\"0\" isNumLockOn=\"false\" isScrollLockOn=\"false\" isCapsLockOn=\"false\" applyIsNumLockOn=\"true\" applyIsScrollLockOn=\"true\" applyIsCapsLockOn=\"true\" uuid=\"28146f79-9fc7-49f9-b4a8-5866a7625683\" />"); 
    114         writeLine(writer, "ComponentMode numberPopupMenues=\"true\" />"); 
    115         writeLine(writer, 
    116                   "<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\" />"); 
    117     } 
    118  
    119     private void writeJacaretoEvents(BufferedWriter writer, Collection<List<Event>> sequences) 
    120         throws IOException 
    121     { 
    122         for (List<Event> sequence : sequences) { 
    123             for (Iterator<Event> eventIter = sequence.iterator(); eventIter.hasNext();) { 
    124                 Event event = eventIter.next(); 
    125  
    126                 // TODO 
    127             } 
    128         } 
    129     } 
    130  
    131     private void writeJacaretoTail(BufferedWriter writer) throws IOException { 
    132         writeLine(writer, "</Record>"); 
    133  
    134         // TODO: There is a really big <structure> part in jacareto's replay 
    135         // files but they make no sense to me right now - skip this until later 
    136         // or until jacareto complains. =) 
    137         writeLine(writer, "<Structure>"); 
    138         writeLine(writer, "</Structure>"); 
    139  
    140         writeLine(writer, "<JacaretoStructure>"); 
    141     } 
    142  
    143     private void writeJacaretoXML(Collection<List<Event>> sequences, String filename) { 
    144         BufferedWriter writer = new BufferedWriter(openReplayFile(filename + ".xml")); 
    145  
    146         try { 
    147             writeJacaretoHead(writer); 
    148             writeJacaretoEvents(writer, sequences); 
    149             writeJacaretoTail(writer); 
    150  
    151             writer.flush(); 
    152             writer.close(); 
    153         } 
    154         catch (IOException e) { 
    155             Console.printerrln("Unable to write Jacareto replay file " + filename); 
    156         } 
    15788    } 
    15889 
     
    225156     * @return {@link OutputStreamWriter} that writes to the replay file 
    226157     */ 
    227     private OutputStreamWriter openReplayFile(String filename, String encoding) { 
     158    protected OutputStreamWriter openReplayFile(String filename, String encoding) { 
    228159        File file = new File(filename); 
    229160        boolean fileCreated; 
     
    257188    } 
    258189 
    259     private OutputStreamWriter openReplayFile(String filename) { 
     190    /** 
     191     * <p> 
     192     * Helper function that opens the replay file for writing. 
     193     * </p> 
     194     *  
     195     * @param filename 
     196     *            name and path of the replay file 
     197     * @return {@link OutputStreamWriter} that writes to the replay file 
     198     */ 
     199    protected OutputStreamWriter openReplayFile(String filename) { 
    260200        return openReplayFile(filename, ""); 
    261201    } 
Note: See TracChangeset for help on using the changeset viewer.