13418 on start-up, main window is mapped before contents are added
authorStephen Talley <stephen.talley@sun.com>
Wed, 16 Dec 2009 14:25:49 -0500
changeset 400 6eb404d32758
parent 399 c20561845781
child 401 fc1223edbd8d
13418 on start-up, main window is mapped before contents are added
usr/src/java/vpanels/panel/org/opensolaris/os/vp/panel/swing/control/PanelWindowControl.java
usr/src/java/vpanels/panel/org/opensolaris/os/vp/panel/swing/control/SetVisibleNavigationListener.java
usr/src/java/vpanels/panel/org/opensolaris/os/vp/panel/swing/control/SwingNavigator.java
--- a/usr/src/java/vpanels/panel/org/opensolaris/os/vp/panel/swing/control/PanelWindowControl.java	Wed Dec 16 13:54:56 2009 -0500
+++ b/usr/src/java/vpanels/panel/org/opensolaris/os/vp/panel/swing/control/PanelWindowControl.java	Wed Dec 16 14:25:49 2009 -0500
@@ -124,7 +124,7 @@
 	    ManagedObject.PROPERTY_STATUS_TEXT, statusListener);
 	statusChanged();
 
-	Window window = ((SwingClientContext)context).getPanelWindow();
+	final Window window = ((SwingClientContext)context).getPanelWindow();
 	if (descriptor instanceof HasImages) {
 	    // Save existing images (probably null)
 	    savedWindowImages = window.getIconImages();
@@ -133,7 +133,24 @@
 	    window.setIconImages(images);
 	}
 
-	window.setVisible(true);
+	// Wait until the navigation is complete, then show the window (as long
+	// as this Control is still started)
+	getNavigator().asyncExec(
+	    new Runnable() {
+		@Override
+		public void run() {
+		    if (isStarted()) {
+			// Use event thread in case setVisible blocks
+			EventQueue.invokeLater(
+			    new Runnable() {
+				@Override
+				public void run() {
+				    window.setVisible(true);
+				}
+			    });
+		    }
+		}
+	    });
     }
 
     @Override
@@ -147,9 +164,8 @@
 	descriptor.removePropertyChangeListener(healthListener);
 	descriptor.removePropertyChangeListener(statusListener);
 
-	final Window window = ((SwingClientContext)context).getPanelWindow();
+	Window window = ((SwingClientContext)context).getPanelWindow();
 	if (savedWindowImages != null) {
-	    // Restore
 	    window.setIconImages(savedWindowImages);
 	}
 
--- a/usr/src/java/vpanels/panel/org/opensolaris/os/vp/panel/swing/control/SetVisibleNavigationListener.java	Wed Dec 16 13:54:56 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-package org.opensolaris.os.vp.panel.swing.control;
-
-import java.awt.*;
-import java.util.List;
-import org.opensolaris.os.vp.panel.common.control.*;
-
-/**
- * The {@code SetVisibleNavigationListener} class waits for a completed
- * navigation containing a {@link SwingControl}.  It then ensures that all
- * {@code Window}s that contain {@code Component}s from all {@link
- * SwingControl}s are showing, and then removes itself from the {@link
- * Navigator}'s list of {@link NavigationListener}s.
- */
-public class SetVisibleNavigationListener implements NavigationListener {
-    //
-    // NavigationListener methods
-    //
-
-    @Override
-    public void navigationStarted(NavigationStartEvent e) {
-    }
-
-    @Override
-    public void navigationStopped(NavigationStopEvent event) {
-	final List<Window> windows = SwingNavigator.getWindows(
-	    event.getSource());
-
-	if (!windows.isEmpty()) {
-	    for (Window window : windows) {
-		final Window w = window;
-		EventQueue.invokeLater(
-		    new Runnable() {
-			@Override
-			public void run() {
-			    // In case we're not already
-			    w.setVisible(true);
-			}
-		    });
-	    }
-
-	    // No longer needed now that window is visible
-	    event.getSource().removeNavigationListener(this);
-	}
-    }
-}
--- a/usr/src/java/vpanels/panel/org/opensolaris/os/vp/panel/swing/control/SwingNavigator.java	Wed Dec 16 13:54:56 2009 -0500
+++ b/usr/src/java/vpanels/panel/org/opensolaris/os/vp/panel/swing/control/SwingNavigator.java	Wed Dec 16 14:25:49 2009 -0500
@@ -43,9 +43,6 @@
 	// Resize windows on each navigation
 	addNavigationListener(new NavigationWindowResizer());
 
-	// Set all Windows visible after initial navigation
-	addNavigationListener(new SetVisibleNavigationListener());
-
 	// Display a dialog on error
 	addNavigationListener(new SwingNavigationErrorHandler());