directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r581733 - /directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionUniversalListener.java
Date Wed, 03 Oct 2007 21:45:21 GMT
Author: seelmann
Date: Wed Oct  3 14:45:17 2007
New Revision: 581733

URL: http://svn.apache.org/viewvc?rev=581733&view=rev
Log:
DIRSTUDIO-187: expand/collapse connection folders on double click

Modified:
    directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionUniversalListener.java

Modified: directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionUniversalListener.java?rev=581733&r1=581732&r2=581733&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionUniversalListener.java
(original)
+++ directory/studio/trunk/studio-connection-ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ConnectionUniversalListener.java
Wed Oct  3 14:45:17 2007
@@ -26,6 +26,10 @@
 import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
 import org.apache.directory.studio.connection.core.event.ConnectionUpdateListener;
 import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeViewer;
 
@@ -42,7 +46,29 @@
     /** The tree viewer */
     protected TreeViewer viewer;
 
-
+    /** This listener expands/collapses a connection folder when double clicking */
+    private IDoubleClickListener viewerDoubleClickListener = new IDoubleClickListener()
+    {
+        public void doubleClick( DoubleClickEvent event )
+        {
+            if ( event.getSelection() instanceof IStructuredSelection )
+            {
+                Object obj = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+                if ( obj instanceof ConnectionFolder )
+                {
+                    if ( viewer.getExpandedState( obj ) )
+                    {
+                        viewer.collapseToLevel( obj, 1 );
+                    }
+                    else if ( ( ( ITreeContentProvider ) viewer.getContentProvider() ).hasChildren(
obj ) )
+                    {
+                        viewer.expandToLevel( obj, 1 );
+                    }
+                }
+            }
+        }
+    };
+    
     /**
      * Creates a new instance of ConnectionUniversalListener.
      *
@@ -52,6 +78,7 @@
     {
         this.viewer = viewer;
 
+        this.viewer.addDoubleClickListener( viewerDoubleClickListener );
         ConnectionEventRegistry.addConnectionUpdateListener( this, ConnectionUIPlugin.getDefault().getEventRunner()
);
     }
 



Mime
View raw message