directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r514297 - /directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/search/ReturningAttributesContentAssistProcessor.java
Date Sun, 04 Mar 2007 00:49:36 GMT
Author: seelmann
Date: Sat Mar  3 16:49:35 2007
New Revision: 514297

URL: http://svn.apache.org/viewvc?view=rev&rev=514297
Log:
Made proposals case-insensitive, Code cleaning, Javadoc

Modified:
    directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/search/ReturningAttributesContentAssistProcessor.java

Modified: directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/search/ReturningAttributesContentAssistProcessor.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/search/ReturningAttributesContentAssistProcessor.java?view=diff&rev=514297&r1=514296&r2=514297
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/search/ReturningAttributesContentAssistProcessor.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-ui/src/main/java/org/apache/directory/ldapstudio/browser/ui/widgets/search/ReturningAttributesContentAssistProcessor.java
Sat Mar  3 16:49:35 2007
@@ -23,7 +23,10 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import org.eclipse.jface.contentassist.IContentAssistSubjectControl;
 import org.eclipse.jface.contentassist.ISubjectControlContentAssistProcessor;
@@ -35,51 +38,97 @@
 import org.eclipse.jface.text.contentassist.IContextInformationValidator;
 
 
+/**
+ * The ReturningAttributesContentAssistProcessor provides proposals for the 
+ * {@link ReturningAttributesWidget}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class ReturningAttributesContentAssistProcessor implements ISubjectControlContentAssistProcessor
 {
 
+    /** The auto activation characters */
     private char[] autoActivationCharacters;
 
+    /** The possible attribute types */
     private String[] possibleAttributeTypes;
 
 
+    /**
+     * Creates a new instance of ReturningAttributesContentAssistProcessor.
+     *
+     * @param possibleAttributeNames
+     */
     public ReturningAttributesContentAssistProcessor( String[] possibleAttributeNames )
     {
         super();
-        this.setPossibleAttributeTypes( possibleAttributeNames );
+        setPossibleAttributeTypes( possibleAttributeTypes );
+    }
 
-        this.autoActivationCharacters = new char[26 + 26];
-        int i = 0;
-        for ( char c = 'a'; c <= 'z'; c++, i++ )
-        {
-            this.autoActivationCharacters[i] = c;
-        }
-        for ( char c = 'A'; c <= 'Z'; c++, i++ )
-        {
-            this.autoActivationCharacters[i] = c;
-        }
+
+    /**
+     * {@inheritDoc}
+     */
+    public char[] getCompletionProposalAutoActivationCharacters()
+    {
+        return autoActivationCharacters;
     }
 
 
+    /**
+     * Sets the possible attribute types.
+     * 
+     * @param possibleAttributeTypes the possible strings
+     */
     public void setPossibleAttributeTypes( String[] possibleAttributeTypes )
     {
+        if ( possibleAttributeTypes == null )
+        {
+            possibleAttributeTypes = new String[0];
+        }
+
+        // set possible strings
         Arrays.sort( possibleAttributeTypes );
         this.possibleAttributeTypes = possibleAttributeTypes;
-    }
-
 
-    public char[] getCompletionProposalAutoActivationCharacters()
-    {
-        return this.autoActivationCharacters;
+        // set auto activation characters
+        Set<Character> characterSet = new HashSet<Character>();
+        for ( int i = 0; i < possibleAttributeTypes.length; i++ )
+        {
+            String string = possibleAttributeTypes[i];
+            for ( int k = 0; k < string.length(); k++ )
+            {
+                char ch = string.charAt( k );
+                characterSet.add( Character.toLowerCase( ch ) );
+                characterSet.add( Character.toUpperCase( ch ) );
+            }
+        }
+        autoActivationCharacters = new char[characterSet.size()];
+        int i = 0;
+        for ( Iterator<Character> it = characterSet.iterator(); it.hasNext(); )
+        {
+            Character ch = it.next();
+            autoActivationCharacters[i] = ch.charValue();
+            i++;
+        }
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation always returns null.
+     */
     public ICompletionProposal[] computeCompletionProposals( ITextViewer viewer, int offset
)
     {
         return null;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public ICompletionProposal[] computeCompletionProposals( IContentAssistSubjectControl
contentAssistSubjectControl,
         int documentOffset )
     {
@@ -97,33 +146,48 @@
         }
         String attribute = text.substring( start, documentOffset );
 
-        List proposalList = new ArrayList();
-        for ( int k = 0; k < this.possibleAttributeTypes.length; k++ )
+        List<ICompletionProposal> proposalList = new ArrayList<ICompletionProposal>();
+        for ( int k = 0; k < possibleAttributeTypes.length; k++ )
         {
-            if ( this.possibleAttributeTypes[k].startsWith( attribute ) )
+            if ( possibleAttributeTypes[k].toUpperCase().startsWith( attribute.toUpperCase()
) )
             {
-                ICompletionProposal proposal = new CompletionProposal( this.possibleAttributeTypes[k]
+ ", ", start,
-                    documentOffset - start, this.possibleAttributeTypes[k].length() + 2,
null,
-                    this.possibleAttributeTypes[k], null, null );
+                ICompletionProposal proposal = new CompletionProposal( possibleAttributeTypes[k]
+ ", ", start,
+                    documentOffset - start, possibleAttributeTypes[k].length() + 2, null,
possibleAttributeTypes[k],
+                    null, null );
                 proposalList.add( proposal );
             }
         }
-        return ( ICompletionProposal[] ) proposalList.toArray( new ICompletionProposal[0]
);
+        return proposalList.toArray( new ICompletionProposal[proposalList.size()] );
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation always returns null.
+     */
     public char[] getContextInformationAutoActivationCharacters()
     {
         return null;
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation always returns null.
+     */
     public IContextInformation[] computeContextInformation( ITextViewer viewer, int offset
)
     {
         return null;
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation always returns null.
+     */
     public IContextInformation[] computeContextInformation( IContentAssistSubjectControl
contentAssistSubjectControl,
         int documentOffset )
     {
@@ -131,14 +195,25 @@
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation always returns null.
+     */
     public String getErrorMessage()
     {
         return null;
     }
 
 
+    /**
+     * {@inheritDoc}
+     * 
+     * This implementation always returns null.
+     */
     public IContextInformationValidator getContextInformationValidator()
     {
         return null;
     }
+
 }



Mime
View raw message