001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.spi.editor.completion;
043:
044: /**
045: * The inteface of a task performing a code completion query.
046: * <br>
047: * The support class
048: * {@link org.netbeans.spi.editor.completion.support.AsyncCompletionTask}
049: * can be used for convenience when the task requires an asynchronous evaluation.
050: *
051: * @see CompletionProvider
052: *
053: * @author Miloslav Metelka, Dusan Balek
054: * @version 1.01
055: */
056:
057: public interface CompletionTask {
058:
059: /**
060: * Called by the code completion infrastructure to ask the task
061: * to do a query and return the results through the given completion listener.
062: * <br>
063: * This method is called only once during the lifetime of the completion task
064: * object.
065: *
066: * <p>
067: * This method is always called in AWT thread but it may reschedule
068: * its processing into another thread and fire the given listener
069: * once the computing is finished.
070: *
071: * @param resultSet non-null result set to which the results
072: * of the query must be added.
073: */
074: public void query(CompletionResultSet resultSet);
075:
076: /**
077: * Called by the code completion infrastructure to inform the task about
078: * changes in the corresponding document. The task should reflect these
079: * changes while creating the query result.
080: * <br>
081: * This method can be called multiple times on a single task instance.
082: * <br>
083: * Typically it is called AFTER the <code>query()</code> was invoked
084: * but it may also be invoked BEFORE the <code>query()</code> in case
085: * the user types even before the <code>query()</code>
086: * was called by the infrastructure. In such
087: * case the <code>resultSet</code> parameter will be <code>null</code>.
088: * <br>
089: * It is guaranteed that this method will not be invoked in case
090: * the document instance set in the component would change since the last invocation
091: * of either the <code>query()</code> or <code>refresh()</code>.
092: *
093: * <p>
094: * This method is always called in AWT thread but it may reschedule
095: * its processing into another thread and fire the given listener
096: * once the computing is finished.
097: *
098: * @param resultSet non-null result set to which the results
099: * of the refreshing must be added.
100: * <br/>
101: * Null result set may be passed in case the <code>query()</code>
102: * was not invoked yet and user has typed a character. In this case
103: * the provider may hide the completion
104: * by using <code>Completion.get().hideAll()</code>
105: * if the typed character is inappropriate e.g. ";" for java completion.
106: */
107: public void refresh(CompletionResultSet resultSet);
108:
109: /**
110: * Called by the code completion infrastructure to cancel the task.
111: * <br>
112: * Once the cancel is done on the task no more querying or refreshing
113: * is done on it.
114: *
115: * <p>
116: * This method may potentially be called from any thread.
117: */
118: public void cancel();
119:
120: }
|