directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r926769 - in /directory/studio/trunk: ldapbrowser-ui/ ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/ test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/
Date Tue, 23 Mar 2010 20:47:56 GMT
Author: seelmann
Date: Tue Mar 23 20:47:55 2010
New Revision: 926769

URL: http://svn.apache.org/viewvc?rev=926769&view=rev
Log:
Fix for DIRSTUDIO-625 (Add Connection Context in the LDAP Browser Window)
o added connection information for search result editor
o use a matching strategy for the search result editor
o search result editor tab label is now the search name, tooltip is the search URL

Added:
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SingleTabSearchResultEditorMatchingStrategy.java
Modified:
    directory/studio/trunk/ldapbrowser-ui/plugin.xml
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java
    directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorInput.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java

Modified: directory/studio/trunk/ldapbrowser-ui/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/plugin.xml?rev=926769&r1=926768&r2=926769&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/plugin.xml (original)
+++ directory/studio/trunk/ldapbrowser-ui/plugin.xml Tue Mar 23 20:47:55 2010
@@ -74,6 +74,7 @@
        default="true"
        icon="resources/icons/browser_searchresulteditor.gif"
        id="%Editor_SearchResultEditor_id"
+       matchingStrategy="org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SingleTabSearchResultEditorMatchingStrategy"
        name="%Editor_SearchResultEditor_name"/>
  <editor
        class="org.apache.directory.studio.ldapbrowser.ui.editors.schemabrowser.SchemaBrowser"

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java?rev=926769&r1=926768&r2=926769&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java
Tue Mar 23 20:47:55 2010
@@ -54,6 +54,7 @@ import org.eclipse.ui.IEditorSite;
 import org.eclipse.ui.INavigationLocation;
 import org.eclipse.ui.INavigationLocationProvider;
 import org.eclipse.ui.IReusableEditor;
+import org.eclipse.ui.IShowEditorInput;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.part.EditorPart;
@@ -70,7 +71,7 @@ import org.eclipse.ui.part.ShowInContext
  * @version $Rev$, $Date$
  */
 public class SearchResultEditor extends EditorPart implements INavigationLocationProvider,
IReusableEditor,
-    IPropertyChangeListener
+    IShowEditorInput, IPropertyChangeListener
 {
 
     /** The configuration. */
@@ -166,28 +167,36 @@ public class SearchResultEditor extends 
 
         if ( input instanceof SearchResultEditorInput && universalListener != null
)
         {
-            SearchResultEditorInput srei = ( SearchResultEditorInput ) input;
-            ISearch search = srei.getSearch();
+            setPartName( input.getName() );
 
+            SearchResultEditorInput srei = ( SearchResultEditorInput ) input;
             setSearchResultEditorWidgetInput( srei );
-
-            if ( search != null )
-            {
-                // disable one instance hack before firing the input change event 
-                // otherwise the navigation history is cleared.
-                // Note: seems this behavior has been changed with Eclipse 3.3
-                SearchResultEditorInput.enableOneInstanceHack( false );
-                firePropertyChange( IEditorPart.PROP_INPUT );
-
-                // enable one instance hack for marking the location
-                // Note: seems this behavior has been changed with Eclipse 3.3
-                SearchResultEditorInput.enableOneInstanceHack( true );
-                getSite().getPage().getNavigationHistory().markLocation( this );
-            }
         }
+    }
 
-        // finally enable the one instance hack 
-        SearchResultEditorInput.enableOneInstanceHack( true );
+
+    public void showEditorInput( IEditorInput input )
+    {
+        if ( input instanceof SearchResultEditorInput )
+        {
+            /*
+             * Workaround to make link-with-editor working for the single-tab editor:
+             * The call of firePropertyChange is used to inform the link-with-editor action.
+             * However firePropertyChange also modifies the navigation history.
+             * Thus, a dummy input with the real search but dummy flag is set.
+             * This avoids to modification of the navigation history.
+             * Afterwards the real input is set.
+             */
+            SearchResultEditorInput srei = ( SearchResultEditorInput ) input;
+            ISearch search = srei.getSearch();
+            SearchResultEditorInput dummyInput = new SearchResultEditorInput( search, true
);
+            setInput( dummyInput );
+            firePropertyChange( IEditorPart.PROP_INPUT );
+
+            // now set the real input and mark history location
+            setInput( input );
+            getSite().getPage().getNavigationHistory().markLocation( this );
+        }
     }
 
 

Modified: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorInput.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorInput.java?rev=926769&r1=926768&r2=926769&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorInput.java
(original)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorInput.java
Tue Mar 23 20:47:55 2010
@@ -21,6 +21,7 @@
 package org.apache.directory.studio.ldapbrowser.ui.editors.searchresult;
 
 
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
 import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
 import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
@@ -53,8 +54,8 @@ public class SearchResultEditorInput imp
     /** The search input */
     private ISearch search;
 
