cz.cuni.jagrlib.gui.comp
Class CommonFileFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by cz.cuni.jagrlib.gui.comp.CommonFileFilter

public class CommonFileFilter
extends javax.swing.filechooser.FileFilter

Filter for files for JFileChooser.

See Also:
CommonFileFilter.java

Constructor Summary
CommonFileFilter()
          Creates a file filter.
CommonFileFilter(java.lang.String extension)
          Creates a file filter that accepts files with the given extension.
CommonFileFilter(java.lang.String[] filters)
          Creates a file filter from the given string array.
CommonFileFilter(java.lang.String[] filters, java.lang.String description)
          Creates a file filter from the given string array and description.
CommonFileFilter(java.lang.String extension, java.lang.String description)
          Creates a file filter that accepts the given file type.
 
Method Summary
 boolean accept(java.io.File f)
          Return true if this file should be shown in the directory pane, false if it shouldn't.
 void addExtension(java.lang.String extension)
          Adds a filetype "dot" extension to filter against.
 java.lang.String getDescription()
          Returns the human readable description of this filter.
 java.lang.String getExtension(java.io.File f)
          Return the extension portion of the file's name .
 boolean isExtensionListInDescription()
          Returns whether the extension list (.xml, .html, etc) should show up in the human readable description.
 void setDescription(java.lang.String description)
          Sets the human readable description of this filter.
 void setExtensionListInDescription(boolean b)
          Determines whether the extension list (.xml, .html, etc) should show up in the human readable description.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonFileFilter

public CommonFileFilter()
Creates a file filter. If no filters are added, then all files are accepted.

See Also:
addExtension(java.lang.String)

CommonFileFilter

public CommonFileFilter(java.lang.String extension)
Creates a file filter that accepts files with the given extension.

Parameters:
extension - . Example: new ExampleFileFilter("xml");
See Also:
addExtension(java.lang.String)

CommonFileFilter

public CommonFileFilter(java.lang.String extension,
                        java.lang.String description)
Creates a file filter that accepts the given file type.

Parameters:
extension - .
description - . Example: new ExampleFileFilter("xml", "XML Files"); Note that the "." before the extension is not needed. If provided, it will be ignored.
See Also:
addExtension(java.lang.String)

CommonFileFilter

public CommonFileFilter(java.lang.String[] filters)
Creates a file filter from the given string array.

Parameters:
filters - . Example: new ExampleFileFilter(String {"xml", "html"}); Note that the "." before the extension is not needed and will be ignored.
See Also:
addExtension(java.lang.String)

CommonFileFilter

public CommonFileFilter(java.lang.String[] filters,
                        java.lang.String description)
Creates a file filter from the given string array and description.

Parameters:
filters - .
description - . Example: new ExampleFileFilter(String {"xml", "html"}, "Xml and Html Files"); Note that the "." before the extension is not needed and will be ignored.
See Also:
addExtension(java.lang.String)
Method Detail

accept

public boolean accept(java.io.File f)
Return true if this file should be shown in the directory pane, false if it shouldn't. Files that begin with "." are ignored.

Specified by:
accept in class javax.swing.filechooser.FileFilter
Parameters:
f - .
Returns:
.
See Also:
getExtension(java.io.File), FileFilter.accept(java.io.File)

getExtension

public java.lang.String getExtension(java.io.File f)
Return the extension portion of the file's name .

Parameters:
f - .
Returns:
.
See Also:
getExtension(java.io.File), FileFilter.accept(java.io.File)

addExtension

public void addExtension(java.lang.String extension)
Adds a filetype "dot" extension to filter against. For example: the following code will create a filter that filters out all files except those that end in ".xml" and ".html":

Parameters:
extension - . ExampleFileFilter filter = new ExampleFileFilter(); filter.addExtension("xml"); filter.addExtension("html"); Note that the "." before the extension is not needed and will be ignored.

getDescription

public java.lang.String getDescription()
Returns the human readable description of this filter. For example: "XML and HTML Files (*.xml, *.html)"

Specified by:
getDescription in class javax.swing.filechooser.FileFilter
Returns:
.
See Also:
setDescription(java.lang.String), setExtensionListInDescription(boolean), isExtensionListInDescription(), FileFilter.getDescription()

setDescription

public void setDescription(java.lang.String description)
Sets the human readable description of this filter. For example: filter.setDescription("Xml and Html files");

Parameters:
description - .
See Also:
setDescription(java.lang.String), setExtensionListInDescription(boolean), isExtensionListInDescription()

setExtensionListInDescription

public void setExtensionListInDescription(boolean b)
Determines whether the extension list (.xml, .html, etc) should show up in the human readable description. Only relevant if a description was provided in the constructor or using setDescription();

Parameters:
b - .
See Also:
getDescription(), setDescription(java.lang.String), isExtensionListInDescription()

isExtensionListInDescription

public boolean isExtensionListInDescription()
Returns whether the extension list (.xml, .html, etc) should show up in the human readable description. Only relevant if a description was provided in the constructor or using setDescription();

Returns:
.
See Also:
getDescription(), setDescription(java.lang.String), setExtensionListInDescription(boolean)