From 950f927644139bbc8805c518dff2cd80cc3bcb6e Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Thu, 09 Apr 2015 12:41:47 +0000
Subject: [PATCH] OPENDJ-1714 (CR-6595) UI setup backend type choice

---
 opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/DataOptionsPanel.java |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/DataOptionsPanel.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/DataOptionsPanel.java
index ac34991..4615583 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/DataOptionsPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/DataOptionsPanel.java
@@ -40,7 +40,9 @@
 
 import javax.swing.Box;
 import javax.swing.ButtonGroup;
+import javax.swing.DefaultComboBoxModel;
 import javax.swing.JButton;
+import javax.swing.JComboBox;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JRadioButton;
@@ -58,6 +60,7 @@
 import org.opends.quicksetup.ui.QuickSetupStepPanel;
 import org.opends.quicksetup.ui.UIFactory;
 import org.opends.quicksetup.ui.Utilities;
+import org.opends.server.tools.BackendTypeHelper;
 
 /**
  * This is the panel that contains the Data Options: the suffix dn, whether to
@@ -80,6 +83,8 @@
 
   private JButton ldifBrowseButton;
 
+  private JComboBox backendTypeComboBox;
+
   /**
    * Constructor of the panel.
    *
@@ -91,6 +96,7 @@
     super(application);
     this.defaultUserData = application.getUserData();
     populateComponentMaps();
+    createBackendTypeComboBox();
     addDocumentListeners();
     addFocusListeners();
     addActionListeners();
@@ -108,7 +114,10 @@
           return type;
         }
       }
-
+    }
+    else if (FieldName.BACKEND_TYPE == fieldName)
+    {
+      return backendTypeComboBox.getSelectedItem().toString();
     }
     else
     {
@@ -151,6 +160,7 @@
 
     GridBagConstraints gbc = new GridBagConstraints();
     // Add the server location widgets
+    addBackendTypeSection(panel, gbc);
     addBaseDNSection(panel, gbc);
 
     int h1 = getLabel(FieldName.DATA_OPTIONS).getPreferredSize().height;
@@ -175,14 +185,14 @@
     return panel;
   }
 
-  private void addBaseDNSection(final JPanel panel, final GridBagConstraints gbc)
+  private void addBackendTypeSection(final JPanel panel, final GridBagConstraints gbc)
   {
     gbc.gridwidth = GridBagConstraints.RELATIVE;
     gbc.weightx = 0.0;
     gbc.insets.top = 0;
     gbc.insets.left = 0;
     gbc.anchor = GridBagConstraints.WEST;
-    panel.add(getLabel(FieldName.DIRECTORY_BASE_DN), gbc);
+    panel.add(getLabel(FieldName.BACKEND_TYPE), gbc);
 
     JPanel auxPanel = new JPanel(new GridBagLayout());
     auxPanel.setOpaque(false);
@@ -190,7 +200,7 @@
     gbc.insets = UIFactory.getEmptyInsets();
     gbc.fill = GridBagConstraints.HORIZONTAL;
     gbc.weightx = 0.0;
-    auxPanel.add(getField(FieldName.DIRECTORY_BASE_DN), gbc);
+    auxPanel.add(backendTypeComboBox, gbc);
 
     gbc.gridwidth = GridBagConstraints.REMAINDER;
     gbc.insets.left = UIFactory.LEFT_INSET_BROWSE;
@@ -203,6 +213,35 @@
     gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
     gbc.gridwidth = GridBagConstraints.REMAINDER;
     panel.add(auxPanel, gbc);
+  }
+
+  private void addBaseDNSection(final JPanel panel, final GridBagConstraints gbc)
+  {
+    gbc.gridwidth = GridBagConstraints.RELATIVE;
+    gbc.weightx = 0.0;
+    gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
+    gbc.insets.left = 0;
+    gbc.anchor = GridBagConstraints.WEST;
+    panel.add(getLabel(FieldName.DIRECTORY_BASE_DN), gbc);
+
+    final JPanel auxPanel = new JPanel(new GridBagLayout());
+    auxPanel.setOpaque(false);
+    gbc.weightx = 1.0;
+    gbc.fill = GridBagConstraints.HORIZONTAL;
+    gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
+    gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
+    gbc.gridwidth = GridBagConstraints.REMAINDER;
+    panel.add(auxPanel, gbc);
+
+    gbc.gridwidth = GridBagConstraints.RELATIVE;
+    gbc.insets = UIFactory.getEmptyInsets();
+    gbc.weightx = 0.0;
+    auxPanel.add(getField(FieldName.DIRECTORY_BASE_DN), gbc);
+
+    gbc.gridwidth = GridBagConstraints.REMAINDER;
+    gbc.weightx = 1.0;
+    gbc.fill = GridBagConstraints.HORIZONTAL;
+    auxPanel.add(Box.createHorizontalGlue(), gbc);
 
     gbc.gridwidth = GridBagConstraints.RELATIVE;
     gbc.weightx = 0.0;
@@ -394,10 +433,20 @@
     final JLabel dataLabel = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, INFO_DIRECTORY_DATA_LABEL.get(),
                                                   UIFactory.TextStyle.PRIMARY_FIELD_VALID);
     hmLabels.put(FieldName.DATA_OPTIONS, dataLabel);
+
+    final JLabel backendTypeLabel = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, INFO_BACKEND_TYPE_LABEL.get(),
+                                                         UIFactory.TextStyle.PRIMARY_FIELD_VALID);
+    hmLabels.put(FieldName.BACKEND_TYPE, backendTypeLabel);
     createDirectoryDataChoiceRadioButton(dataLabel);
     checkEnablingState();
   }
 
+  private void createBackendTypeComboBox()
+  {
+    final BackendTypeHelper backendTypeHelper = new BackendTypeHelper();
+    backendTypeComboBox = new JComboBox(new DefaultComboBoxModel(backendTypeHelper.getBackendTypeNames().toArray()));
+  }
+
   private void createDirectoryDataChoiceRadioButton(final JLabel dataLabel)
   {
     final JRadioButton createBaseEntryRB = UIFactory.makeJRadioButton(

--
Gitblit v1.10.0