From 6cd45b63b3dd6b053b875cede938b15225181c3d Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 25 Jun 2009 03:32:11 +0000
Subject: [PATCH] Fix for issue 4068'(The Create first instance of base DN to be replicated' option is broken and confusing)

---
 opends/src/messages/messages/quicksetup.properties                                     |   11 ---
 opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java                   |   12 +--
 opends/src/quicksetup/org/opends/quicksetup/installer/ui/SuffixesToReplicatePanel.java |  132 -------------------------------------------
 3 files changed, 9 insertions(+), 146 deletions(-)

diff --git a/opends/src/messages/messages/quicksetup.properties b/opends/src/messages/messages/quicksetup.properties
index d8e8801..1f742eb 100644
--- a/opends/src/messages/messages/quicksetup.properties
+++ b/opends/src/messages/messages/quicksetup.properties
@@ -207,9 +207,6 @@
 INFO_CREATE_BASE_ENTRY_TOOLTIP=Only create the top entry for the Directory \
  Base DN
 INFO_CREATE_GLOBAL_ADMINISTRATOR_STEP=Global Administrator
-INFO_CREATE_NEW_SUFFIX_LABEL=Create first instance of base DN to be \
- replicated
-INFO_CREATE_NEW_SUFFIX_TOOLTIP=Check this to create a new base DN.
 # Only translate if the image is specific to the local
 INFO_CURRENT_STEP_ICON=images/currentstep.png
 INFO_CURRENT_STEP_ICON_DESCRIPTION=Current Step Indicator.
@@ -816,10 +813,6 @@
 INFO_REMOTE_SERVER_PWD_TOOLTIP=The password of an administrator in the OpenDS \
  you want to replicate data with.
 INFO_REMOTE_SERVER_REPLICATION_PORT=%s - To be configured on remote server %s
-INFO_REPLICATE_WITH_SUFFIXES_LABEL=Create local instance of existing base DNs \
- and configure replication:
-INFO_REPLICATE_WITH_SUFFIXES_TOOLTIP=Check this to Create Base DNs whose \
- Contents are replicated with Existing Base DNs.
 INFO_REPLICATED_SERVER_LABEL=This server will be part of a replication \
  topology
 INFO_REPLICATED_SERVER_TOOLTIP=Check this if you want to replicate the data \
@@ -981,8 +974,8 @@
 INFO_SUFFIXES_STEP=Data Replication
 INFO_SUFFIXES_TO_REPLICATE_DN_TOOLTIP=The Distinguished Name (DN) of the base \
  DN to replicate.
