From 75d92e5488ccaa51b1c05242cee772988eec75fe Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 18 Dec 2006 13:33:24 +0000
Subject: [PATCH] Fix some issues with the dialog position when they were displayed.
---
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java | 21 +++-
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CurrentInstallStatus.java | 38 ++-----
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupStepPanel.java | 5
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupErrorPanel.java | 1
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebBrowserErrorDialog.java | 6 +
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java | 75 +++++++++++++++
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java | 58 +++++++----
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java | 53 +---------
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties | 22 ++--
9 files changed, 165 insertions(+), 114 deletions(-)
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CurrentInstallStatus.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CurrentInstallStatus.java
index 9fb8074..22d74b5 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CurrentInstallStatus.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CurrentInstallStatus.java
@@ -35,8 +35,6 @@
import java.util.HashSet;
import java.util.Set;
-import javax.naming.NamingException;
-
import org.opends.quicksetup.i18n.ResourceProvider;
import org.opends.quicksetup.util.Utils;
@@ -201,36 +199,14 @@
}
/**
- * Indicates whether there is the server is running in the localhost on the
- * LDAP port specified in config.ldif file. Note that this method performs
- * LDAP requests which can be time consuming.
+ * Indicates whether there is the server is running.
*
* @return <CODE>true</CODE> if the server is running, or <CODE>false</CODE>
* if not.
*/
public boolean isServerRunning()
{
- boolean isServerRunning = false;
-
- try
- {
- Utils.createLdapContext(getLdapUrl(), null, null, 3000, null);
- isServerRunning = true;
- } catch (NamingException ne)
- {
- try
- {
- if (getSecurePort() != -1)
- {
- Utils.createLdapContext(getLdapsUrl(), null, null, 3000, null);
- isServerRunning = true;
- }
- } catch (NamingException ne2)
- {
- }
- }
-
- return isServerRunning;
+ return Utils.isServerRunning(Utils.getInstallPathFromClasspath());
}
/**
@@ -242,7 +218,10 @@
{
if (ldapUrl == null)
{
- ldapUrl = "ldap://localhost:"+getPort();
+ if (getPort() != -1)
+ {
+ ldapUrl = "ldap://localhost:"+getPort();
+ }
}
return ldapUrl;
}
@@ -257,7 +236,10 @@
{
if (ldapsUrl == null)
{
- ldapsUrl = "ldaps://localhost:"+getSecurePort();
+ if (getSecurePort() != -1)
+ {
+ ldapsUrl = "ldaps://localhost:"+getSecurePort();
+ }
}
return ldapsUrl;
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
index b01ccce..aae9180 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -926,9 +926,9 @@
* message id informing that it started. So it seems that everything
* went fine.
*
- * However in Windows we can have issues with the firewalls. Just check
- * if we can connect to the server. Try 5 times with an interval of
- * 1 second between try.
+ * However we can have issues with the firewalls or do not have rights
+ * to connect. Just check if we can connect to the server.
+ * Try 5 times with an interval of 1 second between try.
*/
boolean connected = false;
for (int i=0; i<5 && !connected; i++)
@@ -958,9 +958,18 @@
}
if (!connected)
{
- String[] arg = {String.valueOf(userData.getServerPort())};
- throw new InstallException(InstallException.Type.START_ERROR,
- getMsg("error-starting-server-in-windows", arg), null);
+ if (Utils.isWindows())
+ {
+ String[] arg = {String.valueOf(userData.getServerPort())};
+ throw new InstallException(InstallException.Type.START_ERROR,
+ getMsg("error-starting-server-in-windows", arg), null);
+ }
+ else
+ {
+ String[] arg = {String.valueOf(userData.getServerPort())};
+ throw new InstallException(InstallException.Type.START_ERROR,
+ getMsg("error-starting-server-in-unix", arg), null);
+ }
}
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
index fe13de9..cfb1ba8 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -117,7 +117,7 @@
you sure you want to continue?
cli-uninstall-stop-authentication-generic-prompt1=The server is currently \
running and must be stopped before uninstallation can continue.
-cli-uninstall-stop-authentication-generic-prompt2=You must provide the \
+cli-uninstall-stop-authentication-generic-prompt2=You must provide an \
Administrative User DN and password to stop the server.
cli-uninstall-error-reading-pwd-file=Could not read the password from \
file {0}. Check that the file path is correct, that you have access rights to \
@@ -292,13 +292,13 @@
#
# Icon tooltips.
#
-current-step-icon-tooltip=Current Step Indicator.
-splash-icon-tooltip=Open DS QuickSetup Launching.
-minimized-icon-tooltip=OpenDS QuickSetup.
-background-icon-tooltip=OpenDS QuickSetup.
-warning-icon-tooltip=Warning.
-error-icon-tooltip=Error.
-information-icon-tooltip=Information.
+current-step-icon-tooltip=Current Step Indicator
+splash-icon-tooltip=Open DS QuickSetup Launching
+minimized-icon-tooltip=OpenDS QuickSetup
+background-icon-tooltip=OpenDS QuickSetup
+warning-icon-tooltip=Warning
+error-icon-tooltip=Error
+information-icon-tooltip=Information
#
# Icon paths. This is done to be able to provide localizable icons (for
@@ -453,12 +453,12 @@
following locations outside the server path:
delete-outside-dbs-label=Delete these Database Files
delete-outside-dbs-tooltip=Check this box to Delete the Database Files located \
-outside the install directory.
+outside the install directory
delete-outside-logs-msg=The Directory Server contains log files in the \
following locations outside the server path:
delete-outside-logs-label=Delete these Log Files
delete-outside-logs-tooltip=Check this box to Delete the Log Files located \
-outside the install directory.
+outside the install directory
#
# Miscellaneous labels
@@ -561,6 +561,8 @@
error-starting-server=Error Starting Directory Server.
error-starting-server-in-windows=Could not connect to Server after Start. \
If you have a firewall configured check that it allows connections to port {0}.
+error-starting-server-in-unix=Could not connect to Server after Start. \
+Verify that you have the rights to access to port {0}.
error-stopping-server=Error Stopping Directory Server.
error-stopping-server-code=Error Stopping Directory Server. Error code: {0}.
error-reading-erroroutput=Error Reading error output.
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java
index 054cf81..c6895b1 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/DirectoryManagerAuthenticationDialog.java
@@ -94,10 +94,6 @@
this.parent = parent;
this.installStatus = installStatus;
getContentPane().add(createPanel());
-// TODO: find a way to calculate this dynamically
- setPreferredSize(new Dimension(500, 300));
- addComponentListener(new MinimumSizeComponentListener(this,
- 500, 300));
}
/**
@@ -117,10 +113,17 @@
*/
public void packAndShow()
{
+ /*
+ * TODO: find a way to calculate this dynamically. This is done to avoid
+ * all the text in a single line.
+ */
+ setPreferredSize(new Dimension(500, 300));
+ addComponentListener(new MinimumSizeComponentListener(this,
+ 500, 300));
+ getRootPane().setDefaultButton(shutDownButton);
pack();
Utils.centerOnComponent(this, parent);
tfPwd.requestFocusInWindow();
- getRootPane().setDefaultButton(shutDownButton);
setVisible(true);
}
@@ -226,10 +229,20 @@
gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
gbc.fill = GridBagConstraints.NONE;
gbc.gridwidth = GridBagConstraints.REMAINDER;
+ JPanel p3 = new JPanel(new GridBagLayout());
+ p3.setOpaque(false);
tfPwd = UIFactory.makeJPasswordField(null,
getMsg("shutdown-directory-manager-pwd-tooltip"),
UIFactory.PASSWORD_FIELD_SIZE, UIFactory.TextStyle.PASSWORD_FIELD);
p2.add(tfPwd, gbc);
+ p2.add(p3, gbc);
+ gbc.insets = UIFactory.getEmptyInsets();
+ gbc.gridwidth = GridBagConstraints.RELATIVE;
+ gbc.weightx = 0.0;
+ p3.add(tfPwd, gbc);
+ gbc.gridwidth = GridBagConstraints.REMAINDER;
+ gbc.weightx = 1.0;
+ p3.add(Box.createHorizontalGlue(), gbc);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = UIFactory.getEmptyInsets();
@@ -398,23 +411,6 @@
pwdInvalid = true;
possibleCauses.add(getMsg("empty-pwd"));
}
- if (possibleCauses.size() > 0)
- {
- // Message with causes
- String[] arg = {
- Utils.getStringFromCollection(possibleCauses, "\n")
- };
- displayError(
- getMsg("cannot-connect-to-shutdown-with-cause", arg),
- getMsg("error-title"));
- }
- else
- {
- // Generic message
- displayError(
- getMsg("cannot-connect-to-shutdown-without-cause"),
- getMsg("error-title"));
- }
if (dnInvalid)
{
@@ -437,6 +433,24 @@
UIFactory.setTextStyle(lPwd,
UIFactory.TextStyle.PRIMARY_FIELD_VALID);
}
+
+ if (possibleCauses.size() > 0)
+ {
+ // Message with causes
+ String[] arg = {
+ Utils.getStringFromCollection(possibleCauses, "\n")
+ };
+ displayError(
+ getMsg("cannot-connect-to-shutdown-with-cause", arg),
+ getMsg("error-title"));
+ }
+ else
+ {
+ // Generic message
+ displayError(
+ getMsg("cannot-connect-to-shutdown-without-cause"),
+ getMsg("error-title"));
+ }
}
else
{
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupErrorPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupErrorPanel.java
index 0fb0107..03a8f8a 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupErrorPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupErrorPanel.java
@@ -119,6 +119,7 @@
setLayout(new GridBagLayout());
setBackground(UIFactory.DEFAULT_BACKGROUND);
+ setOpaque(true);
gbc.insets = UIFactory.getEmptyInsets();
gbc.fill = GridBagConstraints.BOTH;
gbc.gridwidth = GridBagConstraints.REMAINDER;
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupStepPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupStepPanel.java
index a6c03c6..c247493 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupStepPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupStepPanel.java
@@ -65,8 +65,9 @@
private ProgressMessageFormatter formatter;
- // We can use a HashMap (not multi-thread safe) because all
- // the calls to this object are done in the event-thread.
+ /* We can use a HashMap (not multi-thread safe) because all
+ the calls to this object are done in the event-thread.
+ */
private HashMap<String, URLWorker> hmURLWorkers =
new HashMap<String, URLWorker>();
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebBrowserErrorDialog.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebBrowserErrorDialog.java
index 5f4f499..1f8a2da 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebBrowserErrorDialog.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/WebBrowserErrorDialog.java
@@ -41,6 +41,7 @@
import javax.swing.JPanel;
import javax.swing.text.JTextComponent;
+import org.opends.quicksetup.event.MinimumSizeComponentListener;
import org.opends.quicksetup.i18n.ResourceProvider;
import org.opends.quicksetup.util.Utils;
import org.opends.quicksetup.util.WebBrowserException;
@@ -84,6 +85,10 @@
public void packAndShow()
{
pack();
+ int minWidth = (int) getPreferredSize().getWidth();
+ int minHeight = (int) getPreferredSize().getHeight();
+ addComponentListener(new MinimumSizeComponentListener(this,
+ minWidth, minHeight));
Utils.centerOnComponent(this, parent);
setVisible(true);
}
@@ -124,6 +129,7 @@
gbc.gridwidth = GridBagConstraints.RELATIVE;
Insets pInsets = UIFactory.getCurrentStepPanelInsets();
gbc.insets.left = 0;
+ gbc.fill = GridBagConstraints.BOTH;
String msg = getMsg("error-browser-display-msg", new String[]
{ url });
JTextComponent tf =
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
index 01e5a71..9c0357b 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
@@ -28,13 +28,10 @@
package org.opends.quicksetup.uninstaller;
import java.io.BufferedReader;
-import java.io.BufferedWriter;
import java.io.File;
import java.io.FileFilter;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -670,8 +667,8 @@
/* Create these objects to resend the stop process output to the details
* area.
*/
- new StopReader(err, true);
- new StopReader(out, false);
+ StopReader errorReader = new StopReader(err, true);
+ StopReader outputReader = new StopReader(out, false);
int returnValue = process.waitFor();
@@ -688,12 +685,11 @@
*/
int nTries = 10;
boolean stopped = false;
- String testPath = Utils.getInstallPathFromClasspath()+File.separator+
- "locks"+File.separator+"server.lock";
- File testFile = new File(testPath);
+
for (int i=0; i<nTries && !stopped; i++)
{
- stopped = canWriteFile(testFile);
+ stopped = !Utils.isServerRunning(
+ Utils.getInstallPathFromClasspath());
if (!stopped)
{
String msg =
@@ -1104,8 +1100,6 @@
*/
private class StopReader
{
- private UninstallException ex;
-
private boolean isFirstLine;
/**
@@ -1150,50 +1144,17 @@
} catch (IOException ioe)
{
String errorMsg = getThrowableMsg(errorTag, ioe);
- ex =
- new UninstallException(UninstallException.Type.STOP_ERROR,
- errorMsg, ioe);
+ notifyListeners(errorMsg);
} catch (Throwable t)
{
String errorMsg = getThrowableMsg(errorTag, t);
- ex =
- new UninstallException(UninstallException.Type.STOP_ERROR,
- errorMsg, t);
+ notifyListeners(errorMsg);
}
}
});
t.start();
}
-
- /**
- * Returns the UninstallException that occurred reading the Stop error and
- * output or <CODE>null</CODE> if no exception occurred.
- * @return the exception that occurred reading or <CODE>null</CODE> if
- * no exception occurred.
- */
- public UninstallException getException()
- {
- return ex;
- }
- }
-
- private boolean canWriteFile(File file)
- {
- boolean canWriteFile = false;
- Writer output = null;
- try {
- //use buffering
- //FileWriter always assumes default encoding is OK!
- output = new BufferedWriter( new FileWriter(file) );
- output.write("test");
- output.close();
- canWriteFile = true;
- }
- catch (Throwable t)
- {
- }
- return canWriteFile;
}
/**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 12b16be..b416de1 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -31,6 +31,7 @@
import java.awt.Toolkit;
import java.awt.Window;
import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
@@ -38,9 +39,11 @@
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.RandomAccessFile;
+import java.io.Writer;
import java.net.ConnectException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
+import java.net.Socket;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -176,6 +179,22 @@
}
serverSocket.bind(socketAddress);
canUseAsPort = true;
+
+ serverSocket.close();
+
+ /* Try to create a socket because sometimes even if we can create a server
+ * socket there is already someone listening to the port (is the case
+ * of products as Sun DS 6.0).
+ */
+ try
+ {
+ new Socket("localhost", port);
+ canUseAsPort = false;
+
+ } catch (IOException ioe)
+ {
+ }
+
} catch (IOException ex)
{
canUseAsPort = false;
@@ -1158,6 +1177,62 @@
}
/**
+ * Returns if the server is running on the given path.
+ * @param serverPath the installation path of the server.
+ * @return <CODE>true</CODE> if the server is running and <CODE>false</CODE>
+ * otherwise.
+ */
+ public static boolean isServerRunning(String serverPath)
+ {
+ boolean isServerRunning;
+ if (isWindows())
+ {
+ String testPath = serverPath+File.separator+
+ "locks"+File.separator+"server.lock";
+ File testFile = new File(testPath);
+
+ boolean canWriteFile = false;
+ Writer output = null;
+ try {
+ //use buffering
+ //FileWriter always assumes default encoding is OK!
+ output = new BufferedWriter( new FileWriter(testFile) );
+ output.write("test");
+ output.close();
+ output = new BufferedWriter( new FileWriter(testFile) );
+ output.write("");
+ output.close();
+
+ canWriteFile = true;
+
+ }
+ catch (Throwable t)
+ {
+ }
+ finally
+ {
+ if (output != null)
+ {
+ try
+ {
+ output.close();
+ }
+ catch (Throwable t)
+ {
+ }
+ }
+ }
+ isServerRunning = !canWriteFile;
+ }
+ else
+ {
+ isServerRunning = fileExists(serverPath+File.separator+
+ "logs"+File.separator+"server.pid");
+ }
+ return isServerRunning;
+ }
+
+ /**
* This is just a commodity method used to try to get an InitialLdapContext.
* @param t the Thread to be used to create the InitialLdapContext.
* @param pair an Object[] array that contains the InitialLdapContext and the
--
Gitblit v1.10.0