mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
19.19.2008 03605532e7a79384ee40dcf1838135de8c5cdc7c
Complete fix for issue 3622.  Make all the elements in the schema panels sorted without taking into account the case.
1 files added
5 files modified
94 ■■■■ changed files
opends/src/guitools/org/opends/guitools/controlpanel/ui/AttributeSyntaxPanel.java 5 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java 12 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/StandardAttributePanel.java 7 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/StandardObjectClassPanel.java 7 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/util/LowerCaseComparator.java 61 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java 2 ●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/AttributeSyntaxPanel.java
@@ -33,6 +33,7 @@
import java.awt.GridBagConstraints;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Comparator;
import java.util.TreeSet;
import javax.swing.DefaultListModel;
@@ -41,6 +42,7 @@
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.ui.components.TitlePanel;
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.Message;
import org.opends.server.api.AttributeSyntax;
@@ -204,7 +206,8 @@
    }
    description.setText(n);
    TreeSet<String> attributes = new TreeSet<String>();
    Comparator<String> lowerCaseComparator = new LowerCaseComparator();
    TreeSet<String> attributes = new TreeSet<String>(lowerCaseComparator);
    for (AttributeType attr : schema.getAttributeTypes().values())
    {
      if (syntax == attr.getSyntax())
opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
@@ -80,6 +80,7 @@
import org.opends.guitools.controlpanel.ui.nodes.*;
import org.opends.guitools.controlpanel.ui.renderer.CustomListCellRenderer;
import org.opends.guitools.controlpanel.ui.renderer.TreeCellRenderer;
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.Message;
import org.opends.server.api.AttributeSyntax;
@@ -693,16 +694,7 @@
    }
    TreePath newSelectionPath = null;
    /**
     * {@inheritDoc}
     */
    Comparator<String> lowerCaseComparator = new Comparator<String>()
    {
      public int compare(String s1, String s2)
      {
        return s1.toLowerCase().compareTo(s2.toLowerCase());
      }
    };
    Comparator<String> lowerCaseComparator = new LowerCaseComparator();
    TreeSet<String> standardOcNames = new TreeSet<String>(lowerCaseComparator);
    HashMap<String, StandardObjectClassTreeNode> hmStandardOcs =
opends/src/guitools/org/opends/guitools/controlpanel/ui/StandardAttributePanel.java
@@ -35,6 +35,7 @@
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -44,6 +45,7 @@
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.ui.components.TitlePanel;
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.Message;
import org.opends.messages.MessageBuilder;
@@ -328,7 +330,8 @@
    type.setText(getTypeValue(attr).toString());
    SortedSet<String> requiredByOcs = new TreeSet<String>();
    Comparator<String> lowerCaseComparator = new LowerCaseComparator();
    SortedSet<String> requiredByOcs = new TreeSet<String>(lowerCaseComparator);
    for (ObjectClass oc : schema.getObjectClasses().values())
    {
      if (oc.getRequiredAttributeChain().contains(attr))
@@ -344,7 +347,7 @@
      model.addElement(oc);
    }
    SortedSet<String> optionalByOcs = new TreeSet<String>();
    SortedSet<String> optionalByOcs = new TreeSet<String>(lowerCaseComparator);
    for (ObjectClass oc : schema.getObjectClasses().values())
    {
      if (oc.getOptionalAttributeChain().contains(attr))
opends/src/guitools/org/opends/guitools/controlpanel/ui/StandardObjectClassPanel.java
@@ -35,6 +35,7 @@
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -49,6 +50,7 @@
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.ui.components.TitlePanel;
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.Message;
import org.opends.messages.MessageBuilder;
@@ -357,7 +359,8 @@
    type.setText(getTypeValue(oc).toString());
    SortedSet<String> requiredAttrs = new TreeSet<String>();
    Comparator<String> lowerCaseComparator = new LowerCaseComparator();
    SortedSet<String> requiredAttrs = new TreeSet<String>(lowerCaseComparator);
    Set<String> inheritedAttrs = new HashSet<String>();
    for (AttributeType attr : oc.getRequiredAttributeChain())
    {
@@ -389,7 +392,7 @@
      hmAttrs.put(v, schema.getAttributeType(attr.toLowerCase()));
    }
    SortedSet<String> optionalAttrs = new TreeSet<String>();
    SortedSet<String> optionalAttrs = new TreeSet<String>(lowerCaseComparator);
    inheritedAttrs = new HashSet<String>();
    for (AttributeType attr : oc.getOptionalAttributeChain())
    {
opends/src/guitools/org/opends/guitools/controlpanel/util/LowerCaseComparator.java
New file
@@ -0,0 +1,61 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.util;
import java.util.Comparator;
/**
 * Class used to compare Strings without take into account the case.  It can
 * be used to sort Strings in TreeSets for instance.
 *
 */
public class LowerCaseComparator implements Comparator<String>
{
  /**
   * {@inheritDoc}
   */
  public int compare(String s1, String s2)
  {
    if ((s1 != null) && (s2 != null))
    {
      return s1.toLowerCase().compareTo(s2.toLowerCase());
    }
    else if (s2 != null)
    {
      return -1;
    }
    else if (s1 != null)
    {
      return 1;
    }
    else
    {
      return 0;
    }
  }
}
opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
@@ -1721,7 +1721,7 @@
      }
      if (!isStandard)
      {
        isStandard = fileName.indexOf("-rfc") != -1;
        isStandard = fileName.toLowerCase().indexOf("-rfc") != -1;
      }
    }
    return isStandard;