directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r509339 [2/3] - in /directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui: actions/ editors/entry/ editors/searchresult/ views/browser/ views/connection/ widgets/browser/ widgets/connectio...
Date Mon, 19 Feb 2007 21:37:31 GMT
Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java?view=diff&rev=509339&r1=509338&r2=509339
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java Mon Feb 19 13:37:30 2007
@@ -44,184 +44,364 @@
 import org.apache.directory.ldapstudio.browser.core.model.ISearch;
 import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
 import org.apache.directory.ldapstudio.browser.ui.actions.SelectionUtils;
-import org.apache.directory.ldapstudio.browser.ui.editors.entry.EntryEditorManager;
-import org.apache.directory.ldapstudio.browser.ui.editors.searchresult.SearchResultEditorManager;
+import org.apache.directory.ldapstudio.browser.ui.editors.entry.EntryEditor;
+import org.apache.directory.ldapstudio.browser.ui.editors.entry.EntryEditorInput;
+import org.apache.directory.ldapstudio.browser.ui.editors.searchresult.SearchResultEditor;
+import org.apache.directory.ldapstudio.browser.ui.editors.searchresult.SearchResultEditorInput;
+import org.apache.directory.ldapstudio.browser.ui.views.connection.ConnectionView;
 import org.apache.directory.ldapstudio.browser.ui.widgets.browser.BrowserCategory;
 import org.apache.directory.ldapstudio.browser.ui.widgets.browser.BrowserUniversalListener;
-import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.INullSelectionListener;
 import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.ISelectionListener;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.contexts.IContextActivation;
 import org.eclipse.ui.contexts.IContextService;
 
 
-public class BrowserViewUniversalListener extends BrowserUniversalListener implements ISelectionListener,
-    SearchUpdateListener, EntryUpdateListener, ConnectionUpdateListener, BookmarkUpdateListener, IPartListener2
+/**
+ * The BrowserViewUniversalListener manages all events for the browser view.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BrowserViewUniversalListener extends BrowserUniversalListener implements SearchUpdateListener,
+    EntryUpdateListener, ConnectionUpdateListener, BookmarkUpdateListener
 {
 
-    private Map connectionToExpandedElementsMap;
+    /** This map contains all expanded elements for a particular connection */
+    private Map<IConnection, Object[]> connectionToExpandedElementsMap;
 
-    private Map connectionToSelectedElementMap;
+    /** This map contains all selected elements for a particular connection */
+    private Map<IConnection, ISelection> connectionToSelectedElementMap;
 
+    /** The browser view */
     private BrowserView view;
 
+    /** Token used to activate and deactivate shortcuts in the view */
     private IContextActivation contextActivation;
 
+    /** Listener that listens for selections of connections */
+    private INullSelectionListener connectionSelectionListener = new INullSelectionListener()
+    {
+        /**
+         * {@inheritDoc}
+         * 
+         * This implementation sets the input when another connection was selected.
+         */
+        public void selectionChanged( IWorkbenchPart part, ISelection selection )
+        {
+            if ( view != null && part != null )
+            {
+                if ( view.getSite().getWorkbenchWindow() == part.getSite().getWorkbenchWindow() )
+                {
+                    IConnection[] connections = SelectionUtils.getConnections( selection );
+                    if ( connections.length == 1 )
+                    {
+                        setInput( connections[0] );
+                    }
+                    else
+                    {
+                        setInput( null );
+                    }
+                }
+            }
+        }
+    };
 
-    public BrowserViewUniversalListener( BrowserView view )
+    /** The part listener used to activate and deactivate the shortcuts */
+    private IPartListener2 partListener = new IPartListener2()
     {
-        super( view.getMainWidget().getViewer() );
-        this.view = view;
+        /**
+         * {@inheritDoc}
+         * 
+         * This implementation deactivates the shortcuts when the part is deactivated.
+         */
+        public void partDeactivated( IWorkbenchPartReference partRef )
+        {
+            if ( partRef.getPart( false ) == view && contextActivation != null )
+            {
 
-        this.connectionToExpandedElementsMap = new HashMap();
-        this.connectionToSelectedElementMap = new HashMap();
+                view.getActionGroup().deactivateGlobalActionHandlers();
 
-        EventRegistry.addSearchUpdateListener( this );
-        EventRegistry.addBookmarkUpdateListener( this );
-        EventRegistry.addEntryUpdateListener( this );
-        EventRegistry.addConnectionUpdateListener( this );
-        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addSelectionListener( this );
-        view.getSite().getPage().addPartListener( this );
-    }
+                IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+                    IContextService.class );
+                contextService.deactivateContext( contextActivation );
+                contextActivation = null;
+            }
+        }
 
 
-    public void dispose()
-    {
-        if ( this.view != null )
+        /**
+         * {@inheritDoc}
+         * 
+         * This implementation activates the shortcuts when the part is activated.
+         */
+        public void partActivated( IWorkbenchPartReference partRef )
         {
-            view.getSite().getPage().removePartListener( this );
-            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removeSelectionListener( this );
-            EventRegistry.removeSearchUpdateListener( this );
-            EventRegistry.removeBookmarkUpdateListener( this );
-            EventRegistry.removeEntryUpdateListener( this );
-            EventRegistry.removeConnectionUpdateListener( this );
+            if ( partRef.getPart( false ) == view )
+            {
+
+                IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+                    IContextService.class );
+                contextActivation = contextService
+                    .activateContext( "org.apache.directory.ldapstudio.browser.action.context" );
+                // org.eclipse.ui.contexts.dialogAndWindow
+                // org.eclipse.ui.contexts.window
+                // org.eclipse.ui.text_editor_context
 
-            this.view = null;
-            this.connectionToExpandedElementsMap.clear();
-            this.connectionToExpandedElementsMap = null;
-            this.connectionToSelectedElementMap.clear();
-            this.connectionToSelectedElementMap = null;
+                view.getActionGroup().activateGlobalActionHandlers();
+            }
         }
 
-        super.dispose();
-    }
 
+        /**
+         * {@inheritDoc}
+         */
+        public void partBroughtToTop( IWorkbenchPartReference partRef )
+        {
+        }
 
