Changeset 1673 for trunk/autoquest-plugin-jfc
- Timestamp:
- 08/13/14 16:48:31 (10 years ago)
- 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 13 13 // limitations under the License. 14 14 15 package de.ugoe.cs.autoquest. commands.sequences;15 package de.ugoe.cs.autoquest.plugin.jfc.commands; 16 16 17 17 import java.io.BufferedWriter; 18 import java.io.File; 19 import java.io.FileOutputStream; 18 20 import java.io.IOException; 21 import java.io.OutputStreamWriter; 19 22 import java.util.ArrayList; 20 23 import java.util.Collection; 21 24 import java.util.Iterator; 22 25 import java.util.List; 26 import java.util.logging.Level; 23 27 24 28 import de.ugoe.cs.autoquest.CommandHelpers; 25 29 import de.ugoe.cs.autoquest.SequenceInstanceOf; 30 import de.ugoe.cs.util.console.Command; 26 31 import de.ugoe.cs.autoquest.eventcore.Event; 32 import de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement; 27 33 import de.ugoe.cs.util.console.Console; 28 34 import de.ugoe.cs.util.console.GlobalDataContainer; … … 36 42 * @version 1.0 37 43 */ 38 public class CMDgenerateJacaretoReplay extends CMDgenerateReplayfile{44 public class CMDgenerateJacaretoReplay implements Command { 39 45 40 46 /* … … 56 62 @Override 57 63 public void run(List<Object> parameters) { 58 // TODO: except for the last lines, this function is identical to59 // superclass CMDgenerateReplayfile, extract a function60 64 String filename; 61 65 String sequencesName; … … 125 129 Event event = eventIter.next(); 126 130 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 } 130 145 } 131 146 } … … 145 160 } 146 161 writeLine(writer, "</Structure>"); 147 148 writeLine(writer, "<JacaretoStructure>");149 162 } 150 163 … … 156 169 ArrayList<String> structure = writeJacaretoEvents(writer, sequences); 157 170 writeJacaretoTail(writer, structure); 171 writeLine(writer, "<JacaretoStructure>"); 158 172 159 173 writer.flush(); … … 165 179 } 166 180 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 } 167 218 }
Note: See TracChangeset
for help on using the changeset viewer.