org.xnap.gui.component
Class DefaultCompletionModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by javax.swing.DefaultComboBoxModel
          extended by org.xnap.gui.component.DefaultCompletionModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.ComboBoxModel, javax.swing.ListModel, javax.swing.MutableComboBoxModel, CompletionModel

public class DefaultCompletionModel
extends javax.swing.DefaultComboBoxModel
implements CompletionModel

The DefaultComboBoxModel uses a ternary search tree for completion.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
DefaultCompletionModel()
          Constructs a new model with no items.
DefaultCompletionModel(java.lang.Object[] items)
          Constructs a new model using the given items for completion.
DefaultCompletionModel(java.lang.Object[] items, boolean sorted)
          Constructs a new model using the given items for completion.
 
Method Summary
 boolean complete(java.lang.String prefix)
          Finds possible completions for a prefix.
 java.lang.String completeUniquePrefix(java.lang.String prefix)
          Returns largest common prefix of all possible completions for the given prefix.
 void insert(java.lang.Object object)
          Adds an object to the completion tree.
 void remove(java.lang.Object object)
          Removes an object from the 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

DefaultCompletionModel

public DefaultCompletionModel()
Constructs a new model with no items.


DefaultCompletionModel

public DefaultCompletionModel(java.lang.Object[] items)
Constructs a new model using the given items for completion.

Parameters:
items - the objects used for completion

DefaultCompletionModel

public DefaultCompletionModel(java.lang.Object[] items,
                              boolean sorted)
Constructs a new model using the given items for completion.

Parameters:
items - the array of objects used for completion
sorted - whether the array of items is sorted or not
Method Detail

complete

public boolean complete(java.lang.String prefix)
Description copied from interface: CompletionModel
Finds possible completions for a prefix. As a side effect the completions are added to the MutableComboBoxModel.

Specified by:
complete in interface CompletionModel
Parameters:
prefix - the prefix being matched
Returns:
true, if completion was successful, i.e. the prefix matches at least one item in the model

completeUniquePrefix

public java.lang.String completeUniquePrefix(java.lang.String prefix)
Description copied from interface: CompletionModel
Returns largest common prefix of all possible completions for the given prefix.

Specified by:
completeUniquePrefix in interface CompletionModel
Parameters:
prefix - the prefix being matched
Returns:
the largest common prefix of all possible matches

insert

public void insert(java.lang.Object object)
Adds an object to the completion tree.

Specified by:
insert in interface CompletionModel
Parameters:
object - the object which is completed using its Object.toString() method

remove

public void remove(java.lang.Object object)
Description copied from interface: CompletionModel
Removes an object from the completion model.

Specified by:
remove in interface CompletionModel
Parameters:
object - the object to be removed


Copyright © 2001-2005 XNap Team. All Rights Reserved.