-    public void selectionChanged( IWorkbenchPart part, ISelection selection )
-    {
 
-        if ( part.getClass() == BrowserView.class )
+        /**
+         * {@inheritDoc}
+         */
+        public void partClosed( IWorkbenchPartReference partRef )
         {
-            this.sendSelectionHints( selection );
         }
 
-    }
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partOpened( IWorkbenchPartReference partRef )
+        {
+        }
 
 
-    private void sendSelectionHints( ISelection selection )
+        /**
+         * {@inheritDoc}
+         */
+        public void partHidden( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partVisible( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partInputChanged( IWorkbenchPartReference partRef )
+        {
+        }
+    };
+
+    /** This listener is used to ensure that the entry editor and search result editor are opened
+     when an object in the browser view is selected */
+    private ISelectionChangedListener viewerSelectionListener = new ISelectionChangedListener()
+    {
+        /**
+         * {@inheritDoc}
+         */
+        public void selectionChanged( SelectionChangedEvent event )
+        {
+            ensureEditorsVisible( event.getSelection() );
+        }
+    };
+
+
+    public BrowserViewUniversalListener( BrowserView view )
     {
+        super( view.getMainWidget().getViewer() );
+        this.view = view;
+
+        // create maps
+        connectionToExpandedElementsMap = new HashMap<IConnection, Object[]>();
+        connectionToSelectedElementMap = new HashMap<IConnection, ISelection>();
 
-        IEntry[] entries = SelectionUtils.getEntries( selection );
-        ISearchResult[] searchResults = SelectionUtils.getSearchResults( selection );
-        IBookmark[] bookmarks = SelectionUtils.getBookmarks( selection );
+        // register listeners
+        EventRegistry.addSearchUpdateListener( this );
+        EventRegistry.addBookmarkUpdateListener( this );
+        EventRegistry.addEntryUpdateListener( this );
+        EventRegistry.addConnectionUpdateListener( this );
+
+        view.getSite().getPage().addPartListener( partListener );
+        view.getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener( ConnectionView.getId(),
+            connectionSelectionListener );
+
+        viewer.addSelectionChangedListener( viewerSelectionListener );
+    }
 
-        ISearch[] searches = SelectionUtils.getSearches( selection );
 
-        if ( entries.length + searchResults.length + bookmarks.length + searches.length == 1 )
+    /**
+     * Ensures that the entry editor or the search result editor are 
+     * opended and ready to show the given selection.
+     *
+     * @param selection the browser's selection.
+     */
+    private void ensureEditorsVisible( ISelection selection )
+    {
+        if ( view != null )
         {
-            if ( entries.length == 1 )
-            {
-                EntryEditorManager.setInput( entries[0] );
-                SearchResultEditorManager.setInput( null );
-            }
-            else if ( searchResults.length == 1 )
-            {
-                EntryEditorManager.setInput( searchResults[0] );
-                SearchResultEditorManager.setInput( null );
-            }
-            else if ( bookmarks.length == 1 )
-            {
-                EntryEditorManager.setInput( bookmarks[0] );
-                SearchResultEditorManager.setInput( null );
-            }
-            else if ( searches.length == 1 )
+            IEntry[] entries = SelectionUtils.getEntries( selection );
+            ISearchResult[] searchResults = SelectionUtils.getSearchResults( selection );
+            IBookmark[] bookmarks = SelectionUtils.getBookmarks( selection );
+            ISearch[] searches = SelectionUtils.getSearches( selection );
+
+            if ( entries.length + searchResults.length + bookmarks.length + searches.length == 1 )
             {
-                EntryEditorManager.setInput( ( IEntry ) null );
-                SearchResultEditorManager.setInput( searches[0] );
+                if ( entries.length == 1 )
+                {
+                    try
+                    {
+                        EntryEditorInput input = new EntryEditorInput( entries[0] );
+                        view.getSite().getPage().openEditor( input, EntryEditor.getId(), false );
+                    }
+                    catch ( PartInitException e )
+                    {
+                    }
+                }
+                else if ( searchResults.length == 1 )
+                {
+                    try
+                    {
+                        EntryEditorInput input = new EntryEditorInput( searchResults[0] );
+                        view.getSite().getPage().openEditor( input, EntryEditor.getId(), false );
+                    }
+                    catch ( PartInitException e )
+                    {
+                    }
+                }
+                else if ( bookmarks.length == 1 )
+                {
+                    try
+                    {
+                        EntryEditorInput input = new EntryEditorInput( bookmarks[0] );
+                        view.getSite().getPage().openEditor( input, EntryEditor.getId(), false );
+                    }
+                    catch ( PartInitException e )
+                    {
+                    }
+                }
+                else if ( searches.length == 1 )
+                {
+                    try
+                    {
+                        SearchResultEditorInput input = new SearchResultEditorInput( searches[0] );
+                        view.getSite().getPage().openEditor( input, SearchResultEditor.getId(), false );
+                    }
+                    catch ( PartInitException e )
+                    {
+                    }
+                }
             }
         }
-        else
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose()
+    {
+        if ( view != null )
         {
-            EntryEditorManager.setInput( ( IEntry ) null );
-            SearchResultEditorManager.setInput( null );
+            EventRegistry.removeSearchUpdateListener( this );
+            EventRegistry.removeBookmarkUpdateListener( this );
+            EventRegistry.removeEntryUpdateListener( this );
+            EventRegistry.removeConnectionUpdateListener( this );
+
+            view.getSite().getPage().removePartListener( partListener );
+            view.getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(
+                ConnectionView.getId(), connectionSelectionListener );
+
+            view = null;
+            connectionToExpandedElementsMap.clear();
+            connectionToExpandedElementsMap = null;
+            connectionToSelectedElementMap.clear();
+            connectionToSelectedElementMap = null;
         }
 
+        super.dispose();
     }
 
 
+    /**
+     * Sets the input to the viewer and saves/restores the expanded and selected elements.
+     *
+     * @param connection the connection input
+     */
     void setInput( IConnection connection )
     {
 
         // only if another connection is selected
-        if ( connection != this.viewer.getInput() )
+        if ( connection != viewer.getInput() )
         {
 
-            IConnection currentConnection = this.viewer.getInput() instanceof IConnection ? ( IConnection ) this.viewer
+            IConnection currentConnection = viewer.getInput() instanceof IConnection ? ( IConnection ) viewer
                 .getInput() : null;
 
             // save expanded elements and selection
             if ( currentConnection != null )
             {
-                this.connectionToExpandedElementsMap.put( currentConnection, this.viewer.getExpandedElements() );
-                if ( !this.viewer.getSelection().isEmpty() )
+                connectionToExpandedElementsMap.put( currentConnection, viewer.getExpandedElements() );
+                if ( !viewer.getSelection().isEmpty() )
                 {
-                    this.connectionToSelectedElementMap.put( currentConnection, this.viewer.getSelection() );
+                    connectionToSelectedElementMap.put( currentConnection, viewer.getSelection() );
                 }
             }
 
             // change input
-            this.viewer.setInput( connection );
-            this.view.getActionGroup().setInput( connection );
+            viewer.setInput( connection );
+            view.getActionGroup().setInput( connection );
 
             // restore expanded elements and selection
-            if ( this.view != null && connection != null )
+            if ( view != null && connection != null )
             {
-                if ( this.connectionToExpandedElementsMap.containsKey( connection ) )
+                if ( connectionToExpandedElementsMap.containsKey( connection ) )
                 {
-                    this.viewer
-                        .setExpandedElements( ( Object[] ) this.connectionToExpandedElementsMap.get( connection ) );
+                    viewer.setExpandedElements( ( Object[] ) connectionToExpandedElementsMap.get( connection ) );
                 }
-                if ( this.connectionToSelectedElementMap.containsKey( connection )
-                    && this.view.getSite().getPage().isPartVisible( this.view ) )
+                if ( connectionToSelectedElementMap.containsKey( connection )
+                    && this.view.getSite().getPage().isPartVisible( view ) )
                 {
-                    this.viewer.setSelection( ( ISelection ) this.connectionToSelectedElementMap.get( connection ),
-                        true );
+                    viewer.setSelection( ( ISelection ) connectionToSelectedElementMap.get( connection ), true );
                 }
             }
-
-            // send selection hint
-            this.sendSelectionHints( this.viewer.getSelection() );
         }
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation refreshes the tree and expands/collapses the 
+     * tree when the connection is opene/closed.
+     */
     public void connectionUpdated( ConnectionUpdateEvent connectionUpdateEvent )
     {
-
         if ( connectionUpdateEvent.getDetail() == ConnectionUpdateEvent.CONNECTION_OPENED )
         {
-            this.viewer.refresh( connectionUpdateEvent.getConnection() );
-            this.viewer.expandToLevel( 2 );
+            viewer.refresh( connectionUpdateEvent.getConnection() );
+            viewer.expandToLevel( 2 );
 
-            if ( this.view.getConfiguration().getPreferences().isExpandBaseEntries() )
+            if ( view.getConfiguration().getPreferences().isExpandBaseEntries() )
             {
-                Object[] expandedElements = this.viewer.getExpandedElements();
+                Object[] expandedElements = viewer.getExpandedElements();
                 for ( int i = 0; i < expandedElements.length; i++ )
                 {
                     Object object = expandedElements[i];
@@ -230,57 +410,63 @@
                         BrowserCategory bc = ( BrowserCategory ) object;
                         if ( bc.getType() == BrowserCategory.TYPE_DIT )
                         {
-                            this.viewer.expandToLevel( bc, 3 );
+                            viewer.expandToLevel( bc, 3 );
                         }
                     }
                 }
             }
-            // this.viewer.expandToLevel(this.view.getConfiguration().getPreferences().isExpandBaseEntries()?3:2);
-
         }
         else if ( connectionUpdateEvent.getDetail() == ConnectionUpdateEvent.CONNECTION_CLOSED )
         {
-            this.viewer.collapseAll();
-            this.connectionToExpandedElementsMap.remove( connectionUpdateEvent.getConnection() );
-            this.connectionToSelectedElementMap.remove( connectionUpdateEvent.getConnection() );
-            this.sendSelectionHints( this.viewer.getSelection() );
-            this.viewer.refresh( connectionUpdateEvent.getConnection() );
+            viewer.collapseAll();
+            connectionToExpandedElementsMap.remove( connectionUpdateEvent.getConnection() );
+            connectionToSelectedElementMap.remove( connectionUpdateEvent.getConnection() );
+            viewer.refresh( connectionUpdateEvent.getConnection() );
         }
         else
         {
-            this.viewer.refresh( connectionUpdateEvent.getConnection() );
+            viewer.refresh( connectionUpdateEvent.getConnection() );
         }
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This viewer selects the updated search.
+     */
     public void searchUpdated( SearchUpdateEvent searchUpdateEvent )
     {
         ISearch search = searchUpdateEvent.getSearch();
-        this.viewer.refresh();
-        if ( search.getSearchResults() != null && search.getSearchResults().length > 0 )
-        {
-            // this.viewer.refresh(search);
-            // this.viewer.expandToLevel(search, TreeViewer.ALL_LEVELS);
-        }
+        viewer.refresh();
 
         if ( Arrays.asList( search.getConnection().getSearchManager().getSearches() ).contains( search ) )
         {
-            this.viewer.setSelection( new StructuredSelection( search ), true );
+            viewer.setSelection( new StructuredSelection( search ), true );
         }
         else
         {
-            Object searchCategory = ( ( ITreeContentProvider ) this.viewer.getContentProvider() ).getParent( search );
-            this.viewer.setSelection( new StructuredSelection( searchCategory ), true );
+            Object searchCategory = ( ( ITreeContentProvider ) viewer.getContentProvider() ).getParent( search );
+            viewer.setSelection( new StructuredSelection( searchCategory ), true );
         }
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void bookmarkUpdated( BookmarkUpdateEvent bookmarkUpdateEvent )
     {
-        this.viewer.refresh();
+        viewer.refresh();
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation refreshes the tree and 
+     * selects an entry depending on the event type.
+     */
     public void entryUpdated( EntryModificationEvent event )
     {
 
@@ -301,139 +487,27 @@
 
         if ( event instanceof EntryAddedEvent )
         {
-            this.viewer.refresh( event.getModifiedEntry(), true );
-            this.viewer.refresh( event.getModifiedEntry().getParententry(), true );
-            this.viewer.setSelection( new StructuredSelection( event.getModifiedEntry() ), true );
+            viewer.refresh( event.getModifiedEntry(), true );
+            viewer.refresh( event.getModifiedEntry().getParententry(), true );
+            viewer.setSelection( new StructuredSelection( event.getModifiedEntry() ), true );
         }
         else if ( event instanceof EntryRenamedEvent )
         {
             EntryRenamedEvent ere = ( EntryRenamedEvent ) event;
-            this.viewer.refresh( ere.getNewEntry().getParententry(), true );
-            this.viewer.refresh( ere.getNewEntry(), true );
-            this.viewer.setSelection( new StructuredSelection( ere.getNewEntry() ), true );
+            viewer.refresh( ere.getNewEntry().getParententry(), true );
+            viewer.refresh( ere.getNewEntry(), true );
+            viewer.setSelection( new StructuredSelection( ere.getNewEntry() ), true );
         }
         else if ( event instanceof EntryMovedEvent )
         {
             EntryMovedEvent eme = ( EntryMovedEvent ) event;
-            this.viewer.refresh( eme.getOldEntry().getParententry(), true );
-            this.viewer.refresh( eme.getNewEntry().getParententry(), true );
-            this.viewer.refresh( eme.getNewEntry(), true );
-            this.viewer.setSelection( new StructuredSelection( eme.getNewEntry() ), true );
-        }
-
-        // else if(event instanceof EntryDeletedEvent) {
-        // this.viewer.refresh(event.getModifiedEntry(), true);
-        // this.viewer.refresh(event.getModifiedEntry().getParententry(), true);
-        // this.viewer.setSelection(new
-        // StructuredSelection(event.getModifiedEntry().getParententry()),
-        // true);
-        // }
-        // else if(event instanceof EntryRenamedEvent) {
-        // EntryRenamedEvent ere = (EntryRenamedEvent) event;
-        // this.viewer.refresh(ere.getModifiedEntry(), true);
-        // this.viewer.refresh(ere.getOriginalParent(), true);
-        // this.viewer.refresh(ere.getNewParent(), true);
-        // }
-        // else if(event instanceof EntryMovedEvent) {
-        // EntryMovedEvent eme = (EntryMovedEvent) event;
-        // this.viewer.refresh(eme.getModifiedEntry(), true);
-        // this.viewer.refresh(eme.getOriginalParent(), true);
-        // this.viewer.refresh(eme.getNewParent(), true);
-        // }
-        // else {
-        // this.viewer.refresh(event.getModifiedEntry(), true);
-        // }
-
-        this.viewer.refresh( event.getModifiedEntry(), true );
-    }
-
-
-    public void doubleClick( DoubleClickEvent event )
-    {
-
-        // special behaviour for searches:
-        // perform search on doouble-click but do not expand the tree.
-        // if(event.getSelection() instanceof IStructuredSelection) {
-        // Object obj =
-        // ((IStructuredSelection)event.getSelection()).getFirstElement();
-        //		    
-        // // perform search
-        // if(obj instanceof ISearch) {
-        // ISearch search = (ISearch) obj;
-        // if(search.getSearchResults() == null) {
-        // IAction action = view.getActionGroup().getRefreshAction();
-        // if(action.isEnabled()) {
-        // action.run();
-        // return;
-        // }
-        // }
-        // }
-        // }
-
-        super.doubleClick( event );
-    }
-
-
-    public void partDeactivated( IWorkbenchPartReference partRef )
-    {
-        if ( partRef.getPart( false ) == this.view && contextActivation != null )
-        {
-
-            this.view.getActionGroup().deactivateGlobalActionHandlers();
-
-            IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
-                IContextService.class );
-            contextService.deactivateContext( contextActivation );
-            contextActivation = null;
-        }
-    }
-
-
-    public void partActivated( IWorkbenchPartReference partRef )
-    {
-        if ( partRef.getPart( false ) == this.view )
-        {
-
-            IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
-                IContextService.class );
-            contextActivation = contextService
-                .activateContext( "org.apache.directory.ldapstudio.browser.action.context" );
-            // org.eclipse.ui.contexts.dialogAndWindow
-            // org.eclipse.ui.contexts.window
-            // org.eclipse.ui.text_editor_context
-
-            this.view.getActionGroup().activateGlobalActionHandlers();
+            viewer.refresh( eme.getOldEntry().getParententry(), true );
+            viewer.refresh( eme.getNewEntry().getParententry(), true );
+            viewer.refresh( eme.getNewEntry(), true );
+            viewer.setSelection( new StructuredSelection( eme.getNewEntry() ), true );
         }
-    }
-
-
-    public void partBroughtToTop( IWorkbenchPartReference partRef )
-    {
-    }
-
-
-    public void partClosed( IWorkbenchPartReference partRef )
-    {
-    }
-
-
-    public void partOpened( IWorkbenchPartReference partRef )
-    {
-    }
 
-
-    public void partHidden( IWorkbenchPartReference partRef )
-    {
-    }
-
-
-    public void partVisible( IWorkbenchPartReference partRef )
-    {
-    }
-
-
-    public void partInputChanged( IWorkbenchPartReference partRef )
-    {
+        viewer.refresh( event.getModifiedEntry(), true );
     }
 
 }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/LinkWithEditorAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/LinkWithEditorAction.java?view=diff&rev=509339&r1=509338&r2=509339
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/LinkWithEditorAction.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/browser/LinkWithEditorAction.java Mon Feb 19 13:37:30 2007
@@ -20,23 +20,23 @@
 package org.apache.directory.ldapstudio.browser.ui.views.browser;
 
 
-import org.apache.directory.ldapstudio.browser.core.model.ISearch;
 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
 import org.apache.directory.ldapstudio.browser.ui.editors.entry.EntryEditor;
-import org.apache.directory.ldapstudio.browser.ui.editors.entry.EntryEditorManager;
+import org.apache.directory.ldapstudio.browser.ui.editors.entry.EntryEditorInput;
 import org.apache.directory.ldapstudio.browser.ui.editors.searchresult.SearchResultEditor;
-import org.apache.directory.ldapstudio.browser.ui.editors.searchresult.SearchResultEditorManager;
+import org.apache.directory.ldapstudio.browser.ui.editors.searchresult.SearchResultEditorInput;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.PlatformUI;
 
 
 /**
- * This class implements the Link With Editor Action for the Browser View
+ * This class implements the Link With Editor Action for the Browser View.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
@@ -49,65 +49,65 @@
     /** The listener listening on changes on editors */
     private IPartListener2 editorListener = new IPartListener2()
     {
-        /* (non-Javadoc)
-         * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference)
+        /**
+         * {@inheritDoc}
          */
         public void partBroughtToTop( IWorkbenchPartReference partRef )
         {
         }
 
 
-        /* (non-Javadoc)
-         * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference)
+        /**
+         * {@inheritDoc}
          */
         public void partActivated( IWorkbenchPartReference partRef )
         {
         }
 
 
-        /* (non-Javadoc)
-         * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
+        /**
+         * {@inheritDoc}
          */
         public void partClosed( IWorkbenchPartReference partRef )
         {
         }
 
 
-        /* (non-Javadoc)
-         * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference)
+        /**
+         * {@inheritDoc}
          */
         public void partDeactivated( IWorkbenchPartReference partRef )
         {
         }
 
 
-        /* (non-Javadoc)
-         * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference)
+        /**
+         * {@inheritDoc}
          */
         public void partHidden( IWorkbenchPartReference partRef )
         {
         }
 
 
-        /* (non-Javadoc)
-         * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference)
+        /**
+         * {@inheritDoc}
          */
         public void partInputChanged( IWorkbenchPartReference partRef )
         {
-            linkViewWithEditor( partRef.getId() );
+            linkViewWithEditor( partRef.getPart( false ) );
         }
 
 
-        /* (non-Javadoc)
-         * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference)
+        /**
+         * {@inheritDoc}
          */
         public void partOpened( IWorkbenchPartReference partRef )
         {
         }
 
 
-        /* (non-Javadoc)
-         * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference)
+        /**
+         * {@inheritDoc}
          */
         public void partVisible( IWorkbenchPartReference partRef )
         {
@@ -118,13 +118,12 @@
     /**
      * Creates a new instance of LinkWithEditorAction.
      *
-     * @param view
+     * @param browserView
      *      the associated view
      */
     public LinkWithEditorAction( BrowserView browserView )
     {
         super( "Link with editor", AS_CHECK_BOX );
-        //        super.setActionDefinitionId( Activator.PLUGIN_ID + "linkwitheditorschemasview" );
 
         super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
             BrowserUIConstants.IMG_LINK_WITH_EDITOR ) );
@@ -134,16 +133,16 @@
         super.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
             BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR ) );
 
-        // Enabling the listeners
+        // Enable the listeners
         if ( isChecked() )
         {
-            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener( editorListener );
+            browserView.getSite().getWorkbenchWindow().getPartService().addPartListener( editorListener );
         }
     }
 
 
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.action.Action#run()
+    /**
+     * {@inheritDoc}
      */
     public void run()
     {
@@ -153,24 +152,17 @@
 
         if ( isChecked() )
         {
-            // Enabling the listeners
-            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener( editorListener );
+            // Enable the listener
+            browserView.getSite().getWorkbenchWindow().getPartService().addPartListener( editorListener );
 
-            IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
-                .getActiveEditor();
-            if ( activeEditor instanceof EntryEditor )
-            {
-                linkViewWithEditor( EntryEditor.getId() );
-            }
-            else if ( activeEditor instanceof SearchResultEditor )
-            {
-                linkViewWithEditor( SearchResultEditor.getId() );
-            }
+            // link
+            IEditorPart activeEditor = browserView.getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
+            linkViewWithEditor( activeEditor );
         }
         else
         {
-            // Disabling the listeners
-            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().removePartListener( editorListener );
+            // Disable the listener
+            browserView.getSite().getWorkbenchWindow().getPartService().removePartListener( editorListener );
         }
     }
 
