You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2010/03/22 18:17:33 UTC

svn commit: r926202 - /directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java

Author: seelmann
Date: Mon Mar 22 17:17:32 2010
New Revision: 926202

URL: http://svn.apache.org/viewvc?rev=926202&view=rev
Log:
Fix for DIRSTUDIO-629 (Entry editor tab is activated when executing a search)

Modified:
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java?rev=926202&r1=926201&r2=926202&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java (original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java Mon Mar 22 17:17:32 2010
@@ -27,6 +27,8 @@ import java.util.Map;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
 import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
+import org.apache.directory.studio.entryeditors.EntryEditorExtension;
+import org.apache.directory.studio.entryeditors.EntryEditorInput;
 import org.apache.directory.studio.entryeditors.EntryEditorManager;
 import org.apache.directory.studio.entryeditors.IEntryEditor;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
@@ -336,13 +338,21 @@ public class BrowserViewUniversalListene
             ISearch[] searches = BrowserSelectionUtils.getSearches( selection );
             EntryEditorManager entryEditorManager = BrowserUIPlugin.getDefault().getEntryEditorManager();
 
-            if ( entries.length + searchResults.length + bookmarks.length + searches.length == 1 )
+            if ( entries.length + searchResults.length + bookmarks.length == 1 )
             {
-                if ( ( entries.length == 1 ) || ( searchResults.length == 1 ) || ( bookmarks.length == 1 ) )
-                {
-                    entryEditorManager.openEntryEditor( entries, searchResults, bookmarks );
-                }
-                else if ( searches.length == 1 )
+                entryEditorManager.openEntryEditor( entries, searchResults, bookmarks );
+                // atm it is not necessary to blank the search result editor, it blanks itself
+            }
+            else
+            {
+                // Checking if there's at least one entry editor open.
+                // We need to blank them.
+                // This is done before the search result editor is opened, 
+                // otherwise the entry editor would be activated. 
+                // We can blank them directly here, without using the  OpenEntryEditorRunnable.
+                blankSingleTabEntryEditors();
+
+                if ( searches.length == 1 )
                 {
                     try
                     {
@@ -354,24 +364,14 @@ public class BrowserViewUniversalListene
                     }
                 }
             }
-            // Checking if there's at least one entry editor open.
-            // We need to blank it
-            else if ( isOneOrMoreOpenSingleTabEntryEditors() )
-            {
-                entryEditorManager.openEntryEditor( new IEntry[0], new ISearchResult[0], new IBookmark[0] );
-            }
         }
     }
 
 
     /**
-     * Indicates when one or more single-tab entry editor is (are) open.
-     *
-     * @return
-     *      <code>true</code> if one or more single-tab entry editor is (are) open,
-     *      <code>false</code> if not.
+     * Blanks all single-tab entry editors.
      */
-    private boolean isOneOrMoreOpenSingleTabEntryEditors()
+    private void blankSingleTabEntryEditors()
     {
         IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
         for ( IEditorReference ref : activePage.getEditorReferences() )
@@ -381,15 +381,24 @@ public class BrowserViewUniversalListene
             {
                 IEntryEditor editor = ( IEntryEditor ) part;
                 if ( ( editor != null ) && ( editor.getEntryEditorInput() != null )
+                    && ( editor.getEntryEditorInput().getResolvedEntry() != null )
                     && ( editor.getEntryEditorInput().getExtension() != null )
                     && ( !editor.getEntryEditorInput().getExtension().isMultiWindow() ) )
                 {
-                    return true;
+
+                    EntryEditorExtension extension = editor.getEntryEditorInput().getExtension();
+                    String editorId = extension.getEditorId();
+                    EntryEditorInput input = new EntryEditorInput( ( IEntry ) null, extension );
+                    try
+                    {
+                        view.getSite().getPage().openEditor( input, editorId, false );
+                    }
+                    catch ( PartInitException e )
+                    {
+                    }
                 }
             }
         }
-
-        return false;
     }
 
 
@@ -630,7 +639,7 @@ public class BrowserViewUniversalListene
                     if ( viewer.getExpandedState( child ) )
                     {
                         // In that particular case, we need to remove the child from the tree viewer.
-                        // As it's a costlyÊoperation we're only using this in that particular case,
+                        // As it's a costly�operation we're only using this in that particular case,
                         // and not as default option.
                         viewer.remove( child );
                     }