org.xnap.gui.component
Class FileCompletionModel
java.lang.Object
javax.swing.AbstractListModel
javax.swing.DefaultComboBoxModel
org.xnap.gui.component.FileCompletionModel
- All Implemented Interfaces:
- java.io.Serializable, javax.swing.ComboBoxModel, javax.swing.ListModel, javax.swing.MutableComboBoxModel, CompletionModel
public class FileCompletionModel
- extends javax.swing.DefaultComboBoxModel
- implements CompletionModel
This class provides completion for path prefixes on the local file system.
- See Also:
- Serialized Form
Fields inherited from class javax.swing.AbstractListModel |
listenerList |
Method Summary |
boolean |
complete(java.lang.String prefix)
Returns true if there are files in the local file system having the
given prefix. |
java.lang.String |
completeUniquePrefix(java.lang.String prefix)
This method's behaviour is a matter of taste. |
void |
insert(java.lang.Object object)
Does nothing, since we don't do any data keeping of our own. |
void |
remove(java.lang.Object object)
Does nothing, since we don't do any data keeping of our own. |
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 |
FileCompletionModel
public FileCompletionModel(boolean completeOnlyDirectories)
- Constructs a new file completion model.
- Parameters:
completeOnlyDirectories
- if true only subdirectories are
suggested as possible completions, otherwise files are taken into
account too
FileCompletionModel
public FileCompletionModel()
- Constructs a new file completion model.
The default setting is to complete subdirectories and files.
complete
public boolean complete(java.lang.String prefix)
- Returns true if there are files in the local file system having the
given prefix.
First we test if the given prefix denotes a file which exists and is a
directory. If that is the case all the files contained in that
directory are added to the model.
Regardless of the above results the parent directory if there is one is
searched for files matching the prefix. Thus we get all possible
completions that make sense.
- 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)
- This method's behaviour is a matter of taste.
It first checks if the given prefix is an existing directory. If that
is the case the commmon unique prefix of all files found in the
directory is returned.
Only if the above fails the parent directory is searched for the common
unique 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)
- Does nothing, since we don't do any data keeping of our own.
- Specified by:
insert
in interface CompletionModel
- Parameters:
object
- the object to be added
remove
public void remove(java.lang.Object object)
- Does nothing, since we don't do any data keeping of our own.
- Specified by:
remove
in interface CompletionModel
- Parameters:
object
- the object to be removed
Copyright © 2001-2005 XNap Team. All Rights Reserved.