-INFO_SUFFIXES_TO_REPLICATE_PANEL_INSTRUCTIONS=Choose whether to create base \
- DNs as defined on remote servers or to create a new base DN.
+INFO_SUFFIXES_TO_REPLICATE_PANEL_INSTRUCTIONS=Choose the base DNs that you \
+ want to create and whose contents will be replicated with the remote servers.
 INFO_SUFFIXES_TO_REPLICATE_PANEL_TITLE=Data Replication
 INFO_SUMMARY_CANCELING=Canceling...
 INFO_SUMMARY_CONFIGURING=Configuring Directory Server...
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
index 150a5d1..352afdf 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -2070,10 +2070,9 @@
         "INFO_SUMMARY_INSTALL_FINISHED_SUCCESSFULLY",
         INFO_SUMMARY_INSTALL_FINISHED_SUCCESSFULLY.get(
             formatter.getFormattedText(
-                    Message.raw(
-                        getPath(new File(getInstancePath())))),
-            INFO_GENERAL_SERVER_STOPPED.get(),
-            cmd), Message.class);
+                Message.raw(getPath(new File(getInstancePath())))),
+                INFO_GENERAL_SERVER_STOPPED.get(),
+                cmd), Message.class);
     hmSummary.put(InstallProgressStep.FINISHED_SUCCESSFULLY,
             getFormattedSuccess(successMessage));
     hmSummary.put(InstallProgressStep.FINISHED_CANCELED,
@@ -2107,8 +2106,7 @@
        "INFO_SUMMARY_INSTALL_FINISHED_SUCCESSFULLY",
        INFO_SUMMARY_INSTALL_FINISHED_SUCCESSFULLY.get(
            formatter.getFormattedText(
-                   Message.raw(
-                       getPath(new File(getInstancePath())))),
+               Message.raw(getPath(new File(getInstancePath())))),
            status,
            cmd), Message.class);
     hmSummary.put(InstallProgressStep.FINISHED_SUCCESSFULLY,
@@ -4086,7 +4084,7 @@
     if ((suf == null) || (suf.getType() ==
       SuffixesToReplicateOptions.Type.NO_SUFFIX_TO_REPLICATE))
     {
-      type = suf.getType();
+      type = SuffixesToReplicateOptions.Type.NO_SUFFIX_TO_REPLICATE;
     }
     else
     {
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/ui/SuffixesToReplicatePanel.java b/opends/src/quicksetup/org/opends/quicksetup/installer/ui/SuffixesToReplicatePanel.java
index aae7190..074773e 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/ui/SuffixesToReplicatePanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/ui/SuffixesToReplicatePanel.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2009 Sun Microsystems, Inc.
  */
 
 package org.opends.quicksetup.installer.ui;
@@ -30,10 +30,6 @@
 import java.awt.Component;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -41,12 +37,10 @@
 import java.util.TreeSet;
 
 import javax.swing.Box;
-import javax.swing.ButtonGroup;
 import javax.swing.JCheckBox;
 import javax.swing.JEditorPane;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
-import javax.swing.JRadioButton;
 import javax.swing.JScrollPane;
 import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
@@ -56,10 +50,8 @@
 import org.opends.admin.ads.ServerDescriptor;
 import org.opends.admin.ads.SuffixDescriptor;
 
-import org.opends.quicksetup.ButtonName;
 import org.opends.quicksetup.Constants;
 import org.opends.quicksetup.UserData;
-import org.opends.quicksetup.event.ButtonEvent;
 import org.opends.quicksetup.installer.AuthenticationData;
 import org.opends.quicksetup.installer.SuffixesToReplicateOptions;
 import org.opends.quicksetup.ui.FieldName;
@@ -81,7 +73,6 @@
 {
   private static final long serialVersionUID = -8051367953737385327L;
   private Component lastFocusComponent;
-  private UserData defaultUserData;
   private TreeSet<SuffixDescriptor> orderedSuffixes =
     new TreeSet<SuffixDescriptor>(this);
   private HashMap<String, JCheckBox> hmCheckBoxes =
@@ -91,9 +82,6 @@
   // panel
   private String serverToConnectDisplay = null;
 
-
-  private JRadioButton rbCreateNewSuffix;
-  private JRadioButton rbReplicate;
   private JLabel noSuffixLabel;
   private Component labelGlue;
   private JPanel checkBoxPanel;
@@ -107,9 +95,7 @@
   public SuffixesToReplicatePanel(GuiApplication application)
   {
     super(application);
-    this.defaultUserData = application.getUserData();
     createComponents();
-    addFocusListeners();
   }
 
   /**
@@ -121,15 +107,7 @@
 
     if (fieldName == FieldName.SUFFIXES_TO_REPLICATE_OPTIONS)
     {
-      if (rbCreateNewSuffix.isSelected())
-      {
-        value = SuffixesToReplicateOptions.Type.NEW_SUFFIX_IN_TOPOLOGY;
-      }
-      else
-      {
-        value =
-          SuffixesToReplicateOptions.Type.REPLICATE_WITH_EXISTING_SUFFIXES;
-      }
+      value = SuffixesToReplicateOptions.Type.REPLICATE_WITH_EXISTING_SUFFIXES;
     }
     else if (fieldName == FieldName.SUFFIXES_TO_REPLICATE)
     {
@@ -152,19 +130,6 @@
    */
   public void displayFieldInvalid(FieldName fieldName, boolean invalid)
   {
-    if (fieldName == FieldName.SUFFIXES_TO_REPLICATE)
-    {
-      UIFactory.TextStyle style;
-      if (invalid)
-      {
-        style = UIFactory.TextStyle.SECONDARY_FIELD_INVALID;
-      } else
-      {
-        style = UIFactory.TextStyle.SECONDARY_FIELD_VALID;
-      }
-
-      UIFactory.setTextStyle(rbReplicate, style);
-    }
   }
 
   /**
@@ -195,10 +160,6 @@
     gbc.fill = GridBagConstraints.HORIZONTAL;
     gbc.gridwidth = GridBagConstraints.REMAINDER;
     gbc.insets = UIFactory.getEmptyInsets();
-    panel.add(rbCreateNewSuffix, gbc);
-
-    gbc.insets.top = UIFactory.TOP_INSET_RADIOBUTTON;
-    panel.add(rbReplicate, gbc);
 
     gbc.insets.top = UIFactory.TOP_INSET_SECONDARY_FIELD;
     gbc.insets.left = UIFactory.LEFT_INSET_SUBPANEL_SUBORDINATE;
@@ -302,16 +263,6 @@
         {
           cb.setSelected(v);
         }
-        cb.addActionListener(new ActionListener()
-        {
-          public void actionPerformed(ActionEvent ev)
-          {
-            if (((JCheckBox)ev.getSource()).isSelected())
-            {
-              rbReplicate.setSelected(true);
-            }
-          }
-        });
         hmCheckBoxes.put(suffix.getId(), cb);
       }
       populateCheckBoxPanel();
@@ -321,13 +272,6 @@
     noSuffixLabel.setVisible(!display);
     labelGlue.setVisible(!display);
     scroll.setVisible(display);
-    if (!display)
-    {
-      rbCreateNewSuffix.setSelected(true);
-    }
-    rbReplicate.setEnabled(display);
-
-    checkEnablingState();
   }
 
   /**
@@ -346,65 +290,9 @@
    */
   private void createComponents()
   {
-    ButtonGroup buttonGroup = new ButtonGroup();
-    rbCreateNewSuffix =
-      UIFactory.makeJRadioButton(INFO_CREATE_NEW_SUFFIX_LABEL.get(),
-          INFO_CREATE_NEW_SUFFIX_TOOLTIP.get(),
-          UIFactory.TextStyle.SECONDARY_FIELD_VALID);
-    rbCreateNewSuffix.setOpaque(false);
-    rbReplicate =
-      UIFactory.makeJRadioButton(INFO_REPLICATE_WITH_SUFFIXES_LABEL.get(),
-          INFO_REPLICATE_WITH_SUFFIXES_TOOLTIP.get(),
-          UIFactory.TextStyle.SECONDARY_FIELD_VALID);
-    rbReplicate.setOpaque(false);
-    buttonGroup.add(rbCreateNewSuffix);
-    buttonGroup.add(rbReplicate);
-
-    SuffixesToReplicateOptions.Type type =
-      defaultUserData.getSuffixesToReplicateOptions().getType();
-    rbCreateNewSuffix.setSelected(type ==
-      SuffixesToReplicateOptions.Type.NEW_SUFFIX_IN_TOPOLOGY);
-    rbReplicate.setSelected(type ==
-      SuffixesToReplicateOptions.Type.REPLICATE_WITH_EXISTING_SUFFIXES);
-
     noSuffixLabel = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
         INFO_SUFFIX_LIST_EMPTY.get(),
         UIFactory.TextStyle.SECONDARY_FIELD_VALID);
-
-    ActionListener l = new ActionListener()
-    {
-      public void actionPerformed(ActionEvent ev)
-      {
-        checkEnablingState();
-        ButtonEvent be = new ButtonEvent(ev.getSource(),
-            ButtonName.INPUT_PANEL_BUTTON);
-        notifyButtonListeners(be);
-      }
-    };
-    rbCreateNewSuffix.addActionListener(l);
-    rbReplicate.addActionListener(l);
-  }
-
-  /**
-   * Adds the required focus listeners to the fields.
-   */
-  private void addFocusListeners()
-  {
-    final FocusListener l = new FocusListener()
-    {
-      public void focusGained(FocusEvent e)
-      {
-        lastFocusComponent = e.getComponent();
-      }
-
-      public void focusLost(FocusEvent e)
-      {
-      }
-    };
-    rbReplicate.addFocusListener(l);
-    rbCreateNewSuffix.addFocusListener(l);
-
-    lastFocusComponent = rbReplicate;
   }
 
   private void populateCheckBoxPanel()
@@ -523,21 +411,5 @@
   {
     return getSuffixString(desc1).compareTo(getSuffixString(desc2));
   }
-
-  private void checkEnablingState()
-  {
-    boolean enable = rbReplicate.isSelected();
-    for (JCheckBox cb : hmCheckBoxes.values())
-    {
-      cb.setEnabled(enable);
-    }
-
-    for (JEditorPane p : suffixLabels)
-    {
-      p.setEnabled(enable);
-    }
-
-    noSuffixLabel.setEnabled(enable);
-  }
 }
 

--
Gitblit v1.10.0