Ignore:
Timestamp:
08/13/14 16:48:31 (10 years ago)
Author:
dmay
Message:

move jacareto replay file generation into jfc plugin

File:
1 moved

Legend:

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

    r1671 r1673  
    1313//   limitations under the License. 
    1414 
    15 package de.ugoe.cs.autoquest.commands.sequences; 
     15package de.ugoe.cs.autoquest.plugin.jfc.commands; 
    1616 
    1717import java.io.BufferedWriter; 
     18import java.io.File; 
     19import java.io.FileOutputStream; 
    1820import java.io.IOException; 
     21import java.io.OutputStreamWriter; 
    1922import java.util.ArrayList; 
    2023import java.util.Collection; 
    2124import java.util.Iterator; 
    2225import java.util.List; 
     26import java.util.logging.Level; 
    2327 
    2428import de.ugoe.cs.autoquest.CommandHelpers; 
    2529import de.ugoe.cs.autoquest.SequenceInstanceOf; 
     30import de.ugoe.cs.util.console.Command; 
    2631import de.ugoe.cs.autoquest.eventcore.Event; 
     32import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement; 
    2733import de.ugoe.cs.util.console.Console; 
    2834import de.ugoe.cs.util.console.GlobalDataContainer; 
     
    3642 * @version 1.0 
    3743 */ 
    38 public class CMDgenerateJacaretoReplay extends CMDgenerateReplayfile { 
     44public class CMDgenerateJacaretoReplay implements Command { 
    3945 
    4046    /* 
     
    5662    @Override 
    5763    public void run(List<Object> parameters) { 
    58         // TODO: except for the last lines, this function is identical to 
    59         // superclass CMDgenerateReplayfile, extract a function 
    6064        String filename; 
    6165        String sequencesName; 
     
    125129                Event event = eventIter.next(); 
    126130 
    127                 // TODO 
    128                 System.out.println(event.getTarget()); 
    129                 System.out.println(event.getType()); 
     131                // TODO: do a mapping file or something to map 
     132                // 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()); 
     144                } 
    130145            } 
    131146        } 
     
    145160        } 
    146161        writeLine(writer, "</Structure>"); 
    147  
    148         writeLine(writer, "<JacaretoStructure>"); 
    149162    } 
    150163 
     
    156169            ArrayList<String> structure = writeJacaretoEvents(writer, sequences); 
    157170            writeJacaretoTail(writer, structure); 
     171            writeLine(writer, "<JacaretoStructure>"); 
    158172 
    159173            writer.flush(); 
     
    165179    } 
    166180 
     181    /** 
     182     * <p> 
     183     * Helper function that opens the replay file for writing. 
     184     * </p> 
     185     *  
     186     * @param filename 
     187     *            name and path of the replay file 
     188     * @param encoding 
     189     *            file encoding, empty string for platform default 
     190     * @return {@link OutputStreamWriter} that writes to the replay file 
     191     */ 
     192    private OutputStreamWriter openReplayFile(String filename) { 
     193        File file = new File(filename); 
     194        boolean fileCreated; 
     195        try { 
     196            fileCreated = file.createNewFile(); 
     197            if (!fileCreated) { 
     198                Console.traceln(Level.INFO, "Created logfile " + filename); 
     199            } 
     200            else { 
     201                Console.traceln(Level.INFO, "Overwrote existing logfile " + filename); 
     202            } 
     203        } 
     204        catch (IOException e) { 
     205            Console.printerrln("Unable to create file " + filename); 
     206            Console.logException(e); 
     207        } 
     208        OutputStreamWriter writer = null; 
     209        try { 
     210            writer = new OutputStreamWriter(new FileOutputStream(file)); 
     211        } 
     212        catch (IOException e) { 
     213            Console.printerrln("Unable to open file for writing (read-only file):" + filename); 
     214            Console.logException(e); 
     215        } 
     216        return writer; 
     217    } 
    167218} 
Note: See TracChangeset for help on using the changeset viewer.