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/quicksetup/org/opends/quicksetup/installer/ui/InstallReviewPanel.java |   54 +++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 39 insertions(+), 15 deletions(-)

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());
   }
 }

--
Gitblit v1.10.0