TrueZIP Swing 7.0

de.schlichtherle.truezip.io.swing
Class FileComboBoxBrowser

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

@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class)
public class FileComboBoxBrowser
extends AbstractComboBoxBrowser

Subclasses AbstractComboBoxBrowser to complete relative and absolute path names of files and directories. This class uses a FileSystemView in order to create file objects for auto completion.

To use it, use something like this:

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

Author:
Christian Schlichtherle
See Also:
Serialized Form

Field Summary
private  File directory
           
private  FileSystemView fileSystemView
           
private static long serialVersionUID
           
 
Constructor Summary
FileComboBoxBrowser()
          Constructs a new file combo box auto completion browser.
FileComboBoxBrowser(FileSystemView fileSystemView)
           
FileComboBoxBrowser(JComboBox comboBox)
           
FileComboBoxBrowser(JComboBox comboBox, FileSystemView fileSystemView)
          Creates a new combo box auto completion browser.
 
Method Summary
 File getDirectory()
          Returns the directory which is used for autocompleting relative path names.
 FileSystemView getFileSystemView()
          Returns the file system view.
 void setDirectory(File directory)
          Sets the directory which is used for autocompleting relative path names.
 void setFileSystemView(FileSystemView fileSystemView)
          Sets the file system view.
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.
private  boolean update0(String initials)
           
 
Methods inherited from class de.schlichtherle.truezip.swing.AbstractComboBoxBrowser
getComboBox, setComboBox
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

fileSystemView

@CheckForNull
private transient FileSystemView fileSystemView

directory

@CheckForNull
private transient File directory
Constructor Detail

FileComboBoxBrowser

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


FileComboBoxBrowser

public FileComboBoxBrowser(@CheckForNull
                           JComboBox comboBox)

FileComboBoxBrowser

public FileComboBoxBrowser(@CheckForNull
                           FileSystemView fileSystemView)

FileComboBoxBrowser

public FileComboBoxBrowser(@CheckForNull
                           JComboBox comboBox,
                           @CheckForNull
                           FileSystemView fileSystemView)
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 for autocompleting relative path names. If this property has been set to null before, it's reinitialized by calling createFileObject(".") on the current file system view, so null is never returned.

Returns:
The directory which is used for autocompleting relative path names.

setDirectory

public void setDirectory(@CheckForNull
                         File directory)
Sets the directory which is used for autocompleting relative path names.

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

getFileSystemView

public FileSystemView getFileSystemView()
Returns the file system view. If this property has been set to null before, it's reinitialized by calling FileSystemView.getFileSystemView(), so null is never returned.

Returns:
The file system view.

setFileSystemView

public void setFileSystemView(@CheckForNull
                              FileSystemView fileSystemView)
Sets the file system view.

Parameters:
fileSystemView - the file system view.

update

protected boolean update(@CheckForNull
                         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.

update0

private boolean update0(@CheckForNull
                        String initials)

TrueZIP Swing 7.0

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.