directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r754856 - in /directory/studio/trunk: ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/ ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ ldapbrowser-core/src/m...
Date Mon, 16 Mar 2009 10:18:28 GMT
Author: seelmann
Date: Mon Mar 16 10:18:28 2009
New Revision: 754856

URL: http://svn.apache.org/viewvc?rev=754856&view=rev
Log:
DIRSTUDIO-335:
o history of recently used search attributes
o don't escape '*' in search value
o let quick search widget enabled when quick search is selected
o added tooltips

Modified:
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserQuickSearchWidget.java
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/messages.properties
    directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/messages_de.properties
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IQuickSearch.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/QuickSearch.java

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserQuickSearchWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserQuickSearchWidget.java?rev=754856&r1=754855&r2=754856&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserQuickSearchWidget.java
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserQuickSearchWidget.java
Mon Mar 16 10:18:28 2009
@@ -36,11 +36,11 @@
 import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IQuickSearch;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch.SearchScope;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.QuickSearch;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
-import org.apache.directory.studio.ldapbrowser.core.utils.LdapFilterUtils;
 import org.eclipse.jface.fieldassist.ComboContentAdapter;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -71,6 +71,10 @@
     public static final String VALUE_HISTORY_DIALOGSETTING_KEY = BrowserQuickSearchWidget.class.getName()
         + ".valueHistory"; //$NON-NLS-1$
 
+    /** The Constant ATTRIBUTE_HISTORY_DIALOGSETTING_KEY. */
+    public static final String ATTRIBUTE_HISTORY_DIALOGSETTING_KEY = BrowserQuickSearchWidget.class.getName()
+        + ".attributeHistory"; //$NON-NLS-1$
+
     /** An empty string array */
     private static final String[] EMPTY = new String[0];
 
@@ -135,6 +139,21 @@
         {
             BrowserCommonActivator.getDefault().getDialogSettings().put( VALUE_HISTORY_DIALOGSETTING_KEY,
EMPTY );
         }
+        if ( BrowserCommonActivator.getDefault().getDialogSettings().get( ATTRIBUTE_HISTORY_DIALOGSETTING_KEY
) == null )
+        {
+            BrowserCommonActivator.getDefault().getDialogSettings().put( ATTRIBUTE_HISTORY_DIALOGSETTING_KEY,
+                new String[]
+                    { "cn", //$NON-NLS-1$
+                        "sn", //$NON-NLS-1$
+                        "givenName", //$NON-NLS-1$
+                        "mail", //$NON-NLS-1$
+                        "uid", //$NON-NLS-1$
+                        "description", //$NON-NLS-1$
+                        "o", //$NON-NLS-1$
+                        "ou", //$NON-NLS-1$
+                        "member" //$NON-NLS-1$
+                    } );
+        }
     }
 
 
@@ -166,8 +185,9 @@
 
         innerComposite = BaseWidgetUtils.createColumnContainer( composite, 5, 1 );
 
-        quickSearchAttributeCombo = BaseWidgetUtils.createCombo( innerComposite, EMPTY, -1,
1 );
-        quickSearchAttributePP = new ListContentProposalProvider( EMPTY );
+        String[] attributes = HistoryUtils.load( ATTRIBUTE_HISTORY_DIALOGSETTING_KEY );
+        quickSearchAttributeCombo = BaseWidgetUtils.createCombo( innerComposite, attributes,
-1, 1 );
+        quickSearchAttributePP = new ListContentProposalProvider( attributes );
         new ExtendedContentAssistCommandAdapter( quickSearchAttributeCombo, new ComboContentAdapter(),
             quickSearchAttributePP, null, null, true );
         quickSearchAttributeCombo.addModifyListener( new ModifyListener()
@@ -250,6 +270,10 @@
             return;
         }
 
+        HistoryUtils.save( ATTRIBUTE_HISTORY_DIALOGSETTING_KEY, quickSearchAttributeCombo.getText()
);
+        String[] attributes = HistoryUtils.load( ATTRIBUTE_HISTORY_DIALOGSETTING_KEY );
+        quickSearchAttributeCombo.setItems( attributes );
+        quickSearchAttributeCombo.select( 0 );
         HistoryUtils.save( VALUE_HISTORY_DIALOGSETTING_KEY, quickSearchValueCombo.getText()
);
         String[] values = HistoryUtils.load( VALUE_HISTORY_DIALOGSETTING_KEY );
         quickSearchValueCombo.setItems( values );