@@ -178,35 +170,46 @@
     /**
      * Links the view with the right editor
      *
-     * @param editorID
-     *      the id of the editor
+     * @param partRef the part
      */
-    private void linkViewWithEditor( String editorID )
+    private void linkViewWithEditor( IWorkbenchPart part )
     {
-        Object objectToSelect = null;
-
-        // Only entry editor and search result editor are accepted
-        if ( editorID.equals( EntryEditor.getId() ) )
+        if ( part != null && browserView != null
+            && part.getSite().getWorkbenchWindow() == browserView.getSite().getWorkbenchWindow() )
         {
-            Object input = EntryEditorManager.getInput();
-            objectToSelect = input;
+            Object objectToSelect = null;
 
-        }
-        else if ( editorID.equals( SearchResultEditor.getId() ) )
-        {
-            ISearch search = SearchResultEditorManager.getInput();
-            objectToSelect = search;
-        }
+            if ( part instanceof EntryEditor )
+            {
+                EntryEditor editor = ( EntryEditor ) part;
+                IEditorInput input = editor.getEditorInput();
+                if ( input != null && input instanceof EntryEditorInput )
+                {
+                    EntryEditorInput eei = ( EntryEditorInput ) input;
+                    objectToSelect = eei.getInput();
+                }
+            }
+            else if ( part instanceof SearchResultEditor )
+            {
+                SearchResultEditor editor = ( SearchResultEditor ) part;
+                IEditorInput input = editor.getEditorInput();
+                if ( input != null && input instanceof SearchResultEditorInput )
+                {
+                    SearchResultEditorInput srei = ( SearchResultEditorInput ) input;
+                    objectToSelect = srei.getSearch();
+                }
+            }
 
-        if ( objectToSelect != null )
-        {
-            // do not select if already selected!
-            // necessary to avoid infinite loops!
-            IStructuredSelection selection = ( IStructuredSelection ) browserView.getMainWidget().getViewer()
-                .getSelection();
-            if ( selection.size() != 1 || !selection.getFirstElement().equals( objectToSelect ) )
+            if ( objectToSelect != null )
             {
-                browserView.select( objectToSelect );
+                // do not select if already selected!
+                // necessary to avoid infinite loops!
+                IStructuredSelection selection = ( IStructuredSelection ) browserView.getMainWidget().getViewer()
+                    .getSelection();
+                if ( selection.size() != 1 || !selection.getFirstElement().equals( objectToSelect ) )
+                {
+                    browserView.select( objectToSelect );
+                }
             }
         }
     }
