KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > aciitemeditor > sourceeditor > ACIContentAssistProcessor


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20 package org.apache.directory.ldapstudio.aciitemeditor.sourceeditor;
21
22
23 import java.util.ArrayList JavaDoc;
24 import java.util.Arrays JavaDoc;
25 import java.util.List JavaDoc;
26
27 import org.apache.directory.ldapstudio.aciitemeditor.ACIITemConstants;
28 import org.apache.directory.ldapstudio.aciitemeditor.Activator;
29 import org.eclipse.jface.text.IRegion;
30 import org.eclipse.jface.text.ITextViewer;
31 import org.eclipse.jface.text.contentassist.ICompletionProposal;
32 import org.eclipse.jface.text.contentassist.IContextInformation;
33 import org.eclipse.jface.text.contentassist.IContextInformationValidator;
34 import org.eclipse.jface.text.templates.Template;
35 import org.eclipse.jface.text.templates.TemplateCompletionProcessor;
36 import org.eclipse.jface.text.templates.TemplateContextType;
37 import org.eclipse.swt.graphics.Image;
38
39
40 /**
41  * This class implements the Content Assist Processor for ACI Item
42  *
43  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
44  * @version $Rev$, $Date$
45  */

46 public class ACIContentAssistProcessor extends TemplateCompletionProcessor
47 {
48     /* (non-Javadoc)
49      * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
50      */

51     public ICompletionProposal[] computeCompletionProposals( ITextViewer viewer, int offset )
52     {
53         List JavaDoc<ICompletionProposal> proposalList = new ArrayList JavaDoc<ICompletionProposal>();
54
55         // Add context dependend template proposals
56
ICompletionProposal[] templateProposals = super.computeCompletionProposals( viewer, offset );
57         if ( templateProposals != null )
58         {
59             proposalList.addAll( Arrays.asList( templateProposals ) );
60         }
61
62         return ( ICompletionProposal[] ) proposalList.toArray( new ICompletionProposal[0] );
63     }
64
65
66     /* (non-Javadoc)
67      * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
68      */

69     public IContextInformation[] computeContextInformation( ITextViewer viewer, int offset )
70     {
71         return null;
72     }
73
74
75     /* (non-Javadoc)
76      * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getCompletionProposalAutoActivationCharacters()
77      */

78     public char[] getCompletionProposalAutoActivationCharacters()
79     {
80
81         char[] chars = new char[52];
82         for ( int i = 0; i < 26; i++ )
83         {
84             chars[i] = ( char ) ( 'a' + i );
85         }
86         for ( int i = 0; i < 26; i++ )
87         {
88             chars[i + 26] = ( char ) ( 'A' + i );
89         }
90
91         return chars;
92     }
93
94
95     /* (non-Javadoc)
96      * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getContextInformationAutoActivationCharacters()
97      */

98     public char[] getContextInformationAutoActivationCharacters()
99     {
100         return null;
101     }
102
103
104     /* (non-Javadoc)
105      * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getContextInformationValidator()
106      */

107     public IContextInformationValidator getContextInformationValidator()
108     {
109         return null;
110     }
111
112
113     /* (non-Javadoc)
114      * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getErrorMessage()
115      */

116     public String JavaDoc getErrorMessage()
117     {
118         return null;
119     }
120
121
122     /* (non-Javadoc)
123      * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getContextType(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
124      */

125     @Override JavaDoc
126     protected TemplateContextType getContextType( ITextViewer viewer, IRegion region )
127     {
128         return Activator.getDefault().getAciTemplateContextTypeRegistry().getContextType(
129             ACIITemConstants.ACI_ITEM_TEMPLATE_ID );
130     }
131
132
133     /* (non-Javadoc)
134      * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getImage(org.eclipse.jface.text.templates.Template)
135      */

136     @Override JavaDoc
137     protected Image getImage( Template template )
138     {
139         return null;
140     }
141
142
143     /* (non-Javadoc)
144      * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getTemplates(java.lang.String)
145      */

146     @Override JavaDoc
147     protected Template[] getTemplates( String JavaDoc contextTypeId )
148     {
149         return Activator.getDefault().getAciTemplateStore().getTemplates( contextTypeId );
150     }
151 }
152
Popular Tags