directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r510647 [2/2] - in /directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui: views/browser/ widgets/browser/ widgets/connection/
Date Thu, 22 Feb 2007 20:52:26 GMT
Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserUniversalListener.java?view=diff&rev=510647&r1=510646&r2=510647
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserUniversalListener.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserUniversalListener.java
Thu Feb 22 12:52:24 2007
@@ -37,73 +37,141 @@
 import org.eclipse.jface.viewers.TreeViewer;
 
 
-public class BrowserUniversalListener implements ITreeViewerListener, IDoubleClickListener,
ConnectionUpdateListener,
-    EntryUpdateListener
+/**
+ * The BrowserUniversalListener manages all events for the browser widget.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserUniversalListener implements ConnectionUpdateListener, EntryUpdateListener
 {
 
+    /** The tree viewer */
     protected TreeViewer viewer;
 
+    /** The tree viewer listener */
+    private ITreeViewerListener treeViewerListener = new ITreeViewerListener()
+    {
+        /**
+         * {@inheritDoc}
+         * 
+         * This implementation checks if the collapsed entry more children
+         * than currently fetched. If this is the case cached children are 
+         * cleared an must be fetched newly when expanding the tree.
+         * 
+         * This could happen when first using a search that returns
+         * only some of an entry's children. 
+         */
+        public void treeCollapsed( TreeExpansionEvent event )
+        {
+            if ( event.getElement() instanceof IEntry )
+            {
+                IEntry entry = ( IEntry ) event.getElement();
+                if ( entry.isChildrenInitialized() && entry.hasMoreChildren()
+                    && entry.getChildrenCount() < entry.getConnection().getCountLimit()
)
+                {
+                    entry.setChildrenInitialized( false );
+                }
+            }
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void treeExpanded( TreeExpansionEvent event )
+        {
+        }
+    };
+
+    /** The double click listener. */
+    private IDoubleClickListener doubleClickListener = new IDoubleClickListener()
+    {
+
+        public void doubleClick( DoubleClickEvent event )
+        {
+            if ( event.getSelection() instanceof IStructuredSelection )
+            {
+                Object obj = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+                if ( viewer.getExpandedState( obj ) )
+                {
+                    viewer.collapseToLevel( obj, 1 );
+                }
+                else if ( ( ( ITreeContentProvider ) viewer.getContentProvider() ).hasChildren(
obj ) )
+                {
+                    viewer.expandToLevel( obj, 1 );
+                }
+            }
+        }
+
+    };
+
 
+    /**
+     * Creates a new instance of BrowserUniversalListener.
+     *
+     * @param viewer the tree viewer
+     */
     public BrowserUniversalListener( TreeViewer viewer )
     {
         this.viewer = viewer;
 
-        this.viewer.addTreeListener( this );
-        this.viewer.addDoubleClickListener( this );
+        viewer.addTreeListener( treeViewerListener );
+        viewer.addDoubleClickListener( doubleClickListener );
+
         EventRegistry.addConnectionUpdateListener( this );
         EventRegistry.addEntryUpdateListener( this );
     }
 
 
+    /**
+     * Disposes this listener.
+     */
     public void dispose()
     {
-        if ( this.viewer != null )
+        if ( viewer != null )
         {
-            this.viewer.removeTreeListener( this );
-            this.viewer.removeDoubleClickListener( this );
+            viewer.removeTreeListener( treeViewerListener );
+            viewer.removeDoubleClickListener( doubleClickListener );
+
             EventRegistry.removeConnectionUpdateListener( this );
             EventRegistry.removeEntryUpdateListener( this );
 
-            this.viewer = null;
-        }
-    }
-
-
-    public void doubleClick( DoubleClickEvent event )
-    {
-        if ( event.getSelection() instanceof IStructuredSelection )
-        {
-            Object obj = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
-            if ( this.viewer.getExpandedState( obj ) )
-                this.viewer.collapseToLevel( obj, 1 );
-            else if ( ( ( ITreeContentProvider ) this.viewer.getContentProvider() ).hasChildren(
obj ) )
-            {
-                this.viewer.expandToLevel( obj, 1 );
-            }
+            viewer = null;
         }
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation refreshes the tree and collapses the 
+     * tree when the connection is closed.
+     */
     public void connectionUpdated( ConnectionUpdateEvent connectionUpdateEvent )
     {
         if ( connectionUpdateEvent.getDetail() == ConnectionUpdateEvent.CONNECTION_CLOSED
)
         {
-            this.viewer.collapseAll();
+            viewer.collapseAll();
         }
         else if ( connectionUpdateEvent.getDetail() == ConnectionUpdateEvent.CONNECTION_OPENED
)
         {
-            this.viewer.refresh( connectionUpdateEvent.getConnection() );
+            viewer.refresh( connectionUpdateEvent.getConnection() );
         }
         else
         {
-            this.viewer.refresh( connectionUpdateEvent.getConnection() );
+            viewer.refresh( connectionUpdateEvent.getConnection() );
         }
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation refreshes the tree.
+     */
     public void entryUpdated( EntryModificationEvent event )
     {
-
         // Don't handle attribute initalization, could cause double
         // retrieval of children. 
         //
@@ -119,29 +187,8 @@
             return;
         }
 
-        this.viewer.refresh( event.getModifiedEntry(), true );
-
-    }
-
-
-    public void treeCollapsed( TreeExpansionEvent event )
-    {
-        // System.out.println("treeCollapsed() " + event + ", " +
-        // event.getElement());
-        if ( event.getElement() instanceof IEntry )
-        {
-            IEntry entry = ( IEntry ) event.getElement();
-            if ( entry.isChildrenInitialized() && entry.hasMoreChildren()
-                && entry.getChildrenCount() < entry.getConnection().getCountLimit()
)
-            {
-                entry.setChildrenInitialized( false );
-            }
-        }
-    }
-
+        viewer.refresh( event.getModifiedEntry(), true );
 
-    public void treeExpanded( TreeExpansionEvent event )
-    {
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserWidget.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserWidget.java?view=diff&rev=510647&r1=510646&r2=510647
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserWidget.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserWidget.java
Thu Feb 22 12:52:24 2007
@@ -21,6 +21,8 @@
 package org.apache.directory.ldapstudio.browser.ui.widgets.browser;
 
 
+import org.apache.directory.ldapstudio.browser.ui.dialogs.SelectEntryDialog;
+import org.apache.directory.ldapstudio.browser.ui.views.browser.BrowserView;
 import org.apache.directory.ldapstudio.browser.ui.widgets.ViewFormWidget;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.IToolBarManager;
@@ -33,18 +35,39 @@
 import org.eclipse.ui.IActionBars;
 
 
+/**
+ * The BrowserWidget is a reusable widget that displays the DIT, searches
+ * and bookmarks of a connection a tree viewer.
+ * It is used by {@link BrowserView} and {@link SelectEntryDialog}.
+ * 
+ * It provides a context menu and a local toolbar with actions to
+ * manage entries, searches and bookmarks.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class BrowserWidget extends ViewFormWidget
 {
 
+    /** The widget's configuration with the content provider, label provider and menu manager
*/
     private BrowserConfiguration configuration;
 
+    /** The action bars. */
     private IActionBars actionBars;
 
+    /** The tree widget used by the tree viewer */
     private Tree tree;
 
+    /** The tree viewer. */
     private TreeViewer viewer;
 
 
+    /**
+     * Creates a new instance of BrowserWidget.
+     *
+     * @param configuration the configuration
+     * @param actionBars the action bars
+     */
     public BrowserWidget( BrowserConfiguration configuration, IActionBars actionBars )
     {
         this.configuration = configuration;
@@ -52,6 +75,9 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void createWidget( Composite parent )
     {
         if ( actionBars == null )
@@ -65,6 +91,9 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public IToolBarManager getToolBarManager()
     {
         if ( actionBars == null )
@@ -78,6 +107,9 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public IMenuManager getMenuManager()
     {
         if ( actionBars == null )
@@ -91,6 +123,9 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public IMenuManager getContextMenuManager()
     {
         if ( actionBars == null )
@@ -104,42 +139,56 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     protected Control createContent( Composite parent )
     {
 
         // create tree widget and viewer
-        this.tree = new Tree( parent, SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
| SWT.BORDER );
+        tree = new Tree( parent, SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL |
SWT.BORDER );
         GridData data = new GridData( GridData.FILL_BOTH );
         data.widthHint = 450;
         data.heightHint = 250;
-        this.tree.setLayoutData( data );
-        this.viewer = new TreeViewer( this.tree );
-        this.viewer.setUseHashlookup( true );
+        tree.setLayoutData( data );
+        viewer = new TreeViewer( tree );
+        viewer.setUseHashlookup( true );
 
         // setup sorter, filter and layout
-        this.configuration.getSorter().connect( this.viewer );
-        this.configuration.getPreferences().connect( this.viewer );
+        configuration.getSorter().connect( viewer );
+        configuration.getPreferences().connect( viewer );
 
         // setup providers
-        this.viewer.setContentProvider( configuration.getContentProvider( this.viewer ) );
-        this.viewer.setLabelProvider( configuration.getLabelProvider( this.viewer ) );
+        viewer.setContentProvider( configuration.getContentProvider( viewer ) );
+        viewer.setLabelProvider( configuration.getLabelProvider( viewer ) );
 
-        return this.tree;
+        return tree;
     }
 
 
+    /**
+     * Sets the input to the tree viewer.
+     *
+     * @param input the input
+     */
     public void setInput( Object input )
     {
-        this.viewer.setInput( input );
+        viewer.setInput( input );
     }
 
 
+    /**
+     * Sets focus to the table viewer.
+     */
     public void setFocus()
     {
-        this.viewer.getTree().setFocus();
+        viewer.getTree().setFocus();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void dispose()
     {
         if ( this.viewer != null )
@@ -154,6 +203,11 @@
     }
 
 
+    /**
+     * Gets the tree viewer.
+     * 
+     * @return the tree viewer
+     */
     public TreeViewer getViewer()
     {
         return viewer;

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/OpenSortDialogAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/OpenSortDialogAction.java?view=diff&rev=510647&r1=510646&r2=510647
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/OpenSortDialogAction.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/OpenSortDialogAction.java
Thu Feb 22 12:52:24 2007
@@ -27,12 +27,24 @@
 import org.eclipse.ui.PlatformUI;
 
 
+/**
+ * This action opens the {@link BrowserSorterDialog}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class OpenSortDialogAction extends Action
 {
 
+    /** The preferences. */
     private BrowserPreferences preferences;
 
 
+    /**
+     * Creates a new instance of OpenSortDialogAction.
+     *
+     * @param preferences the preferences
+     */
     public OpenSortDialogAction( BrowserPreferences preferences )
     {
         super( "Sorting...", BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_SORT
) );
@@ -42,17 +54,23 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void run()
     {
         BrowserSorterDialog dlg = new BrowserSorterDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell(),
-            this.preferences );
+            preferences );
         dlg.open();
     }
 
 
+    /**
+     * Disposes this action.
+     */
     public void dispose()
     {
-        this.preferences = null;
+        preferences = null;
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/connection/ConnectionWidget.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/connection/ConnectionWidget.java?view=diff&rev=510647&r1=510646&r2=510647
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/connection/ConnectionWidget.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/connection/ConnectionWidget.java
Thu Feb 22 12:52:24 2007
@@ -21,6 +21,9 @@
 package org.apache.directory.ldapstudio.browser.ui.widgets.connection;
 
 
+import org.apache.directory.ldapstudio.browser.ui.dialogs.SelectConnectionDialog;
+import org.apache.directory.ldapstudio.browser.ui.dialogs.SelectReferralConnectionDialog;
+import org.apache.directory.ldapstudio.browser.ui.views.connection.ConnectionView;
 import org.apache.directory.ldapstudio.browser.ui.widgets.ViewFormWidget;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.IToolBarManager;
@@ -35,11 +38,12 @@
 
 /**
  * The ConnectionWidget is a reusable widget that displays all connections
- * in a table viewer. 
+ * in a table viewer. It is used by {@link ConnectionView}, {@link SelectConnectionDialog}
+ * and {@link SelectReferralConnectionDialog}. 
  * 
  * It includes a content and label provider to display connections with a nice icon.
  * 
- * Further is provides a context and a local toolbar menu with actions to
+ * Further is provides a context menu and a local toolbar with actions to
  * add, modify, delete, open and close connections.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>



Mime
View raw message