Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [albireo-dev] Focus Management Test Cases

Bruno Haible wrote:

I'm committing the FocusDebugging class, so use can use that easily for
the analysis.

I have a different, simpler way of tracing the AWT focus events. It uses a property change listener on the keyboard focus manager. It's a little more helpful to me because it also tracks events on AWT dialogs.

I'm committing this debug code to AwtEnvironment. If it can provide all the AWT information that the FocusDebugging provides, then I suggest keeping only this simpler version of the trace code and removing the AWT tracing from FocusDebugging.


### Eclipse Workspace Patch 1.0
#P org.eclipse.albireo.core
Index: src/org/eclipse/albireo/core/AwtEnvironment.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.core/src/org/eclipse/albireo/core/AwtEnvironment.java,v
retrieving revision 1.7
diff -u -r1.7 AwtEnvironment.java
--- src/org/eclipse/albireo/core/AwtEnvironment.java	11 Feb 2008 22:46:31 -0000	1.7
+++ src/org/eclipse/albireo/core/AwtEnvironment.java	12 Feb 2008 23:45:55 -0000
@@ -70,6 +70,9 @@
     private final Display display;
     private final AwtDialogListener dialogListener;
 
+    // Whether to print debugging information regarding focus events.
+    //private static final boolean verboseFocusEvents = false;
+    private static final boolean verboseFocusEvents = false;
     private static PropertyChangeListener focusDebugListener;
 
     /**
@@ -142,18 +145,22 @@
                 public void run() {
                     setLookAndFeel();
 
-//                    if (focusDebugListener == null) {
-//                        focusDebugListener = new PropertyChangeListener() {
-//                            public void propertyChange(PropertyChangeEvent event) {
-//                                System.out.println("@"+System.currentTimeMillis() +
-//                                        " " + event.getPropertyName() + 
-//                                        " new=" + event.getNewValue() +
-//                                        " old=" + event.getOldValue());
-//                            }
-//                        };
-//                        KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
-//                        focusManager.addPropertyChangeListener(focusDebugListener);
-//                    }
+                    if (verboseFocusEvents) {
+                        if (focusDebugListener == null) {
+                            final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+                            focusDebugListener = new PropertyChangeListener() {
+                                public void propertyChange(PropertyChangeEvent event) {
+                                    System.err.println("@"+System.currentTimeMillis() + " " + event.getPropertyName());
+                                    System.err.println("  new=" + event.getNewValue());
+                                    System.err.println("  old=" + event.getOldValue());
+                                    if (event.getPropertyName().equals("focusedWindow")) {
+                                        System.err.println("  permanent="+kfm.getPermanentFocusOwner());
+                                    }
+                                }
+                            };
+                            kfm.addPropertyChangeListener(focusDebugListener);
+                        }
+                    }
                 }
             });
         } catch (InterruptedException e) {

Back to the top