|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jakubholy.jedit.autocomplete.AutoComplete
public final class AutoComplete
Try to complete a word typed in the associated buffer.
Automatically try to find any completions for the current
word being typed and if there're any, present them to the user
in a pop-up list. A list of possible completions is
constructed from words typed so far in the buffer that
satisfy some conditions.
The class observers an WordTypedListener
to get notified of word events such as a word
started/finished/invalidated (when the user
jumps to another location etc.).
PreferencesManager
,
WordTypedListener
,
Based on jEdit's CompleteWord feature.
Method Summary | |
---|---|
void |
attach(org.gjt.sp.jedit.Buffer buffer)
Attach the AutoCompletion to the buffer == start completing there. |
static AutoComplete |
attachAction(org.gjt.sp.jedit.Buffer buffer)
Attach an AutoComplete to the buffer. |
static void |
attachToAllBuffersAction()
Attach AutoComplete to all opened buffers. |
static AutoComplete |
createAutoCompleteAction(org.gjt.sp.jedit.Buffer buffer)
Create a new AutoComplete that starts working for the given buffer if the buffer has none. |
static void |
destroyAllAutoCompletes()
Detach and destroy (forget) all instance of AutoComplete. |
void |
detach()
Detach the AutoCompletion from the buffer it's bound to == stop working. |
static void |
detachAction(org.gjt.sp.jedit.Buffer buffer)
Detach the AutoCompletion from the given buffer if it has one. |
protected void |
displayCompletionPopup()
Display a pop-up window with possible completions for the word being typed. |
void |
exportWordList()
Save the list of remembered words to the user supplied file. |
static void |
forgetAllWordsAction(org.gjt.sp.jedit.Buffer buffer)
Forget all words in the completions list including those from the buffer and those from other sources such as the default word list. |
boolean |
forgetWord(java.lang.String word2remove)
Remove the given word from the list of remembered words. |
static AutoComplete |
getAutoCompleteOfBuffer(org.gjt.sp.jedit.Buffer buffer)
Return the AutoComplete associated with the buffer or null if no AutoComplete has been attached to the buffer so far. |
org.gjt.sp.jedit.Buffer |
getBuffer()
Return the buffer this AutoComplete is attached to. |
protected net.jakubholy.jedit.autocomplete.Completion[] |
getCompletions(java.lang.String prefix)
Get all possible completion for the given prefix. |
java.lang.String |
getThePrefix()
The prefix to complete/typed so far. |
WordList |
getWordList()
Set the list of words used to find completions. |
java.lang.String |
getWords()
A concatenation of all rememberd words. |
int |
importWordList()
Read words from a file supplied by the user and add them to those remembered for this buffer. |
int |
importWordList(java.io.Reader wordListReader)
Read words via the provided Reader and add them to those remembered for this buffer. |
static void |
parseAction(org.gjt.sp.jedit.Buffer buffer)
Parse the current buffer and add all words in it to the list. |
void |
parseBuffer()
Parse the current buffer and add all words in it to the list. |
boolean |
rememberWord(java.lang.String word2remember)
As rememberWord(String, boolean) but silent == false. |
boolean |
rememberWord(java.lang.String word2remember,
boolean silent)
Add the given word to the list of remembered words. |
boolean |
rememberWordSilent(java.lang.String word2remember)
As rememberWord(String, boolean) but silent == true. |
void |
setThePrefix(java.lang.String thePrefix)
The prefix to complete/typed so far. |
void |
setWordList(WordList wordList)
Get the list of words used to find completions. |
static void |
showWordsAction(org.gjt.sp.jedit.Buffer buffer)
Show the WordList Editor user interface to edit words remembered for the current buffer. |
void |
update(java.util.Observable observable,
java.lang.Object arg)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static AutoComplete createAutoCompleteAction(org.gjt.sp.jedit.Buffer buffer)
public static AutoComplete attachAction(org.gjt.sp.jedit.Buffer buffer)
public static void detachAction(org.gjt.sp.jedit.Buffer buffer)
public static void parseAction(org.gjt.sp.jedit.Buffer buffer) throws ActionException
ActionException
- When the action cannot be performed for some reasonpublic static void forgetAllWordsAction(org.gjt.sp.jedit.Buffer buffer) throws ActionException
ActionException
- When the action cannot be performed for some reasonpublic static void showWordsAction(org.gjt.sp.jedit.Buffer buffer) throws ActionException
ActionException
- When the action cannot be performed for some reasonpublic static AutoComplete getAutoCompleteOfBuffer(org.gjt.sp.jedit.Buffer buffer)
getBuffer()
doesn't return null and that it matches the
buffer.
buffer
- The buffer whose AutoComplete you want to access.
public static void attachToAllBuffersAction() throws ActionException
ActionException
- When the action cannot be performed for some reasonpublic void exportWordList() throws java.io.IOException
java.io.IOException
public int importWordList() throws MaxWordsExceededException, java.io.FileNotFoundException, java.io.IOException
See importWordList(Reader)
for details
on the file format.
MaxWordsExceededException
- When the maximal number of
remembered words have already been reached.
java.io.FileNotFoundException
- The import file couldn't be found
java.io.IOException
- Exception when trying to read the filepublic int importWordList(java.io.Reader wordListReader) throws java.io.IOException, MaxWordsExceededException
The file must contain one word per line. We do not check that they're words, remove white spaces or anything like that - we import them as they are. Only rows that contain nothing but whitespaces are ignored.
Note: The wordListReader
is closed at the end.
wordListReader
- A reader (e.g. FileReader) for reading the word list.
Note: it's closed at the end.
MaxWordsExceededException
- When the maximal number of
remembered words have already been reached.
java.io.IOException
- Exception when trying to read the filepublic static void destroyAllAutoCompletes()
public void detach()
public void attach(org.gjt.sp.jedit.Buffer buffer)
public void update(java.util.Observable observable, java.lang.Object arg)
update
in interface java.util.Observer
WordTypedListener
protected void displayCompletionPopup()
protected net.jakubholy.jedit.autocomplete.Completion[] getCompletions(java.lang.String prefix)
public java.lang.String getThePrefix()
public void setThePrefix(java.lang.String thePrefix)
public WordList getWordList()
public void setWordList(WordList wordList)
public boolean forgetWord(java.lang.String word2remove)
public boolean rememberWord(java.lang.String word2remember, boolean silent) throws MaxWordsExceededException
word2remember
- The word/string to remembersilent
- If true don't throw MaxWordsExceededException,
only do nothing and return false
MaxWordsExceededException
- When the maximal number of
remembered words have already been reached - unless silent is true.public boolean rememberWord(java.lang.String word2remember) throws MaxWordsExceededException
rememberWord(String, boolean)
but silent == false.
(Throw an exception when the max. number of words is exceeded.)
MaxWordsExceededException
public boolean rememberWordSilent(java.lang.String word2remember)
rememberWord(String, boolean)
but silent == true.
(Never throw an exception when the max. number of words is exceeded.)
public java.lang.String getWords()
public void parseBuffer()
public org.gjt.sp.jedit.Buffer getBuffer()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |