You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/09/16 18:27:24 UTC

svn commit: r815865 - in /incubator/pivot/trunk: tutorials/src/org/apache/pivot/tutorials/ tutorials/src/org/apache/pivot/tutorials/layout/ tutorials/src/org/apache/pivot/tutorials/menus/ wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/conte...

Author: gbrown
Date: Wed Sep 16 16:27:22 2009
New Revision: 815865

URL: http://svn.apache.org/viewvc?rev=815865&view=rev
Log:
Resolve issue PIVOT-297.

Modified:
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/TablePanes.java
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Dialog.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuPopup.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Palette.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Sheet.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListViewItemEditor.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellEditor.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuItemSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
    incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/CardPaneTest.java
    incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/SheetTest.java
    incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/WindowTest.java

Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java Wed Sep 16 16:27:22 2009
@@ -41,6 +41,8 @@
 import org.apache.pivot.wtk.Button;
 import org.apache.pivot.wtk.ButtonPressListener;
 import org.apache.pivot.wtk.ComponentMouseButtonListener;
+import org.apache.pivot.wtk.Dialog;
+import org.apache.pivot.wtk.DialogCloseListener;
 import org.apache.pivot.wtk.ListButton;
 import org.apache.pivot.wtk.MenuHandler;
 import org.apache.pivot.wtk.DesktopApplicationContext;
@@ -61,6 +63,8 @@
 import org.apache.pivot.wtk.Display;
 import org.apache.pivot.wtk.Rollup;
 import org.apache.pivot.wtk.RollupStateListener;
+import org.apache.pivot.wtk.Sheet;
+import org.apache.pivot.wtk.SheetCloseListener;
 import org.apache.pivot.wtk.Slider;
 import org.apache.pivot.wtk.SliderValueListener;
 import org.apache.pivot.wtk.Spinner;
@@ -823,13 +827,19 @@
                                 System.err.println(exception);
                             }
 
-                            Alert alert = new Alert(MessageType.QUESTION, "Please select your favorite icon:",
+                            final Alert alert = new Alert(MessageType.QUESTION, "Please select your favorite icon:",
                                 options, body);
                             alert.setTitle("Select Icon");
                             alert.setSelectedOption(0);
                             alert.getDecorators().update(0, new ReflectionDecorator());
 
-                            alert.open(window);
+                            alert.setOwner(window);
+                            alert.open(window.getDisplay(), new DialogCloseListener() {
+                                @Override
+                                public void dialogClosed(Dialog dialog) {
+                                    alert.setOwner(null);
+                                }
+                            });
                         } else {
                             String message = (String)userData.get("message");
                             Alert.alert(MessageType.valueOf(messageType.toUpperCase()), message, window);
@@ -865,13 +875,19 @@
                                 System.err.println(exception);
                             }
 
-                            Prompt prompt = new Prompt(MessageType.QUESTION, "Please select your favorite icon:",
+                            final Prompt prompt = new Prompt(MessageType.QUESTION, "Please select your favorite icon:",
                                 options, body);
                             prompt.setTitle("Select Icon");
                             prompt.setSelectedOption(0);
                             prompt.getDecorators().update(0, new ReflectionDecorator());
 
-                            prompt.open(window);
+                            prompt.setOwner(window);
+                            prompt.open(window.getDisplay(), new SheetCloseListener() {
+                                @Override
+                                public void sheetClosed(Sheet sheet) {
+                                    prompt.setOwner(null);
+                                }
+                            });
                         } else {
                             String message = (String)userData.get("message");
                             Prompt.prompt(MessageType.valueOf(messageType.toUpperCase()), message, window);

Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/TablePanes.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/TablePanes.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/TablePanes.java (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/TablePanes.java Wed Sep 16 16:27:22 2009
@@ -111,7 +111,13 @@
                     throw new RuntimeException(exception);
                 }
 
-                sheet.open(window);
+                sheet.setOwner(window);
+                sheet.open(window.getDisplay(), new SheetCloseListener() {
+                    @Override
+                    public void sheetClosed(Sheet sheet) {
+                        sheet.setOwner(null);
+                    }
+                });
             }
         });
 
