public class DefaultCompletionProvider extends AbstractCompletionProvider
AbstractCompletionProvider.CaseInsensitiveComparator
限定符和类型 | 字段和说明 |
---|---|
protected javax.swing.text.Segment |
seg |
comparator, completions
EMPTY_STRING
构造器和说明 |
---|
DefaultCompletionProvider()
Constructor.
|
DefaultCompletionProvider(java.lang.String[] words)
Creates a completion provider that provides completion for a simple
list of words.
|
限定符和类型 | 方法和说明 |
---|---|
java.lang.String |
getAlreadyEnteredText(javax.swing.text.JTextComponent comp)
Returns the text just before the current caret position that could be
the start of something auto-completable.
|
java.util.List<Completion> |
getCompletionsAt(javax.swing.text.JTextComponent tc,
java.awt.Point p)
Returns the completions that have been entered at the specified visual
location.
|
java.util.List<ParameterizedCompletion> |
getParameterizedCompletions(javax.swing.text.JTextComponent tc)
Returns a list of parameterized completions that have been entered
at the current caret position of a text component (and thus can have
their completion choices displayed).
|
protected void |
init()
Initializes this completion provider.
|
protected boolean |
isValidChar(char ch)
Returns whether the specified character is valid in an auto-completion.
|
void |
loadFromXML(java.io.File file)
Loads completions from an XML file.
|
void |
loadFromXML(java.io.InputStream in)
Loads completions from an XML input stream.
|
void |
loadFromXML(java.io.InputStream in,
java.lang.ClassLoader cl)
Loads completions from an XML input stream.
|
void |
loadFromXML(java.lang.String resource)
Loads completions from an XML file.
|
addCompletion, addCompletions, addWordCompletions, checkProviderAndAdd, clear, getCompletionByInputText, getCompletionsImpl, removeCompletion
clearParameterizedCompletionParams, getCompletions, getListCellRenderer, getParameterChoicesProvider, getParameterListEnd, getParameterListSeparator, getParameterListStart, getParent, isAutoActivateOkay, setAutoActivationRules, setListCellRenderer, setParameterChoicesProvider, setParameterizedCompletionParams, setParent
public DefaultCompletionProvider()
public DefaultCompletionProvider(java.lang.String[] words)
words
- The words to offer as completion suggestions. If this is
null
, no completions will be known.BasicCompletion
public java.lang.String getAlreadyEnteredText(javax.swing.text.JTextComponent comp)
This method returns all characters before the caret that are matched
by isValidChar(char)
.
Returns the text just before the current caret position that could be
the start of something auto-completable.
comp
- The text component.null
means nothing
should be auto-completed; a value of an empty string
(""
) means auto-completion should still be
considered (i.e., all possible choices are valid).public java.util.List<Completion> getCompletionsAt(javax.swing.text.JTextComponent tc, java.awt.Point p)
tc
- The text component.p
- The position, usually from a MouseEvent.public java.util.List<ParameterizedCompletion> getParameterizedCompletions(javax.swing.text.JTextComponent tc)
tc
- The text component.ParameterizedCompletion
s. If no completions
are available, this may be null
.protected void init()
protected boolean isValidChar(char ch)
Character.isLetterOrDigit(ch) || ch=='_'
". Subclasses
can override this method to change what characters are matched.ch
- The character.public void loadFromXML(java.io.File file) throws java.io.IOException
CompletionXml.dtd
.file
- An XML file to load from.java.io.IOException
- If an IO error occurs.public void loadFromXML(java.io.InputStream in) throws java.io.IOException
CompletionXml.dtd
.in
- The input stream to read from.java.io.IOException
- If an IO error occurs.public void loadFromXML(java.io.InputStream in, java.lang.ClassLoader cl) throws java.io.IOException
CompletionXml.dtd
.in
- The input stream to read from.cl
- The class loader to use when loading any extra classes defined
in the XML, such as custom FunctionCompletion
s. This
may be null
if the default is to be used, or if no
custom completions are defined in the XML.java.io.IOException
- If an IO error occurs.public void loadFromXML(java.lang.String resource) throws java.io.IOException
CompletionXml.dtd
.resource
- A resource the current ClassLoader can get to.java.io.IOException
- If an IO error occurs.