@@ -219,7 +222,7 @@
     {
         if ( editorListener != null )
         {
-            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().removePartListener( editorListener );
+            browserView.getSite().getWorkbenchWindow().getPartService().removePartListener( editorListener );
             editorListener = null;
         }
 

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionView.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionView.java?view=diff&rev=509339&r1=509338&r2=509339
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionView.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionView.java Mon Feb 19 13:37:30 2007
@@ -26,7 +26,6 @@
 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
 import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionConfiguration;
 import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionWidget;
-
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.SWT;
@@ -37,48 +36,73 @@
 import org.eclipse.ui.part.ViewPart;
 
 
+/**
+ * This class implements the connection view. It displays all connections.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class ConnectionView extends ViewPart
 {
 
+    /** The configuration. */
     private ConnectionConfiguration configuration;
 
+    /** The actions */
     private ConnectionViewActionGroup actionGroup;
 
+    /** The main widget */
     private ConnectionWidget mainWidget;
 
+    /** The listeners */
     private ConnectionViewUniversalListener universalListener;
 
 
+    /**
+     * Returns the connection view ID.
+     * 
+     * @return the connection view ID.
+     */
     public static String getId()
     {
         return ConnectionView.class.getName();
     }
 
 
+    /**
+     * Creates a new instance of ConnectionView.
+     */
     public ConnectionView()
     {
-        super();
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation sets focus to the viewer's control.
+     */
     public void setFocus()
     {
         mainWidget.getViewer().getControl().setFocus();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void dispose()
     {
-        if ( this.configuration != null )
+        if ( configuration != null )
         {
-            this.actionGroup.dispose();
-            this.actionGroup = null;
-            this.configuration.dispose();
-            this.configuration = null;
-            this.universalListener.dispose();
-            this.universalListener = null;
-            this.mainWidget.dispose();
-            this.mainWidget = null;
+            actionGroup.dispose();
+            actionGroup = null;
+            configuration.dispose();
+            configuration = null;
+            universalListener.dispose();
+            universalListener = null;
+            mainWidget.dispose();
+            mainWidget = null;
             getSite().setSelectionProvider( null );
         }
 
@@ -86,6 +110,9 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void createPartControl( Composite parent )
     {
 
@@ -100,54 +127,93 @@
             BrowserUIPlugin.PLUGIN_ID + "." + "tools_connections_view" );
 
         // create configuration
-        this.configuration = new ConnectionConfiguration();
+        configuration = new ConnectionConfiguration();
 
         // create main widget
-        this.mainWidget = new ConnectionWidget( this.configuration, getViewSite().getActionBars() );
-        this.mainWidget.createWidget( composite );
-        this.mainWidget.setInput( BrowserCorePlugin.getDefault().getConnectionManager() );
+        mainWidget = new ConnectionWidget( configuration, getViewSite().getActionBars() );
+        mainWidget.createWidget( composite );
+        mainWidget.setInput( BrowserCorePlugin.getDefault().getConnectionManager() );
 
         // create actions and context menu (and register global actions)
-        this.actionGroup = new ConnectionViewActionGroup( this );
-        this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
-        this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
-        this.actionGroup.enableGlobalActionHandlers( getViewSite().getActionBars() );
-        this.actionGroup.fillContextMenu( this.configuration.getContextMenuManager( this.mainWidget.getViewer() ) );
+        actionGroup = new ConnectionViewActionGroup( this );
+        actionGroup.fillToolBar( mainWidget.getToolBarManager() );
+        actionGroup.fillMenu( mainWidget.getMenuManager() );
+        actionGroup.enableGlobalActionHandlers( getViewSite().getActionBars() );
+        actionGroup.fillContextMenu( configuration.getContextMenuManager( mainWidget.getViewer() ) );
 
         // create the listener
-        getSite().setSelectionProvider( this.mainWidget.getViewer() );
-        this.universalListener = new ConnectionViewUniversalListener( this );
+        getSite().setSelectionProvider( mainWidget.getViewer() );
+        universalListener = new ConnectionViewUniversalListener( this );
 
         // default selection
         IConnection[] connections = BrowserCorePlugin.getDefault().getConnectionManager().getConnections();
         if ( connections.length > 0 )
         {
             ISelection selection = new StructuredSelection( connections[0] );
-            this.mainWidget.getViewer().setSelection( selection );
-            this.universalListener.selectionChanged( this, selection );
+            mainWidget.getViewer().setSelection( selection );
+            //this.universalListener.selectionChanged( this, selection );
         }
 
     }
 
 
+    /**
+     * Selects the given object in the tree. The object
+     * must be an IConnection.
+     * 
+     * @param obj the object to select
+     */
+    public void select( Object obj )
+    {
+        if ( obj instanceof IConnection )
+        {
+            IConnection connection = ( IConnection ) obj;
+
+            mainWidget.getViewer().reveal( connection );
+            mainWidget.getViewer().refresh( connection, true );
+            mainWidget.getViewer().setSelection( new StructuredSelection( connection ), true );
+        }
+    }
+
+
+    /**
+     * Gets the action group.
+     * 
+     * @return the action group
+     */
     public ConnectionViewActionGroup getActionGroup()
     {
         return actionGroup;
     }
 
 
+    /**
+     * Gets the configuration.
+     * 
+     * @return the configuration
+     */
     public ConnectionConfiguration getConfiguration()
     {
         return configuration;
     }
 
 
+    /**
+     * Gets the main widget.
+     * 
+     * @return the main widget
+     */
     public ConnectionWidget getMainWidget()
     {
         return mainWidget;
     }
 
 
+    /**
+     * Gets the universal listener.
+     * 
+     * @return the universal listener
+     */
     public ConnectionViewUniversalListener getUniversalListener()
     {
         return universalListener;

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewActionGroup.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewActionGroup.java?view=diff&rev=509339&r1=509338&r2=509339
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewActionGroup.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewActionGroup.java Mon Feb 19 13:37:30 2007
@@ -39,118 +39,158 @@
 import org.eclipse.ui.actions.ActionFactory;
 
 
+/**
+ * This class manages all the actions of the connection view.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class ConnectionViewActionGroup extends ConnectionActionGroup
 {
+
+    /** The connection view */
     private ConnectionView view;
 
+    /** The link with editor action. */
+    private LinkWithEditorAction linkWithEditorAction;
+
+    /** The Constant selectAllAction. */
     private static final String selectAllAction = "selectAllAction";
 
+    /** The Constant importDsmlAction. */
     private static final String importDsmlAction = "importDsmlAction";
-    
+
+    /** The Constant exportDsmlAction. */
     private static final String exportDsmlAction = "exportDsmlAction";
 
+    /** The Constant importLdifAction. */
     private static final String importLdifAction = "importLdifAction";
 
+    /** The Constant exportLdifAction. */
     private static final String exportLdifAction = "exportLdifAction";
 
+    /** The Constant exportCsvAction. */
     private static final String exportCsvAction = "exportCsvAction";
 
+    /** The Constant exportExcelAction. */
     private static final String exportExcelAction = "exportExcelAction";
 
+    /** The Constant openSchemaBrowserAction. */
     private static final String openSchemaBrowserAction = "openSchemaBrowserAction";
 
+    /** The drag connection listener. */
     private DragConnectionListener dragConnectionListener;
 
+    /** The drop connection listener. */
     private DropConnectionListener dropConnectionListener;
 
 
+    /**
+     * Creates a new instance of ConnectionViewActionGroup and creates
+     * all actions.
+     *
+     * @param view the connection view
+     */
     public ConnectionViewActionGroup( ConnectionView view )
     {
         super( view.getMainWidget(), view.getConfiguration() );
         this.view = view;
         TableViewer viewer = view.getMainWidget().getViewer();
 
-        this.connectionActionMap.put( selectAllAction, new ConnectionViewActionProxy( viewer, new SelectAllAction(
-            viewer ) ) );
-        this.connectionActionMap.put( importDsmlAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
+        linkWithEditorAction = new LinkWithEditorAction( view );
+        connectionActionMap
+            .put( selectAllAction, new ConnectionViewActionProxy( viewer, new SelectAllAction( viewer ) ) );
+        connectionActionMap.put( importDsmlAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
             ImportExportAction.TYPE_IMPORT_DSML ) ) );
-        this.connectionActionMap.put( exportDsmlAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
+        connectionActionMap.put( exportDsmlAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
             ImportExportAction.TYPE_EXPORT_DSML ) ) );
-        this.connectionActionMap.put( importLdifAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
+        connectionActionMap.put( importLdifAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
             ImportExportAction.TYPE_IMPORT_LDIF ) ) );
-        this.connectionActionMap.put( exportLdifAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
+        connectionActionMap.put( exportLdifAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
             ImportExportAction.TYPE_EXPORT_LDIF ) ) );
-        this.connectionActionMap.put( exportCsvAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
+        connectionActionMap.put( exportCsvAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
             ImportExportAction.TYPE_EXPORT_CSV ) ) );