@@ -134,7 +140,13 @@
                     throw new RuntimeException(exception);
                 }
 
-                sheet.open(window);
+                sheet.setOwner(window);
+                sheet.open(window.getDisplay(), new SheetCloseListener() {
+                    @Override
+                    public void sheetClosed(Sheet sheet) {
+                        sheet.setOwner(null);
+                    }
+                });
             }
         });
 
@@ -168,7 +180,13 @@
                     throw new RuntimeException(exception);
                 }
 
-                sheet.open(window);
+                sheet.setOwner(window);
+                sheet.open(window.getDisplay(), new SheetCloseListener() {
+                    @Override
+                    public void sheetClosed(Sheet sheet) {
+                        sheet.setOwner(null);
+                    }
+                });
             }
         });
 
@@ -183,13 +201,16 @@
                 final Prompt prompt = new Prompt(MessageType.QUESTION, message, options, body);
                 prompt.setSelectedOption(0);
 
-                prompt.open(window, new SheetCloseListener() {
+                prompt.setOwner(window);
+                prompt.open(window.getDisplay(), new SheetCloseListener() {
                     @Override
                     public void sheetClosed(Sheet sheet) {
                         if (prompt.getResult() && prompt.getSelectedOption() == 0) {
                             int rowIndex = tablePane.getRowAt(contextMenuHandler.getY());
                             tablePane.getRows().remove(rowIndex, 1);
                         }
+
+                        prompt.setOwner(null);
                     }
                 });
             }
@@ -214,7 +235,13 @@
                     throw new RuntimeException(exception);
                 }
 
-                sheet.open(window);
+                sheet.setOwner(window);
+                sheet.open(window.getDisplay(), new SheetCloseListener() {
+                    @Override
+                    public void sheetClosed(Sheet sheet) {
+                        sheet.setOwner(null);
+                    }
+                });
             }
         });
 
@@ -249,7 +276,13 @@
                     throw new RuntimeException(exception);
                 }
 
-                sheet.open(window);
+                sheet.setOwner(window);
+                sheet.open(window.getDisplay(), new SheetCloseListener() {
+                    @Override
+                    public void sheetClosed(Sheet sheet) {
+                        sheet.setOwner(null);
+                    }
+                });
             }
         });
 
@@ -264,7 +297,8 @@
                 final Prompt prompt = new Prompt(MessageType.QUESTION, message, options, body);
                 prompt.setSelectedOption(0);
 
