From e0302537bd687bab02f6174e66fd1d9c2f13ba9d Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 26 Mar 2008 12:00:42 +0000
Subject: [PATCH] Fix for issue 3064 (The setup command should check the Java version)

---
 opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java |   50 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
index 5365efc..1260689 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -63,12 +63,15 @@
 import org.opends.admin.ads.util.ConnectionUtils;
 import org.opends.admin.ads.util.PreferredConnection;
 import org.opends.quicksetup.ui.*;
+import org.opends.quicksetup.util.IncompatibleVersionException;
 import org.opends.quicksetup.util.Utils;
 
 import static org.opends.quicksetup.util.Utils.*;
 import static org.opends.quicksetup.Step.*;
 import org.opends.quicksetup.*;
 import org.opends.server.util.CertificateManager;
+import org.opends.quicksetup.event.ButtonActionListener;
+import org.opends.quicksetup.event.ButtonEvent;
 import org.opends.quicksetup.installer.ui.DataOptionsPanel;
 import org.opends.quicksetup.installer.ui.DataReplicationPanel;
 import org.opends.quicksetup.installer.ui.GlobalAdministratorPanel;
@@ -111,6 +114,8 @@
   /** When true indicates that the user has canceled this operation. */
   protected boolean canceled = false;
 
+  private boolean javaVersionCheckFailed;
+
   /** Map containing information about what has been configured remotely. */
   Map<ServerDescriptor, ConfiguredReplication> hmConfiguredRemoteReplication =
     new HashMap<ServerDescriptor, ConfiguredReplication>();
@@ -403,6 +408,11 @@
               "Cannot click on quit from progress step");
     } else if (installStatus.isInstalled()) {
       qs.quit();
+
+    } else if (javaVersionCheckFailed)
+    {
+      qs.quit();
+
     } else if (qs.displayConfirmation(INFO_CONFIRM_QUIT_INSTALL_MSG.get(),
             INFO_CONFIRM_QUIT_INSTALL_TITLE.get())) {
       qs.quit();
@@ -436,10 +446,42 @@
    */
   public JPanel createFramePanel(QuickSetupDialog dlg) {
     JPanel p;
-    if (installStatus.isInstalled() && !forceToDisplaySetup) {
-      p = dlg.getInstalledPanel();
-    } else {
-      p = super.createFramePanel(dlg);
+    javaVersionCheckFailed = true;
+    try
+    {
+      Utils.checkJavaVersion();
+      javaVersionCheckFailed = false;
+      if (installStatus.isInstalled() && !forceToDisplaySetup) {
+        p = dlg.getInstalledPanel();
+      } else {
+        p = super.createFramePanel(dlg);
+      }
+    }
+    catch (IncompatibleVersionException ijv)
+    {
+      MessageBuilder sb = new MessageBuilder();
+      sb.append(Utils.breakHtmlString(
+          Utils.getHtml(ijv.getMessageObject().toString()),
+          Constants.MAX_CHARS_PER_LINE_IN_DIALOG));
+      QuickSetupErrorPanel errPanel =
+        new QuickSetupErrorPanel(this, sb.toMessage());
+      final QuickSetupDialog fDlg = dlg;
+      errPanel.addButtonActionListener(
+          new ButtonActionListener()
+          {
+            /**
+             * ButtonActionListener implementation. It assumes that we are
+             * called in the event thread.
+             *
+             * @param ev the ButtonEvent we receive.
+             */
+            public void buttonActionPerformed(ButtonEvent ev)
+            {
+              // Simulate a close button event
+              fDlg.notifyButtonEvent(ButtonName.QUIT);
+            }
+          });
+      p = errPanel;
     }
     return p;
   }

--
Gitblit v1.10.0