-        this.connectionActionMap.put( exportExcelAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
+        connectionActionMap.put( exportExcelAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
             ImportExportAction.TYPE_EXPORT_EXCEL ) ) );
 
-        this.connectionActionMap.put( openSchemaBrowserAction, new ConnectionViewActionProxy( viewer,
+        connectionActionMap.put( openSchemaBrowserAction, new ConnectionViewActionProxy( viewer,
             new OpenSchemaBrowserAction() ) );
 
         // DND support
-        this.dropConnectionListener = new DropConnectionListener();
-        this.dragConnectionListener = new DragConnectionListener();
+        dropConnectionListener = new DropConnectionListener();
+        dragConnectionListener = new DragConnectionListener();
         int ops = DND.DROP_COPY | DND.DROP_MOVE;
         Transfer[] transfers = new Transfer[]
             { ConnectionTransfer.getInstance(), SearchTransfer.getInstance() };
-        viewer.addDragSupport( ops, transfers, this.dragConnectionListener );
-        viewer.addDropSupport( ops, transfers, this.dropConnectionListener );
+        viewer.addDragSupport( ops, transfers, dragConnectionListener );
+        viewer.addDropSupport( ops, transfers, dropConnectionListener );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void dispose()
     {
-        if ( this.view != null )
+        if ( view != null )
         {
+            linkWithEditorAction.dispose();
+            linkWithEditorAction = null;
 
-            this.dragConnectionListener.dispose();
-            this.dragConnectionListener = null;
-            this.dropConnectionListener.dispose();
-            this.dropConnectionListener = null;
+            dragConnectionListener.dispose();
+            dragConnectionListener = null;
+            dropConnectionListener.dispose();
+            dropConnectionListener = null;
 
-            this.view = null;
+            view = null;
         }
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void menuAboutToShow( IMenuManager menuManager )
     {
 
         // add
-        menuManager.add( ( IAction ) this.connectionActionMap.get( newConnectionAction ) );
+        menuManager.add( ( IAction ) connectionActionMap.get( newConnectionAction ) );
         menuManager.add( new Separator() );
 
         // open/close
-        if ( ( ( IAction ) this.connectionActionMap.get( closeConnectionAction ) ).isEnabled() )
-            menuManager.add( ( IAction ) this.connectionActionMap.get( closeConnectionAction ) );
-        else if ( ( ( IAction ) this.connectionActionMap.get( openConnectionAction ) ).isEnabled() )
-            menuManager.add( ( IAction ) this.connectionActionMap.get( openConnectionAction ) );
+        if ( ( ( IAction ) connectionActionMap.get( closeConnectionAction ) ).isEnabled() )
+        {
+            menuManager.add( ( IAction ) connectionActionMap.get( closeConnectionAction ) );
+        }
+        else if ( ( ( IAction ) connectionActionMap.get( openConnectionAction ) ).isEnabled() )
+        {
+            menuManager.add( ( IAction ) connectionActionMap.get( openConnectionAction ) );
+        }
         menuManager.add( new Separator() );
 
-        menuManager.add( ( IAction ) this.connectionActionMap.get( openSchemaBrowserAction ) );
+        menuManager.add( ( IAction ) connectionActionMap.get( openSchemaBrowserAction ) );
         menuManager.add( new Separator() );
 
         // copy/paste/...
-        menuManager.add( ( IAction ) this.connectionActionMap.get( copyConnectionAction ) );
-        menuManager.add( ( IAction ) this.connectionActionMap.get( pasteConnectionAction ) );
-        menuManager.add( ( IAction ) this.connectionActionMap.get( deleteConnectionAction ) );
-        menuManager.add( ( IAction ) this.connectionActionMap.get( selectAllAction ) );
-        menuManager.add( ( IAction ) this.connectionActionMap.get( renameConnectionAction ) );
+        menuManager.add( ( IAction ) connectionActionMap.get( copyConnectionAction ) );
+        menuManager.add( ( IAction ) connectionActionMap.get( pasteConnectionAction ) );
+        menuManager.add( ( IAction ) connectionActionMap.get( deleteConnectionAction ) );
+        menuManager.add( ( IAction ) connectionActionMap.get( selectAllAction ) );
+        menuManager.add( ( IAction ) connectionActionMap.get( renameConnectionAction ) );
         menuManager.add( new Separator() );
 
         // import/export
         MenuManager importMenuManager = new MenuManager( "Import" );
-        importMenuManager.add( ( IAction ) this.connectionActionMap.get( importLdifAction ) );
-        importMenuManager.add( ( IAction ) this.connectionActionMap.get( importDsmlAction ) );
+        importMenuManager.add( ( IAction ) connectionActionMap.get( importLdifAction ) );
+        importMenuManager.add( ( IAction ) connectionActionMap.get( importDsmlAction ) );
         importMenuManager.add( new Separator() );
         menuManager.add( importMenuManager );
         MenuManager exportMenuManager = new MenuManager( "Export" );
-        exportMenuManager.add( ( IAction ) this.connectionActionMap.get( exportLdifAction ) );
-        exportMenuManager.add( ( IAction ) this.connectionActionMap.get( exportDsmlAction ) );
+        exportMenuManager.add( ( IAction ) connectionActionMap.get( exportLdifAction ) );
+        exportMenuManager.add( ( IAction ) connectionActionMap.get( exportDsmlAction ) );
         exportMenuManager.add( new Separator() );
-        exportMenuManager.add( ( IAction ) this.connectionActionMap.get( exportCsvAction ) );
-        exportMenuManager.add( ( IAction ) this.connectionActionMap.get( exportExcelAction ) );
+        exportMenuManager.add( ( IAction ) connectionActionMap.get( exportCsvAction ) );
+        exportMenuManager.add( ( IAction ) connectionActionMap.get( exportExcelAction ) );
         menuManager.add( exportMenuManager );
         menuManager.add( new Separator() );
 
@@ -158,16 +198,19 @@
         menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
 
         // properties
-        menuManager.add( ( IAction ) this.connectionActionMap.get( propertyDialogAction ) );
+        menuManager.add( ( IAction ) connectionActionMap.get( propertyDialogAction ) );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void activateGlobalActionHandlers()
     {
 
-        if ( this.actionBars != null )
+        if ( actionBars != null )
         {
-            actionBars.setGlobalActionHandler( ActionFactory.SELECT_ALL.getId(), ( IAction ) this.connectionActionMap
+            actionBars.setGlobalActionHandler( ActionFactory.SELECT_ALL.getId(), ( IAction ) connectionActionMap
                 .get( selectAllAction ) );
         }
 
@@ -176,10 +219,13 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void deactivateGlobalActionHandlers()
     {
 
-        if ( this.actionBars != null )
+        if ( actionBars != null )
         {
             actionBars.setGlobalActionHandler( ActionFactory.SELECT_ALL.getId(), null );
         }

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewUniversalListener.java?view=diff&rev=509339&r1=509338&r2=509339
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewUniversalListener.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewUniversalListener.java Mon Feb 19 13:37:30 2007
@@ -25,93 +25,124 @@
 import org.apache.directory.ldapstudio.browser.core.model.IConnection;
 import org.apache.directory.ldapstudio.browser.ui.actions.SelectionUtils;
 import org.apache.directory.ldapstudio.browser.ui.views.browser.BrowserView;
-import org.apache.directory.ldapstudio.browser.ui.views.modificationlogs.ModificationLogsView;
 import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionUniversalListener;
-
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 
 
-public class ConnectionViewUniversalListener extends ConnectionUniversalListener implements ISelectionListener,
-    IDoubleClickListener
+/**
+ * The ConnectionViewUniversalListener manages all events for the connection view.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ConnectionViewUniversalListener extends ConnectionUniversalListener
 {
 
+    /** The connection view */
     protected ConnectionView view;
 
+    /** This listener is used to ensure that the browser view is opened
+     when an object in the connection view is selected */
+    private ISelectionChangedListener viewerSelectionListener = new ISelectionChangedListener()
+    {
+        public void selectionChanged( SelectionChangedEvent event )
+        {
+            IConnection[] connections = SelectionUtils.getConnections( event.getSelection() );
+            if ( connections.length == 1 )
+            {
+                ensureBrowserViewVisible( connections[0] );
+            }
+        }
+    };
+
+    /** This listener opens/closes a connection when double clicking a connection */
+    private IDoubleClickListener viewerDoubleClickListener = new IDoubleClickListener()
+    {
+        public void doubleClick( DoubleClickEvent event )
+        {
+            IConnection[] connections = SelectionUtils.getConnections( event.getSelection() );
+            if ( connections.length == 1 )
+            {
+                toggleConnection( connections[0] );
+            }
+        }
+    };
+
 
+    /**
+     * Creates a new instance of ConnectionViewUniversalListener.
+     *
+     * @param view
+     */
     public ConnectionViewUniversalListener( ConnectionView view )
     {
         super( view.getMainWidget().getViewer() );
         this.view = view;
 
-        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addSelectionListener( this );
-        viewer.addDoubleClickListener( this );
+        // listeners
+        viewer.addSelectionChangedListener( viewerSelectionListener );
+        viewer.addDoubleClickListener( viewerDoubleClickListener );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void dispose()
     {
-        if ( this.view != null )
-        {
-            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removeSelectionListener( this );
-            this.view = null;
-        }
-        if ( viewer != null )
-        {
-            viewer.removeDoubleClickListener( this );
-        }
+        this.view = null;
         super.dispose();
     }
 
 
-    public void selectionChanged( IWorkbenchPart part, ISelection selection )
+    /**
+     * Ensures that the browser view is opended and ready to show the given selection.
+     *
+     * @param selection the view's selection.
+     */
+    private void ensureBrowserViewVisible( IConnection selection )
     {
         if ( this.view != null )
         {
-            if ( part.getClass() == ConnectionView.class )
+            try
+            {
+                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( BrowserView.getId(),
+                    null, IWorkbenchPage.VIEW_VISIBLE );
+            }
+            catch ( PartInitException e )
+            {
+            }
+            catch ( NullPointerException e )
             {
-                IConnection[] connections = SelectionUtils.getConnections( selection );
-                if ( connections.length == 1 )
-                {
-                    BrowserView.setInput( connections[0] );
-                    ModificationLogsView.setInput( connections[0] );
-                }
-                else
-                {
-                    BrowserView.setInput( null );
-                    ModificationLogsView.setInput( null );
-                }
             }
         }
     }
 
 
-    public void doubleClick( DoubleClickEvent event )
+    /**
+     * Opens a closed connections or closes an opened connection. 
+     *
+     * @param connection the connection
+     */
+    private void toggleConnection( IConnection connection )
     {
-        if ( !event.getSelection().isEmpty() )
+        if ( connection.isOpened() )
         {
-            Object o = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
-            if ( o instanceof IConnection )
+            if ( connection.canClose() )
             {
-                IConnection connection = ( IConnection ) o;
-                if ( connection.isOpened() )
-                {
-                    if ( connection.canClose() )
-                    {
-                        connection.close();
-                    }
-                }
-                else
-                {
-                    OpenConnectionsJob ocj = new OpenConnectionsJob( connection );
-                    ocj.execute();
-                }
+                connection.close();
             }
+        }
+        else
+        {
+            OpenConnectionsJob ocj = new OpenConnectionsJob( connection );
+            ocj.execute();
         }
     }
 

Added: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/LinkWithEditorAction.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/LinkWithEditorAction.java?view=auto&rev=509339
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/LinkWithEditorAction.java (added)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/views/connection/LinkWithEditorAction.java Mon Feb 19 13:37:30 2007
@@ -0,0 +1,264 @@
+/*
+ *  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.browser.ui.views.connection;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.editors.entry.EntryEditor;
+import org.apache.directory.ldapstudio.browser.ui.editors.entry.EntryEditorInput;
+import org.apache.directory.ldapstudio.browser.ui.editors.searchresult.SearchResultEditor;
+import org.apache.directory.ldapstudio.browser.ui.editors.searchresult.SearchResultEditorInput;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+
+
+/**
+ * This class implements the Link With Editor Action for the Connection View.
+ * 
+ * This action is not visible to the user, but it listens to to the link 
+ * with editor property of the browser view.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LinkWithEditorAction extends Action
+{
+    /** The connection view */
+    private ConnectionView connectionView;
+
+    /** The listener listening on changes on editors */
+    private IPartListener2 editorListener = new IPartListener2()
+    {
+        /**
+         * {@inheritDoc}
+         */
+        public void partBroughtToTop( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partActivated( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partClosed( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partDeactivated( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partHidden( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partInputChanged( IWorkbenchPartReference partRef )
+        {
+            linkViewWithEditor( partRef.getPart( false ) );
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partOpened( IWorkbenchPartReference partRef )
+        {
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        public void partVisible( IWorkbenchPartReference partRef )
+        {
+        }
+    };
+
+    /** The listener listening on changes of the link with editor action of the browser view */
+    private IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener()
+    {
+
+        /**
+         * {@inheritDoc}
+         */
+        public void propertyChange( PropertyChangeEvent event )
+        {
+            if ( BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR.equals( event.getProperty() ) )
+            {
+                run();
+            }
+        }
+    };
+
+
+    /**
+     * Creates a new instance of LinkWithEditorAction.
+     *
+     * @param connectionView
+     *      the associated view
+     */
+    public LinkWithEditorAction( ConnectionView connectionView )
+    {
+        super( "Link with editor", AS_CHECK_BOX );
+
+        super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+            BrowserUIConstants.IMG_LINK_WITH_EDITOR ) );
+        super.setEnabled( true );
+        this.connectionView = connectionView;
+
+        super.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+            BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR ) );
+
+        // enable the listeners
+        BrowserUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( propertyChangeListener );
+        if ( isChecked() )
+        {
+            connectionView.getSite().getWorkbenchWindow().getPartService().addPartListener( editorListener );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void run()
+    {
+        setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+            BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR ) );
+
+        if ( isChecked() )
+        {
+            // enable the listeners
+            connectionView.getSite().getWorkbenchWindow().getPartService().addPartListener( editorListener );
+
+            // link
+            IEditorPart activeEditor = connectionView.getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
+            linkViewWithEditor( activeEditor );
+        }
+        else
+        {
+            // dsable the listeners
+            connectionView.getSite().getWorkbenchWindow().getPartService().removePartListener( editorListener );
+        }
+    }
+
+
+    /**
+     * Links the view with the right editor
+     *
+     * @param partRef the part
+     */
+    private void linkViewWithEditor( IWorkbenchPart part )
+    {
+        if ( part != null && connectionView != null
+            && part.getSite().getWorkbenchWindow() == connectionView.getSite().getWorkbenchWindow() )
+        {
+            Object objectToSelect = null;
+
+            if ( part instanceof EntryEditor )
+            {
+                EntryEditor editor = ( EntryEditor ) part;
+                IEditorInput input = editor.getEditorInput();
+                if ( input != null && input instanceof EntryEditorInput )
+                {
+                    EntryEditorInput eei = ( EntryEditorInput ) input;
+                    IEntry entry = eei.getResolvedEntry();
+                    if ( entry != null )
+                    {
+                        objectToSelect = entry.getConnection();
+                    }
+                }
+            }
+            else if ( part instanceof SearchResultEditor )
+            {
+                SearchResultEditor editor = ( SearchResultEditor ) part;
+                IEditorInput input = editor.getEditorInput();
+                if ( input != null && input instanceof SearchResultEditorInput )
+                {
+                    SearchResultEditorInput srei = ( SearchResultEditorInput ) input;
+                    ISearch search = srei.getSearch();
+                    if ( search != null )
+                    {
+                        objectToSelect = search.getConnection();
+                    }
+                }
+            }
+
+            if ( objectToSelect != null )
+            {
+                // do not select if already selected!
+                // necessary to avoid infinite loops!
+                IStructuredSelection selection = ( IStructuredSelection ) connectionView.getMainWidget().getViewer()
+                    .getSelection();
+                if ( selection.size() != 1 || !selection.getFirstElement().equals( objectToSelect ) )
+                {
+                    connectionView.select( objectToSelect );
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Disposes this action.
+     */
+    public void dispose()
+    {
+        if ( editorListener != null )
+        {
+            connectionView.getSite().getWorkbenchWindow().getPartService().removePartListener( editorListener );
+            BrowserUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( propertyChangeListener );
+            editorListener = null;
+        }
+
+        connectionView = null;
+    }
+
+}

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserActionGroup.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserActionGroup.java?view=diff&rev=509339&r1=509338&r2=509339
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserActionGroup.java (original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/browser/BrowserActionGroup.java Mon Feb 19 13:37:30 2007
@@ -33,7 +33,6 @@
 import org.apache.directory.ldapstudio.browser.ui.actions.UnfilterChildrenAction;
 import org.apache.directory.ldapstudio.browser.ui.actions.UpAction;
 import org.apache.directory.ldapstudio.browser.ui.actions.proxy.BrowserViewActionProxy;
-
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.action.IMenuManager;
@@ -47,103 +46,145 @@
 import org.eclipse.ui.commands.ICommandService;
 
 
+/**
+ * This class manages all the actions of the browser widget.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class BrowserActionGroup implements IMenuListener
 {
 
+    /** The open sort dialog action. */
     protected OpenSortDialogAction openSortDialogAction;
 
+    /** The collapse all action. */
     protected CollapseAllAction collapseAllAction;
 
+    /** The Constant upAction. */
     protected static final String upAction = "upAction";
 
+    /** The Constant refreshAction. */
     protected static final String refreshAction = "refreshAction";
 
+    /** The Constant filterChildrenAction. */
     protected static final String filterChildrenAction = "filterChildrenAction";
 
+    /** The Constant unfilterChildrenAction. */
     protected static final String unfilterChildrenAction = "unfilterChildrenAction";
 
+    /** The Constant propertyDialogAction. */
     protected static final String propertyDialogAction = "propertyDialogAction";
 
-    protected Map browserActionMap;
+    /** The browser action map. */
+    protected Map<String, BrowserViewActionProxy> browserActionMap;
 
+    /** The action bars. */
     protected IActionBars actionBars;
 
+    /** The browser's main widget. */
     protected BrowserWidget mainWidget;
 
 
+    /**
+     * Creates a new instance of BrowserActionGroup.
+     *
+     * @param mainWidget the browser's main widget
+     * @param configuration the  browser's configuration
+     */
     public BrowserActionGroup( BrowserWidget mainWidget, BrowserConfiguration configuration )
     {
         this.mainWidget = mainWidget;
-        this.browserActionMap = new HashMap();
-        TreeViewer viewer = mainWidget.getViewer();
+        this.browserActionMap = new HashMap<String, BrowserViewActionProxy>();
 
-        this.openSortDialogAction = new OpenSortDialogAction( ( BrowserPreferences ) configuration.getPreferences() );
-        this.collapseAllAction = new CollapseAllAction( viewer );
+        TreeViewer viewer = mainWidget.getViewer();
+        openSortDialogAction = new OpenSortDialogAction( ( BrowserPreferences ) configuration.getPreferences() );
+        collapseAllAction = new CollapseAllAction( viewer );
 
-        this.browserActionMap.put( upAction, new BrowserViewActionProxy( viewer, new UpAction( viewer ) ) );
-        this.browserActionMap.put( refreshAction, new BrowserViewActionProxy( viewer, new RefreshAction() ) );
-        this.browserActionMap
-            .put( filterChildrenAction, new BrowserViewActionProxy( viewer, new FilterChildrenAction() ) );
-        this.browserActionMap.put( unfilterChildrenAction, new BrowserViewActionProxy( viewer,
-            new UnfilterChildrenAction() ) );
-        this.browserActionMap.put( propertyDialogAction, new BrowserViewActionProxy( viewer, new PropertiesAction() ) );
+        browserActionMap.put( upAction, new BrowserViewActionProxy( viewer, new UpAction( viewer ) ) );
+        browserActionMap.put( refreshAction, new BrowserViewActionProxy( viewer, new RefreshAction() ) );
+        browserActionMap.put( filterChildrenAction, new BrowserViewActionProxy( viewer, new FilterChildrenAction() ) );
+        browserActionMap
+            .put( unfilterChildrenAction, new BrowserViewActionProxy( viewer, new UnfilterChildrenAction() ) );
+        browserActionMap.put( propertyDialogAction, new BrowserViewActionProxy( viewer, new PropertiesAction() ) );
     }
 
 
+    /**
+     * Disposes this action group.
+     */
     public void dispose()
     {
-        if ( this.mainWidget != null )
+        if ( mainWidget != null )
         {
 
-            this.openSortDialogAction.dispose();
-            this.openSortDialogAction = null;
-            this.collapseAllAction.dispose();
-            this.collapseAllAction = null;
+            openSortDialogAction.dispose();
+            openSortDialogAction = null;
+            collapseAllAction.dispose();
+            collapseAllAction = null;
 
-            for ( Iterator it = this.browserActionMap.keySet().iterator(); it.hasNext(); )
+            for ( Iterator it = browserActionMap.keySet().iterator(); it.hasNext(); )
             {
                 String key = ( String ) it.next();
-                BrowserViewActionProxy action = ( BrowserViewActionProxy ) this.browserActionMap.get( key );
+                BrowserViewActionProxy action = ( BrowserViewActionProxy ) browserActionMap.get( key );
                 action.dispose();
                 action = null;
                 it.remove();
             }
-            this.browserActionMap.clear();
-            this.browserActionMap = null;
+            browserActionMap.clear();
+            browserActionMap = null;
 
-            this.actionBars = null;
-            this.mainWidget = null;
+            actionBars = null;
+            mainWidget = null;
         }
     }
 
 
+    /**
+     * Enables the action handlers.
+     *
+     * @param actionBars the action bars
+     */
     public void enableGlobalActionHandlers( IActionBars actionBars )
     {
         this.actionBars = actionBars;
-        this.activateGlobalActionHandlers();
+        activateGlobalActionHandlers();
     }
 
 
+    /**
+     * Fills the tool bar.
+     *
+     * @param toolBarManager the tool bar manager
+     */
     public void fillToolBar( IToolBarManager toolBarManager )
     {
-
-        toolBarManager.add( ( IAction ) this.browserActionMap.get( upAction ) );
+        toolBarManager.add( ( IAction ) browserActionMap.get( upAction ) );
         toolBarManager.add( new Separator() );
-        toolBarManager.add( this.collapseAllAction );
-        toolBarManager.add( ( IAction ) this.browserActionMap.get( refreshAction ) );
+        toolBarManager.add( collapseAllAction );
+        toolBarManager.add( ( IAction ) browserActionMap.get( refreshAction ) );
         toolBarManager.update( true );
-
     }
 
 
+    /**
+     * Fills the local menu.
+     *
+     * @param menuManager the local menu manager
+     */
     public void fillMenu( IMenuManager menuManager )
     {
-        menuManager.add( this.openSortDialogAction );
+        menuManager.add( openSortDialogAction );
         menuManager.add( new Separator() );
         menuManager.update( true );
     }
 
 
+    /**
+     * Fills the context menu.
+     *
+     * @param menuManager the context menu manager
+     */
     public void fillContextMenu( IMenuManager menuManager )
     {
         menuManager.setRemoveAllWhenShown( true );
@@ -151,42 +192,47 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation fills the context menu.
+     */
     public void menuAboutToShow( IMenuManager menuManager )
     {
-
         // up
-        menuManager.add( ( IAction ) this.browserActionMap.get( upAction ) );
+        menuManager.add( ( IAction ) browserActionMap.get( upAction ) );
         menuManager.add( new Separator() );
 
         // filter
-        menuManager.add( ( IAction ) this.browserActionMap.get( filterChildrenAction ) );
-        if ( ( ( IAction ) this.browserActionMap.get( unfilterChildrenAction ) ).isEnabled() )
+        menuManager.add( ( IAction ) browserActionMap.get( filterChildrenAction ) );
+        if ( ( ( IAction ) browserActionMap.get( unfilterChildrenAction ) ).isEnabled() )
         {
-            menuManager.add( ( IAction ) this.browserActionMap.get( unfilterChildrenAction ) );
+            menuManager.add( ( IAction ) browserActionMap.get( unfilterChildrenAction ) );
         }
         menuManager.add( new Separator() );
 
         // refresh
-        menuManager.add( ( IAction ) this.browserActionMap.get( refreshAction ) );
+        menuManager.add( ( IAction ) browserActionMap.get( refreshAction ) );
         menuManager.add( new Separator() );
 
         // properties
-        menuManager.add( ( IAction ) this.browserActionMap.get( propertyDialogAction ) );
-
+        menuManager.add( ( IAction ) browserActionMap.get( propertyDialogAction ) );
     }
 
 
+    /**
+     * Activates the action handlers.
+     */
     public void activateGlobalActionHandlers()
     {
-
         ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
             ICommandService.class );
 
-        if ( this.actionBars != null )
+        if ( actionBars != null )
         {
-            actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), ( IAction ) this.browserActionMap
+            actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), ( IAction ) browserActionMap
                 .get( refreshAction ) );
-            actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), ( IAction ) this.browserActionMap
+            actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), ( IAction ) browserActionMap
                 .get( propertyDialogAction ) );
             actionBars.updateActionBars();
         }
@@ -194,31 +240,33 @@
         {
             if ( commandService != null )
             {
-                IAction pda = ( IAction ) this.browserActionMap.get( propertyDialogAction );
+                IAction pda = ( IAction ) browserActionMap.get( propertyDialogAction );
                 pda.setActionDefinitionId( "org.apache.directory.ldapstudio.browser.action.properties" );
                 commandService.getCommand( pda.getActionDefinitionId() ).setHandler( new ActionHandler( pda ) );
 
-                IAction ra = ( IAction ) this.browserActionMap.get( refreshAction );
+                IAction ra = ( IAction ) browserActionMap.get( refreshAction );
                 commandService.getCommand( ra.getActionDefinitionId() ).setHandler( new ActionHandler( ra ) );
             }
         }
 
         if ( commandService != null )
         {
-            IAction ua = ( IAction ) this.browserActionMap.get( upAction );
+            IAction ua = ( IAction ) browserActionMap.get( upAction );
             commandService.getCommand( ua.getActionDefinitionId() ).setHandler( new ActionHandler( ua ) );
         }
-
     }
 
 
+    /**
+     * Deactivates the action handlers.
+     */
     public void deactivateGlobalActionHandlers()
     {
 
         ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
             ICommandService.class );
 
-        if ( this.actionBars != null )
+        if ( actionBars != null )
         {
             actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), null );
             actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), null );
@@ -228,32 +276,31 @@
         {
             if ( commandService != null )
             {
-                IAction pda = ( IAction ) this.browserActionMap.get( propertyDialogAction );
+                IAction pda = ( IAction ) browserActionMap.get( propertyDialogAction );
                 commandService.getCommand( pda.getActionDefinitionId() ).setHandler( null );
 
-                IAction ra = ( IAction ) this.browserActionMap.get( refreshAction );
+                IAction ra = ( IAction ) browserActionMap.get( refreshAction );
                 commandService.getCommand( ra.getActionDefinitionId() ).setHandler( null );
             }
         }
 
         if ( commandService != null )
         {
-            IAction ua = ( IAction ) this.browserActionMap.get( upAction );
+            IAction ua = ( IAction ) browserActionMap.get( upAction );
             commandService.getCommand( ua.getActionDefinitionId() ).setHandler( null );
         }
 
     }
 
 
-    public IAction getRefreshAction()
-    {
-        return ( IAction ) this.browserActionMap.get( refreshAction );
-    }
-
-
+    /**
+     * Sets the connection input to all actions
+     *
+     * @param connection the connection
+     */
     public void setInput( IConnection connection )
     {
-        for ( Iterator it = this.browserActionMap.values().iterator(); it.hasNext(); )
+        for ( Iterator it = browserActionMap.values().iterator(); it.hasNext(); )
         {
             BrowserViewActionProxy action = ( BrowserViewActionProxy ) it.next();
             action.inputChanged( connection );



Mime
View raw message