-                prompt.open(window, new SheetCloseListener() {
+                prompt.setOwner(window);
+                prompt.open(window.getDisplay(), new SheetCloseListener() {
                     @Override
                     public void sheetClosed(Sheet sheet) {
                         if (prompt.getResult() && prompt.getSelectedOption() == 0) {
@@ -277,6 +311,8 @@
 
                             tablePane.getColumns().remove(columnIndex, 1);
                         }
+
+                        prompt.setOwner(null);
                     }
                 });
             }

Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuBars.java Wed Sep 16 16:27:22 2009
@@ -38,6 +38,7 @@
 public class MenuBars implements Application {
     private Window window = null;
     private TabPane tabPane = null;
+    private FileBrowserSheet fileBrowserSheet = null;
 
     private MenuHandler menuHandler = new MenuHandler.Adapter() {
         @Override
@@ -81,8 +82,7 @@
         Action.getNamedActions().put("fileOpen", new Action() {
             @Override
             public void perform() {
-                FileBrowserSheet fileBrowserSheet = new FileBrowserSheet(FileBrowserSheet.Mode.OPEN);
-                fileBrowserSheet.open(window);
+                fileBrowserSheet.open(window.getDisplay());
             }
         });
 
@@ -119,6 +119,9 @@
 
         tabPane = (TabPane)wtkxSerializer.get("tabPane");
 
+        fileBrowserSheet = new FileBrowserSheet(FileBrowserSheet.Mode.OPEN);
+        fileBrowserSheet.setOwner(window);
+
         window.open(display);
     }
 

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java Wed Sep 16 16:27:22 2009
@@ -153,7 +153,16 @@
     public static void alert(MessageType messageType, String message, Component body, Window owner,
         DialogCloseListener dialogCloseListener) {
         Alert alert = createAlert(messageType, message, body);
-        alert.open(owner, dialogCloseListener);
+        alert.setOwner(owner);
+
+        alert.getDialogStateListeners().add(new DialogStateListener.Adapter() {
+            @Override
+            public void dialogClosed(Dialog dialog) {
+                dialog.setOwner(null);
+            }
+        });
+
+        alert.open(owner.getDisplay(), dialogCloseListener);
     }
 
     private static Alert createAlert(MessageType messageType, String message, Component body) {

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Dialog.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Dialog.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Dialog.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Dialog.java Wed Sep 16 16:27:22 2009
@@ -77,83 +77,67 @@
         installSkin(Dialog.class);
     }
 
-    /**
-     * Opens the dialog.
-     *
-     * @param display
-     */
     @Override
-    public final void open(Display display) {
-        open(display, null);
+    public final void setOwner(Window owner) {
+        if (isOpen()
+            && modal) {
+            throw new IllegalStateException("Dialog is open.");
+        }
+
+        super.setOwner(owner);
     }
 
     /**
      * Opens the dialog.
      *
      * @param display
-     * @param dialogCloseListener
-     */
-    public void open(Display display, DialogCloseListener dialogCloseListener) {
-        super.open(display);
-
-        if (isOpen()) {
-            this.dialogCloseListener = dialogCloseListener;
-            this.modal = false;
-        }
-    }
-
-    /**
-     * Opens the dialog as modal over its owner.
-     *
-     * @param owner
      */
     @Override
-    public final void open(Window owner) {
-        open(owner, true, null);
+    public final void open(Display display) {
+        open(display, true, null);
     }
 
     /**
      * Opens the dialog.
      *
-     * @param owner
+     * @param display
      * @param modal
      */
-    public final void open(Window owner, boolean modal) {
-        open(owner, modal, null);
+    public final void open(Display display, boolean modal) {
+        open(display, modal, null);
     }
 
     /**
-     * Opens the dialog as modal over its owner.
-     *
-     * @param owner
-     * The dialog's owner.
+     * Opens the dialog.
      *
+     * @param display
      * @param dialogCloseListener
-     * Optional dialog close listener to be called when the dialog is closed.
      */
-    public final void open(Window owner, DialogCloseListener dialogCloseListener) {
-        open(owner, true, dialogCloseListener);
+    public final void open(Display display, DialogCloseListener dialogCloseListener) {
+        open(display, true, dialogCloseListener);
     }
 
     /**
      * Opens the dialog.
      *
-     * @param owner
-     * The dialog's owner.
-     *
+     * @param display
      * @param modal
-     * If <tt>true</tt>, the dialog is opened as modal, disabling its owner
-     * tree.
-     *
      * @param dialogCloseListener
-     * Optional dialog close listener to be called when the dialog is closed.
      */
-    public void open(Window owner, boolean modal, DialogCloseListener dialogCloseListener) {
-        super.open(owner);
+    public void open(Display display, boolean modal, DialogCloseListener dialogCloseListener) {
+        Window owner = getOwner();
+        if (modal
+            && owner == null) {
+            throw new IllegalStateException("Dialog does not have an owner.");
+        }
+
+        super.open(display);
 
         if (isOpen()) {
-            this.dialogCloseListener = dialogCloseListener;
             this.modal = modal;
+            this.dialogCloseListener = dialogCloseListener;
+
+            result = false;
         }
     }
 

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuPopup.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuPopup.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuPopup.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuPopup.java Wed Sep 16 16:27:22 2009
@@ -112,21 +112,6 @@
         open(display, location.x, location.y);
     }
 
-    public void open(Window owner, int x, int y) {
-        autoClose = true;
-
-        setLocation(x, y);
-        super.open(owner);
-    }
-
-    public final void open(Window owner, Point location) {
-        if (location == null) {
-            throw new IllegalArgumentException("location is null.");
-        }
-
-        open(owner, location.x, location.y);
-    }
-
     @Override
     public boolean isClosing() {
         return closing;

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Palette.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Palette.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Palette.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Palette.java Wed Sep 16 16:27:22 2009
@@ -42,14 +42,21 @@
 
     @Override
     public final void setOwner(Window owner) {
-        if (owner == null) {
-            throw new UnsupportedOperationException("A palette must have an owner.");
+        if (isOpen()
+            && owner == null) {
+            throw new IllegalStateException("Palette is open.");
         }
 
-        if (owner.isAuxilliary()) {
-            throw new UnsupportedOperationException("A palette window must have a primary owner.");
+        super.setOwner(owner);
+    }
+
+    @Override
+    public void open(Display display) {
+        Window owner = getOwner();
+        if (owner == null) {
+            throw new IllegalStateException("Palette does not have an owner.");
         }
 
-        super.setOwner(owner);
+        super.open(display);
     }
 }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt.java Wed Sep 16 16:27:22 2009
@@ -140,7 +140,16 @@
     public static void prompt(MessageType messageType, String message, Component body, Window owner,
         SheetCloseListener sheetCloseListener) {
         Prompt prompt = createPrompt(messageType, message, body);
-        prompt.open(owner, sheetCloseListener);
+        prompt.setOwner(owner);
+
+        prompt.getSheetStateListeners().add(new SheetStateListener.Adapter() {
+            @Override
+            public void sheetClosed(Sheet sheet) {
+                sheet.setOwner(null);
+            }
+        });
+
+        prompt.open(owner.getDisplay(), sheetCloseListener);
     }
 
     private static Prompt createPrompt(MessageType messageType, String message, Component body) {

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Sheet.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Sheet.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Sheet.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Sheet.java Wed Sep 16 16:27:22 2009
@@ -80,34 +80,25 @@
 
     @Override
     public final void setOwner(Window owner) {
-        if (owner == null) {
-            throw new UnsupportedOperationException("A sheet must have an owner.");
-        }
-
-        if (owner.getContent() == null) {
-            throw new UnsupportedOperationException("A sheet's owner must have a content component.");
+        if (isOpen()) {
+            throw new IllegalStateException("Sheet is open.");
         }
 
         super.setOwner(owner);
     }
 
     @Override
-    public void open(Display display) {
+    public final void open(Display display) {
+        open(display, null);
+    }
+
+    public void open(Display display, SheetCloseListener sheetCloseListener) {
         Window owner = getOwner();
         if (owner == null) {
             throw new IllegalStateException("Sheet does not have an owner.");
         }
 
         super.open(display);
-    }
-
-    @Override
-    public final void open(Window owner) {
-        open(owner, null);
-    }
-
-    public void open(Window owner, SheetCloseListener sheetCloseListener) {
-        super.open(owner);
 
         if (isOpen()) {
             this.sheetCloseListener = sheetCloseListener;

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java Wed Sep 16 16:27:22 2009
@@ -494,8 +494,8 @@
 
     public void setOwner(Window owner) {
         if (owner != null
-            && owner.isAuxilliary()
-            && !isAuxilliary()) {
+            && !isAuxilliary()
+            && owner.isAuxilliary()) {
             throw new IllegalArgumentException("Primary windows must have a"
                 + " primary owner.");
         }
@@ -620,26 +620,6 @@
     }
 
     /**
-     * Opens the window.
-     *
-     * @param owner
-     * The window's owner.
-     */
-    public void open(Window owner) {
-        if (owner == null) {
-            throw new IllegalArgumentException("owner is null.");
-        }
-
-        if (isOpen()
-            && getOwner() != owner) {
-            throw new IllegalStateException("Window is already open with a different owner.");
-        }
-
-        setOwner(owner);
-        open(owner.getDisplay());
-    }
-
-    /**
      * Returns this window's closed state.
      *
      * @return

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListViewItemEditor.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListViewItemEditor.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListViewItemEditor.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListViewItemEditor.java Wed Sep 16 16:27:22 2009
@@ -117,6 +117,8 @@
     private WindowStateListener popupWindowStateHandler = new WindowStateListener.Adapter() {
         @Override
         public void windowOpened(Window window) {
+            window.setOwner(listView.getWindow());
+
             Display display = window.getDisplay();
             display.getContainerMouseListeners().add(displayMouseHandler);
 
@@ -134,6 +136,7 @@
             listView.getListViewItemListeners().remove(listViewItemListener);
 
             window.getOwner().moveToFront();
+            window.setOwner(null);
 
             listView = null;
             index = -1;
@@ -199,7 +202,7 @@
         // Create and open the popup
         popup = new Window(textInput, true);
         popup.getWindowStateListeners().add(popupWindowStateHandler);
-        popup.open(listView.getWindow());
+        popup.open(listView.getDisplay());
         reposition();
 
         textInput.selectAll();

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellEditor.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellEditor.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellEditor.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellEditor.java Wed Sep 16 16:27:22 2009
@@ -131,6 +131,8 @@
     private WindowStateListener popupWindowStateHandler = new WindowStateListener.Adapter() {
         @Override
         public void windowOpened(Window window) {
+            window.setOwner(tableView.getWindow());
+
             Display display = window.getDisplay();
             display.getContainerMouseListeners().add(displayMouseHandler);
 
@@ -150,6 +152,7 @@
 
             // Move the owner to front
             window.getOwner().moveToFront();
+            window.setOwner(null);
 
             // Free memory
             tableView = null;
@@ -245,7 +248,7 @@
             // Create and open the popup
             popup = new Window(textInput, true);
             popup.getWindowStateListeners().add(popupWindowStateHandler);
-            popup.open(tableView.getWindow());
+            popup.open(tableView.getDisplay());
             reposition();
 
             textInput.selectAll();

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java Wed Sep 16 16:27:22 2009
@@ -203,6 +203,8 @@
                 super.open(display);
 
                 if (isOpen()) {
+                    setOwner(tableView.getWindow());
+
                     display.getContainerMouseListeners().add(this);
                     tableView.getComponentListeners().add(this);
                     tableView.getTableViewListeners().add(this);
@@ -255,8 +257,6 @@
 
                     // Move the owner to front
                     getOwner().moveToFront();
-
-                    // Clear the owner, or we'll leak memory!
                     setOwner(null);
 
                     // Clear the table pane row so the custom cell editors
@@ -309,7 +309,8 @@
         }
 
         public void edit() {
-            open(tableView.getWindow());
+            Window window = tableView.getWindow();
+            open(window.getDisplay());
             reposition();
         }
 

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TreeViewNodeEditor.java Wed Sep 16 16:27:22 2009
@@ -77,6 +77,8 @@
     private WindowStateListener popupStateHandler = new WindowStateListener.Adapter() {
         @Override
         public void windowOpened(Window window) {
+            window.setOwner(treeView.getWindow());
+
             Display display = window.getDisplay();
             display.getContainerMouseListeners().add(displayMouseHandler);
 
@@ -96,6 +98,7 @@
 
             // Move the owner to front
             window.getOwner().moveToFront();
+            window.setOwner(null);
 
             // Free memory
             treeView = null;
@@ -229,7 +232,7 @@
 
         popup = new Window(textInput, true);
         popup.getWindowStateListeners().add(popupStateHandler);
-        popup.open(treeView.getWindow());
+        popup.open(treeView.getDisplay());
         reposition();
 
         textInput.selectAll();

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java Wed Sep 16 16:27:22 2009
@@ -38,6 +38,8 @@
 import org.apache.pivot.wtk.Point;
 import org.apache.pivot.wtk.Skin;
 import org.apache.pivot.wtk.Tooltip;
+import org.apache.pivot.wtk.Window;
+import org.apache.pivot.wtk.WindowStateListener;
 
 /**
  * Abstract base class for component skins.
@@ -54,7 +56,7 @@
             // The tooltip text may have been cleared while the timeout was
             // outstanding; if so, don't display the tooltip
             if (tooltipText != null) {
-                Tooltip tooltip = new Tooltip(tooltipText);
+                final Tooltip tooltip = new Tooltip(tooltipText);
 
                 Point location = component.getDisplay().getMouseLocation();
                 int x = location.x;
@@ -68,7 +70,18 @@
                 }
 
                 tooltip.setLocation(x + 16, y);
-                tooltip.open(component.getWindow());
+
+                Window window = component.getWindow();
+                tooltip.setOwner(window);
+
+                tooltip.getWindowStateListeners().add(new WindowStateListener.Adapter() {
+                    @Override
+                    public void windowClosed(Window window, Display display) {
+                        tooltip.setOwner(null);
+                    }
+                });
+
+                tooltip.open(window.getDisplay());
             }
         }
     }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java Wed Sep 16 16:27:22 2009
@@ -64,6 +64,8 @@
     private WindowStateListener menuPopupWindowStateListener = new WindowStateListener.Adapter() {
         @Override
         public void windowOpened(Window window) {
+            window.setOwner(getComponent().getWindow());
+
             Display display = window.getDisplay();
             display.getContainerMouseListeners().add(displayMouseListener);
         }
@@ -84,6 +86,8 @@
                 }
             }
 
+            window.setOwner(null);
+
             display.getContainerMouseListeners().remove(displayMouseListener);
 
             closeMenuPopup = false;
@@ -201,7 +205,7 @@
             // TODO Ensure that the popup remains within the bounds of the display
 
             menuPopup.setLocation(menuBarItemLocation.x, menuBarItemLocation.y);
-            menuPopup.open(menuBarItem.getWindow());
+            menuPopup.open(menuBarItem.getDisplay());
             menuPopup.requestFocus();
         } else {
             menuPopup.close(true);

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuItemSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuItemSkin.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuItemSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuItemSkin.java Wed Sep 16 16:27:22 2009
@@ -38,12 +38,16 @@
     private WindowStateListener menuPopupWindowStateListener = new WindowStateListener.Adapter() {
         @Override
         public void windowOpened(Window window) {
+            window.setOwner(getComponent().getWindow());
+
             Display display = window.getDisplay();
             display.getContainerMouseListeners().add(displayMouseListener);
         }
 
         @Override
         public void windowClosed(Window window, Display display) {
+            window.setOwner(null);
+
             display.getContainerMouseListeners().remove(displayMouseListener);
         }
     };
@@ -174,7 +178,7 @@
             // TODO Ensure that the popup remains within the bounds of the display
 
             menuPopup.setLocation(location.x, location.y);
-            menuPopup.open(menuItem.getWindow());
+            menuPopup.open(menuItem.getDisplay());
             menuPopup.requestFocus();
         }
     }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java Wed Sep 16 16:27:22 2009
@@ -53,8 +53,6 @@
  */
 public class TerraCalendarButtonSkin extends CalendarButtonSkin {
     private WindowStateListener calendarPopupStateListener = new WindowStateListener() {
-        private boolean focusButtonOnClose = true;
-
         @Override
         public Vote previewWindowOpen(Window window, Display display) {
             return Vote.APPROVE;
@@ -67,7 +65,7 @@
 
         @Override
         public void windowOpened(Window window) {
-            focusButtonOnClose = true;
+            window.setOwner(getComponent().getWindow());
         }
 
         @Override
@@ -82,7 +80,6 @@
                 closeTransition.start(new TransitionListener() {
                     @Override
                     public void transitionCompleted(Transition transition) {
-                        focusButtonOnClose = window.containsFocus();
                         window.close();
                     }
                 });
@@ -107,10 +104,7 @@
         @Override
         public void windowClosed(Window window, Display display) {
             closeTransition = null;
-            if (focusButtonOnClose) {
-                CalendarButton calendarButton = (CalendarButton)getComponent();
-                calendarButton.requestFocus();
-            }
+            window.setOwner(null);
         }
     };
 
@@ -538,7 +532,7 @@
 
                 calendarPopup.setLocation(x, y);
                 calendarPopup.setPreferredSize(popupWidth, popupHeight);
-                calendarPopup.open(calendarButton.getWindow());
+                calendarPopup.open(calendarButton.getDisplay());
 
                 calendar.requestFocus();
             }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java Wed Sep 16 16:27:22 2009
@@ -53,8 +53,6 @@
  */
 public class TerraListButtonSkin extends ListButtonSkin {
     private WindowStateListener listViewPopupStateListener = new WindowStateListener() {
-        private boolean focusButtonOnClose = true;
-
         @Override
         public Vote previewWindowOpen(Window window, Display display) {
             return Vote.APPROVE;
@@ -67,7 +65,7 @@
 
         @Override
         public void windowOpened(Window window) {
-            focusButtonOnClose = true;
+            window.setOwner(getComponent().getWindow());
         }
 
         @Override
@@ -82,7 +80,6 @@
                 closeTransition.start(new TransitionListener() {
                     @Override
                     public void transitionCompleted(Transition transition) {
-                        focusButtonOnClose = window.containsFocus();
                         window.close();
                     }
                 });
@@ -107,10 +104,7 @@
         @Override
         public void windowClosed(Window window, Display display) {
             closeTransition = null;
-            if (focusButtonOnClose) {
-                ListButton listButton = (ListButton)getComponent();
-                listButton.requestFocus();
-            }
+            window.setOwner(null);
         }
     };
 
@@ -664,7 +658,7 @@
 
                     listViewPopup.setLocation(x, y);
                     listViewPopup.setPreferredSize(popupWidth, popupHeight);
-                    listViewPopup.open(listButton.getWindow());
+                    listViewPopup.open(listButton.getDisplay());
 
                     if (listView.getSelectedIndex() == -1
                         && listView.getListData().getLength() > 0) {

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java Wed Sep 16 16:27:22 2009
@@ -64,7 +64,13 @@
 
     private WindowStateListener menuPopupWindowStateListener = new WindowStateListener.Adapter() {
         @Override
+        public void windowOpened(Window window) {
+            window.setOwner(getComponent().getWindow());
+        }
+
+        @Override
         public void windowClosed(Window window, Display display) {
+            window.setOwner(null);
             repaintComponent();
         }
     };
@@ -519,7 +525,7 @@
 
                 menuPopup.setLocation(x, y);
                 menuPopup.setPreferredSize(popupWidth, popupHeight);
-                menuPopup.open(menuButton.getWindow());
+                menuPopup.open(menuButton.getDisplay());
 
                 menuPopup.requestFocus();
             }

Modified: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/CardPaneTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/CardPaneTest.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/CardPaneTest.java (original)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/CardPaneTest.java Wed Sep 16 16:27:22 2009
@@ -86,7 +86,9 @@
         });
 
         frame.open(display);
-        sheet.open(frame);
+
+        sheet.setOwner(frame);
+        sheet.open(display);
     }
 
     @Override

Modified: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/SheetTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/SheetTest.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/SheetTest.java (original)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/SheetTest.java Wed Sep 16 16:27:22 2009
@@ -75,6 +75,7 @@
 
         final Prompt prompt = new Prompt(MessageType.INFO, "Prompt", new ArrayList<String>("OK"), promptBody);
         prompt.setTitle("Prompt");
+        prompt.setOwner(frame);
 
         Label alertBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
         alertBody.getStyles().put("wrapText", true);
@@ -103,9 +104,7 @@
         windowContent.getButtonPressListeners().add(new ButtonPressListener() {
             @Override
             public void buttonPressed(Button button) {
-                // sheet.open(frame);
-                prompt.open(frame);
-                // alert.open(frame);
+                prompt.open(display);
             }
         });
 

Modified: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/WindowTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/WindowTest.java?rev=815865&r1=815864&r2=815865&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/WindowTest.java (original)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/WindowTest.java Wed Sep 16 16:27:22 2009
@@ -60,49 +60,58 @@
 
         Sheet sheet = new Sheet();
         sheet.setContent(new Label("Hello Foo"));
-        sheet.open(window1);
+        sheet.setOwner(window1);
+        sheet.open(display);
 
         Frame window1a = new Frame();
         window1a.setTitle("Window 1 A");
         window1a.setPreferredSize(160, 120);
-        window1a.open(display); // window1);
+        window1a.setOwner(window1);
+        window1a.open(display);
 
         Frame window1ai = new Frame();
         window1ai.setTitle("Window 1 A I");
         window1ai.setPreferredSize(160, 60);
-        window1ai.open(display); // window1a);
+        window1ai.setOwner(window1a);
+        window1ai.open(display);
         window1ai.getDecorators().update(0, new ReflectionDecorator());
 
         Frame window1aii = new Frame();
         window1aii.setTitle("Window 1 A II");
         window1aii.setPreferredSize(160, 60);
-        window1aii.open(window1a);
+        window1aii.setOwner(window1a);
+        window1aii.open(display);
 
         Frame window1b = new Frame();
         window1b.setTitle("Window 1 B");
         window1b.setPreferredSize(160, 120);
         window1b.setLocation(20, 20);
-        window1b.open(window1);
+        window1b.setOwner(window1);
+        window1b.open(display);
 
         Frame window1bi = new Frame();
         window1bi.setTitle("Window 1 B I");
         window1bi.setPreferredSize(160, 60);
-        window1bi.open(window1b);
+        window1bi.setOwner(window1b);
+        window1bi.open(display);
 
         Frame window1bii = new Frame();
         window1bii.setTitle("Window 1 B II");
         window1bii.setPreferredSize(160, 60);
-        window1bii.open(window1b);
+        window1bii.setOwner(window1b);
+        window1bii.open(display);
 
         Palette palette1 = new Palette();
         palette1.setTitle("Palette 1bii 1");
         palette1.setPreferredSize(160, 60);
-        palette1.open(window1bii);
+        palette1.setOwner(window1bii);
+        palette1.open(display);
 
         Palette palette2 = new Palette();
         palette2.setTitle("Palette 1bii 2");
         palette2.setPreferredSize(160, 60);
-        palette2.open(window1bii);
+        palette2.setOwner(window1bii);
+        palette2.open(display);
 
         Frame dialogOwner = new Frame();
         dialogOwner.setTitle("Dialog Owner");
@@ -112,12 +121,14 @@
         Dialog dialog = new Dialog();
         dialog.setTitle("Dialog 1");
         dialog.setPreferredSize(160, 60);
-        dialog.open(dialogOwner, true);
+        dialog.setOwner(dialogOwner);
+        dialog.open(display, true);
 
         Dialog dialog2 = new Dialog();
         dialog2.setTitle("Dialog 2");
         dialog2.setPreferredSize(160, 60);
-        dialog2.open(dialog, true);
+        dialog2.setOwner(dialog);
+        dialog2.open(display, true);
     }
 
     @Override