From c96108b4530dde68a2613fd3f190c5b6cf9f37aa Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 04 Jan 2010 11:09:59 +0000
Subject: [PATCH] Fix for issue 4415 (Control panel connection chooser doesn't show in task bar) Use a JFrame instead of a JDialog for the initial login dialog.
---
opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java | 4
opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java | 70 ++++++++++++++++++++--
opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java | 57 ++++++++++++++++++
3 files changed, 120 insertions(+), 11 deletions(-)
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java
index f80f386..778b8e8 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008-2009 Sun Microsystems, Inc.
+ * Copyright 2008-2010 Sun Microsystems, Inc.
*/
package org.opends.guitools.controlpanel;
@@ -32,17 +32,21 @@
import java.awt.Component;
import java.awt.Container;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
+import javax.swing.RootPaneContainer;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.ui.ControlCenterMainPane;
-import org.opends.guitools.controlpanel.ui.GenericDialog;
+import org.opends.guitools.controlpanel.ui.GenericFrame;
import org.opends.guitools.controlpanel.ui.LocalOrRemotePanel;
import org.opends.guitools.controlpanel.ui.MainMenuBar;
import org.opends.guitools.controlpanel.util.BlindApplicationTrustManager;
@@ -129,8 +133,10 @@
*/
public void createAndDisplayGUI()
{
- GenericDialog localOrRemote =
- ControlCenterMainPane.getLocalOrRemoteDialog(info);
+ LocalOrRemotePanel localOrRemotePanel = new LocalOrRemotePanel();
+ localOrRemotePanel.setInfo(info);
+ final GenericFrame localOrRemote = new GenericFrame(localOrRemotePanel);
+ localOrRemote.pack();
Utilities.centerOnScreen(localOrRemote);
if (argParser.getBindPassword() != null)
@@ -140,17 +146,32 @@
setCallOKWhenVisible(true);
}
+ ComponentListener listener = new ComponentAdapter()
+ {
+ /**
+ * {@inheritDoc}
+ */
+ public void componentHidden(ComponentEvent e)
+ {
+ handleWindowClosed(localOrRemote, info);
+ }
+ };
+ localOrRemote.addComponentListener(listener);
localOrRemote.setVisible(true);
+ }
- getLocalOrRemotePanel(localOrRemote.getContentPane()).
- setCallOKWhenVisible(false);
-
+ private void handleWindowClosed(GenericFrame localOrRemote,
+ final ControlPanelInfo info)
+ {
if (info.getServerDescriptor() == null)
{
MainMenuBar menuBar = new MainMenuBar(info);
// Assume that the user decided to quit the application
menuBar.quitClicked();
}
+
+ updateSharedLocalOrRemotePanel(localOrRemote, info);
+
// To be sure that the dialog receives the new configuration event before
// calling pack.
SwingUtilities.invokeLater(new Runnable()
@@ -216,7 +237,7 @@
}
}
- private void updateLocalOrRemotePanel(GenericDialog localOrRemote)
+ private void updateLocalOrRemotePanel(RootPaneContainer localOrRemote)
{
LocalOrRemotePanel panel =
getLocalOrRemotePanel(localOrRemote.getContentPane());
@@ -243,6 +264,39 @@
}
}
+ /**
+ * A method used to update the contents of the dialog displayed when the user
+ * selects 'Server To Administer...'. This is done because this class
+ * displays a GenericFrame and in the rest of the UI a GenericDialog is
+ * shown.
+ * @param localOrRemote the frame displayed by this class.
+ * @param info the generic info.
+ */
+ private void updateSharedLocalOrRemotePanel(RootPaneContainer localOrRemote,
+ ControlPanelInfo info)
+ {
+ LocalOrRemotePanel panel =
+ getLocalOrRemotePanel(localOrRemote.getContentPane());
+ LocalOrRemotePanel panelToUpdate = getLocalOrRemotePanel(
+ ControlCenterMainPane.getLocalOrRemoteDialog(info));
+ if (panel != null && panelToUpdate != null)
+ {
+ panelToUpdate.setRemote(panel.isRemote());
+ if (panel.getHostName() != null)
+ {
+ panelToUpdate.setHostName(panel.getHostName());
+ }
+ if (panel.getPort() != -1)
+ {
+ panelToUpdate.setPort(panel.getPort());
+ }
+ if (panel.getBindDN() != null)
+ {
+ panelToUpdate.setBindDN(panel.getBindDN());
+ }
+ }
+ }
+
private LocalOrRemotePanel getLocalOrRemotePanel(Container c)
{
LocalOrRemotePanel panel = null;
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java
index 45e7016..8757afc 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2009 Sun Microsystems, Inc.
+ * Copyright 2009-2010 Sun Microsystems, Inc.
*/
package org.opends.guitools.controlpanel.ui;
@@ -134,6 +134,61 @@
}
/**
+ * Returns the displayed host name.
+ * @return the displayed host name.
+ */
+ public String getHostName()
+ {
+ return hostName.getText();
+ }
+
+ /**
+ * Returns the displayed administration port.
+ * @return the displayed administration port.
+ */
+ public int getPort()
+ {
+ int port = -1;
+ try
+ {
+ port = new Integer(this.port.getText().trim());
+ }
+ catch (Exception ex)
+ {
+ // Ignore
+ }
+ return port;
+ }
+
+ /**
+ * Returns the displayed bind DN.
+ * @return the displayed bind DN.
+ */
+ public String getBindDN()
+ {
+ return dn.getText();
+ }
+
+ /**
+ * Returns the displayed password.
+ * @return the displayed password.
+ */
+ public char[] getBindPassword()
+ {
+ return pwd.getPassword();
+ }
+
+ /**
+ * Returns whether the panel displays the remote or the local server.
+ * @return whether the panel displays the remote or the local server.
+ */
+ public boolean isRemote()
+ {
+ int index = combo.getSelectedIndex();
+ return index == 1;
+ }
+
+ /**
* Sets the displayed host name.
* @param hostName the host name.
*/
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java
index 4c4a6c7..dfcecec 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008-2009 Sun Microsystems, Inc.
+ * Copyright 2008-2010 Sun Microsystems, Inc.
*/
package org.opends.guitools.controlpanel.ui;
@@ -187,7 +187,7 @@
{
Class<? extends Object> applicationClass =
Class.forName("com.apple.eawt.Application");
- Class applicationListenerClass =
+ Class<? extends Object> applicationListenerClass =
Class.forName("com.apple.eawt.ApplicationListener");
final Object macApplication = applicationClass.getConstructor(
(Class[])null).newInstance((Object[])null);
--
Gitblit v1.10.0