From e28cc1961ce7b02aef1cb20aeb0346def9c49754 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 23 Dec 2009 10:50:38 +0000
Subject: [PATCH] Follow up to fix issue 4414 (It would be nice to have the equivalent command-line displayed in setup) Include the stop-ds command-line when the user chooses to configure replication and not to run the server when setup is complete. Make the displayed command-line to be dynamically updated when the user clicks on the check boxes (start server and configure windows service) in the review panel.
---
opends/src/messages/messages/quicksetup.properties | 2
opends/src/quicksetup/org/opends/quicksetup/util/Utils.java | 113 ++++++++++++++++++++++++++++---------
opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java | 54 +++++++++++++-----
3 files changed, 125 insertions(+), 44 deletions(-)
diff --git a/opends/src/messages/messages/quicksetup.properties b/opends/src/messages/messages/quicksetup.properties
index 51037fe..d334066 100644
--- a/opends/src/messages/messages/quicksetup.properties
+++ b/opends/src/messages/messages/quicksetup.properties
@@ -895,6 +895,8 @@
non-interactive command-lines to enable replication:
INFO_INSTALL_INITIALIZE_REPLICATION_EQUIVALENT_COMMAND_LINES=Equivalent \
non-interactive command-lines to initialize replication:
+INFO_INSTALL_STOP_SERVER_EQUIVALENT_COMMAND_LINE=Equivalent command-line to \
+ stop the server:
INFO_SECURITY_OPTIONS_CANCEL_BUTTON_TOOLTIP=Close this dialog and discard \
configuration.
INFO_SECURITY_OPTIONS_DIALOG_TITLE=Security Options
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java b/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java
index 5b14a5f..66145cd 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java
@@ -32,6 +32,7 @@
import static org.opends.messages.QuickSetupMessages.*;
import org.opends.admin.ads.ServerDescriptor;
+import org.opends.quicksetup.Installation;
import org.opends.quicksetup.UserData;
import org.opends.quicksetup.installer.AuthenticationData;
import org.opends.quicksetup.installer.DataReplicationOptions;
@@ -42,7 +43,6 @@
import javax.swing.*;
import javax.swing.border.EmptyBorder;
-import javax.swing.text.BadLocationException;
import javax.swing.text.JTextComponent;
import java.awt.*;
import java.awt.event.ActionEvent;
@@ -81,6 +81,8 @@
private JEditorPane equivalentCommandPane;
+ private UserData lastUserData;
+
/**
* Constructor of the panel.
* @param application Application represented by this panel
@@ -141,6 +143,8 @@
}
checkStartWarningLabel();
updateEquivalentCommand(userData);
+
+ lastUserData = userData;
}
/**
@@ -476,8 +480,9 @@
UIFactory.LEFT_INSET_SECONDARY_FIELD));
cardLayoutPanel.add(new JScrollPane(p), DISPLAY_TEXT.toString());
- cardLayoutPanel.add(new JScrollPane(createEquivalentCommandPanel()),
- DISPLAY_EQUIVALENT_COMMAND.toString());
+ JScrollPane scroll = new JScrollPane();
+ createEquivalentCommandPanel(scroll);
+ cardLayoutPanel.add(scroll, DISPLAY_EQUIVALENT_COMMAND.toString());
gbc.gridx = 0;
gbc.gridy = 0;
@@ -559,10 +564,11 @@
return panel;
}
- private Component createEquivalentCommandPanel()
+ private Component createEquivalentCommandPanel(JScrollPane scroll)
{
- equivalentCommandPane = UIFactory.makeHtmlPane(Message.EMPTY,
- UIFactory.INSTRUCTIONS_FONT);
+ equivalentCommandPane = UIFactory.makeProgressPane(scroll);
+ equivalentCommandPane.setAutoscrolls(true);
+ scroll.setViewportView(equivalentCommandPane);
return equivalentCommandPane;
}
@@ -623,6 +629,8 @@
public void actionPerformed(ActionEvent ev)
{
checkStartWarningLabel();
+ lastUserData.setStartServer(startCheckBox.isSelected());
+ updateEquivalentCommand(lastUserData);
}
});
}
@@ -639,6 +647,18 @@
UIFactory.TextStyle.CHECKBOX);
enableWindowsServiceCheckBox.setSelected(
getApplication().getUserData().getEnableWindowsService());
+ enableWindowsServiceCheckBox.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ if (Utils.isWindows())
+ {
+ lastUserData.setEnableWindowsService(
+ enableWindowsServiceCheckBox.isSelected());
+ updateEquivalentCommand(lastUserData);
+ }
+ }
+ });
}
return enableWindowsServiceCheckBox;
}
@@ -664,15 +684,6 @@
HtmlProgressMessageFormatter formatter =
new HtmlProgressMessageFormatter();
StringBuilder sb = new StringBuilder();
- try
- {
- equivalentCommandPane.getDocument().remove(0,
- equivalentCommandPane.getDocument().getLength());
- }
- catch (BadLocationException ble)
- {
- throw new RuntimeException("Unexpected error: "+ble, ble);
- }
sb.append(formatter.getFormattedProgress(
INFO_INSTALL_SETUP_EQUIVALENT_COMMAND_LINE.get()));
sb.append(formatter.getLineBreak());
@@ -742,6 +753,19 @@
"</b>");
}
}
+
+ if (userData.getReplicationOptions().getType() !=
+ DataReplicationOptions.Type.STANDALONE &&
+ !userData.getStartServer())
+ {
+ sb.append(formatter.getTaskSeparator());
+ String cmd =
+ Utils.getPath(Installation.getLocal().getServerStopCommandFile());
+ sb.append(formatter.getFormattedProgress(
+ INFO_INSTALL_STOP_SERVER_EQUIVALENT_COMMAND_LINE.get()));
+ sb.append(formatter.getLineBreak());
+ sb.append("<b>"+formatter.getFormattedProgress(Message.raw(cmd))+"</b>");
+ }
equivalentCommandPane.setText(sb.toString());
}
}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index df040c2..a043530 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -2221,7 +2221,7 @@
for (int i=initialIndex ; i<cmd.size(); i++)
{
String s = cmd.get(i);
- if (s.startsWith("-") && i > initialIndex)
+ if (s.startsWith("-"))
{
builder.append(lineSeparator);
builder.append(formatter.getFormattedProgress(Message.raw(s)));
@@ -2296,7 +2296,7 @@
{
setupFile = Installation.UNIX_SETUP_FILE_NAME;
}
- cmdLine.add(setupFile);
+ cmdLine.add(getInstallDir() + setupFile);
cmdLine.add("--cli");
for (String baseDN : getBaseDNs(userData))
@@ -2350,6 +2350,10 @@
cmdLine.add("--rootUserPassword");
cmdLine.add(OBFUSCATED_VALUE);
+ if (Utils.isWindows() && userData.getEnableWindowsService())
+ {
+ cmdLine.add("--enableWindowsService");
+ }
if (userData.getReplicationOptions().getType() ==
DataReplicationOptions.Type.STANDALONE &&
!userData.getStartServer())
@@ -2483,15 +2487,7 @@
UserData userData, Set<String> baseDNs, ServerDescriptor server)
{
ArrayList<String> cmdLine = new ArrayList<String>();
- String cmdName;
- if (Utils.isWindows())
- {
- cmdName = "dsreplication.bat";
- }
- else
- {
- cmdName = "dsreplication";
- }
+ String cmdName = getCommandLinePath("dsreplication");
cmdLine.add(cmdName);
cmdLine.add("enable");
@@ -2564,20 +2560,87 @@
return cmdLine;
}
+ /**
+ * Returns the full path of the command-line for a given script name.
+ * @param scriptBasicName the script basic name (with no extension).
+ * @return the full path of the command-line for a given script name.
+ */
+ private static String getCommandLinePath(String scriptBasicName)
+ {
+ String cmdLineName;
+ if (isWindows())
+ {
+ cmdLineName = getBinaryDir()+scriptBasicName+".bat";
+ }
+ else
+ {
+ cmdLineName = getBinaryDir()+scriptBasicName;
+ }
+ return cmdLineName;
+ }
+
+ private static String binDir;
+ /**
+ * Returns the binary/script directory.
+ * @return the binary/script directory.
+ */
+ private static String getBinaryDir()
+ {
+ if (binDir == null)
+ {
+ File f = Installation.getLocal().getBinariesDirectory();
+ try
+ {
+ binDir = f.getCanonicalPath();
+ }
+ catch (Throwable t)
+ {
+ binDir = f.getAbsolutePath();
+ }
+ if (binDir.lastIndexOf(File.separatorChar) != (binDir.length() - 1))
+ {
+ binDir += File.separatorChar;
+ }
+ }
+
+ return binDir;
+ }
+
+ private static String installDir;
+ /**
+ * Returns the installation directory.
+ * @return the installation directory.
+ */
+ private static String getInstallDir()
+ {
+ if (installDir == null)
+ {
+ File f =
+ org.opends.quicksetup.Installation.getLocal().getRootDirectory();
+ try
+ {
+ installDir = f.getCanonicalPath();
+ }
+ catch (Throwable t)
+ {
+ installDir = f.getAbsolutePath();
+ }
+ if (installDir.lastIndexOf(File.separatorChar) !=
+ (installDir.length() - 1))
+ {
+ installDir += File.separatorChar;
+ }
+ }
+
+ return installDir;
+ }
+
private static ArrayList<String>
getDsReplicationInitializeEquivalentCommandLine(
UserData userData, Set<String> baseDNs, ServerDescriptor server)
{
ArrayList<String> cmdLine = new ArrayList<String>();
- String cmdName;
- if (Utils.isWindows())
- {
- cmdName = "dsreplication.bat";
- }
- else
- {
- cmdName = "dsreplication";
- }
+ String cmdName = getCommandLinePath("dsreplication");
cmdLine.add(cmdName);
cmdLine.add("initialize");
@@ -2706,15 +2769,7 @@
{
ArrayList<ArrayList<String>> cmdLines = new ArrayList<ArrayList<String>>();
- String cmdName;
- if (Utils.isWindows())
- {
- cmdName = "dsconfig.bat";
- }
- else
- {
- cmdName = "dsconfig";
- }
+ String cmdName = getCommandLinePath("dsconfig");
ArrayList<String> connectionArgs = new ArrayList<String>();
connectionArgs.add("--hostName");
--
Gitblit v1.10.0