From e85e6d0af6875147e77127f10e0211c014ca28d9 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Thu, 10 May 2007 14:16:11 +0000
Subject: [PATCH] This commit addresses several issues that Brian brought up regarding the upgrader.

---
 opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java |   65 +++++++++++++++++++++++++-------
 1 files changed, 51 insertions(+), 14 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java
index c7edb7b..ca37042 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java
@@ -35,9 +35,9 @@
 import org.opends.quicksetup.upgrader.Build;
 import org.opends.quicksetup.ApplicationException;
 import org.opends.quicksetup.UserData;
+import org.opends.quicksetup.BuildInformation;
 
 import javax.swing.*;
-import javax.swing.text.JTextComponent;
 import java.awt.*;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -53,9 +53,9 @@
 
   private static final long serialVersionUID = 5942916658585976799L;
 
-  JTextComponent tcServerLocation = null;
-  JTextComponent tcOldBuild = null;
-  JTextComponent tcNewBuild = null;
+  JLabel tcServerLocation = null;
+  JLabel tcOldBuild = null;
+  JLabel tcNewBuild = null;
   private JCheckBox checkBox;
 
   /**
@@ -134,6 +134,18 @@
       0
     );
 
+    // Here we use labels instead of calling UIFactory.makeJTextComponent.
+    // which supplies us with a JEditorPane for read-only values.  We don't
+    // know the values of these fields at this time.  If we use JEditorPanes
+    // here when the panel is made visible there is an effect where the text
+    // is seen racing left when first seen.
+    tcServerLocation = UIFactory.makeJLabel(serverDescriptor);
+    UIFactory.setTextStyle(tcServerLocation, UIFactory.TextStyle.READ_ONLY);
+    tcOldBuild = UIFactory.makeJLabel(oldVersionDescriptor);
+    UIFactory.setTextStyle(tcOldBuild, UIFactory.TextStyle.READ_ONLY);
+    tcNewBuild = UIFactory.makeJLabel(newVersionDescriptor);
+    UIFactory.setTextStyle(tcNewBuild, UIFactory.TextStyle.READ_ONLY);
+
     p.setLayout(new GridBagLayout());
     GridBagConstraints gbc = new GridBagConstraints();
 
@@ -149,8 +161,7 @@
     gbc.gridy = 0;
     gbc.weightx = 1.0;
     gbc.fill = GridBagConstraints.HORIZONTAL;
-    p.add(tcServerLocation = UIFactory.makeJTextComponent(serverDescriptor,
-            null), gbc);
+    p.add(tcServerLocation, gbc);
 
     gbc.gridx = 0;
     gbc.gridy = 1;
@@ -160,8 +171,7 @@
     gbc.gridx = 1;
     gbc.gridy = 1;
     gbc.fill = GridBagConstraints.HORIZONTAL;
-    p.add(tcOldBuild = UIFactory.makeJTextComponent(oldVersionDescriptor,
-            null), gbc);
+    p.add(tcOldBuild, gbc);
 
     gbc.gridx = 0;
     gbc.gridy = 2;
@@ -172,8 +182,7 @@
     gbc.gridy = 2;
     gbc.weighty = 1.0;
     gbc.fill = GridBagConstraints.HORIZONTAL;
-    p.add(tcNewBuild = UIFactory.makeJTextComponent(newVersionDescriptor,
-            null), gbc);
+    p.add(tcNewBuild, gbc);
 
     return p;
   }
@@ -183,12 +192,17 @@
   }
 
   private String getOldBuildString() {
-    String oldVersion;
+    String oldVersion = null;
     try {
-      oldVersion = getApplication().getInstallation().
-              getBuildInformation().getBuildId();
+      BuildInformation bi = getApplication().getInstallation().
+              getBuildInformation();
+      if (bi != null) {
+        oldVersion = bi.toString();
+      }
     } catch (ApplicationException e) {
       LOG.log(Level.INFO, "error", e);
+    }
+    if (oldVersion == null) {
       oldVersion = getMsg("upgrade-build-id-unknown");
     }
     return oldVersion;
@@ -210,7 +224,6 @@
       newVersion = getMsg("upgrade-build-id-unknown");
     }
     return newVersion;
-
   }
 
   /**
@@ -227,4 +240,28 @@
     }
     return checkBox;
   }
+
+//  public static void main(String[] args) {
+//    final UserData ud = new UpgradeUserData();
+//    ud.setServerLocation("XXX/XXXXX/XX/XXXXXXXXXXXX/XXXX");
+//    Upgrader app = new Upgrader();
+//    app.setUserData(ud);
+//    final UpgraderReviewPanel p = new UpgraderReviewPanel(app);
+//    p.initialize();
+//    JFrame frame = new JFrame();
+//    frame.getContentPane().add(p);
+//    frame.addComponentListener(new ComponentAdapter() {
+//      public void componentHidden(ComponentEvent componentEvent) {
+//        System.exit(0);
+//      }
+//    });
+//    frame.pack();
+//    frame.setVisible(true);
+//    new Thread(new Runnable() {
+//      public void run() {
+//        p.beginDisplay(ud);
+//      }
+//    }).start();
+//
+//  }
 }

--
Gitblit v1.10.0