directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r823166 - /directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java
Date Thu, 08 Oct 2009 13:26:15 GMT
Author: pamarcelot
Date: Thu Oct  8 13:26:14 2009
New Revision: 823166

URL: http://svn.apache.org/viewvc?rev=823166&view=rev
Log:
Fixed the behavior when no single-tab entry editor is open. No empty entry editor is opened
now..

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=823166&r1=823165&r2=823166&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
Thu Oct  8 13:26:14 2009
@@ -28,6 +28,7 @@
 import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry;
 import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
 import org.apache.directory.studio.entryeditors.EntryEditorManager;
+import org.apache.directory.studio.entryeditors.IEntryEditor;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
 import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils;
@@ -67,8 +68,10 @@
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.IEditorReference;
 import org.eclipse.ui.INullSelectionListener;
 import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.IWorkbenchPartReference;
 import org.eclipse.ui.PartInitException;
@@ -349,7 +352,9 @@
                     }
                 }
             }
-            else
+            // 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] );
             }
@@ -358,6 +363,35 @@
 
 
     /**
+     * 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.
+     */
+    private boolean isOneOrMoreOpenSingleTabEntryEditors()
+    {
+        IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+        for ( IEditorReference ref : activePage.getEditorReferences() )
+        {
+            IWorkbenchPart part = ref.getPart( false );
+            if ( part != null && part instanceof IEntryEditor )
+            {
+                IEntryEditor editor = ( IEntryEditor ) part;
+                if ( ( editor != null ) && ( editor.getEntryEditorInput() != null
)
+                    && ( editor.getEntryEditorInput().getExtension() != null )
+                    && ( !editor.getEntryEditorInput().getExtension().isMultiWindow()
) )
+                {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
+
+
+    /**
      * {@inheritDoc}
      */
     public void dispose()



Mime
View raw message