KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > editor > completion > CompletionProvider


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.spi.editor.completion;
21
22 import javax.swing.text.JTextComponent JavaDoc;
23
24 /**
25  * The basic interface of the code completion querying SPI. Various implementations can
26  * be registered per a document mime-type.
27  *
28  * @author Miloslav Metelka, Dusan Balek
29  * @version 1.01
30  */

31
32 public interface CompletionProvider {
33
34     /**
35      * The <code>int</code> value representing the query for a code completion.
36      */

37     public static final int COMPLETION_QUERY_TYPE = 1;
38
39     /**
40      * The <code>int</code> value representing the query for a documentation.
41      */

42     public static final int DOCUMENTATION_QUERY_TYPE = 2;
43     
44     /**
45      * The <code>int</code> value representing the query for a tooltip hint.
46      */

47     public static final int TOOLTIP_QUERY_TYPE = 4;
48
49     /**
50      * The <code>int</code> value representing the query for an all code completion.
51      */

52     public static final int COMPLETION_ALL_QUERY_TYPE = 9;
53
54     /**
55      * Creates a task that performs a query of the given type on the given component.
56      * <br>
57      * This method is invoked in AWT thread only and the returned task
58      * may either be synchronous (if it's not complex)
59      * or it may be asynchonous
60      * (see {@link org.netbeans.spi.editor.completion.support.AsyncCompletionTask}).
61      * <br>
62      * The task usually inspects the component's document, the
63      * text up to the caret position and returns the appropriate result.
64      *
65      * @param queryType a type ot the query. It can be one of the {@link #COMPLETION_QUERY_TYPE},
66      * {@link #COMPLETION_ALL_QUERY_TYPE}, {@link #DOCUMENTATION_QUERY_TYPE},
67      * or {@link #TOOLTIP_QUERY_TYPE} (but not their combination).
68      * @param component a component on which the query is performed
69      *
70      * @return a task performing the query.
71      */

72     public CompletionTask createTask(int queryType, JTextComponent JavaDoc component);
73
74     /**
75      * Called by the code completion infrastructure to check whether a text just typed
76      * into a text component triggers an automatic query invocation.
77      * <br>
78      * If the particular query type is returned the infrastructure
79      * will then call {@link #createTask(int, JTextComponent)}.
80      *
81      * @param component a component in which typing appeared
82      * @param typedText a typed text
83      *
84      * @return a combination of the {@link #COMPLETION_QUERY_TYPE}, {@link #COMPLETION_ALL_QUERY_TYPE},
85      * {@link #DOCUMENTATION_QUERY_TYPE}, and {@link #TOOLTIP_QUERY_TYPE}
86      * values, or zero if no query should be automatically invoked.
87      */

88     public int getAutoQueryTypes(JTextComponent JavaDoc component, String JavaDoc typedText);
89
90 }
91
Popular Tags