|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.AbstractListModel javax.swing.DefaultComboBoxModel org.xnap.commons.gui.completion.DefaultCompletionModel
public class DefaultCompletionModel
This classl uses a ternary search tree for completion.
You can easily add arrays of objects to it and remove single object if they should not show up as possible completions anymore.
A toArray()
method gives access to all objects stored in the model
and can be used for serialization.
See also CompletionSettingDirector
.
Field Summary |
---|
Fields inherited from class javax.swing.AbstractListModel |
---|
listenerList |
Constructor Summary | |
---|---|
DefaultCompletionModel()
Constructs a new model with no items. |
|
DefaultCompletionModel(Object[] items)
Constructs a new model using the given items for completion. |
|
DefaultCompletionModel(Object[] items,
boolean sorted)
Constructs a new model using the given items for completion. |
Method Summary | |
---|---|
void |
clear()
Clears the model. |
boolean |
complete(String prefix)
Finds possible completions for a prefix. |
String |
completeUniquePrefix(String prefix)
Returns largest common prefix of all possible completions for the given prefix. |
void |
insert(Object object)
Adds an object to the completion model's ternary search tree. |
void |
insert(Object[] items)
Adds an array of objects to the completion model's ternary search tree. |
void |
insert(Object[] items,
boolean sorted)
Adds an array of objects to the completion model's ternary search tree. |
void |
remove(Object object)
Removes the object from the ternary search tree. |
Object[] |
toArray()
Returns an array containing all of the elements in this completion model. |
Methods inherited from class javax.swing.DefaultComboBoxModel |
---|
addElement, getElementAt, getIndexOf, getSelectedItem, getSize, insertElementAt, removeAllElements, removeElement, removeElementAt, setSelectedItem |
Methods inherited from class javax.swing.AbstractListModel |
---|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.swing.MutableComboBoxModel |
---|
addElement, insertElementAt, removeElement, removeElementAt |
Methods inherited from interface javax.swing.ComboBoxModel |
---|
getSelectedItem, setSelectedItem |
Methods inherited from interface javax.swing.ListModel |
---|
addListDataListener, getElementAt, getSize, removeListDataListener |
Constructor Detail |
---|
public DefaultCompletionModel()
public DefaultCompletionModel(Object[] items)
items
- the objects used for completionpublic DefaultCompletionModel(Object[] items, boolean sorted)
items
- the array of objects used for completionsorted
- whether the array of items is sorted or notMethod Detail |
---|
public boolean complete(String prefix)
CompletionModel
MutableComboBoxModel
. Use ListModel.getSize()
to get the number of
completions found and retrieve them with ListModel.getElementAt(int)
.
complete
in interface CompletionModel
prefix
- the prefix being matched
public String completeUniquePrefix(String prefix)
CompletionModel
completeUniquePrefix
in interface CompletionModel
prefix
- the prefix being matched
public void insert(Object object)
Object.toString()
method. If
another object with the same name exists it is simply replaced by this
one, no equality tests are carried out.
object
- the object which is completed using its Object.toString()
methodpublic void insert(Object[] items, boolean sorted)
items
- the array of objects used for completionsorted
- whether the array of items is sorted or notpublic void insert(Object[] items)
items
- the array of objects used for completioninsert(Object[], boolean)
public void remove(Object object)
Object.equals(Object)
method.
object
- the object to be removed from the search treepublic Object[] toArray()
Object.toString()
.
public void clear()
Subsequent calls to complete(String)
will return
false
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |