|
org.netbeans.modules.editor.completion/1 1.6.22 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.netbeans.spi.editor.completion.support.AsyncCompletionQuery
public abstract class AsyncCompletionQuery
Defines query processing of an asynchronous completion task.
The query(CompletionResultSet, Document, int)
abstract method
needs to be implemented to define the asynchronous querying behavior.
In addition filtering of the result set computed during querying
can be implemented by overriding the
canFilter(JTextComponent)
and filter(CompletionResultSet)
.
Constructor Summary | |
---|---|
AsyncCompletionQuery()
|
Method Summary | |
---|---|
protected boolean |
canFilter(JTextComponent component)
Check whether the query results can successfully be filtered. |
protected void |
filter(CompletionResultSet resultSet)
Filter the data collected during the last query(CompletionResultSet, Document, int) invocation. |
boolean |
isTaskCancelled()
Check whether the task corresponding to this query was cancelled. |
protected void |
prepareQuery(JTextComponent component)
Collect additional information in AWT thread before query(CompletionResultSet, Document, int)
is called asynchronously. |
protected void |
preQueryUpdate(JTextComponent component)
Called in response to CompletionTask.refresh(null) . |
protected abstract void |
query(CompletionResultSet resultSet,
Document doc,
int caretOffset)
Perform the query and add results to the given result set. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AsyncCompletionQuery()
Method Detail |
---|
protected void preQueryUpdate(JTextComponent component)
CompletionTask.refresh(null)
.
CompletionTask.query()
was not yet invoked.
protected abstract void query(CompletionResultSet resultSet, Document doc, int caretOffset)
RequestProcessor
thread.
resultSet
- result set into which the computed data should be added.
The result set must always be finished
by CompletionResultSet.finish()
.doc
- document of the text component on which the query is being run.
null
if the corresponding component is null.caretOffset
- present caret offset of the text component
on which the query is being run.
-1
if the corresponding component is null.protected boolean canFilter(JTextComponent component)
CompletionTask.refresh(CompletionResultSet)
in AWT thread. The asynchronous query method
query(CompletionResultSet, Document, int)
may still be running when this method is invoked.
The implementation typically gets the text between
caret offset remembered during query and the present caret offset
(can be gathered by component.getCaretPosition()
)
and examines whether the results computed (or being computed) during the query
(they should be collected and rememberred in the query method body)
can be filtered appropriately.
For example in java the user can type e.g. "my" and so all the classes
and fields and methods starting with "my" appropriate for the given context
will be computed during the query.
If the user continues typing e.g. "myMethod" then the result set
computed during the query can be filtered and this method should return true.
However if the user has typed e.g. "my()." then the original result
set is useless and this method should return false.
component
- text component for which this provider was constructed.
It may be null if no text component was provided.
false
if the filtering cannot be done or is not supported
at all by this query implementation. The full asynchronous query
will be invoked then.
protected void filter(CompletionResultSet resultSet)
query(CompletionResultSet, Document, int)
invocation.
CompletionTask.refresh(CompletionResultSet)
call.
canFilter(JTextComponent)
returned true
and when there is currently no query in progress
so it is safe to use the results computed during the query.
The implementation typically gets the text between
caret offset remembered during query and the present caret offset
(can be gathered by component.getCaretPosition()
)
and examines whether the results computed during the query
(they should be rememberred in the query method body)
can be filtered appropriately.
For example in java the user can type e.g. "my" and so all the classes
and fields and methods starting with "my" appropriate for the given context
will be computed during the query.
If the user continues typing e.g. "myMethod" then the result set
computed during the query can be filtered and this method should return true.
However if the user has typed e.g. "my()." then the original result
set is useless and this method should return false.
The default implementation does not support filtering
and throws IllegalStateException
.
resultSet
- result set to which the filtering must add
its results. The result set must always be finished
by CompletionResultSet.finish()
.protected void prepareQuery(JTextComponent component)
query(CompletionResultSet, Document, int)
is called asynchronously.
component
- text component for which this provider was constructed.
It may be null if no text component was provided.public final boolean isTaskCancelled()
|
org.netbeans.modules.editor.completion/1 1.6.22 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |