directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r514619 - in /directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers: SchemasViewContentProvider.java wrappers/SchemaSorter.java
Date Mon, 05 Mar 2007 09:30:16 GMT
Author: pamarcelot
Date: Mon Mar  5 01:30:15 2007
New Revision: 514619

URL: http://svn.apache.org/viewvc?view=rev&rev=514619
Log:
Added a sorter for sorting the schemas in the Schemas View.

Added:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/SchemaSorter.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewContentProvider.java

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewContentProvider.java?view=diff&rev=514619&r1=514618&r2=514619
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewContentProvider.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewContentProvider.java
Mon Mar  5 01:30:15 2007
@@ -37,6 +37,7 @@
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.IntermediateNode;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.OidSorter;
+import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.SchemaSorter;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.SchemaWrapper;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.IntermediateNode.IntermediateNodeType;
 import org.eclipse.jface.preference.IPreferenceStore;
@@ -65,6 +66,9 @@
 
     /** The OID Sorter */
     private OidSorter oidSorter;
+    
+    /** The Schema Sorter */
+    private SchemaSorter schemaSorter;
 
 
     /**
@@ -77,6 +81,7 @@
 
         firstNameSorter = new FirstNameSorter();
         oidSorter = new OidSorter();
+        schemaSorter = new SchemaSorter();
     }
 
 
@@ -110,6 +115,8 @@
                 {
                     children.add( new SchemaWrapper( schemas[i], ( IntermediateNode ) parentElement
) );
                 }
+                
+                Collections.sort( children, schemaSorter );
             }
             else if ( intermediate.getType().equals( IntermediateNodeType.ATTRIBUTE_TYPE_FOLDER
) )
             {

Added: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/SchemaSorter.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/SchemaSorter.java?view=auto&rev=514619
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/SchemaSorter.java
(added)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/wrappers/SchemaSorter.java
Mon Mar  5 01:30:15 2007
@@ -0,0 +1,50 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.schemas.view.viewers.wrappers;
+
+
+import java.util.Comparator;
+
+import org.apache.directory.ldapstudio.schemas.model.Schema;
+
+
+/**
+ * This class is used to compare and sort ascending two Schemas
+ */
+public class SchemaSorter implements Comparator<DisplayableTreeElement>
+{
+    /* (non-Javadoc)
+     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+     */
+    public int compare( DisplayableTreeElement o1, DisplayableTreeElement o2 )
+    {
+        if ( ( o1 instanceof SchemaWrapper ) && ( o2 instanceof SchemaWrapper ) )
+        {
+            Schema s1 = ( ( SchemaWrapper ) o1 ).getMySchema();
+            Schema s2 = ( ( SchemaWrapper ) o2 ).getMySchema();
+
+            return s1.getName().compareToIgnoreCase( s2.getName() );
+        }
+
+        // Default
+        return o1.toString().compareToIgnoreCase( o2.toString() );
+    }
+}



Mime
View raw message