From fa5ab3d627a0e76dd4d4a70895aa04a2132623e8 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Wed, 15 Jul 2015 09:30:59 +0000
Subject: [PATCH] Code cleanup

---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java |  796 ++++++++++++++++++++++----------------------------------
 1 files changed, 320 insertions(+), 476 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
index 98e5243..d099813 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
@@ -44,6 +44,8 @@
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 
@@ -94,12 +96,19 @@
 import org.opends.server.types.ObjectClass;
 import org.opends.server.types.Schema;
 
-/**
- * The pane that is displayed when the user clicks on 'Browse Schema'.
- */
-public class BrowseSchemaPanel extends StatusGenericPanel
+/** The pane that is displayed when the user clicks on 'Browse Schema'. */
+class BrowseSchemaPanel extends StatusGenericPanel
 {
   private static final long serialVersionUID = -6462914563743569830L;
+
+  private static final LocalizableMessage FILTER_NAME = INFO_CTRL_PANEL_SCHEMA_ELEMENT_NAME.get();
+  private static final LocalizableMessage FILTER_TYPE = INFO_CTRL_PANEL_SCHEMA_ELEMENT_TYPE.get();
+  private static final LocalizableMessage FILTER_PARENT_CLASS = INFO_CTRL_PANEL_PARENT_CLASS.get();
+  private static final LocalizableMessage FILTER_CHILD_CLASS = INFO_CTRL_PANEL_CHILD_CLASS.get();
+  private static final LocalizableMessage FILTER_REQUIRED_ATTRIBUTES = INFO_CTRL_PANEL_REQUIRED_ATTRIBUTES.get();
+  private static final LocalizableMessage FILTER_OPTIONAL_ATTRIBUTES = INFO_CTRL_PANEL_OPTIONAL_ATTRIBUTES.get();
+  private static final LocalizableMessage NO_SCHEMA_ITEM_SELECTED = INFO_CTRL_PANEL_NO_SCHEMA_ITEM_SELECTED.get();
+
   private JComboBox<LocalizableMessage> filterAttribute;
   private FilterTextField filter;
   private JButton applyButton;
@@ -127,114 +136,72 @@
 
   private CommonSchemaElements lastCreatedElement;
 
-  private final LocalizableMessage NAME = INFO_CTRL_PANEL_SCHEMA_ELEMENT_NAME.get();
-  private final LocalizableMessage TYPE = INFO_CTRL_PANEL_SCHEMA_ELEMENT_TYPE.get();
-  private final LocalizableMessage PARENT_CLASS = INFO_CTRL_PANEL_PARENT_CLASS.get();
-  private final LocalizableMessage CHILD_CLASS = INFO_CTRL_PANEL_CHILD_CLASS.get();
-  private final LocalizableMessage REQUIRED_ATTRIBUTES =
-    INFO_CTRL_PANEL_REQUIRED_ATTRIBUTES.get();
-  private final LocalizableMessage OPTIONAL_ATTRIBUTES =
-    INFO_CTRL_PANEL_OPTIONAL_ATTRIBUTES.get();
 
-  private CategoryTreeNode attributes =
-    new CategoryTreeNode(INFO_CTRL_PANEL_ATTRIBUTES_CATEGORY_NODE.get());
-  private CategoryTreeNode objectClasses =
-    new CategoryTreeNode(INFO_CTRL_PANEL_OBJECTCLASSES_CATEGORY_NODE.get());
-  private CategoryTreeNode standardObjectClasses =
-    new CategoryTreeNode(
-        INFO_CTRL_PANEL_STANDARD_OBJECTCLASSES_CATEGORY_NODE.get());
-  private CategoryTreeNode standardAttributes =
-    new CategoryTreeNode(
-        INFO_CTRL_PANEL_STANDARD_ATTRIBUTES_CATEGORY_NODE.get());
-  private CategoryTreeNode configurationObjectClasses =
-    new CategoryTreeNode(
-        INFO_CTRL_PANEL_CONFIGURATION_OBJECTCLASSES_CATEGORY_NODE.get());
-  private CategoryTreeNode configurationAttributes =
-    new CategoryTreeNode(
-        INFO_CTRL_PANEL_CONFIGURATION_ATTRIBUTES_CATEGORY_NODE.get());
-  private CategoryTreeNode customObjectClasses =
-    new CategoryTreeNode(
-        INFO_CTRL_PANEL_CUSTOM_OBJECTCLASSES_CATEGORY_NODE.get());
-  private CategoryTreeNode customAttributes =
-    new CategoryTreeNode(
-        INFO_CTRL_PANEL_CUSTOM_ATTRIBUTES_CATEGORY_NODE.get());
-  private CategoryTreeNode matchingRules =
-    new CategoryTreeNode(INFO_CTRL_PANEL_MATCHING_RULES_CATEGORY_NODE.get());
-  private CategoryTreeNode syntaxes =
-    new CategoryTreeNode(
-        INFO_CTRL_PANEL_ATTRIBUTE_SYNTAXES_CATEGORY_NODE.get());
-
-  private CategoryTreeNode[] underRootNodes =
-  {
-      objectClasses, attributes, matchingRules, syntaxes
-  };
-
-  private CategoryTreeNode[] categoryNodes = {
-      standardObjectClasses, standardAttributes, customObjectClasses,
-      customAttributes, configurationObjectClasses,
-      configurationAttributes, matchingRules, syntaxes
-  };
+  private final CategoryTreeNode attributes = new CategoryTreeNode(INFO_CTRL_PANEL_ATTRIBUTES_CATEGORY_NODE.get());
+  private final CategoryTreeNode objectClasses =
+      new CategoryTreeNode(INFO_CTRL_PANEL_OBJECTCLASSES_CATEGORY_NODE.get());
+  private final CategoryTreeNode standardObjectClasses =
+      new CategoryTreeNode(INFO_CTRL_PANEL_STANDARD_OBJECTCLASSES_CATEGORY_NODE.get());
+  private final CategoryTreeNode standardAttributes =
+      new CategoryTreeNode(INFO_CTRL_PANEL_STANDARD_ATTRIBUTES_CATEGORY_NODE.get());
+  private final CategoryTreeNode configurationObjectClasses =
+      new CategoryTreeNode(INFO_CTRL_PANEL_CONFIGURATION_OBJECTCLASSES_CATEGORY_NODE.get());
+  private final CategoryTreeNode configurationAttributes =
+      new CategoryTreeNode(INFO_CTRL_PANEL_CONFIGURATION_ATTRIBUTES_CATEGORY_NODE.get());
+  private final CategoryTreeNode customObjectClasses =
+      new CategoryTreeNode(INFO_CTRL_PANEL_CUSTOM_OBJECTCLASSES_CATEGORY_NODE.get());
+  private final CategoryTreeNode customAttributes =
+      new CategoryTreeNode(INFO_CTRL_PANEL_CUSTOM_ATTRIBUTES_CATEGORY_NODE.get());
+  private final CategoryTreeNode matchingRules =
+      new CategoryTreeNode(INFO_CTRL_PANEL_MATCHING_RULES_CATEGORY_NODE.get());
+  private final CategoryTreeNode syntaxes =
+      new CategoryTreeNode(INFO_CTRL_PANEL_ATTRIBUTE_SYNTAXES_CATEGORY_NODE.get());
+  private final CategoryTreeNode[] underRootNodes = { objectClasses, attributes, matchingRules, syntaxes };
+  private final CategoryTreeNode[] categoryNodes = { standardObjectClasses, standardAttributes, customObjectClasses,
+    customAttributes, configurationObjectClasses, configurationAttributes, matchingRules, syntaxes };
 
   private JLabel lNoMatchFound;
-
   private boolean ignoreSelectionEvents;
 
-  private LocalizableMessage NO_SCHEMA_ITEM_SELECTED =
-    INFO_CTRL_PANEL_NO_SCHEMA_ITEM_SELECTED.get();
-  private LocalizableMessage CATEGORY_ITEM_SELECTED =
-    INFO_CTRL_PANEL_CATEGORY_ITEM_SELECTED.get();
-  private LocalizableMessage MULTIPLE_ITEMS_SELECTED =
-    INFO_CTRL_PANEL_MULTIPLE_SCHEMA_ITEMS_SELECTED.get();
-
-  /**
-   * Default constructor.
-   *
-   */
   public BrowseSchemaPanel()
   {
-    super();
     createLayout();
   }
 
-  /** {@inheritDoc} */
   @Override
   public boolean requiresBorder()
   {
     return false;
   }
 
-  /** {@inheritDoc} */
   @Override
   public boolean requiresScroll()
   {
     return false;
   }
 
-  /** {@inheritDoc} */
   @Override
   public boolean callConfigurationChangedInBackground()
   {
     return true;
   }
 
-  /** {@inheritDoc} */
   @Override
   public void toBeDisplayed(boolean visible)
   {
     Window w = Utilities.getParentDialog(this);
     if (w instanceof GenericDialog)
     {
-      ((GenericDialog)w).getRootPane().setDefaultButton(null);
+      ((GenericDialog) w).getRootPane().setDefaultButton(null);
     }
     else if (w instanceof GenericFrame)
     {
-      ((GenericFrame)w).getRootPane().setDefaultButton(null);
+      ((GenericFrame) w).getRootPane().setDefaultButton(null);
     }
   }
 
-  /**
-   * Creates the layout of the panel (but the contents are not populated here).
-   */
+  /** Creates the layout of the panel (but the contents are not populated here). */
+  @SuppressWarnings("unchecked")
   private void createLayout()
   {
     setBackground(ColorAndFontConstants.greyBackground);
@@ -247,7 +214,7 @@
     gbc.fill = GridBagConstraints.BOTH;
     addErrorPane(gbc);
 
-    gbc.gridy ++;
+    gbc.gridy++;
     gbc.gridwidth = 1;
     gbc.weightx = 0;
     gbc.fill = GridBagConstraints.NONE;
@@ -255,14 +222,12 @@
     gbc.fill = GridBagConstraints.HORIZONTAL;
     gbc.insets = new Insets(10, 10, 0, 0);
 
-    newObjectClass = Utilities.createButton(
-        INFO_CTRL_PANEL_NEW_OBJECTCLASS_BUTTON.get());
+    newObjectClass = Utilities.createButton(INFO_CTRL_PANEL_NEW_OBJECTCLASS_BUTTON.get());
     newObjectClass.setOpaque(false);
     gbc.weightx = 0.0;
     add(newObjectClass, gbc);
     newObjectClass.addActionListener(new ActionListener()
     {
-      /** {@inheritDoc} */
       @Override
       public void actionPerformed(ActionEvent ev)
       {
@@ -270,16 +235,14 @@
       }
     });
 
-    newAttribute = Utilities.createButton(
-        INFO_CTRL_PANEL_NEW_ATTRIBUTE_BUTTON.get());
+    newAttribute = Utilities.createButton(INFO_CTRL_PANEL_NEW_ATTRIBUTE_BUTTON.get());
     newAttribute.setOpaque(false);
-    gbc.gridx ++;
+    gbc.gridx++;
     gbc.weightx = 0.0;
     gbc.insets.left = 10;
     add(newAttribute, gbc);
     newAttribute.addActionListener(new ActionListener()
     {
-      /** {@inheritDoc} */
       @Override
       public void actionPerformed(ActionEvent ev)
       {
@@ -287,39 +250,37 @@
       }
     });
 
-    gbc.gridx ++;
+    gbc.gridx++;
     JSeparator sep = new JSeparator(SwingConstants.VERTICAL);
     gbc.fill = GridBagConstraints.VERTICAL;
     add(sep, gbc);
 
     lFilter = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_FILTER_LABEL.get());
     gbc.fill = GridBagConstraints.HORIZONTAL;
-    gbc.gridx ++;
+    gbc.gridx++;
     add(lFilter, gbc);
 
     filterAttribute = Utilities.createComboBox();
     filterAttribute.setModel(
         new DefaultComboBoxModel<>(new LocalizableMessage[]{
-            NAME,
-            TYPE,
-            PARENT_CLASS,
-            CHILD_CLASS,
-            REQUIRED_ATTRIBUTES,
-            OPTIONAL_ATTRIBUTES}));
+            FILTER_NAME,
+            FILTER_TYPE,
+            FILTER_PARENT_CLASS,
+            FILTER_CHILD_CLASS,
+            FILTER_REQUIRED_ATTRIBUTES,
+            FILTER_OPTIONAL_ATTRIBUTES}));
     filterAttribute.setRenderer(new CustomListCellRenderer(filterAttribute));
     gbc.insets.left = 5;