@@ -258,7 +282,7 @@
 
         IBrowserConnection conn = entry.getBrowserConnection();
 
-        QuickSearch quickSearch = new QuickSearch();
+        QuickSearch quickSearch = new QuickSearch( entry );
         quickSearch.setName( "Quick Search" );
         quickSearch.setBrowserConnection( conn );
         quickSearch.setSearchBase( entry.getDn() );
@@ -277,7 +301,15 @@
         }
         filter.append( quickSearchAttributeCombo.getText() );
         filter.append( "!=".equals( quickSearchOperatorCombo.getText() ) ? "=" : quickSearchOperatorCombo.getText()
);
-        filter.append( LdapFilterUtils.getEncodedValue( quickSearchValueCombo.getText() )
);
+
+        // only escape '\', '(', ')', and '\u0000'
+        // don't escape '*' to allow substring search
+        String value = quickSearchValueCombo.getText();
+        value = value.replaceAll( "\\\\", "\\\\5c" );
+        value = value.replaceAll( "\u0000", "\\\\00" );
+        value = value.replaceAll( "\\(", "\\\\28" );
+        value = value.replaceAll( "\\)", "\\\\29" );
+        filter.append( value );
         if ( "!=".equals( quickSearchOperatorCombo.getText() ) )
         {
             filter.append( ")" );
@@ -298,11 +330,18 @@
     {
         ISelection selection = browserWidget.getViewer().getSelection();
         IEntry[] entries = BrowserSelectionUtils.getEntries( selection );
+        ISearch[] searches = BrowserSelectionUtils.getSearches( selection );
         if ( entries != null && entries.length == 1 )
         {
             IEntry entry = entries[0];
             return entry;
         }
+        else if ( searches != null && searches.length == 1 && ( searches[0]
instanceof IQuickSearch ) )
+        {
+            IQuickSearch quickSearch = ( IQuickSearch ) searches[0];
+            IEntry entry = quickSearch.getSearchBaseEntry();
+            return entry;
+        }
         else
         {
             return null;
@@ -350,7 +389,7 @@
      * 
      * @param enabled true to enable this quick search widget, false to disable it
      */
-    public void setEnabled( boolean enabled )
+    private void setEnabled( boolean enabled )
     {
         if ( composite != null && !composite.isDisposed() )
         {
@@ -374,8 +413,10 @@
             }
             else
             {
-                quickSearchAttributeCombo.setToolTipText( Messages.getString( "BrowserQuickSearchWidget.SearchAttribute"
) ); //$NON-NLS-1$
-                quickSearchOperatorCombo.setToolTipText( Messages.getString( "BrowserQuickSearchWidget.SearchOperator"
) ); //$NON-NLS-1$
+                quickSearchAttributeCombo.setToolTipText( Messages
+                    .getString( "BrowserQuickSearchWidget.SearchAttribute" ) ); //$NON-NLS-1$
+                quickSearchOperatorCombo
+                    .setToolTipText( Messages.getString( "BrowserQuickSearchWidget.SearchOperator"
) ); //$NON-NLS-1$
                 quickSearchValueCombo.setToolTipText( Messages.getString( "BrowserQuickSearchWidget.SearchValue"
) ); //$NON-NLS-1$
                 parent.setToolTipText( null );
             }
@@ -432,7 +473,6 @@
                 atdNames = EMPTY;
                 setEnabled( false );
             }
-            quickSearchAttributeCombo.setItems( atdNames );
             quickSearchAttributePP.setProposals( Arrays.asList( atdNames ) );
         }
     }

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/messages.properties?rev=754856&r1=754855&r2=754856&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/messages.properties
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/messages.properties
Mon Mar 16 10:18:28 2009
@@ -48,7 +48,7 @@
 BrowserQuickSearchWidget.RunQuickSearch=Run Quick Search
 BrowserQuickSearchWidget.ScopeOneLevelToolTip=Search one level only
 BrowserQuickSearchWidget.ScopeSubtreeToolTip=Search whole subtree
-BrowserQuickSearchWidget.SearchAttribute=Search Attribute
-BrowserQuickSearchWidget.SearchOperator=Search Operator, one of 'equal', 'not equal', 'less
than or equal', 'greater then or equal', 'approximately'
-BrowserQuickSearchWidget.SearchValue=Search Value
+BrowserQuickSearchWidget.SearchAttribute=Search Attribute: Type in a search attribute or
select a recently used search attribute from the list.
+BrowserQuickSearchWidget.SearchOperator=Search Operator. Select one of 'equal', 'not equal',
'less than or equal', 'greater then or equal' or 'approximately'
+BrowserQuickSearchWidget.SearchValue=Search Value: Type in a search value or select a recently
used search value from the list.
 BrowserQuickSearchWidget.DisabledToolTipText=Please select one search base entry to activate
quick search.

Modified: directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/messages_de.properties?rev=754856&r1=754855&r2=754856&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/messages_de.properties
(original)
+++ directory/studio/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/messages_de.properties
Mon Mar 16 10:18:28 2009
@@ -48,7 +48,7 @@
 BrowserQuickSearchWidget.RunQuickSearch=Schnellsuche ausführen
 BrowserQuickSearchWidget.ScopeOneLevelToolTip=Nur eine Ebene durchsuchen (One Level)
 BrowserQuickSearchWidget.ScopeSubtreeToolTip=Gesamten Teilbaum durchsuchen (Subtree)
-BrowserQuickSearchWidget.SearchAttribute=Suchattribut
-BrowserQuickSearchWidget.SearchOperator=Suchoperation: 'gleich', 'ungleich', 'kleiner oder
gleich', 'größer oder gleich', 'ungefähr'
-BrowserQuickSearchWidget.SearchValue=Suchwert
+BrowserQuickSearchWidget.SearchAttribute=Suchattribut: Geben Sie ein Suchattribut ein oder
wählen Sie ein kürzlich verwendetes Attribut aus der Liste aus
+BrowserQuickSearchWidget.SearchOperator=Suchoperation: 'gleich', 'ungleich', 'kleiner oder
gleich', 'größer oder gleich' oder 'ungefähr'
+BrowserQuickSearchWidget.SearchValue=Suchwert: Geben Sie einen Suchwert ein oder wählen
Sie einen kürzlich verwendeten Suchwert aus der Liste aus
 BrowserQuickSearchWidget.DisabledToolTipText=Bitte einen Basis-Eintrag für die Schnellsuche
auswählen

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IQuickSearch.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IQuickSearch.java?rev=754856&r1=754855&r2=754856&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IQuickSearch.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IQuickSearch.java
Mon Mar 16 10:18:28 2009
@@ -30,4 +30,12 @@
  */
 public interface IQuickSearch extends ISearch
 {
+
+    /**
+     * Gets the search base entry.
+     * 
+     * @return the search base entry
+     */
+    public IEntry getSearchBaseEntry();
+
 }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/QuickSearch.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/QuickSearch.java?rev=754856&r1=754855&r2=754856&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/QuickSearch.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/QuickSearch.java
Mon Mar 16 10:18:28 2009
@@ -21,6 +21,7 @@
 package org.apache.directory.studio.ldapbrowser.core.model.impl;
 
 
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.IQuickSearch;
 
 
@@ -33,4 +34,24 @@
 public class QuickSearch extends Search implements IQuickSearch
 {
     private static final long serialVersionUID = 4387604973869066354L;
+
+    /** The search base entry. */
+    private IEntry searchBaseEntry;
+
+
+    /**
+     * Instantiates a new quick search.
+     * 
+     * @param searchBaseEntry the search base entry
+     */
+    public QuickSearch( IEntry searchBaseEntry )
+    {
+        this.searchBaseEntry = searchBaseEntry;
+    }
+
+
+    public IEntry getSearchBaseEntry()
+    {
+        return searchBaseEntry;
+    }
 }



Mime
View raw message