Changeset 851 for trunk/quest-jfcmonitor
- Timestamp:
- 10/01/12 12:01:25 (12 years ago)
- Location:
- trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor
- Files:
-
- 1 added
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor/JFCComponent.java
r850 r851 4 4 import java.awt.Component; 5 5 import java.awt.Container; 6 import java.awt.event.ContainerListener; 6 7 import java.beans.PropertyChangeListener; 7 8 import java.io.File; … … 46 47 private static List<PropertyChangeListener> propertyChangeListeners = 47 48 new ArrayList<PropertyChangeListener>(); 49 50 private static List<ContainerListener> containerListeners = 51 new ArrayList<ContainerListener>(); 48 52 49 53 /** … … 60 64 } 61 65 62 public static void add Listener(PropertyChangeListener list){66 public static void addPropertyChangeListener(PropertyChangeListener list){ 63 67 propertyChangeListeners.add(list); 68 } 69 70 public static void addContainerListener(ContainerListener list){ 71 containerListeners.add(list); 72 } 73 74 public static boolean isKnown(Component component){ 75 if (knownComponents.containsKey(component)) 76 return true; 77 return false; 64 78 } 65 79 … … 190 204 191 205 if (component instanceof Container) { 206 for (ContainerListener listener: containerListeners) 207 ((Container) component).addContainerListener(listener); 208 192 209 for (Component childComponent : ((Container) component).getComponents()) { 193 210 add(childComponent, this); … … 223 240 builder.append(" <component"); 224 241 if (parent != null){ 242 if (!JFCComponent.isKnown(parent.component)) 243 throw new AssertionError("Referenced parent is not known."); 225 244 builder.append(" parent=\"" + Integer.toHexString(parent.component.hashCode()) + "\""); 226 245 } -
trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor/JFCNameChangeListener.java
r850 r851 8 8 import java.beans.PropertyChangeListener; 9 9 10 import javax.accessibility.AccessibleContext; 11 10 12 import de.ugoe.cs.util.StringTools; 11 13 … … 14 16 * 15 17 */ 16 public class NameChangeListener implements PropertyChangeListener {18 public class JFCNameChangeListener implements PropertyChangeListener { 17 19 /** 18 20 * <p> … … 22 24 final private JFCMonitorOutputWriter outputWriter; 23 25 24 public NameChangeListener(JFCMonitorOutputWriter outputWriter){26 public JFCNameChangeListener(JFCMonitorOutputWriter outputWriter){ 25 27 this.outputWriter = outputWriter; 26 28 } … … 29 31 public void propertyChange(PropertyChangeEvent evt) { 30 32 if (evt.getPropertyName().equals("AccessibleName")){ 33 AccessibleContext context = (AccessibleContext) evt.getSource(); 34 Component component = (Component) context.getAccessibleParent(); 31 35 StringBuilder builder = new StringBuilder(); 32 36 builder.append("<componentNameChange hash=\""); 33 outputWriter.write(evt.getSource().toString()); 34 if (JFCComponent.find((Component) evt.getSource()) == null) 35 System.err.println("Quelle nicht bekannt"); 36 builder.append(Integer.toHexString(evt.getSource().hashCode())); 37 if (!JFCComponent.isKnown(component)){ 38 System.err.println("Referenced component is not known"); 39 throw new AssertionError("Referenced component is not known."); 40 } 41 builder.append(Integer.toHexString(component.hashCode())); 37 42 builder.append("\" newName=\"" + evt.getNewValue()); 38 43 builder.append("\"/>" + StringTools.ENDLINE); 39 44 outputWriter.write(builder.toString()); 40 } 41 45 } 42 46 } 43 47 -
trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor/Runner.java
r850 r851 64 64 Toolkit.getDefaultToolkit().addAWTEventListener(new WindowMonitor(jfcWriter), 65 65 AWTEvent.WINDOW_EVENT_MASK); 66 JFCComponent.add Listener(newNameChangeListener(jfcWriter));66 JFCComponent.addPropertyChangeListener(new JFCNameChangeListener(jfcWriter)); 67 67 68 68 if (stdOutputWrite) { … … 80 80 Toolkit.getDefaultToolkit().addAWTEventListener(new WindowMonitor(stdJfcWriter), 81 81 AWTEvent.WINDOW_EVENT_MASK); 82 JFCComponent.addListener(new NameChangeListener(stdJfcWriter)); 82 JFCComponent.addPropertyChangeListener(new JFCNameChangeListener(stdJfcWriter)); 83 JFCComponent.addContainerListener(new JFCContainerListener(stdJfcWriter)); 83 84 } 84 85 catch (UnsupportedEncodingException e) { -
trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor/WindowMonitor.java
r850 r851 60 60 } 61 61 break; 62 case WindowEvent.WINDOW_CLOSED:63 window = ((WindowEvent) event).getWindow();64 JFCComponent.remove(window);65 break;66 62 default: 67 63 break;
Note: See TracChangeset
for help on using the changeset viewer.