Changeset 1670
- Timestamp:
- 08/13/14 14:56:12 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/sequences/CMDgenerateReplayfile.java
r1663 r1670 15 15 package de.ugoe.cs.autoquest.commands.sequences; 16 16 17 import java.io.BufferedWriter;18 17 import java.io.File; 19 18 import java.io.FileOutputStream; … … 21 20 import java.io.OutputStreamWriter; 22 21 import java.util.Collection; 23 import java.util.Iterator;24 22 import java.util.List; 25 23 import java.util.logging.Level; … … 88 86 sequences = (Collection<List<Event>>) dataObject; 89 87 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 a105 // specific jacareto replay file right now.106 // Some things such as screen resolution and especially the107 // 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 IOException121 {122 for (List<Event> sequence : sequences) {123 for (Iterator<Event> eventIter = sequence.iterator(); eventIter.hasNext();) {124 Event event = eventIter.next();125 126 // TODO127 }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 replay135 // files but they make no sense to me right now - skip this until later136 // 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 }157 88 } 158 89 … … 225 156 * @return {@link OutputStreamWriter} that writes to the replay file 226 157 */ 227 pr ivateOutputStreamWriter openReplayFile(String filename, String encoding) {158 protected OutputStreamWriter openReplayFile(String filename, String encoding) { 228 159 File file = new File(filename); 229 160 boolean fileCreated; … … 257 188 } 258 189 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) { 260 200 return openReplayFile(filename, ""); 261 201 }
Note: See TracChangeset
for help on using the changeset viewer.