Changeset 842 for trunk/quest-jfcmonitor/src
- Timestamp:
- 09/20/12 17:01:25 (12 years ago)
- Location:
- trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor/JFCComponent.java
r825 r842 23 23 * </p> 24 24 * 25 * @author Steffen Herbold 25 * @author Steffen Herbold, Fabian Glaser 26 26 * @version 1.0 27 27 */ … … 199 199 setTitle(); 200 200 StringBuilder builder = new StringBuilder(); 201 if (parent != null) { 202 builder.append(parent.getXML()); 203 } 204 builder.append(" <component>" + StringTools.ENDLINE); 201 builder.append(" <component"); 202 if (parent != null){ 203 builder.append(" parent=" + Integer.toHexString(parent.component.hashCode())); 204 } 205 builder.append(">"+ StringTools.ENDLINE); 205 206 builder.append(" <param name=\"title\" value=\"" + title + "\" />" + StringTools.ENDLINE); 206 207 builder.append(" <param name=\"class\" value=\"" + componentClass + "\" />" + … … 212 213 builder.append(" </component>" + StringTools.ENDLINE); 213 214 return builder.toString(); 215 } 216 217 /** 218 * <p> 219 * Returns an XML representation of the components children. 220 * </p> 221 * @return XML representation of children 222 */ 223 public String printChildren(){ 224 StringBuilder builder = new StringBuilder(); 225 for (JFCComponent child: children){ 226 builder.append(child.getXML()); 227 builder.append(child.printChildren()); 228 } 229 return builder.toString(); 214 230 } 215 231 -
trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor/JFCListener.java
r825 r842 8 8 import java.awt.event.KeyEvent; 9 9 import java.awt.event.MouseEvent; 10 import java.io.IOException;11 import java.io.OutputStreamWriter;12 10 13 11 import de.ugoe.cs.util.StringTools; … … 19 17 * </p> 20 18 * 21 * @author Steffen Herbold 19 * @author Steffen Herbold, Fabian Glaser 22 20 * @version 1.0 23 21 */ … … 29 27 * </p> 30 28 */ 31 final private OutputStreamWriter outputWriter;29 final private JFCMonitorOutputWriter outputWriter; 32 30 33 31 /** 34 32 * <p> 35 * Constructor. Creates a new JFCListener with a given {@link OutputStreamWriter}, where the33 * Constructor. Creates a new JFCListener with a given {@link JFCMonitorOutputWriter}, where the 36 34 * monitored information is logged. 37 35 * </p> … … 40 38 * writer for the logged information 41 39 */ 42 public JFCListener( OutputStreamWriter outputWriter) {40 public JFCListener(JFCMonitorOutputWriter outputWriter) { 43 41 this.outputWriter = outputWriter; 44 try {45 outputWriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE);46 outputWriter.write("<sessions>" + StringTools.ENDLINE);47 }48 catch (IOException e) {49 System.err.println("JFCMONITOR -- Failure writing to log: " + e.getMessage());50 }51 42 } 52 43 … … 98 89 } 99 90 if (builder.length() > 0 && outputWriter != null) { 100 try { 101 outputWriter.write(builder.toString()); 102 outputWriter.flush(); 103 } 104 catch (IOException e) { 105 System.err.println("JFCMONITOR -- Failure writing to log: " + e.getMessage()); 106 } 91 outputWriter.write(builder.toString()); 107 92 } 108 93 } … … 119 104 */ 120 105 private void addSourceInfo(StringBuilder builder, AWTEvent event) { 121 builder.append(" <source>" + StringTools.ENDLINE); 106 builder.append(" <source"); 107 if (event.getSource() instanceof Component) { 108 Component source = (Component) event.getSource(); 109 builder.append(" hash=" + Integer.toHexString(source.hashCode())); 110 } 111 builder.append(">" + StringTools.ENDLINE); 122 112 builder.append(" <param name=\"toString\" value=\"" + 123 113 StringTools.xmlEntityReplacement(event.getSource().toString()) + "\" />" + 124 114 StringTools.ENDLINE); 125 if (event.getSource() instanceof Component) {126 Component source = (Component) event.getSource();127 JFCComponent jfcComponent = JFCComponent.find(source);128 if (jfcComponent != null) {129 builder.append(jfcComponent.getXML());130 }131 }132 115 builder.append(" </source>" + StringTools.ENDLINE); 133 116 } -
trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor/Runner.java
r825 r842 20 20 * </p> 21 21 * 22 * @author Steffen Herbold 22 * @author Steffen Herbold, Fabian Glaser 23 23 * @version 1.0 24 24 */ … … 50 50 // the writer is not closed explicitly! 51 51 fis = new FileOutputStream(logfileName, true); 52 writer = new OutputStreamWriter(fis, "UTF- 16");52 writer = new OutputStreamWriter(fis, "UTF-8"); 53 53 } 54 54 catch (IOException e) { … … 57 57 } 58 58 59 AWTEventListener listenerFile = new JFCListener(writer); 59 JFCMonitorOutputWriter jfcWriter = new JFCMonitorOutputWriter(writer); 60 AWTEventListener listenerFile = new JFCListener(jfcWriter); 60 61 Toolkit.getDefaultToolkit().addAWTEventListener(listenerFile, AWTEvent.KEY_EVENT_MASK); 61 62 Toolkit.getDefaultToolkit().addAWTEventListener(listenerFile, AWTEvent.MOUSE_EVENT_MASK); 62 63 Toolkit.getDefaultToolkit().addAWTEventListener(listenerFile, FocusEvent.FOCUS_EVENT_MASK); 63 Toolkit.getDefaultToolkit().addAWTEventListener(new WindowMonitor( ),64 Toolkit.getDefaultToolkit().addAWTEventListener(new WindowMonitor(jfcWriter), 64 65 AWTEvent.WINDOW_EVENT_MASK); 65 66 … … 67 68 AWTEventListener listenerStdOut; 68 69 try { 69 listenerStdOut = new JFCListener(new OutputStreamWriter(System.out, "UTF-8")); 70 OutputStreamWriter stdOutputWriter = new OutputStreamWriter(System.out, "UTF-8"); 71 JFCMonitorOutputWriter stdJfcWriter = new JFCMonitorOutputWriter(stdOutputWriter); 72 listenerStdOut = new JFCListener(stdJfcWriter); 70 73 Toolkit.getDefaultToolkit().addAWTEventListener(listenerStdOut, 71 74 AWTEvent.KEY_EVENT_MASK); … … 74 77 Toolkit.getDefaultToolkit().addAWTEventListener(listenerStdOut, 75 78 FocusEvent.FOCUS_EVENT_MASK); 79 Toolkit.getDefaultToolkit().addAWTEventListener(new WindowMonitor(stdJfcWriter), 80 AWTEvent.WINDOW_EVENT_MASK); 76 81 } 77 82 catch (UnsupportedEncodingException e) { -
trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor/WindowMonitor.java
r825 r842 12 12 * </p> 13 13 * 14 * @author Steffen Herbold 14 * @author Steffen Herbold, Fabian Glaser 15 15 * @version 1.0 16 16 */ 17 17 public class WindowMonitor implements AWTEventListener { 18 /** 19 * <p> 20 * Writer for logging events. 21 * </p> 22 */ 23 final private JFCMonitorOutputWriter outputWriter; 24 25 /** 26 * <p> 27 * Constructor. Creates a new WindowMonitor with a given {@link JFCMonitorOutputWriter}, where the 28 * monitored information is logged. 29 * </p> 30 * 31 * @param outputWriter 32 * writer for the logged information 33 */ 34 public WindowMonitor(JFCMonitorOutputWriter outputWriter) { 35 this.outputWriter = outputWriter; 36 } 37 18 38 19 39 /** … … 34 54 window = ((WindowEvent) event).getWindow(); 35 55 JFCComponent.add(window); 56 JFCComponent jfcComponent = JFCComponent.find(window); 57 if (jfcComponent != null) { 58 outputWriter.write(jfcComponent.getXML()); 59 outputWriter.write(jfcComponent.printChildren()); 60 } 36 61 break; 37 62 case WindowEvent.WINDOW_CLOSED:
Note: See TracChangeset
for help on using the changeset viewer.