usr/src/java/vpanels/client/org/opensolaris/os/vp/client/swing/AppInstance.java
author Stephen Talley <stephen.talley@sun.com>
Tue, 15 Sep 2009 17:46:37 -0400
changeset 356 379b8150bb93
parent 344 acffa4b97c50
child 365 d3e845ff291e
permissions -rw-r--r--
11379 apache: unable to cancel app with bad data in outstanding changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     1
/*
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     2
 * CDDL HEADER START
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     3
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     7
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    11
 * and limitations under the License.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    12
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    18
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    19
 * CDDL HEADER END
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    20
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    21
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    22
/*
219
57841c113efe 6788 package names should share o.o.o.vp prefix
Stephen Talley <stephen.talley@sun.com>
parents: 176
diff changeset
    23
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    24
 * Use is subject to license terms.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    25
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    26
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    27
package org.opensolaris.os.vp.client.swing;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    28
262
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
    29
import java.awt.*;
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
    30
import java.awt.event.*;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    31
import java.net.*;
279
b82f64a1f586 8129 smf/sharemgr/sysid: breadcrumbs should be shown until UI redesign is implemented
Stephen Talley <stephen.talley@sun.com>
parents: 275
diff changeset
    32
import java.util.Properties;
262
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
    33
import java.util.logging.*;
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
    34
import javax.help.*;
344
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    35
import javax.swing.*;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    36
import org.opensolaris.os.vp.client.common.*;
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
    37
import org.opensolaris.os.vp.panel.common.*;
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
    38
import org.opensolaris.os.vp.panel.common.action.*;
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
    39
import org.opensolaris.os.vp.panel.common.control.*;
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
    40
import org.opensolaris.os.vp.panel.common.view.BusyIndicator;
251
2d4060817fe2 7905 NavigationListeners that resize a window or handle UI flicker should not be tied to a specific Window
Stephen Talley <stephen.talley@sun.com>
parents: 243
diff changeset
    41
import org.opensolaris.os.vp.panel.swing.control.*;
266
b6e25669b646 7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents: 262
diff changeset
    42
import org.opensolaris.os.vp.panel.swing.view.AuthPanel;
220
696985231edf 6899 --topless/-t option should be changed to --undecorated
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    43
import org.opensolaris.os.vp.util.misc.*;
219
57841c113efe 6788 package names should share o.o.o.vp prefix
Stephen Talley <stephen.talley@sun.com>
parents: 176
diff changeset
    44
import org.opensolaris.os.vp.util.swing.GUIUtil;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    45
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    46
@SuppressWarnings({"serial"})
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    47
public class AppInstance implements ClientContext {
344
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    48
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    49
    static {
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    50
	// Force early load of runtime properties
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    51
	AppProperties a = AppProperties.singleton;
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    52
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    53
	// Set look and feel unless user has a preference
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    54
	String gtk = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    55
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    56
	if (System.getProperty("swing.defaultlaf") == null) {
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    57
	    String lafName = UIManager.getSystemLookAndFeelClassName();
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    58
	    // Refuse to be a victim of Solaris's Motif default
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    59
	    if (lafName.contains("MotifLookAndFeel"))
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    60
		lafName = gtk;
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    61
	    try {
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    62
		UIManager.setLookAndFeel(lafName);
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    63
	    } catch (Exception ignore) {
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    64
	    }
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    65
	}
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    66
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    67
	LookAndFeel laf = UIManager.getLookAndFeel();
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    68
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    69
	// Handle Gnome-specific bugs
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    70
	if (laf != null && laf.getClass().getName().equals(gtk)) {
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    71
	    // Gnome L&F doesn't set this correctly
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    72
	    UIManager.put("ToolTip.background", new JToolTip().getBackground());
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    73
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    74
	    // Gnome L&F is the only L&F that does this
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    75
	    UIManager.put("Slider.paintValue", Boolean.FALSE);
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    76
	}
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    77
    }
acffa4b97c50 10973 Move notion of health from vpanels-client to vpanels-panel
David Powell <David.Powell@sun.com>
parents: 323
diff changeset
    78
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    79
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    80
    // Instance data
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    81
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    82
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    83
    private App app;
256
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
    84
    private LoginPane loginPane;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    85
    private String title;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    86
    private AppFrame frame;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    87
    private AppLoginManager loginManager;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    88
    private ConnectionInfo info;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    89
    private PanelDescriptorFactory factory;
262
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
    90
    private SwingNavigator navigator;
157
f4316b998c95 4857 all classes that handle event management should use EventListeners class
Stephen Talley <stephen.talley@sun.com>
parents: 156
diff changeset
    91
    private ConnectionListeners listeners = new ConnectionListeners(true);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    92
262
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
    93
    private HelpBroker helpBroker;
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
    94
    private ActionListener showHelpAction;
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
    95
55
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
    96
    // Wrap the AppFrame's BusyIndicator in non-UI-thread-accessible methods
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
    97
    private BusyIndicator busyIndicator = new BusyIndicator() {
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
    98
	@Override
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
    99
	public int getDelay() {
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   100
	    return frame.getBusyIndicator().getDelay();
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   101
	}
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   102
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   103
	@Override
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   104
	public String getMessage() {
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   105
	    return frame.getBusyIndicator().getMessage();
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   106
	}
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   107
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   108
	@Override
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   109
	public boolean isShown() {
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   110
	    return frame.getBusyIndicator().isShown();
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   111
	}
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   112
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   113
	@Override
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   114
	public void setDelay(int delay) {
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   115
	    frame.getBusyIndicator().setDelay(delay);
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   116
	}
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   117
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   118
	@Override
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   119
	public void setShown(final boolean shown) {
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   120
	    GUIUtil.invokeAndWait(
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   121
		new Runnable() {
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   122
		    @Override
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   123
		    public void run() {
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   124
			frame.getBusyIndicator().setShown(shown);
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   125
		    }
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   126
		});
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   127
	}
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   128
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   129
	@Override
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   130
	public void setMessage(final String message) {
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   131
	    GUIUtil.invokeAndWait(
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   132
		new Runnable() {
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   133
		    @Override
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   134
		    public void run() {
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   135
			frame.getBusyIndicator().setMessage(message);
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   136
		    }
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   137
		});
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   138
	}
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   139
    };
bf29b35b1773 3318 sharemgr: Navigating to new share after creation causes unintended login popup
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   140
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   141
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   142
    // Constructors
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   143
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   144
279
b82f64a1f586 8129 smf/sharemgr/sysid: breadcrumbs should be shown until UI redesign is implemented
Stephen Talley <stephen.talley@sun.com>
parents: 275
diff changeset
   145
    public AppInstance(App app, Properties properteis) {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   146
	this.app = app;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   147
279
b82f64a1f586 8129 smf/sharemgr/sysid: breadcrumbs should be shown until UI redesign is implemented
Stephen Talley <stephen.talley@sun.com>
parents: 275
diff changeset
   148
	frame = new AppFrame(this, properteis);
312
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   149
	frame.addWindowListener(
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   150
	    new WindowAdapter() {
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   151
		@Override
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   152
		public void windowClosing(WindowEvent e) {
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   153
		    navigator.asyncExec(
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   154
			new Runnable() {
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   155
			    @Override
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   156
			    public void run() {
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   157
				try {
356
379b8150bb93 11379 apache: unable to cancel app with bad data in outstanding changes
Stephen Talley <stephen.talley@sun.com>
parents: 344
diff changeset
   158
				    closeInstance(false);
312
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   159
				} catch (ActionAbortedException ignore) {
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   160
				}
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   161
			    }
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   162
			});
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   163
		}
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   164
	    });
d435e63e1a43 9323 apache: list selection changes even when navigation is aborted
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   165
256
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   166
	createLoginPane();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   167
256
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   168
	loginManager = new AppLoginManager(this);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   169
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   170
	PanelResourceManager manager = new SwingPanelResourceManager(this);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   171
	factory = new SwingPanelDescriptorFactory(this, manager);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   172
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   173
	createNavigator();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   174
	frame.navigatorCreated();
262
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   175
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   176
	createHelp();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   177
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   178
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   179
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   180
    // ClientContext methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   181
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   182
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   183
    @Override
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   184
    public void addConnectionListener(ConnectionListener listener) {
157
f4316b998c95 4857 all classes that handle event management should use EventListeners class
Stephen Talley <stephen.talley@sun.com>
parents: 156
diff changeset
   185
	listeners.add(listener);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   186
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   187
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   188
    @Override
356
379b8150bb93 11379 apache: unable to cancel app with bad data in outstanding changes
Stephen Talley <stephen.talley@sun.com>
parents: 344
diff changeset
   189
    public void closeInstance(boolean isCancel) throws ActionAbortedException {
256
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   190
	if (loginPane.isShowing()) {
176
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   191
	    throw new ActionAbortedException();
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   192
	}
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   193
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   194
	try {
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   195
	    // Unwind navigation stack to force user to handle pending changes
356
379b8150bb93 11379 apache: unable to cancel app with bad data in outstanding changes
Stephen Talley <stephen.talley@sun.com>
parents: 344
diff changeset
   196
	    navigator.goToAsyncAndWait(isCancel, null);
176
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   197
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   198
	} catch (NavigationAbortedException e) {
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   199
	    throw new ActionAbortedException(e);
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   200
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   201
	} catch (InvalidAddressException e) {
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   202
	    // Should not be possible
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   203
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   204
	} catch (InvalidParameterException e) {
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   205
	    // Should not be possible
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   206
	}
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   207
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   208
	close();
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   209
    }
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   210
323
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   211
    public void newInstance(String path) {
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   212
	app.load(info, path);
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   213
    }
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   214
176
75562bda9d0d 5276 SettingsButtonBar should support Apply, Quit buttons
Stephen Talley <stephen.talley@sun.com>
parents: 171
diff changeset
   215
    @Override
220
696985231edf 6899 --topless/-t option should be changed to --undecorated
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   216
    public BusyIndicator getBusyIndicator() {
696985231edf 6899 --topless/-t option should be changed to --undecorated
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   217
	return busyIndicator;
696985231edf 6899 --topless/-t option should be changed to --undecorated
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   218
    }
696985231edf 6899 --topless/-t option should be changed to --undecorated
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   219
696985231edf 6899 --topless/-t option should be changed to --undecorated
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   220
    @Override
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   221
    public ConnectionInfo getConnectionInfo() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   222
	return info;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   223
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   224
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   225
    @Override
220
696985231edf 6899 --topless/-t option should be changed to --undecorated
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   226
    public HelpBroker getHelpBroker() {
262
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   227
	return helpBroker;
220
696985231edf 6899 --topless/-t option should be changed to --undecorated
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   228
    }
696985231edf 6899 --topless/-t option should be changed to --undecorated
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   229
696985231edf 6899 --topless/-t option should be changed to --undecorated
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   230
    @Override
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   231
    public Logger getLog() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   232
	return App.log;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   233
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   234
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   235
    @Override
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   236
    public String getTitle() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   237
	return title;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   238
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   239
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   240
    @Override
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   241
    public boolean removeConnectionListener(ConnectionListener listener) {
220
696985231edf 6899 --topless/-t option should be changed to --undecorated
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   242
	return listeners.remove(listener);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   243
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   244
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   245
    @Override
39
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   246
    public void requestConnection(String user, String role,
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   247
	DialogMessage message) throws ActionAbortedException {
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   248
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   249
	loginPane.setDefaultMessage(message);
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   250
	loginPane.setHostFieldEditable(false);
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   251
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   252
	try {
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   253
	    // Create or retrieve ConnectionInfo - throws ActionAbortedException
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   254
	    ConnectionInfo info = getConnectionInfo(null, -1, user, role, true);
39
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   255
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   256
	    // Guaranteed to be non-null
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   257
	    setConnectionInfo(info);
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   258
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   259
	} catch (NavigationAbortedException e) {
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   260
	    // Should not be possible since the host didn't change
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   261
	    throw new ActionAbortedException(e);
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   262
39
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   263
	} finally {
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   264
	    loginPane.setDefaultMessage(null);
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   265
	    loginPane.setHostFieldEditable(true);
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   266
	}
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   267
    }
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   268
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   269
    @Override
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   270
    public void setTitle(String title) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   271
	this.title = title;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   272
	setTitle();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   273
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   274
171
ec6f1c5d031c 2537 API and UI should support deep-linking into help text
Stephen Talley <stephen.talley@sun.com>
parents: 161
diff changeset
   275
    @Override
ec6f1c5d031c 2537 API and UI should support deep-linking into help text
Stephen Talley <stephen.talley@sun.com>
parents: 161
diff changeset
   276
    public void showHelp() {
262
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   277
	Window window = navigator.getWindow();
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   278
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   279
	ActionEvent event = new ActionEvent(
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   280
	    window, ActionEvent.ACTION_PERFORMED, "showHelp");
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   281
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   282
	showHelpAction.actionPerformed(event);
171
ec6f1c5d031c 2537 API and UI should support deep-linking into help text
Stephen Talley <stephen.talley@sun.com>
parents: 161
diff changeset
   283
    }
ec6f1c5d031c 2537 API and UI should support deep-linking into help text
Stephen Talley <stephen.talley@sun.com>
parents: 161
diff changeset
   284
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   285
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   286
    // AppInstance methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   287
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   288
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   289
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   290
     * Closes this {@code AppInstance} unconditionally.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   291
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   292
    public void close() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   293
	ConnectionInfo info = getConnectionInfo();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   294
	if (info != null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   295
	    app.getConnectionManager().removeConnection(info, this);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   296
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   297
256
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   298
	loginPane.dispose();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   299
	frame.dispose();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   300
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   301
	// Notify App
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   302
	app.instanceClosed(this);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   303
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   304
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   305
    protected void fireChangeEvent(
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   306
	ConnectionInfo oldInfo, ConnectionInfo info) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   307
102
a39a3f68b935 3751 add enable/disable actions to SMF panel
David Powell <David.Powell@sun.com>
parents: 61
diff changeset
   308
	listeners.connectionChanged(new ConnectionEvent(this, oldInfo, info));
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   309
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   310
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   311
    public App getApp() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   312
	return app;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   313
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   314
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   315
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   316
     * Retrieve or create a {@link ConnectionInfo} for the given host and user.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   317
     * If {@code forceManualLogin} is {@code false}, an attempt is first made to
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   318
     * find an existing connection for the given parameters.  If no connection
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   319
     * is found, {@link #getConnectionInfoFromLogin} is called to prompt the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   320
     * user to select or create a connection through the login pane.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   321
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   322
     * @param	    host
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   323
     *		    the host, or {@code null} to use the host and port from the
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   324
     *		    current connection, if any
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   325
     *
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   326
     * @param	    port
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   327
     *		    the port, or {@code -1} to use the default port
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   328
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   329
     * @param	    user
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   330
     *		    the user, or {@code null} to use the user from the current
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   331
     *		    connection, if any
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   332
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   333
     * @param	    role
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   334
     *		    the role, or {@code null} to use the role from the current
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   335
     *		    connection, if any
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   336
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   337
     * @param	    forceManualLogin
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   338
     *		    if {@code true}, do not search for an existing connection
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   339
     *		    connection before displaying the login pane
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   340
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   341
     * @return	    a non-{@code null} {@link ConnectionInfo}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   342
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   343
     * @exception   ActionAbortedException
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   344
     *		    if no existing {@link ConnectionInfo} matching the given
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   345
     *		    host/user is found, and the user cancels the login pane
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   346
     */
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   347
    protected ConnectionInfo getConnectionInfo(String host, int port,
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   348
	String user, String role, boolean forceManualLogin)
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   349
	throws ActionAbortedException {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   350
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   351
	ConnectionInfo oldinfo = getConnectionInfo();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   352
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   353
	if (oldinfo != null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   354
	    if (host == null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   355
		host = oldinfo.getHost();
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   356
		port = oldinfo.getPort();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   357
	    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   358
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   359
	    if (user == null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   360
		user = oldinfo.getUser();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   361
	    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   362
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   363
	    if (role == null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   364
		role = oldinfo.getRole();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   365
	    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   366
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   367
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   368
	ConnectionInfo info = null;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   369
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   370
	if (!forceManualLogin && host != null && user != null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   371
	    // Search for an existing connection
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   372
	    info = app.getConnectionManager().getConnection(host, port, user,
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   373
		role);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   374
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   375
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   376
	if (info == null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   377
	    // Prompt user to select or create a connection
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   378
	    info = getConnectionInfoFromLogin(host, port, user, role, oldinfo);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   379
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   380
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   381
	return info;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   382
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   383
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   384
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   385
     * Create or retrieve a {@link ConnectionInfo} from user interaction with
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   386
     * the login pane.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   387
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   388
     * @param	    host
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   389
     *		    if non-{@code null}, the initial value to place in the login
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   390
     *		    pane's host field
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   391
     *
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   392
     * @param	    port
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   393
     *		    if not {@code -1}, the initial port value to place in the
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   394
     *		    login pane's host field
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   395
     *
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   396
     * @param	    user
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   397
     *		    if non-{@code null}, the initial value to place in the login
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   398
     *		    pane's user field
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   399
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   400
     * @param	    role
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   401
     *		    if non-{@code null}, the initial value to place in the login
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   402
     *		    pane's role field
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   403
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   404
     * @return	    a non-{@code null} {@link ConnectionInfo}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   405
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   406
     * @exception   ActionAbortedException
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   407
     *		    if the user cancels the login pane
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   408
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   409
    protected ConnectionInfo getConnectionInfoFromLogin(
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   410
	String host, int port, String user, String role, ConnectionInfo oldinfo)
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   411
	throws ActionAbortedException {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   412
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   413
	boolean useExisting = true;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   414
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   415
	// Prepopulate LoginPane
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   416
	if (host != null) {
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   417
	    String hoststr = (port == -1) ? host : host + ":" + port;
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   418
	    loginPane.setHost(hoststr);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   419
	    useExisting = false;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   420
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   421
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   422
	if (user != null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   423
	    loginPane.setUser(user);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   424
	    useExisting = false;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   425
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   426
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   427
	if (role != null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   428
	    loginPane.setRole(role);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   429
	    useExisting = false;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   430
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   431
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   432
	// Select "Use existing connection..." by default in login pane
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   433
	loginPane.setUseExistingSelected(useExisting);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   434
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   435
	// Throws ActionAbortedException
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   436
	return loginManager.getConnectionInfo(oldinfo);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   437
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   438
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   439
    public AppFrame getFrame() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   440
	return frame;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   441
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   442
256
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   443
    protected LoginPane getLoginPane() {
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   444
	return loginPane;
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   445
    }
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   446
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   447
    public Navigator getNavigator() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   448
	return navigator;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   449
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   450
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   451
    public PanelDescriptorFactory getPanelDescriptorFactory() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   452
	return factory;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   453
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   454
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   455
    public URI getURI() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   456
	try {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   457
	    ConnectionInfo info = getConnectionInfo();
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   458
	    return App.createURI(info.getHost(), info.getUser(),
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   459
		info.getRole(), info.getPort(), navigator.getPathString());
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   460
	} catch (URISyntaxException e) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   461
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   462
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   463
	return null;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   464
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   465
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   466
    /**
39
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   467
     * Retrieve or create a connection, then navigate to the given path.
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   468
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   469
     * @param	    host
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   470
     *		    the host, or {@code null} to use the host and port from the
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   471
     *		    current connection, if any
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   472
     *
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   473
     * @param	    port
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   474
     *		    the port, or {@code -1} to use the default port
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   475
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   476
     * @param	    user
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   477
     *		    the user, or {@code null} to use the user from the current
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   478
     *		    connection, if any
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   479
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   480
     * @param	    role
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   481
     *		    the role, or {@code null} to use the role from the current
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   482
     *		    connection, if any
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   483
     *
39
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   484
     * @param	    path
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   485
     *		    the path to navigate to after creating the connection, or
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   486
     *		    {@code null} to navigate to the current path
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 32
diff changeset
   487
     *
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   488
     * @param	    forceManualLogin
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   489
     *		    if {@code true}, do not search for an existing connection
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   490
     *		    connection before displaying the login pane
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   491
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   492
     * @exception   ActionAbortedException
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   493
     *		    see {@link #getConnectionInfo(String,String,String,boolean)}
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   494
     *
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   495
     * @exception   NavigationAbortedException
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 300
diff changeset
   496
     *		    see {@link Navigator#goTo(boolean,Control,Navigable...)}
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   497
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   498
     * @exception   InvalidAddressException
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 300
diff changeset
   499
     *		    see {@link Navigator#goTo(boolean,Control,Navigable...)}
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   500
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   501
     * @exception   MissingParameterException
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 300
diff changeset
   502
     *		    see {@link Navigator#goTo(boolean,Control,Navigable...)}
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   503
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   504
     * @exception   InvalidParameterException
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 300
diff changeset
   505
     *		    see {@link Navigator#goTo(boolean,Control,Navigable...)}
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   506
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   507
     * @exception   IllegalArgumentException
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 300
diff changeset
   508
     *		    see {@link Navigator#goTo(boolean,Control,Navigable...)}
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   509
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   510
     * @see	    #getConnectionInfo(String,String,String,boolean)
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   511
     */
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   512
    protected void load(String host, int port, String user, String role,
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   513
	String path, boolean forceManualLogin) throws ActionAbortedException,
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   514
	NavigationAbortedException, InvalidAddressException,
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   515
	MissingParameterException, InvalidParameterException {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   516
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   517
	// Save absolute path now, because logging in may change navigation path
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   518
	if (path == null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   519
	    path = navigator.getPathString();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   520
	} else if (!Navigator.isAbsolute(path)) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   521
	    path = navigator.getPathString() + path;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   522
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   523
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   524
	// Create or retrieve ConnectionInfo - throws AbortedException
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   525
	ConnectionInfo info =
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   526
	    getConnectionInfo(host, port, user, role, forceManualLogin);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   527
323
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   528
	navigate(info, path);
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   529
    }
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   530
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   531
    void load(ConnectionInfo info, String path)
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   532
	throws ActionAbortedException, NavigationAbortedException,
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   533
	InvalidAddressException, MissingParameterException,
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   534
	InvalidParameterException {
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   535
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   536
	if (!Navigator.isAbsolute(path))
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   537
	    throw (new InvalidAddressException(path));
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   538
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   539
	navigate(info, path);
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   540
    }
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   541
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   542
    private void navigate(ConnectionInfo info, final String path)
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   543
	throws NavigationAbortedException, InvalidAddressException,
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   544
	MissingParameterException, InvalidParameterException
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   545
    {
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   546
	// Guaranteed to be non-null - throws NavigationExceptions
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   547
	setConnectionInfo(info);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   548
61
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   549
	navigator.asyncExecAndWait(
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   550
	    new NavRunnable() {
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   551
		@Override
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   552
		public void run() throws NavigationAbortedException,
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   553
		    InvalidAddressException, MissingParameterException,
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   554
		    InvalidParameterException {
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   555
323
497a785649eb 10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents: 312
diff changeset
   556
		    SimpleNavigable[] pArray = Navigator.toArray(path);
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 300
diff changeset
   557
		    navigator.goTo(false, null, pArray);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   558
61
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   559
		    // Schedule this on the navigation thread so that any other
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   560
		    // pending navigations can be assured that the UI is visible
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   561
		    // before they start.  Ay chihuahua.
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   562
		    GUIUtil.invokeAndWait(
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   563
			new Runnable() {
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   564
			    @Override
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   565
			    public void run() {
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   566
				// In case we're not already
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   567
				frame.setVisible(true);
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   568
			    }
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   569
			});
fb7cd11392e7 3335 sharemgr: PathControl at startup shows dialog before main window is shown
Stephen Talley <stephen.talley@sun.com>
parents: 60
diff changeset
   570
		    }
32
0307255c625b 2834 VP hangs on launching separate VP window
Stephen Talley <stephen.talley@sun.com>
parents: 4
diff changeset
   571
	    });
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   572
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   573
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   574
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   575
     * Show the login screen.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   576
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   577
     * @param	    host
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   578
     *		    if non-{@code null}, the initial value to place in the login
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   579
     *		    pane's host field
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   580
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   581
     * @param	    user
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   582
     *		    if non-{@code null}, the initial value to place in the login
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   583
     *		    pane's user field
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   584
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   585
    public void login(String host, String user, String role) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   586
	try {
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   587
	    load(host, -1, user, role, null, true);
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   588
	} catch (ActionException ignore) {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   589
	} catch (NavigationException ignore) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   590
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   591
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   592
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   593
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   594
     * Sets the current connection.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   595
     * <p>
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   596
     * If the host of the current connection differs from that of the new
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   597
     * connection, the current panel (and in fact most of the navigation stack)
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   598
     * cannot be re-used and must be stopped.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   599
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   600
     * @param	    info
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   601
     *		    a {@link ConnectionInfo}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   602
     *
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   603
     * @exception   NavigationAbortedException
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   604
     *		    if the host differs, as described above, and the user
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   605
     *		    cancels the stop operation
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   606
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   607
    protected void setConnectionInfo(ConnectionInfo info)
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   608
	throws NavigationAbortedException {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   609
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   610
	ConnectionInfo oldInfo = getConnectionInfo();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   611
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   612
	if (oldInfo != info) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   613
	    ConnectionManager connManager = app.getConnectionManager();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   614
	    connManager.addConnection(info, this);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   615
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   616
	    // Has the host changed?
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   617
	    String newHost = info.getHost();
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   618
	    if (oldInfo != null && !oldInfo.matchesHost(newHost)) {
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   619
		// The host has changed.  This means that the current panel (and
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   620
		// in fact most of the navigation stack) cannot be re-used.  So
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   621
		// back out completely, allowing the user to cancel if there are
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   622
		// unsaved changes.
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   623
		try {
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   624
		    // Navigate to root Control
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 300
diff changeset
   625
		    navigator.goTo(false, navigator.getPath().get(0));
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   626
		} catch (NavigationAbortedException e) {
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   627
		    // We're not going to use this connection after all
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   628
		    connManager.removeConnection(info, this);
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   629
		    throw e;
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   630
		} catch (InvalidAddressException e) {
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   631
		    // Should not be possible
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   632
		} catch (InvalidParameterException e) {
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   633
		    // Should not be possible
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   634
		}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   635
	    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   636
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   637
	    // Set and notify any listeners (ie, panels) of change
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   638
	    this.info = info;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   639
	    fireChangeEvent(oldInfo, info);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   640
	    setTitle();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   641
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   642
	    if (oldInfo != null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   643
		// Now that listeners have been notified of the change, remove
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   644
		// the link between this AppInstance and oldInfo, closing
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   645
		// oldInfo if no one else is using it
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   646
		connManager.removeConnection(oldInfo, this);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   647
	    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   648
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   649
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   650
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   651
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   652
    // Private methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   653
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   654
262
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   655
    private void createHelp() {
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   656
	String helpSetName =
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   657
	    getClass().getPackage().getName().replaceAll("\\.", "/") +
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   658
	    "/help/app";
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   659
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   660
	HelpSet helpSet;
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   661
	try {
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   662
	    ClassLoader loader = getClass().getClassLoader();
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   663
	    URL url = HelpSet.findHelpSet(loader, helpSetName);
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   664
	    helpSet = new HelpSet(loader, url);
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   665
	} catch (HelpSetException e) {
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   666
	    String message = String.format(
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   667
		"could not load helpset: %s", helpSetName);
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   668
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   669
	    getLog().log(Level.WARNING, message, e);
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   670
	    helpSet = new HelpSet();
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   671
	}
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   672
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   673
	helpBroker = helpSet.createHelpBroker();
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   674
	showHelpAction = new CSH.DisplayHelpFromSource(helpBroker);
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   675
    }
885abe865e16 8009 Help window should not necessarily be tied to main frame
Stephen Talley <stephen.talley@sun.com>
parents: 256
diff changeset
   676
256
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   677
    private void createLoginPane() {
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   678
	loginPane = new LoginPane(this);
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   679
	loginPane.setHost("localhost");
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   680
	loginPane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   681
    }
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 251
diff changeset
   682
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   683
    private void createNavigator() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   684
	AppRootControl rootControl = new AppRootControl(this);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   685
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   686
	try {
275
1e055a67a9b6 8094 Navigator interface could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 266
diff changeset
   687
	    navigator = new SwingNavigator();
251
2d4060817fe2 7905 NavigationListeners that resize a window or handle UI flicker should not be tied to a specific Window
Stephen Talley <stephen.talley@sun.com>
parents: 243
diff changeset
   688
2d4060817fe2 7905 NavigationListeners that resize a window or handle UI flicker should not be tied to a specific Window
Stephen Talley <stephen.talley@sun.com>
parents: 243
diff changeset
   689
	    // Resize windows on each navigation
2d4060817fe2 7905 NavigationListeners that resize a window or handle UI flicker should not be tied to a specific Window
Stephen Talley <stephen.talley@sun.com>
parents: 243
diff changeset
   690
	    navigator.addNavigationListener(new NavigationWindowResizer());
2d4060817fe2 7905 NavigationListeners that resize a window or handle UI flicker should not be tied to a specific Window
Stephen Talley <stephen.talley@sun.com>
parents: 243
diff changeset
   691
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 300
diff changeset
   692
	    navigator.goToAsyncAndWait(false, null, rootControl);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   693
	} catch (NavigationException unlikely) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   694
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   695
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   696
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   697
    private void setTitle() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   698
	String login = null;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   699
	String resource = "window.title.defaultlogin";
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   700
	ConnectionInfo info = getConnectionInfo();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   701
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   702
	// If not logged in with default host/user/role...
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   703
	if (info != null &&
300
7f3357de9250 8810 incomplete support for port specification
David Powell <David.Powell@sun.com>
parents: 279
diff changeset
   704
	    !info.matches(App.LOCAL_HOST, -1, App.LOCAL_USER, null)) {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   705
266
b6e25669b646 7654 add status/status text to header
Stephen Talley <stephen.talley@sun.com>
parents: 262
diff changeset
   706
	    login = AuthPanel.toString(info);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   707
	    resource = "window.title.nondefaultlogin";
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   708
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   709
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   710
	String title = Finder.getString(resource, getTitle(), login);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   711
	frame.setTitle(title);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   712
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   713
}