-    gbc.gridx ++;
+    gbc.gridx++;
     add(filterAttribute, gbc);
 
     filter = new FilterTextField();
     filter.addKeyListener(new KeyAdapter()
     {
-      /** {@inheritDoc} */
       @Override
       public void keyReleased(KeyEvent e)
       {
-        if (e.getKeyCode() == KeyEvent.VK_ENTER
-            && applyButton.isEnabled())
+        if (e.getKeyCode() == KeyEvent.VK_ENTER && applyButton.isEnabled())
         {
           filter.displayRefreshIcon(FilterTextField.DEFAULT_REFRESH_ICON_TIME);
           repopulateTree(treePane.getTree(), false);
@@ -328,7 +289,6 @@
     });
     filter.addActionListener(new ActionListener()
     {
-      /** {@inheritDoc} */
       @Override
       public void actionPerformed(ActionEvent ev)
       {
@@ -336,20 +296,18 @@
         repopulateTree(treePane.getTree(), false);
       }
     });
-    gbc.gridx ++;
+    gbc.gridx++;
     gbc.weightx = 1.0;
     add(filter, gbc);
 
-    applyButton =
-      Utilities.createButton(INFO_CTRL_PANEL_APPLY_BUTTON_LABEL.get());
+    applyButton = Utilities.createButton(INFO_CTRL_PANEL_APPLY_BUTTON_LABEL.get());
     applyButton.setOpaque(false);
-    gbc.gridx ++;
+    gbc.gridx++;
     gbc.weightx = 0.0;
     gbc.insets.right = 10;
     add(applyButton, gbc);
     applyButton.addActionListener(new ActionListener()
     {
-      /** {@inheritDoc} */
       @Override
       public void actionPerformed(ActionEvent ev)
       {
@@ -360,7 +318,7 @@
 
     gbc.insets = new Insets(10, 0, 0, 0);
     gbc.gridx = 0;
-    gbc.gridy ++;
+    gbc.gridy++;
     gbc.weightx = 1.0;
     gbc.weighty = 1.0;
     gbc.fill = GridBagConstraints.BOTH;
@@ -368,7 +326,7 @@
     add(createSplitPane(), gbc);
 
     // The button panel
-    gbc.gridy ++;
+    gbc.gridy++;
     gbc.weighty = 0.0;
     gbc.insets = new Insets(0, 0, 0, 0);
     add(createButtonsPanel(), gbc);
@@ -388,21 +346,19 @@
     gbc.insets = new Insets(10, 10, 10, 10);
     buttonsPanel.add(lNumberOfElements, gbc);
     gbc.weightx = 1.0;
-    gbc.gridx ++;
+    gbc.gridx++;
     buttonsPanel.add(Box.createHorizontalGlue(), gbc);
     buttonsPanel.setOpaque(true);
     buttonsPanel.setBackground(ColorAndFontConstants.greyBackground);
     gbc.insets.left = 5;
     gbc.insets.right = 10;
-    gbc.gridx ++;
+    gbc.gridx++;
     gbc.weightx = 0.0;
-    JButton closeButton =
-      Utilities.createButton(INFO_CTRL_PANEL_CLOSE_BUTTON_LABEL.get());
+    JButton closeButton = Utilities.createButton(INFO_CTRL_PANEL_CLOSE_BUTTON_LABEL.get());
     closeButton.setOpaque(false);
     buttonsPanel.add(closeButton, gbc);
     closeButton.addActionListener(new ActionListener()
     {
-      /** {@inheritDoc} */
       @Override
       public void actionPerformed(ActionEvent ev)
       {
@@ -410,27 +366,23 @@
       }
     });
 
-    buttonsPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0,
-        ColorAndFontConstants.defaultBorderColor));
+    buttonsPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, ColorAndFontConstants.defaultBorderColor));
 
     return buttonsPanel;
   }
 
-  /** {@inheritDoc} */
   @Override
   public LocalizableMessage getTitle()
   {
     return INFO_CTRL_PANEL_MANAGE_SCHEMA_TITLE.get();
   }
 
-  /** {@inheritDoc} */
   @Override
   public Component getPreferredFocusComponent()
   {
     return filter;
   }
 
-  /** {@inheritDoc} */
   @Override
   public void closeClicked()
   {
@@ -438,14 +390,12 @@
     super.closeClicked();
   }
 
-  /** {@inheritDoc} */
   @Override
   public void okClicked()
   {
     // No ok button
   }
 
