You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2007/10/03 23:29:46 UTC

svn commit: r581728 - in /directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets: ConnectionConfiguration.java ConnectionSorter.java ConnectionWidget.java

Author: seelmann
Date: Wed Oct  3 14:29:45 2007
New Revision: 581728

URL: http://svn.apache.org/viewvc?rev=581728&view=rev
Log:
DIRSTUDIO-187: added sorter to connections view

Added:
    directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionSorter.java
Modified:
    directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionConfiguration.java
    directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionWidget.java

Modified: directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionConfiguration.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionConfiguration.java?rev=581728&r1=581727&r2=581728&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionConfiguration.java (original)
+++ directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionConfiguration.java Wed Oct  3 14:29:45 2007
@@ -47,6 +47,9 @@
     /** The label provider. */
     private ConnectionLabelProvider labelProvider;
 
+    /** The sorter. */
+    private ConnectionSorter sorter;
+    
     /** The context menu manager. */
     private MenuManager contextMenuManager;
 
@@ -142,6 +145,22 @@
         }
 
         return labelProvider;
+    }
+    
+    
+    /**
+     * Gets the sorter.
+     * 
+     * @return the sorter
+     */
+    public ConnectionSorter getSorter()
+    {
+        if ( sorter == null )
+        {
+            sorter = new ConnectionSorter();
+        }
+        
+        return sorter;
     }
 
 }

Added: directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionSorter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionSorter.java?rev=581728&view=auto
==============================================================================
--- directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionSorter.java (added)
+++ directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionSorter.java Wed Oct  3 14:29:45 2007
@@ -0,0 +1,82 @@
+/*
+ *  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.connection.ui.widgets;
+
+
+import org.apache.directory.studio.connection.core.ConnectionFolder;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+
+/**
+ * The ConnectionSorter implements the sorter for the connection widget. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ConnectionSorter extends ViewerSorter
+{
+
+    /**
+     * Creates a new instance of ConnectionSorter.
+     */
+    public ConnectionSorter()
+    {
+    }
+
+
+    /**
+     * Connects the tree viewer to this sorter.
+     *
+     * @param viewer the tree viewer
+     */
+    public void connect( TreeViewer viewer )
+    {
+        viewer.setSorter( this );
+    }
+
+
+    /**
+     * Disposes this sorter.
+     */
+    public void dispose()
+    {
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * 
+     * This method is used to categorize connection folders and connections.
+     */
+    public int category( Object element )
+    {
+        if ( element instanceof ConnectionFolder )
+        {
+            return 1;
+        }
+        else
+        {
+            return 2;
+        }
+    }
+
+}

Modified: directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionWidget.java?rev=581728&r1=581727&r2=581728&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionWidget.java (original)
+++ directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionWidget.java Wed Oct  3 14:29:45 2007
@@ -153,6 +153,9 @@
         tree.setLayoutData( data );
         viewer = new TreeViewer( tree );
 
+        // setup sorter
+        configuration.getSorter().connect( viewer );
+
         // setup providers
         viewer.setContentProvider( configuration.getContentProvider( viewer ) );
         viewer.setLabelProvider( configuration.getLabelProvider( viewer ) );