directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r557269 - in /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view: views/ProjectsViewContentProvider.java wrappers/ProjectSorter.java
Date Wed, 18 Jul 2007 14:10:42 GMT
Author: pamarcelot
Date: Wed Jul 18 07:10:41 2007
New Revision: 557269

URL: http://svn.apache.org/viewvc?view=rev&rev=557269
Log:
Added a "ProjectSorter".

Added:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/ProjectSorter.java
Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProjectsViewContentProvider.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProjectsViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProjectsViewContentProvider.java?view=diff&rev=557269&r1=557268&r2=557269
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProjectsViewContentProvider.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProjectsViewContentProvider.java
Wed Jul 18 07:10:41 2007
@@ -20,12 +20,13 @@
 package org.apache.directory.studio.apacheds.schemaeditor.view.views;
 
 
+import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.List;
 
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.model.Project;
+import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.ProjectSorter;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.ProjectWrapper;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.ProjectsViewRoot;
 import org.apache.directory.studio.apacheds.schemaeditor.view.wrappers.TreeNode;
@@ -46,6 +47,9 @@
     /** The viewer */
     private TableViewer tableViewer;
 
+    /** The Sorter */
+    private ProjectSorter projectSorter;
+
 
     /**
      * Creates a new instance of ProjectsViewContentProvider.
@@ -56,6 +60,7 @@
     public ProjectsViewContentProvider( TableViewer tableViewer )
     {
         this.tableViewer = tableViewer;
+        projectSorter = new ProjectSorter();
     }
 
 
@@ -92,7 +97,7 @@
     @SuppressWarnings("unchecked")
     public Object[] getChildren( Object parentElement )
     {
-        List<TreeNode> children = null;
+        List<TreeNode> children = new ArrayList<TreeNode>();
 
         if ( parentElement instanceof ProjectsViewRoot )
         {
@@ -109,26 +114,7 @@
             children = projectsViewRoot.getChildren();
 
             // Sorting Children
-            Collections.sort( children, new Comparator<TreeNode>()
-            {
-                public int compare( TreeNode tn1, TreeNode tn2 )
-                {
-                    if ( ( tn1 instanceof ProjectWrapper ) && ( tn2 instanceof ProjectWrapper
) )
-                    {
-                        ProjectWrapper pw1 = ( ProjectWrapper ) tn1;
-                        ProjectWrapper pw2 = ( ProjectWrapper ) tn2;
-
-                        return pw1.getProject().getName().compareToIgnoreCase( pw2.getProject().getName()
);
-                    }
-
-                    // Default
-                    return 0;
-                }
-            } );
-        }
-        else if ( parentElement instanceof ProjectWrapper )
-        {
-            return null;
+            Collections.sort( children, projectSorter );
         }
 
         return children.toArray();

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/ProjectSorter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/ProjectSorter.java?view=auto&rev=557269
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/ProjectSorter.java
(added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wrappers/ProjectSorter.java
Wed Jul 18 07:10:41 2007
@@ -0,0 +1,48 @@
+/*
+ *  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.studio.apacheds.schemaeditor.view.wrappers;
+
+
+import java.util.Comparator;
+
+
+/**
+ * This class is used to compare and sort ascending two TreeNode
+ */
+public class ProjectSorter implements Comparator<TreeNode>
+{
+    /* (non-Javadoc)
+     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+     */
+    public int compare( TreeNode tn1, TreeNode tn2 )
+    {
+        if ( ( tn1 instanceof ProjectWrapper ) && ( tn2 instanceof ProjectWrapper
) )
+        {
+            ProjectWrapper pw1 = ( ProjectWrapper ) tn1;
+            ProjectWrapper pw2 = ( ProjectWrapper ) tn2;
+
+            return pw1.getProject().getName().compareToIgnoreCase( pw2.getProject().getName()
);
+        }
+
+        // Default
+        return 0;
+    }
+}



Mime
View raw message