-  /** {@inheritDoc} */
   @Override
   public GenericDialog.ButtonType getButtonType()
   {
@@ -456,8 +406,7 @@
   {
     treePane = new TreePanel();
 
-    lNoMatchFound =Utilities.createDefaultLabel(
-        INFO_CTRL_PANEL_NO_MATCHES_FOUND_LABEL.get());
+    lNoMatchFound = Utilities.createDefaultLabel(INFO_CTRL_PANEL_NO_MATCHES_FOUND_LABEL.get());
     lNoMatchFound.setVisible(false);
 
     entryPane = new SchemaBrowserRightPanel();
@@ -478,49 +427,44 @@
     p.add(lNoMatchFound, gbc);
     treeScroll = Utilities.createScrollPane(p);
 
-    entryPane.addSchemaElementSelectionListener(
-        new SchemaElementSelectionListener()
+    entryPane.addSchemaElementSelectionListener(new SchemaElementSelectionListener()
     {
-      /** {@inheritDoc} */
       @Override
       public void schemaElementSelected(SchemaElementSelectionEvent ev)
       {
         Object element = ev.getSchemaElement();
-        DefaultTreeModel model =
-          (DefaultTreeModel)treePane.getTree().getModel();
+        DefaultTreeModel model = (DefaultTreeModel) treePane.getTree().getModel();
         Object root = model.getRoot();
         selectElementUnder(root, element, model);
       }
     });
-    entryPane.addConfigurationElementCreatedListener(
-        new ConfigurationElementCreatedListener()
-        {
-          @Override
-          public void elementCreated(ConfigurationElementCreatedEvent ev)
-          {
-            configurationElementCreated(ev);
-          }
-        });
+    entryPane.addConfigurationElementCreatedListener(new ConfigurationElementCreatedListener()
+    {
+      @Override
+      public void elementCreated(ConfigurationElementCreatedEvent ev)
+      {
+        configurationElementCreated(ev);
+      }
+    });
 
     treePane.getTree().addTreeSelectionListener(new TreeSelectionListener()
     {
-      /** {@inheritDoc} */
       @Override
       public void valueChanged(TreeSelectionEvent ev)
       {
         if (!ignoreSelectionEvents)
         {
           ignoreSelectionEvents = true;
-          TreePath[] paths = treePane.getTree().getSelectionPaths();
+          final JTree tree = treePane.getTree();
+          TreePath[] paths = tree.getSelectionPaths();
 
           if (entryPane.mustCheckUnsavedChanges())
           {
             ignoreSelectionEvents = true;
-            treePane.getTree().setSelectionPath(lastEntryTreePath);
+            tree.setSelectionPath(lastEntryTreePath);
             switch (entryPane.checkUnsavedChanges())
             {
             case DO_NOT_SAVE:
-              break;
             case SAVE:
               break;
             case CANCEL:
@@ -529,11 +473,11 @@
             }
             if (paths != null)
             {
-              treePane.getTree().setSelectionPaths(paths);
+              tree.setSelectionPaths(paths);
             }
             else
             {
-              treePane.getTree().clearSelection();
+              tree.clearSelection();
             }
           }
 
@@ -548,8 +492,7 @@
               {
                 nonDeletableElementsSelected = true;
               }
-              else if (node instanceof CustomObjectClassTreeNode
-                  || node instanceof CustomAttributeTreeNode)
+              else if (node instanceof CustomObjectClassTreeNode || node instanceof CustomAttributeTreeNode)
               {
                 deletableElementsSelected = true;
               }
@@ -559,8 +502,7 @@
               }
             }
           }
-          deleteMenuItem.setEnabled(deletableElementsSelected &&
-              !nonDeletableElementsSelected);
+          deleteMenuItem.setEnabled(deletableElementsSelected && !nonDeletableElementsSelected);
           updateEntryPane();
           ignoreSelectionEvents = false;
         }
@@ -579,14 +521,12 @@
     tree.expandPath(new TreePath(root));
     tree.setCellRenderer(new SchemaTreeCellRenderer());
     addPopupMenu();
-    treeScroll.setPreferredSize(
-        new Dimension((3 * treeScroll.getPreferredSize().width) / 2,
-            5 * treeScroll.getPreferredSize().height));
+    treeScroll.setPreferredSize(new Dimension(
+        (3 * treeScroll.getPreferredSize().width) / 2, 5 * treeScroll.getPreferredSize().height));
     entryPane.displayMessage(NO_SCHEMA_ITEM_SELECTED);
     entryPane.setBorder(getRightPanelBorder());
-    entryPane.setPreferredSize(
-        new Dimension(treeScroll.getPreferredSize().width,
-        treeScroll.getPreferredSize().height));
+    entryPane.setPreferredSize(new Dimension(
+        treeScroll.getPreferredSize().width, treeScroll.getPreferredSize().height));
     JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
     pane.setOpaque(true); //content panes must be opaque
     pane.setLeftComponent(treeScroll);
@@ -596,7 +536,6 @@
     return pane;
   }
 
-  /** {@inheritDoc} */
   @Override
   public void setInfo(ControlPanelInfo info)
   {
@@ -605,7 +544,6 @@
     entryPane.setInfo(info);
   }
 
-  /** {@inheritDoc} */
   @Override
   public void configurationChanged(ConfigurationChangeEvent ev)
   {
@@ -643,11 +581,8 @@
     }
     else if (lastSchema == null)
     {
-      updateErrorPane(errorPane,
-          ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_SUMMARY.get(),
-          ColorAndFontConstants.errorTitleFont,
-          ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_DETAILS.get(),
-          ColorAndFontConstants.defaultFont);
+      updateErrorPane(errorPane, ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_SUMMARY.get(), ColorAndFontConstants.errorTitleFont,
+          ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_DETAILS.get(), ColorAndFontConstants.defaultFont);
       if (!errorPane.isVisible())
       {
         errorPane.setVisible(true);
@@ -657,23 +592,26 @@
 
   /**
    * Selects the node in the tree that corresponds to a given schema element.
-   * @param root the node we must start searching for the node to be selected.
-   * @param element the schema element.
-   * @param model the tree model.
+   *
+   * @param root
+   *          the node we must start searching for the node to be selected.
+   * @param element
+   *          the schema element.
+   * @param model
+   *          the tree model.
    * @return <CODE>true</CODE> if the node was found and selected and
-   * <CODE>false</CODE> otherwise.
+   *         <CODE>false</CODE> otherwise.
    */
-  private boolean selectElementUnder(Object root, Object element,
-      DefaultTreeModel model)
+  private boolean selectElementUnder(Object root, Object element, DefaultTreeModel model)
   {
     int n = model.getChildCount(root);
     boolean found = false;
-    for (int i=0; i<n && !found; i++)
+    for (int i = 0; i < n && !found; i++)
     {
       Object node = model.getChild(root, i);
       if (node instanceof SchemaElementTreeNode)
       {
-        SchemaElementTreeNode schemaNode = (SchemaElementTreeNode)node;
+        SchemaElementTreeNode schemaNode = (SchemaElementTreeNode) node;
         if (schemaNode.getSchemaElement().equals(element))
         {
           found = true;
@@ -692,8 +630,11 @@
 
   /**
    * Repopulates the tree.
-   * @param tree the tree to be repopulated.
-   * @param forceScroll whether the scroll must be reset or not.
+   *
+   * @param tree
+   *          the tree to be repopulated.
+   * @param forceScroll
+   *          whether the scroll must be reset or not.
    */
   private void repopulateTree(JTree tree, final boolean forceScroll)
   {
@@ -704,25 +645,22 @@
     ignoreSelectionEvents = true;
 
     final Point currentPosition = treeScroll.getViewport().getViewPosition();
-
     DefaultMutableTreeNode root = getRoot(tree);
-
     TreePath path = tree.getSelectionPath();
     DefaultMutableTreeNode lastSelectedNode = null;
     if (path != null)
     {
-      lastSelectedNode = (DefaultMutableTreeNode)path.getLastPathComponent();
+      lastSelectedNode = (DefaultMutableTreeNode) path.getLastPathComponent();
     }
     TreePath newSelectionPath = null;
 
     Comparator<String> lowerCaseComparator = new LowerCaseComparator();
-
-    TreeSet<String> standardOcNames = new TreeSet<>(lowerCaseComparator);
-    HashMap<String, StandardObjectClassTreeNode> hmStandardOcs = new HashMap<>();
-    TreeSet<String> configurationOcNames = new TreeSet<>(lowerCaseComparator);
-    HashMap<String, ConfigurationObjectClassTreeNode> hmConfigurationOcs = new HashMap<>();
-    TreeSet<String> customOcNames = new TreeSet<>(lowerCaseComparator);
-    HashMap<String, CustomObjectClassTreeNode> hmCustomOcs = new HashMap<>();
+    Set<String> standardOcNames = new TreeSet<>(lowerCaseComparator);
+    Map<String, StandardObjectClassTreeNode> hmStandardOcs = new HashMap<>();
+    Set<String> configurationOcNames = new TreeSet<>(lowerCaseComparator);
+    Map<String, ConfigurationObjectClassTreeNode> hmConfigurationOcs = new HashMap<>();
+    Set<String> customOcNames = new TreeSet<>(lowerCaseComparator);
+    Map<String, CustomObjectClassTreeNode> hmCustomOcs = new HashMap<>();
     for (ObjectClass oc : lastSchema.getObjectClasses().values())
     {
       if (mustAdd(oc))
@@ -736,8 +674,7 @@
         else if (Utilities.isConfiguration(oc))
         {
           configurationOcNames.add(name);
-          hmConfigurationOcs.put(name,
-              new ConfigurationObjectClassTreeNode(name, oc));
+          hmConfigurationOcs.put(name, new ConfigurationObjectClassTreeNode(name, oc));
         }
         else
         {
@@ -747,13 +684,12 @@
       }
     }
 
-
-    TreeSet<String> standardAttrNames = new TreeSet<>(lowerCaseComparator);
-    HashMap<String, StandardAttributeTreeNode> hmStandardAttrs = new HashMap<>();
-    TreeSet<String> configurationAttrNames = new TreeSet<>(lowerCaseComparator);
-    HashMap<String, ConfigurationAttributeTreeNode> hmConfigurationAttrs = new HashMap<>();
-    TreeSet<String> customAttrNames = new TreeSet<>(lowerCaseComparator);
-    HashMap<String, CustomAttributeTreeNode> hmCustomAttrs = new HashMap<>();
+    Set<String> standardAttrNames = new TreeSet<>(lowerCaseComparator);
+    Map<String, StandardAttributeTreeNode> hmStandardAttrs = new HashMap<>();
+    Set<String> configurationAttrNames = new TreeSet<>(lowerCaseComparator);
+    Map<String, ConfigurationAttributeTreeNode> hmConfigurationAttrs = new HashMap<>();
+    Set<String> customAttrNames = new TreeSet<>(lowerCaseComparator);
+    Map<String, CustomAttributeTreeNode> hmCustomAttrs = new HashMap<>();
     for (AttributeType attr : lastSchema.getAttributeTypes().values())
     {
       if (mustAdd(attr))
@@ -761,14 +697,13 @@
         String name = attr.getPrimaryName();
         if (Utilities.isStandard(attr))
         {
-         standardAttrNames.add(name);
-         hmStandardAttrs.put(name, new StandardAttributeTreeNode(name, attr));
+          standardAttrNames.add(name);
+          hmStandardAttrs.put(name, new StandardAttributeTreeNode(name, attr));
         }
         else if (Utilities.isConfiguration(attr))
         {
           configurationAttrNames.add(name);
-          hmConfigurationAttrs.put(name,
-              new ConfigurationAttributeTreeNode(name, attr));
+          hmConfigurationAttrs.put(name, new ConfigurationAttributeTreeNode(name, attr));
         }
         else
         {
@@ -778,8 +713,8 @@
       }
     }
 
-    TreeSet<String> matchingRuleNames = new TreeSet<>(lowerCaseComparator);
-    HashMap<String, MatchingRuleTreeNode> hmMatchingRules = new HashMap<>();
+    Set<String> matchingRuleNames = new TreeSet<>(lowerCaseComparator);
+    Map<String, MatchingRuleTreeNode> hmMatchingRules = new HashMap<>();
     for (MatchingRule matchingRule : lastSchema.getMatchingRules().values())
     {
       if (mustAdd(matchingRule))
@@ -790,8 +725,8 @@
       }
     }
 
-    TreeSet<String> syntaxNames = new TreeSet<>(lowerCaseComparator);
-    HashMap<String, AttributeSyntaxTreeNode> hmSyntaxes = new HashMap<>();
+    Set<String> syntaxNames = new TreeSet<>(lowerCaseComparator);
+    Map<String, AttributeSyntaxTreeNode> hmSyntaxes = new HashMap<>();
     for (Syntax syntax : lastSchema.getSyntaxes().values())
     {
       if (mustAdd(syntax))
@@ -806,8 +741,7 @@
       }
     }
 
-
-    ArrayList<TreeSet<String>> names = new ArrayList<>();
+    List<Set<String>> names = new ArrayList<>();
     names.add(standardOcNames);
     names.add(standardAttrNames);
     names.add(customOcNames);
@@ -817,7 +751,7 @@
     names.add(matchingRuleNames);
     names.add(syntaxNames);
 
-    ArrayList<HashMap<String, ? extends DefaultMutableTreeNode>> nodes = new ArrayList<>();
+    List<Map<String, ? extends DefaultMutableTreeNode>> nodes = new ArrayList<>();
     nodes.add(hmStandardOcs);
     nodes.add(hmStandardAttrs);
     nodes.add(hmCustomOcs);
@@ -827,8 +761,7 @@
     nodes.add(hmMatchingRules);
     nodes.add(hmSyntaxes);
 
-    DefaultTreeModel model = (DefaultTreeModel)tree.getModel();
-
+    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
     String f = filter.getText().trim();
     boolean filterProvided = f.length() > 0;
 
@@ -850,7 +783,7 @@
     {
       toExpand.add(new TreePath(objectClasses.getPath()));
     }
-    positionUnderRoot ++;
+    positionUnderRoot++;
 
     expand = filterProvided;
     if (root.getIndex(attributes) == -1)
@@ -865,7 +798,7 @@
     {
       toExpand.add(new TreePath(attributes.getPath()));
     }
-    positionUnderRoot ++;
+    positionUnderRoot++;
     int positionUnderAttributes = 0;
     int positionUnderObjectClass = 0;
 
@@ -882,25 +815,20 @@
       else
       {
         expand = false;
-        if (parent == standardObjectClasses
-            || parent == customObjectClasses
-            || parent == configurationObjectClasses)
+        if (parent == standardObjectClasses || parent == customObjectClasses || parent == configurationObjectClasses)
         {
           if (objectClasses.getIndex(parent) == -1)
           {
-            model.insertNodeInto(parent, objectClasses,
-                positionUnderObjectClass);
+            model.insertNodeInto(parent, objectClasses, positionUnderObjectClass);
           }
           else
           {
             expand = tree.isExpanded(new TreePath(parent.getPath()));
             parent.removeAllChildren();
           }
-          positionUnderObjectClass ++;
+          positionUnderObjectClass++;
         }
-        else if (parent == standardAttributes
-            || parent == customAttributes
-            || parent == configurationAttributes)
+        else if (parent == standardAttributes || parent == customAttributes || parent == configurationAttributes)
         {
           if (attributes.getIndex(parent) == -1)
           {
@@ -911,7 +839,7 @@
             expand = tree.isExpanded(new TreePath(parent.getPath()));
             parent.removeAllChildren();
           }
-          positionUnderAttributes ++;
+          positionUnderAttributes++;
         }
         else
         {
@@ -924,20 +852,18 @@
             expand = tree.isExpanded(new TreePath(parent.getPath()));
             parent.removeAllChildren();
           }
-          positionUnderRoot ++;
+          positionUnderRoot++;
         }
 
         for (String name : names.get(i))
         {
           DefaultMutableTreeNode node = nodes.get(i).get(name);
           parent.add(node);
-          if (newSelectionPath == null
-              && (lastSelectedNode != null || lastCreatedElement != null))
+          if (newSelectionPath == null && (lastSelectedNode != null || lastCreatedElement != null))
           {
             if (lastCreatedElement != null)
             {
-              if (node instanceof CustomObjectClassTreeNode
-                  && lastCreatedElement instanceof ObjectClass)
+              if (node instanceof CustomObjectClassTreeNode && lastCreatedElement instanceof ObjectClass)
               {
                 if (name.equals(lastCreatedElement.getNameOrOID()))
                 {
@@ -945,8 +871,7 @@
                   lastCreatedElement = null;
                 }
               }
-              else if (node instanceof CustomAttributeTreeNode
-                  && lastCreatedElement instanceof AttributeType
+              else if (node instanceof CustomAttributeTreeNode && lastCreatedElement instanceof AttributeType
                   && name.equals(lastCreatedElement.getNameOrOID()))
               {
                 newSelectionPath = new TreePath(node.getPath());
@@ -968,7 +893,7 @@
       i++;
     }
 
-    DefaultMutableTreeNode[] ocAndAttrs = {objectClasses, attributes};
+    DefaultMutableTreeNode[] ocAndAttrs = { objectClasses, attributes };
     for (DefaultMutableTreeNode node : ocAndAttrs)
     {
       if (node.getParent() != null && node.getChildCount() == 0)
@@ -994,15 +919,14 @@
     }
     updateEntryPane();
     ignoreSelectionEvents = false;
-    int nElements = hmStandardOcs.size() + hmConfigurationOcs.size() +
-    hmCustomOcs.size() + hmStandardAttrs.size() + hmConfigurationAttrs.size() +
-    hmCustomAttrs.size() + hmMatchingRules.size() + hmSyntaxes.size();
+    int nElements =
+        hmStandardOcs.size() + hmConfigurationOcs.size() + hmCustomOcs.size() + hmStandardAttrs.size()
+            + hmConfigurationAttrs.size() + hmCustomAttrs.size() + hmMatchingRules.size() + hmSyntaxes.size();
     lNoMatchFound.setVisible(nElements == 0);
     treePane.setVisible(nElements > 0);
     if (nElements > 0)
     {
-      lNumberOfElements.setText(
-          INFO_CTRL_PANEL_SCHEMA_ELEMENT_NUMBER.get(nElements).toString());
+      lNumberOfElements.setText(INFO_CTRL_PANEL_SCHEMA_ELEMENT_NUMBER.get(nElements).toString());
       lNumberOfElements.setVisible(true);
     }
     else
@@ -1011,7 +935,7 @@
     }
     if (newSelectionPath == null && f.length() > 0)
     {
-      for (i=0; i<tree.getRowCount(); i++)
+      for (i = 0; i < tree.getRowCount(); i++)
       {
         newSelectionPath = tree.getPathForRow(i);
         Object node = newSelectionPath.getLastPathComponent();
@@ -1029,22 +953,12 @@
       @Override
       public void run()
       {
-        if (forceScroll)
-        {
-          treeScroll.getViewport().setViewPosition(new Point(0, 0));
-        }
-        else
-        {
-          treeScroll.getViewport().setViewPosition(currentPosition);
-        }
+        treeScroll.getViewport().setViewPosition(forceScroll ? new Point(0, 0) : currentPosition);
       }
     });
   }
 
-  /**
-   * Updates the right entry panel.
-   *
-   */
+  /** Updates the right entry panel. */
   private void updateEntryPane()
   {
     ViewPositions pos = Utilities.getViewPositions(entryPane);
@@ -1061,84 +975,74 @@
       if (node instanceof StandardObjectClassTreeNode)
       {
         entryPane.updateStandardObjectClass(
-            ((StandardObjectClassTreeNode)node).getObjectClass(), lastSchema);
+            ((StandardObjectClassTreeNode) node).getObjectClass(), lastSchema);
       }
       else if (node instanceof ConfigurationObjectClassTreeNode)
       {
         entryPane.updateConfigurationObjectClass(
-            ((ConfigurationObjectClassTreeNode)node).getObjectClass(),
-            lastSchema);
+            ((ConfigurationObjectClassTreeNode) node).getObjectClass(), lastSchema);
       }
       else if (node instanceof CustomObjectClassTreeNode)
       {
-        ObjectClass oc = ((CustomObjectClassTreeNode)node).getObjectClass();
-        entryPane.updateCustomObjectClass(oc, lastSchema);
+        entryPane.updateCustomObjectClass(((CustomObjectClassTreeNode) node).getObjectClass(), lastSchema);
       }
       else if (node instanceof StandardAttributeTreeNode)
       {
-        entryPane.updateStandardAttribute(
-            ((StandardAttributeTreeNode)node).getAttribute(), lastSchema);
+        entryPane.updateStandardAttribute(((StandardAttributeTreeNode) node).getAttribute(), lastSchema);
       }
       else if (node instanceof ConfigurationAttributeTreeNode)
       {
-        entryPane.updateConfigurationAttribute(
-            ((ConfigurationAttributeTreeNode)node).getAttribute(), lastSchema);
+        entryPane.updateConfigurationAttribute(((ConfigurationAttributeTreeNode) node).getAttribute(), lastSchema);
       }
       else if (node instanceof CustomAttributeTreeNode)
       {
-        AttributeType attr = ((CustomAttributeTreeNode)node).getAttribute();
-        entryPane.updateCustomAttribute(attr, lastSchema);
+        entryPane.updateCustomAttribute(((CustomAttributeTreeNode) node).getAttribute(), lastSchema);
       }
       else if (node instanceof MatchingRuleTreeNode)
       {
-        entryPane.updateMatchingRule(
-            ((MatchingRuleTreeNode)node).getMatchingRule(), lastSchema);
+        entryPane.updateMatchingRule(((MatchingRuleTreeNode) node).getMatchingRule(), lastSchema);
       }
       else if (node instanceof AttributeSyntaxTreeNode)
       {
-        entryPane.updateAttributeSyntax(
-            ((AttributeSyntaxTreeNode)node).getAttributeSyntax(), lastSchema);
+        entryPane.updateAttributeSyntax(((AttributeSyntaxTreeNode) node).getAttributeSyntax(), lastSchema);
       }
       else
       {
         entryPane.displayMessage(NO_SCHEMA_ITEM_SELECTED);
       }
     }
-    else
+    else if (paths != null && paths.length > 1)
     {
-      if ((paths != null) && (paths.length > 1))
+      boolean categorySelected = false;
+      int nNonCategory = 0;
+      for (TreePath p : paths)
       {
-        boolean categorySelected = false;
-        int nNonCategory = 0;
-        for (TreePath p : paths)
+        Object node = p.getLastPathComponent();
+        if (node instanceof CategoryTreeNode)
         {
-          Object node = p.getLastPathComponent();
-          if (node instanceof CategoryTreeNode)
-          {
-            categorySelected = true;
-          }
-          else
-          {
-            nNonCategory ++;
-          }
-        }
-        if (nNonCategory == 0)
-        {
-          entryPane.displayMessage(NO_SCHEMA_ITEM_SELECTED);
-        }
-        else if (categorySelected)
-        {
-          entryPane.displayMessage(CATEGORY_ITEM_SELECTED);
+          categorySelected = true;
         }
         else
         {
-          entryPane.displayMessage(MULTIPLE_ITEMS_SELECTED);
+          nNonCategory++;
         }
       }
-      else
+      if (nNonCategory == 0)
       {
         entryPane.displayMessage(NO_SCHEMA_ITEM_SELECTED);
       }
+      else if (categorySelected)
+      {
+        entryPane.displayMessage(INFO_CTRL_PANEL_CATEGORY_ITEM_SELECTED.get());
+      }
+      else
+      {
+        entryPane.displayMessage(INFO_CTRL_PANEL_MULTIPLE_SCHEMA_ITEMS_SELECTED.get());
+      }
+    }
+    else
+    {
+      entryPane.displayMessage(NO_SCHEMA_ITEM_SELECTED);
     }
     Utilities.updateViewPositions(pos);
   }
@@ -1147,11 +1051,9 @@
   private void addPopupMenu()
   {
     popup = new JPopupMenu();
-    JMenuItem menuItem = Utilities.createMenuItem(
-        INFO_CTRL_PANEL_NEW_OBJECTCLASS_MENU.get());
+    JMenuItem menuItem = Utilities.createMenuItem(INFO_CTRL_PANEL_NEW_OBJECTCLASS_MENU.get());
     menuItem.addActionListener(new ActionListener()
     {
-      /** {@inheritDoc} */
       @Override
       public void actionPerformed(ActionEvent ev)
       {
@@ -1159,11 +1061,9 @@
       }
     });
     popup.add(menuItem);
-    menuItem = Utilities.createMenuItem(
-        INFO_CTRL_PANEL_NEW_ATTRIBUTE_MENU.get());
+    menuItem = Utilities.createMenuItem(INFO_CTRL_PANEL_NEW_ATTRIBUTE_MENU.get());
     menuItem.addActionListener(new ActionListener()
     {
-      /** {@inheritDoc} */
       @Override
       public void actionPerformed(ActionEvent ev)
       {
@@ -1172,11 +1072,9 @@
     });
     popup.add(menuItem);
     popup.add(new JSeparator());
-    deleteMenuItem = Utilities.createMenuItem(
-        INFO_CTRL_PANEL_DELETE_SCHEMA_ELEMENT_MENU.get());
+    deleteMenuItem = Utilities.createMenuItem(INFO_CTRL_PANEL_DELETE_SCHEMA_ELEMENT_MENU.get());
     deleteMenuItem.addActionListener(new ActionListener()
     {
-      /** {@inheritDoc} */
       @Override
       public void actionPerformed(ActionEvent ev)
       {
@@ -1185,18 +1083,16 @@
     });
     popup.add(deleteMenuItem);
     deleteMenuItem.setEnabled(false);
-
     popup.setOpaque(true);
-
-    ((CustomTree)treePane.getTree()).setPopupMenu(popup);
+    ((CustomTree) treePane.getTree()).setPopupMenu(popup);
   }
 
   private void deleteClicked()
   {
-    ArrayList<LocalizableMessage> errors = new ArrayList<>();
+    List<LocalizableMessage> errors = new ArrayList<>();
     TreePath[] paths = treePane.getTree().getSelectionPaths();
-    ArrayList<ObjectClass> ocsToDelete = new ArrayList<>();
-    ArrayList<AttributeType> attrsToDelete = new ArrayList<>();
+    List<ObjectClass> ocsToDelete = new ArrayList<>();
+    List<AttributeType> attrsToDelete = new ArrayList<>();
     if (paths != null)
     {
       for (TreePath path : paths)
@@ -1204,11 +1100,11 @@
         Object node = path.getLastPathComponent();
         if (node instanceof CustomObjectClassTreeNode)
         {
-          ocsToDelete.add(((CustomObjectClassTreeNode)node).getObjectClass());
+          ocsToDelete.add(((CustomObjectClassTreeNode) node).getObjectClass());
         }
         else if (node instanceof CustomAttributeTreeNode)
         {
-          attrsToDelete.add(((CustomAttributeTreeNode)node).getAttribute());
+          attrsToDelete.add(((CustomAttributeTreeNode) node).getAttribute());
         }
       }
     }
@@ -1220,13 +1116,9 @@
     }
     if (errors.isEmpty())
     {
-      LocalizableMessage confirmationMessage =
-        getConfirmationMessage(ocsToDelete, attrsToDelete, schema);
-
-      LinkedHashSet<AttributeType> orderedAttributes =
-        getOrderedAttributesToDelete(attrsToDelete);
-      LinkedHashSet<ObjectClass> orderedObjectClasses =
-        getOrderedObjectClassesToDelete(ocsToDelete);
+      LocalizableMessage confirmationMessage = getConfirmationMessage(ocsToDelete, attrsToDelete, schema);
+      Set<AttributeType> orderedAttributes = getOrderedAttributesToDelete(attrsToDelete);
+      Set<ObjectClass> orderedObjectClasses = getOrderedObjectClassesToDelete(ocsToDelete);
 
       LocalizableMessage title;
       if (orderedAttributes.isEmpty())
@@ -1241,32 +1133,25 @@
       {
         title = INFO_CTRL_PANEL_DELETE_OBJECTCLASSES_AND_ATTRIBUTES_TITLE.get();
       }
-      ProgressDialog dlg = new ProgressDialog(
-          Utilities.createFrame(),
-          Utilities.getParentDialog(this), title, getInfo());
+      ProgressDialog dlg =
+          new ProgressDialog(Utilities.createFrame(), Utilities.getParentDialog(this), title, getInfo());
       DeleteSchemaElementsTask newTask =
-        new DeleteSchemaElementsTask(getInfo(), dlg, orderedObjectClasses,
-            orderedAttributes);
+          new DeleteSchemaElementsTask(getInfo(), dlg, orderedObjectClasses, orderedAttributes);
       for (Task task : getInfo().getTasks())
       {
         task.canLaunch(newTask, errors);
       }
       if (errors.isEmpty())
       {
-        ArrayList<String> allNames = new ArrayList<>();
-        if (displayConfirmationDialog(
-            INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(),
-            confirmationMessage))
+        List<String> allNames = new ArrayList<>();
+        if (displayConfirmationDialog(INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(), confirmationMessage))
         {
-          launchOperation(newTask,
-              INFO_CTRL_PANEL_DELETING_SCHEMA_ELEMENTS_SUMMARY.get(),
+          launchOperation(newTask, INFO_CTRL_PANEL_DELETING_SCHEMA_ELEMENTS_SUMMARY.get(),
               INFO_CTRL_PANEL_DELETING_SCHEMA_ELEMENTS_COMPLETE.get(),
-              INFO_CTRL_PANEL_DELETING_SCHEMA_ELEMENTS_SUCCESSFUL.get(
-                  Utilities.getStringFromCollection(allNames, ", ")),
+              INFO_CTRL_PANEL_DELETING_SCHEMA_ELEMENTS_SUCCESSFUL
+                  .get(Utilities.getStringFromCollection(allNames, ", ")),
               ERR_CTRL_PANEL_DELETING_SCHEMA_ELEMENTS_ERROR_SUMMARY.get(),
-              ERR_CTRL_PANEL_DELETING_SCHEMA_ELEMENTS_ERROR_DETAILS.get(),
-              null,
-              dlg);
+              ERR_CTRL_PANEL_DELETING_SCHEMA_ELEMENTS_ERROR_DETAILS.get(), null, dlg);
           dlg.setVisible(true);
         }
       }
@@ -1289,7 +1174,7 @@
 
   private boolean mustAdd(String name, String oid, String primaryName, Iterable<String> names)
   {
-    ArrayList<String> values = new ArrayList<>();
+    List<String> values = new ArrayList<>();
     values.add(oid);
     if (primaryName != null)
     {
@@ -1305,21 +1190,24 @@
 
   /**
    * Check whether the provided attribute must be added or not.
-   * @param attr the attribute.
+   *
+   * @param attr
+   *          the attribute.
    * @return <CODE>true</CODE> if the attribute must be added and
-   * <CODE>false</CODE> otherwise.
+   *         <CODE>false</CODE> otherwise.
    */
   private boolean mustAdd(AttributeType attr)
   {
     String f = filter.getText().trim();
-    if (f.length () > 0)
+    if (f.length() > 0)
     {
       Object filterType = filterAttribute.getSelectedItem();
-      if (NAME.equals(filterType))
+
+      if (FILTER_NAME.equals(filterType))
       {
         return mustAddAttributeName(attr, f);
       }
-      else if (TYPE.equals(filterType))
+      else if (FILTER_TYPE.equals(filterType))
       {
         return mustAddType(f, StandardAttributePanel.getTypeValue(attr));
       }
@@ -1352,44 +1240,42 @@
 
   /**
    * Check whether the provided object class must be added or not.
-   * @param oc the objectclass.
+   *
+   * @param oc
+   *          the objectclass.
    * @return <CODE>true</CODE> if the objectclass must be added and
-   * <CODE>false</CODE> otherwise.
+   *         <CODE>false</CODE> otherwise.
    */
   private boolean mustAdd(ObjectClass oc)
   {
-    String f = filter.getText().trim();
-    if (f.length () > 0)
+    final String filterText = filter.getText().trim();
+    if (filterText.isEmpty())
     {
-      Object filterType = filterAttribute.getSelectedItem();
-
-      if (NAME.equals(filterType))
-      {
-        return mustAddObjectClassName(oc, f);
-      }
-      else if (TYPE.equals(filterType))
-      {
-        return mustAddType(f, StandardObjectClassPanel.getTypeValue(oc));
-      }
-      else if (REQUIRED_ATTRIBUTES.equals(filterType) ||
-          OPTIONAL_ATTRIBUTES.equals(filterType))
-      {
-        return mustAddAttributeName(oc, f, filterType);
-      }
-      else if (CHILD_CLASS.equals(filterType))
-      {
-        return mustAddAnyObjectClassName(oc, f);
-      }
-      else if (PARENT_CLASS.equals(filterType))
-      {
-        return mustAddParentObjectClassName(oc, f);
-      }
-      else
-      {
-        return false;
-      }
+      return true;
     }
-    return true;
+
+    final Object filterType = filterAttribute.getSelectedItem();
+    if (FILTER_NAME.equals(filterType))
+    {
+      return mustAddObjectClassName(oc, filterText);
+    }
+    else if (FILTER_TYPE.equals(filterType))
+    {
+      return mustAddType(filterText, StandardObjectClassPanel.getTypeValue(oc));
+    }
+    else if (FILTER_REQUIRED_ATTRIBUTES.equals(filterType) || FILTER_OPTIONAL_ATTRIBUTES.equals(filterType))
+    {
+      return mustAddAttributeName(oc, filterText, filterType);
+    }
+    else if (FILTER_CHILD_CLASS.equals(filterType))
+    {
+      return mustAddAnyObjectClassName(oc, filterText);
+    }
+    else if (FILTER_PARENT_CLASS.equals(filterType))
+    {
+      return mustAddParentObjectClassName(oc, filterText);
+    }
+    return false;
   }
 
   private boolean mustAddAnyObjectClassName(ObjectClass oc, String f)
@@ -1406,15 +1292,8 @@
 
   private boolean mustAddAttributeName(ObjectClass oc, String f, Object filterType)
   {
-    Set<AttributeType> definedAttrs;
-    if (REQUIRED_ATTRIBUTES.equals(filterType))
-    {
-      definedAttrs = oc.getRequiredAttributeChain();
-    }
-    else
-    {
-      definedAttrs = oc.getOptionalAttributeChain();
-    }
+    Set<AttributeType> definedAttrs = FILTER_REQUIRED_ATTRIBUTES.equals(filterType) ? oc.getRequiredAttributeChain()
+                                                                                    : oc.getOptionalAttributeChain();
     return mustAddAttributeName(f, definedAttrs);
   }
 
@@ -1445,8 +1324,7 @@
   {
     for (ObjectClass parent : oc.getSuperiorClasses())
     {
-      if (mustAddObjectClassName(parent, f) ||
-          mustAddParentObjectClassName(parent, f))
+      if (mustAddObjectClassName(parent, f) || mustAddParentObjectClassName(parent, f))
       {
         return true;
       }
@@ -1457,10 +1335,13 @@
   /**
    * Finds out if a class is descendant of another class using equality of
    * pointers.
-   * @param ocParent the parent object class.
-   * @param oChild the (potentially) descendant object class.
-   * @return {@code true} if the class is a descendant of the parent class
-   * and {@code false} otherwise.
+   *
+   * @param ocParent
+   *          the parent object class.
+   * @param oChild
+   *          the (potentially) descendant object class.
+   * @return {@code true} if the class is a descendant of the parent class and
+   *         {@code false} otherwise.
    */
   private boolean isDescendant(ObjectClass ocParent, ObjectClass oChild)
   {
@@ -1480,47 +1361,37 @@
 
   /**
    * Check whether the provided matching rule must be added or not.
-   * @param matchingRule the matching rule.
+   *
+   * @param matchingRule
+   *          the matching rule.
    * @return <CODE>true</CODE> if the matching rule must be added and
-   * <CODE>false</CODE> otherwise.
+   *         <CODE>false</CODE> otherwise.
    */
   private boolean mustAdd(MatchingRule matchingRule)
   {
     String f = filter.getText().trim();
-    if (f.length () > 0)
-    {
-      if (NAME.equals(filterAttribute.getSelectedItem()))
-      {
-        return mustAdd(f, matchingRule.getOID(), matchingRule.getNameOrOID());
-      }
-      return false;
-    }
-    return true;
+    return f.length () <= 0 || (FILTER_NAME.equals(filterAttribute.getSelectedItem())
+                                 && mustAdd(f, matchingRule.getOID(), matchingRule.getNameOrOID()));
   }
 
   /**
    * Check whether the provided attribute syntax must be added or not.
-   * @param syntax the attribute syntax.
+   *
+   * @param syntax
+   *          the attribute syntax.
    * @return <CODE>true</CODE> if the attribute syntax must be added and
-   * <CODE>false</CODE> otherwise.
+   *         <CODE>false</CODE> otherwise.
    */
   private boolean mustAdd(Syntax syntax)
   {
     String f = filter.getText().trim();
-    if (f.length () > 0)
-    {
-      if (NAME.equals(filterAttribute.getSelectedItem()))
-      {
-        return mustAdd(f, syntax.getOID(), syntax.getName());
-      }
-      return false;
-    }
-    return true;
+    return f.length() <= 0
+        || (FILTER_NAME.equals(filterAttribute.getSelectedItem()) && mustAdd(f, syntax.getOID(), syntax.getName()));
   }
 
   private boolean mustAdd(String f, String oid, String name)
   {
-    ArrayList<String> values = new ArrayList<>(2);
+    List<String> values = new ArrayList<>(2);
     values.add(oid);
     if (name != null)
     {
@@ -1530,14 +1401,11 @@
     return matchFilter(values, f, false);
   }
 
-  private boolean matchFilter(Collection<String> values, String filter,
-      boolean exact)
+  private boolean matchFilter(Collection<String> values, String filter, boolean exact)
   {
     for (String value : values)
     {
-      boolean matchFilter = exact
-          ? value.equalsIgnoreCase(filter)
-          : value.toLowerCase().contains(filter.toLowerCase());
+      boolean matchFilter = exact ? value.equalsIgnoreCase(filter) : value.toLowerCase().contains(filter.toLowerCase());
       if (matchFilter)
       {
         return true;
@@ -1548,28 +1416,25 @@
 
   private DefaultMutableTreeNode getRoot(JTree tree)
   {
-    return (DefaultMutableTreeNode)tree.getModel().getRoot();
+    return (DefaultMutableTreeNode) tree.getModel().getRoot();
   }
 
   private void newAttributeClicked()
   {
     if (newAttributeDialog == null)
     {
-      NewAttributePanel panel = new NewAttributePanel(
-          Utilities.getParentDialog(this));
+      NewAttributePanel panel = new NewAttributePanel(Utilities.getParentDialog(this));
       panel.setInfo(getInfo());
       newAttributeDialog = new GenericDialog(null, panel);
-      Utilities.centerGoldenMean(newAttributeDialog,
-          Utilities.getParentDialog(this));
-      panel.addConfigurationElementCreatedListener(
-          new ConfigurationElementCreatedListener()
-          {
-            @Override
-            public void elementCreated(ConfigurationElementCreatedEvent ev)
-            {
-              configurationElementCreated(ev);
-            }
-          });
+      Utilities.centerGoldenMean(newAttributeDialog, Utilities.getParentDialog(this));
+      panel.addConfigurationElementCreatedListener(new ConfigurationElementCreatedListener()
+      {
+        @Override
+        public void elementCreated(ConfigurationElementCreatedEvent ev)
+        {
+          configurationElementCreated(ev);
+        }
+      });
     }
     newAttributeDialog.setVisible(true);
   }
@@ -1578,21 +1443,18 @@
   {
     if (newObjectClassDialog == null)
     {
-      NewObjectClassPanel panel = new NewObjectClassPanel(
-          Utilities.getParentDialog(this));
+      NewObjectClassPanel panel = new NewObjectClassPanel(Utilities.getParentDialog(this));
       panel.setInfo(getInfo());
       newObjectClassDialog = new GenericDialog(null, panel);
-      Utilities.centerGoldenMean(newObjectClassDialog,
-          Utilities.getParentDialog(this));
-      panel.addConfigurationElementCreatedListener(
-          new ConfigurationElementCreatedListener()
-          {
-            @Override
-            public void elementCreated(ConfigurationElementCreatedEvent ev)
-            {
-              configurationElementCreated(ev);
-            }
-          });
+      Utilities.centerGoldenMean(newObjectClassDialog, Utilities.getParentDialog(this));
+      panel.addConfigurationElementCreatedListener(new ConfigurationElementCreatedListener()
+      {
+        @Override
+        public void elementCreated(ConfigurationElementCreatedEvent ev)
+        {
+          configurationElementCreated(ev);
+        }
+      });
     }
     newObjectClassDialog.setVisible(true);
   }
@@ -1602,53 +1464,45 @@
     Object o = ev.getConfigurationObject();
     if (o instanceof CommonSchemaElements)
     {
-      lastCreatedElement = (CommonSchemaElements)o;
+      lastCreatedElement = (CommonSchemaElements) o;
     }
   }
 
-  private HashMap<Object, ImageIcon> hmCategoryImages = new HashMap<>();
-  private HashMap<Class<?>, ImageIcon> hmImages = new HashMap<>();
+  private final Map<Object, ImageIcon> hmCategoryImages = new HashMap<>();
+  private final Map<Class<?>, ImageIcon> hmImages = new HashMap<>();
   {
     Object[] nodes = {attributes, objectClasses, standardObjectClasses,
         standardAttributes, configurationObjectClasses, configurationAttributes,
         customObjectClasses, customAttributes, matchingRules, syntaxes};
-    String[] paths = {"ds-attr-folder.png", "ds-class-folder.png",
-        "ds-folder.png",
+    String[] paths = {"ds-attr-folder.png", "ds-class-folder.png", "ds-folder.png",
         "ds-folder.png", "ds-folder.png", "ds-folder.png", "ds-folder.png",
         "ds-folder.png", "ds-rule-folder.png", "ds-syntax-folder.png"};
     for (int i=0; i<nodes.length; i++)
     {
-      hmCategoryImages.put(nodes[i],
-          Utilities.createImageIcon(IconPool.IMAGE_PATH+"/"+paths[i]));
+      hmCategoryImages.put(nodes[i], Utilities.createImageIcon(IconPool.IMAGE_PATH + "/" + paths[i]));
     }
-    Class<?>[] classes = {ConfigurationAttributeTreeNode.class,
-        StandardAttributeTreeNode.class, CustomAttributeTreeNode.class,
-        ConfigurationObjectClassTreeNode.class,
-        StandardObjectClassTreeNode.class, CustomObjectClassTreeNode.class,
-        MatchingRuleTreeNode.class, AttributeSyntaxTreeNode.class};
-    String[] ocPaths = {"ds-attr.png", "ds-attr.png", "ds-attr.png",
-        "ds-class.png", "ds-class.png", "ds-class.png", "ds-rule.png",
-        "ds-syntax.png"};
-    for (int i=0; i<classes.length; i++)
+    Class<?>[] classes =
+        { ConfigurationAttributeTreeNode.class, StandardAttributeTreeNode.class, CustomAttributeTreeNode.class,
+          ConfigurationObjectClassTreeNode.class, StandardObjectClassTreeNode.class, CustomObjectClassTreeNode.class,
+          MatchingRuleTreeNode.class, AttributeSyntaxTreeNode.class };
+    String[] ocPaths = { "ds-attr.png", "ds-attr.png", "ds-attr.png",
+      "ds-class.png", "ds-class.png", "ds-class.png", "ds-rule.png", "ds-syntax.png" };
+    for (int i = 0; i < classes.length; i++)
     {
-      hmImages.put(classes[i],
-          Utilities.createImageIcon(IconPool.IMAGE_PATH+"/"+ocPaths[i]));
+      hmImages.put(classes[i], Utilities.createImageIcon(IconPool.IMAGE_PATH + "/" + ocPaths[i]));
     }
   }
 
-  /** Specific class used to render the nodes in the tree.  It uses specific icons for the nodes. */
-  protected class SchemaTreeCellRenderer extends TreeCellRenderer
+  /** Specific class used to render the nodes in the tree. It uses specific icons for the nodes. */
+  private class SchemaTreeCellRenderer extends TreeCellRenderer
   {
     private static final long serialVersionUID = -3390568254259441766L;
 
-    /** {@inheritDoc} */
     @Override
-    public Component getTreeCellRendererComponent(JTree tree, Object value,
-        boolean isSelected, boolean isExpanded, boolean isLeaf, int row,
-        boolean hasFocus)
+    public Component getTreeCellRendererComponent(
+        JTree tree, Object value, boolean isSelected, boolean isExpanded, boolean isLeaf, int row, boolean hasFocus)
     {
-      super.getTreeCellRendererComponent(tree, value, isSelected, isExpanded,
-          isLeaf, row, hasFocus);
+      super.getTreeCellRendererComponent(tree, value, isSelected, isExpanded, isLeaf, row, hasFocus);
       setIcon(getIcon(value));
       return this;
     }
@@ -1664,19 +1518,18 @@
     }
   }
 
-  private LinkedHashSet<ObjectClass> getOrderedObjectClassesToDelete(
-      Collection<ObjectClass> ocsToDelete)
+  private Set<ObjectClass> getOrderedObjectClassesToDelete(Collection<ObjectClass> ocsToDelete)
   {
-    ArrayList<ObjectClass> lOrderedOcs = new ArrayList<>();
+    List<ObjectClass> lOrderedOcs = new ArrayList<>();
     // Reorder objectClasses and attributes to delete them in the proper order.
     for (ObjectClass oc : ocsToDelete)
     {
       int index = -1;
-      for (int i=0; i<lOrderedOcs.size(); i++)
+      for (int i = 0; i < lOrderedOcs.size(); i++)
       {
         if (lOrderedOcs.get(i).isDescendantOf(oc))
         {
-          index = i+1;
+          index = i + 1;
         }
       }
       if (index == -1)
@@ -1691,21 +1544,20 @@
     return new LinkedHashSet<>(lOrderedOcs);
   }
 
-  private LinkedHashSet<AttributeType> getOrderedAttributesToDelete(
-      Collection<AttributeType> attrsToDelete)
+  private Set<AttributeType> getOrderedAttributesToDelete(Collection<AttributeType> attrsToDelete)
   {
-    ArrayList<AttributeType> lOrderedAttributes = new ArrayList<>();
+    List<AttributeType> lOrderedAttributes = new ArrayList<>();
     for (AttributeType attr : attrsToDelete)
     {
       int index = -1;
-      for (int i=0; i<lOrderedAttributes.size(); i++)
+      for (int i = 0; i < lOrderedAttributes.size(); i++)
       {
         AttributeType parent = lOrderedAttributes.get(i).getSuperiorType();
         while (parent != null && index == -1)
         {
           if (parent.equals(attr))
           {
-            index = i+1;
+            index = i + 1;
           }
           else
           {
@@ -1726,11 +1578,9 @@
   }
 
   private LocalizableMessage getConfirmationMessage(
-      Collection<ObjectClass> ocsToDelete,
-      Collection<AttributeType> attrsToDelete,
-      Schema schema)
+      Collection<ObjectClass> ocsToDelete, Collection<AttributeType> attrsToDelete, Schema schema)
   {
-    ArrayList<ObjectClass> childClasses = new ArrayList<>();
+    List<ObjectClass> childClasses = new ArrayList<>();
     // Analyze objectClasses
     for (ObjectClass objectClass : ocsToDelete)
     {
@@ -1744,8 +1594,8 @@
       childClasses.removeAll(ocsToDelete);
     }
 
-    ArrayList<AttributeType> childAttributes = new ArrayList<>();
-    TreeSet<String> dependentClasses = new TreeSet<>();
+    List<AttributeType> childAttributes = new ArrayList<>();
+    Set<String> dependentClasses = new TreeSet<>();
     // Analyze attributes
     for (AttributeType attribute : attrsToDelete)
     {
@@ -1785,34 +1635,30 @@
       }
       if (ocsToDelete.size() == 1)
       {
-        mb.append(INFO_OBJECTCLASS_IS_SUPERIOR.get(
-            ocsToDelete.iterator().next().getNameOrOID(),
+        mb.append(INFO_OBJECTCLASS_IS_SUPERIOR.get(ocsToDelete.iterator().next().getNameOrOID(),
             Utilities.getStringFromCollection(childNames, ", ")));
       }
       else
       {
-        mb.append(INFO_OBJECTCLASSES_ARE_SUPERIOR.get(
-            Utilities.getStringFromCollection(childNames, ", ")));
+        mb.append(INFO_OBJECTCLASSES_ARE_SUPERIOR.get(Utilities.getStringFromCollection(childNames, ", ")));
       }
       mb.append("<br>");
     }
     if (!childAttributes.isEmpty())
     {
-      TreeSet<String> childNames = new TreeSet<>();
+      Set<String> childNames = new TreeSet<>();
       for (AttributeType attr : childAttributes)
       {
         childNames.add(attr.getNameOrOID());
       }
       if (attrsToDelete.size() == 1)
       {
-        mb.append(INFO_ATTRIBUTE_IS_SUPERIOR.get(
-            attrsToDelete.iterator().next().getNameOrOID(),
+        mb.append(INFO_ATTRIBUTE_IS_SUPERIOR.get(attrsToDelete.iterator().next().getNameOrOID(),
             Utilities.getStringFromCollection(childNames, ", ")));
       }
       else
       {
-        mb.append(INFO_ATTRIBUTES_ARE_SUPERIOR.get(
-            Utilities.getStringFromCollection(childNames, ", ")));
+        mb.append(INFO_ATTRIBUTES_ARE_SUPERIOR.get(Utilities.getStringFromCollection(childNames, ", ")));
       }
       mb.append("<br>");
     }
@@ -1820,19 +1666,17 @@
     {
       if (attrsToDelete.size() == 1)
       {
-        mb.append(INFO_ATTRIBUTE_WITH_DEPENDENCIES.get(
-            attrsToDelete.iterator().next().getNameOrOID(),
+        mb.append(INFO_ATTRIBUTE_WITH_DEPENDENCIES.get(attrsToDelete.iterator().next().getNameOrOID(),
             Utilities.getStringFromCollection(dependentClasses, ", ")));
       }
       else
       {
-        mb.append(INFO_ATTRIBUTES_WITH_DEPENDENCIES.get(
-            Utilities.getStringFromCollection(dependentClasses, ", ")));
+        mb.append(INFO_ATTRIBUTES_WITH_DEPENDENCIES.get(Utilities.getStringFromCollection(dependentClasses, ", ")));
       }
       mb.append("<br>");
     }
 
-    ArrayList<String> allNames = new ArrayList<>();
+    List<String> allNames = new ArrayList<>();
     for (ObjectClass ocToDelete : ocsToDelete)
     {
       allNames.add(ocToDelete.getNameOrOID());
@@ -1842,9 +1686,9 @@
       allNames.add(attrToDelete.getNameOrOID());
     }
     LocalizableMessage confirmationMessage =
-      INFO_CTRL_PANEL_CONFIRMATION_DELETE_SCHEMA_ELEMENTS_MSG.get(
-          Utilities.getStringFromCollection(allNames, ", "));
+        INFO_CTRL_PANEL_CONFIRMATION_DELETE_SCHEMA_ELEMENTS_MSG.get(Utilities.getStringFromCollection(allNames, ", "));
     mb.append(confirmationMessage);
     return mb.toMessage();
   }
+
 }

--
Gitblit v1.10.0