Changeset 850


Ignore:
Timestamp:
09/21/12 17:39:44 (12 years ago)
Author:
fglaser
Message:
  • improvements in JFCMonitor: prototype of JFCMonitors ability to log component name changes
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

    r842 r850  
    44import java.awt.Component; 
    55import java.awt.Container; 
     6import java.beans.PropertyChangeListener; 
    67import java.io.File; 
    78import java.lang.reflect.InvocationTargetException; 
    89import java.lang.reflect.Method; 
    910import java.security.InvalidParameterException; 
     11import java.util.ArrayList; 
    1012import java.util.HashMap; 
    1113import java.util.LinkedList; 
     
    3537    private static Map<Component, JFCComponent> knownComponents = 
    3638        new HashMap<Component, JFCComponent>(); 
     39     
     40    /** 
     41     * <p> 
     42     * List of PropertyChangeListeners that are registered on the components. 
     43     * </p> 
     44     */ 
     45     
     46    private static List<PropertyChangeListener> propertyChangeListeners =  
     47        new ArrayList<PropertyChangeListener>(); 
    3748 
    3849    /** 
     
    4758    public static void add(Component component) { 
    4859        add(component, find(component.getParent())); 
     60    } 
     61     
     62    public static void addListener(PropertyChangeListener list){ 
     63        propertyChangeListeners.add(list); 
    4964    } 
    5065 
     
    162177        } 
    163178        this.component = component; 
     179         
     180        AccessibleContext context = component.getAccessibleContext(); 
     181        if (context != null){ 
     182                for (PropertyChangeListener listener: propertyChangeListeners) 
     183                        context.addPropertyChangeListener(listener); 
     184        } 
     185         
    164186        this.parent = parent; 
    165187        if (parent != null) { 
     
    201223        builder.append("  <component"); 
    202224        if (parent != null){ 
    203                 builder.append(" parent=" + Integer.toHexString(parent.component.hashCode())); 
     225                builder.append(" parent=\"" + Integer.toHexString(parent.component.hashCode()) + "\""); 
    204226        } 
    205227        builder.append(">"+ StringTools.ENDLINE); 
     
    351373        } 
    352374    } 
    353  
    354375} 
  • trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor/JFCListener.java

    r842 r850  
    107107        if (event.getSource() instanceof Component) { 
    108108            Component source = (Component) event.getSource(); 
    109             builder.append(" hash=" + Integer.toHexString(source.hashCode())); 
     109            builder.append(" hash=\"" + Integer.toHexString(source.hashCode()) + "\""); 
    110110        }   
    111111        builder.append(">" + StringTools.ENDLINE); 
  • trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor/JFCMonitorOutputWriter.java

    r842 r850  
    3434    public JFCMonitorOutputWriter(OutputStreamWriter outputWriter) { 
    3535        this.outputWriter = outputWriter; 
    36         try { 
    37             outputWriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE); 
    38             outputWriter.write("<sessions>" + StringTools.ENDLINE); 
    39         } 
    40         catch (IOException e) { 
    41             System.err.println("JFCMONITOR -- Failure writing to log: " + e.getMessage()); 
    42         } 
     36        write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE); 
     37        write("<sessions>" + StringTools.ENDLINE); 
    4338    } 
    4439     
  • trunk/quest-jfcmonitor/src/main/java/de/ugoe/cs/quest/jfcmonitor/Runner.java

    r842 r850  
    6464        Toolkit.getDefaultToolkit().addAWTEventListener(new WindowMonitor(jfcWriter), 
    6565                                                        AWTEvent.WINDOW_EVENT_MASK); 
     66        JFCComponent.addListener(new NameChangeListener(jfcWriter)); 
    6667 
    6768        if (stdOutputWrite) { 
     
    7980                Toolkit.getDefaultToolkit().addAWTEventListener(new WindowMonitor(stdJfcWriter), 
    8081                        AWTEvent.WINDOW_EVENT_MASK); 
     82                JFCComponent.addListener(new NameChangeListener(stdJfcWriter)); 
    8183            } 
    8284            catch (UnsupportedEncodingException e) { 
Note: See TracChangeset for help on using the changeset viewer.