de.schlichtherle.io.swing
Class FileComboBoxBrowser

java.lang.Object
  extended by de.schlichtherle.swing.AbstractComboBoxBrowser
      extended by de.schlichtherle.io.swing.FileComboBoxBrowser
All Implemented Interfaces:
Serializable

public class FileComboBoxBrowser
extends AbstractComboBoxBrowser

Subclasses AbstractComboBoxBrowser to complete relative and absolute path names of files and directories. This class uses instances of TrueZIP's custom File class in order to support the browsing of archive files for auto completion.

To use it, use something like this:

    JComboBox box = new JComboBox();
    new FileComboBoxBrowser(box);
    box.setEditable(true);
 

Since:
TrueZIP 6.2
Version:
TrueZIP 6.7
Author:
Christian Schlichtherle
See Also:
Serialized Form

Constructor Summary
FileComboBoxBrowser()
          Creates a new combo box auto completion browser.
FileComboBoxBrowser(JComboBox comboBox)
          Creates a new combo box auto completion browser.
 
Method Summary
 File getDirectory()
          Returns the directory which is used to complete relative path names.
 void setDirectory(File directory)
          Returns the directory which is used to complete relative path names.
protected  boolean update(String initials)
          Interpretes the specified initials as the initial characters of an absolute or relative path name of a node in the file system and updates the contents of the combo box model with possible completions.
 
Methods inherited from class de.schlichtherle.swing.AbstractComboBoxBrowser
getComboBox, setComboBox
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileComboBoxBrowser

public FileComboBoxBrowser()
Creates a new combo box auto completion browser. AbstractComboBoxBrowser.setComboBox(javax.swing.JComboBox) must be called in order to use this object.


FileComboBoxBrowser

public FileComboBoxBrowser(JComboBox comboBox)
Creates a new combo box auto completion browser.

Parameters:
comboBox - The combo box to enable browsing for auto completions. May be null.
Method Detail

getDirectory

public File getDirectory()
Returns the directory which is used to complete relative path names. This defaults to the current directory; null is never returned.


setDirectory

public void setDirectory(File directory)
Returns the directory which is used to complete relative path names.

Parameters:
directory - The directory to use for completion. If this is null, the directory is reset to the current directory.

update

protected boolean update(String initials)
Interpretes the specified initials as the initial characters of an absolute or relative path name of a node in the file system and updates the contents of the combo box model with possible completions. The elements in the combo box model are sorted according to their natural comparison order.

Specified by:
update in class AbstractComboBoxBrowser
Parameters:
initials - The initial characters of a file or directory path name. May be null.
Returns:
true if and only if the file system contains a node with initials as its initial characters and hence the popup window with the completions should be shown.
Throws:
NullPointerException - If the comboBox property is null.