ControlPanel.java revision b138eb36479de1170a91322a845ad9e977c3af56
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * CDDL HEADER START
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * The contents of this file are subject to the terms of the
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * Common Development and Distribution License, Version 1.0 only
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * (the "License"). You may not use this file except in compliance
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * with the License.
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * You can obtain a copy of the license at
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * See the License for the specific language governing permissions
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * and limitations under the License.
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * When distributing Covered Code, include this CDDL HEADER in each
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * file and include the License file at
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * add the following below this CDDL HEADER, with the fields enclosed
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * by brackets "[]" replaced with your own identifying information:
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * Portions Copyright [yyyy] [name of copyright owner]
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * CDDL HEADER END
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara * Copyright 2008-2010 Sun Microsystems, Inc.
dfb68cb378eeec639f7901a708652cda4e60aa72jvergaraimport static org.opends.messages.AdminToolMessages.
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduffimport org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduffimport org.opends.guitools.controlpanel.ui.ControlCenterMainPane;
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergaraimport org.opends.guitools.controlpanel.ui.GenericFrame;
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergaraimport org.opends.guitools.controlpanel.ui.LocalOrRemotePanel;
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduffimport org.opends.guitools.controlpanel.ui.MainMenuBar;
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergaraimport org.opends.guitools.controlpanel.util.BlindApplicationTrustManager;
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduffimport org.opends.guitools.controlpanel.util.Utilities;
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergaraimport org.opends.server.util.args.ArgumentException;
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * The class that is in charge of creating the main dialog of the ControlPanel
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * and the ControlCenterInfo (the data structure that is used by all the GUI
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * components and that contains information about the server status and server
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * configuration).
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * Main method that is used for testing purposes. The control-panel
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * command-line is launched through the ControlPanelLauncher (which displays
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * a splash screen and calls the <code>initialize</code> and
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * <code>createAndDisplayMethods</code>.
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * @param args the arguments that are passed.
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff javax.swing.SwingUtilities.invokeLater(new Runnable() {
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff public void run() {
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * Method that creates the ControlCenterInfo object that will be in all the
b610c3e7694ee7d23d00c046d9cdc37989102492jvergara * control panel. Nothing is done here: the user must say whether the server
b610c3e7694ee7d23d00c046d9cdc37989102492jvergara * is local or remote.
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergara * @param args the arguments that are passed in the command line. The code
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergara * assumes that the arguments have been already validated.
b610c3e7694ee7d23d00c046d9cdc37989102492jvergara // Call Installation because the LocalOrRemotePanel uses it to check
b610c3e7694ee7d23d00c046d9cdc37989102492jvergara // whether the server is running or not and to get the install path.
dfb68cb378eeec639f7901a708652cda4e60aa72jvergara argParser = new ControlPanelArgumentParser(ControlPanel.class.getName(),
dfb68cb378eeec639f7901a708652cda4e60aa72jvergara INFO_CONTROL_PANEL_LAUNCHER_USAGE_DESCRIPTION.get());
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergara throw new IllegalStateException("Arguments not correctly parsed: "+ae,
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergara info.setTrustManager(new BlindApplicationTrustManager());
b138eb36479de1170a91322a845ad9e977c3af56ludovicp info.setConnectTimeout(argParser.getConnectTimeout());
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * Creates the main Control Panel dialog and displays it.
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara LocalOrRemotePanel localOrRemotePanel = new LocalOrRemotePanel();
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara final GenericFrame localOrRemote = new GenericFrame(localOrRemotePanel);
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergara getLocalOrRemotePanel(localOrRemote.getContentPane()).
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara ComponentListener listener = new ComponentAdapter()
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara * {@inheritDoc}
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara private void handleWindowClosed(GenericFrame localOrRemote,
b610c3e7694ee7d23d00c046d9cdc37989102492jvergara // Assume that the user decided to quit the application
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara updateSharedLocalOrRemotePanel(localOrRemote, info);
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergara // To be sure that the dialog receives the new configuration event before
b610c3e7694ee7d23d00c046d9cdc37989102492jvergara // calling pack.
b610c3e7694ee7d23d00c046d9cdc37989102492jvergara public void run()
b610c3e7694ee7d23d00c046d9cdc37989102492jvergara // Create and set up the content pane.
b610c3e7694ee7d23d00c046d9cdc37989102492jvergara controlCenterPane = new ControlCenterMainPane(info);
b610c3e7694ee7d23d00c046d9cdc37989102492jvergara // Create and set up the window.
b610c3e7694ee7d23d00c046d9cdc37989102492jvergara dlg.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
b610c3e7694ee7d23d00c046d9cdc37989102492jvergara "INFO_CONTROL_PANEL_TITLE",
eb1e28ce9e69648d90e077edb7ee59d649a95c41jvergara private static void initLookAndFeel() throws Throwable
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara private void updateLocalOrRemotePanel(RootPaneContainer localOrRemote)
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergara getLocalOrRemotePanel(localOrRemote.getContentPane());
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergara panel.setHostName(argParser.getExplicitHostName());
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergara panel.setBindPassword(argParser.getBindPassword().toCharArray());
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara * A method used to update the contents of the dialog displayed when the user
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara * selects 'Server To Administer...'. This is done because this class
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara * displays a GenericFrame and in the rest of the UI a GenericDialog is
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara * @param localOrRemote the frame displayed by this class.
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara * @param info the generic info.
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara private void updateSharedLocalOrRemotePanel(RootPaneContainer localOrRemote,
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara getLocalOrRemotePanel(localOrRemote.getContentPane());
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara LocalOrRemotePanel panelToUpdate = getLocalOrRemotePanel(
5d36d63aea1c7b88674a08b307ba24b69f6f37bejvergara ControlCenterMainPane.getLocalOrRemoteDialog(info));
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergara private LocalOrRemotePanel getLocalOrRemotePanel(Container c)
ef8adaa9b9e41f2998b8d1d5a043c2100f1e37acjvergara if (c instanceof LocalOrRemotePanel)