org.xnap.commons.gui.completion
Interface CompletionModel

All Superinterfaces:
ComboBoxModel, ListModel, MutableComboBoxModel
All Known Implementing Classes:
DefaultCompletionModel, FileCompletionModel

public interface CompletionModel
extends MutableComboBoxModel

Defines the requirements for classes implementing a CompletionModel.

The completion model can be queried for possible completions of a given prefix. There are two methods a CompletionModel has to implement:

The completion model interface inherits MutableComoboxModel so that possible CompletionModes can use it as the model for a comobobox.

Author:
Felix Berger

Method Summary
 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.
 
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
 

Method Detail

complete

boolean complete(String prefix)
Finds possible completions for a prefix. As a side effect the completions are added to the MutableComboBoxModel. Use ListModel.getSize() to get the number of completions found and retrieve them with ListModel.getElementAt(int).

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

String completeUniquePrefix(String prefix)
Returns largest common prefix of all possible completions for the given prefix.

Parameters:
prefix - the prefix being matched
Returns:
the largest common prefix of all possible matches, the prefix given if no longer prefix can be found


Copyright © 2004-2007 XNap Commons Team. All Rights Reserved.