-    /** One instance hack flag */
-    private static boolean oneInstanceHackEnabled = true;
+    /** Flag indicating this is a dummy input */
+    private boolean dummy;
 
 
     /**
@@ -64,7 +65,20 @@ public class SearchResultEditorInput imp
      */
     public SearchResultEditorInput( ISearch search )
     {
+        this( search, false );
+    }
+
+
+    /**
+     * Creates a new instance of SearchResultEditorInput.
+     * 
+     * @param search the search input
+     * @param dummy the is dummy flag
+     */
+    /*package*/SearchResultEditorInput( ISearch search, boolean dummy )
+    {
         this.search = search;
+        this.dummy = dummy;
     }
 
 
@@ -95,7 +109,12 @@ public class SearchResultEditorInput imp
      */
     public String getName()
     {
-        return Messages.getString( "SearchResultEditorInput.SearchResultEditor" ); //$NON-NLS-1$
+        if ( search != null )
+        {
+            return search.getName();
+        }
+
+        return Messages.getString( "SearchResultEditorContentProvider.NoSearchSelected" );
//$NON-NLS-1$
     }
 
 
@@ -104,7 +123,19 @@ public class SearchResultEditorInput imp
      */
     public String getToolTipText()
     {
-        return Messages.getString( "SearchResultEditorInput.SearchResultEditorToolTip" );
//$NON-NLS-1$
+        if ( search != null )
+        {
+            String toolTipText = search.getUrl().toString();
+
+            IBrowserConnection browserConnection = search.getBrowserConnection();
+            if ( browserConnection != null && browserConnection.getConnection() !=
null )
+            {
+                toolTipText += " - " + browserConnection.getConnection().getName();//$NON-NLS-1$
+            }
+            return toolTipText;
+        }
+
+        return Messages.getString( "SearchResultEditorContentProvider.NoSearchSelected" );
//$NON-NLS-1$
     }
 
 
@@ -144,6 +175,11 @@ public class SearchResultEditorInput imp
      */
     public int hashCode()
     {
+        if ( dummy )
+        {
+            return 0;
+        }
+
         return getToolTipText().hashCode();
     }
 
@@ -153,51 +189,34 @@ public class SearchResultEditorInput imp
      */
     public boolean equals( Object obj )
     {
+        if ( !( obj instanceof SearchResultEditorInput ) )
+        {
+            return false;
+        }
 
-        boolean equal;
+        SearchResultEditorInput other = ( SearchResultEditorInput ) obj;
 
-        if ( oneInstanceHackEnabled )
+        if ( dummy && other.dummy )
         {
-            equal = ( obj instanceof SearchResultEditorInput );
+            return true;
         }
-        else
+        if ( dummy != other.dummy )
         {
-            if ( obj instanceof SearchResultEditorInput )
-            {
-                SearchResultEditorInput other = ( SearchResultEditorInput ) obj;
-                if ( this.search == null && other.search == null )
-                {
-                    return true;
-                }
-                else if ( this.search == null || other.search == null )
-                {
-                    return false;
-                }
-                else
-                {
-                    equal = other.search.equals( this.search );
-                }
-            }
-            else
-            {
-                equal = false;
-            }
+            return false;
         }
 
-        return equal;
-    }
-
-
-    /**
-     * Enables or disabled the one instance hack.
-     *
-     * @param b 
-     *      true to enable the one instance hack,
-     *      false to disable the one instance hack
-     */
-    public static void enableOneInstanceHack( boolean b )
-    {
-        oneInstanceHackEnabled = b;
+        if ( this.search == null && other.search == null )
+        {
+            return true;
+        }
+        else if ( this.search == null || other.search == null )
+        {
+            return false;
+        }
+        else
+        {
+            return other.search.equals( this.search );
+        }
     }
 
 }

Added: directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SingleTabSearchResultEditorMatchingStrategy.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SingleTabSearchResultEditorMatchingStrategy.java?rev=926769&view=auto
==============================================================================
--- directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SingleTabSearchResultEditorMatchingStrategy.java
(added)
+++ directory/studio/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SingleTabSearchResultEditorMatchingStrategy.java
Tue Mar 23 20:47:55 2010
@@ -0,0 +1,51 @@
+/*
+ *  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.studio.ldapbrowser.ui.editors.searchresult;
+
+
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorMatchingStrategy;
+import org.eclipse.ui.IEditorReference;
+
+
+/**
+ * Matching strategy for a single tab search result editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SingleTabSearchResultEditorMatchingStrategy implements IEditorMatchingStrategy
+{
+
+    /**
+     * Returns true if the input is a {@link SearchResultEditorInput}.
+     */
+    public boolean matches( IEditorReference editorRef, IEditorInput input )
+    {
+        if ( !( input instanceof SearchResultEditorInput ) )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+}

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java?rev=926769&r1=926768&r2=926769&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java
Tue Mar 23 20:47:55 2010
@@ -191,7 +191,7 @@ public class SearchTest
         dialogBot.clickSearchButton();
         browserViewBot.selectEntry( "Searches", "Search Admin" );
 
-        SearchResultEditorBot srEditorBot = studioBot.getSearchResultEditorBot( "Search Result
Editor" );
+        SearchResultEditorBot srEditorBot = studioBot.getSearchResultEditorBot( "Search Admin"
);
         srEditorBot.activate();
         assertTrue( srEditorBot.isEnabled() );
 



Mime
View raw message