edu.iastate.metnet.metaomgraph
Class GraphFileFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by edu.iastate.metnet.metaomgraph.GraphFileFilter

public class GraphFileFilter
extends javax.swing.filechooser.FileFilter

File filter used in MetaOmGraph file chooser dialogs. The filter can be set to one of three modes via the setMode(int) method. If the mode is GraphFileFilter.XML, only files with a .xml extension will be accepted. If it's set to GraphFileFilter.TEXT, .txt and .csv files will be accepted. And if it's set to GraphFileFilter.PROJECT, .mcg and .mog files will be accepted.

Author:
Nick Ransom

Field Summary
static int PNG
          Mode to accept .png files
static int PROJECT
          Mode to accept .mcg and .mog files
static int TEXT
          Mode to accept .txt and .csv files
static int XML
          Mode to accept .xml files
 
Constructor Summary
GraphFileFilter()
          Creates a GraphFileFilter in text mode (*.txt, *.csv).
GraphFileFilter(int mode)
          Creates a GraphFileFilter with the specified mode.
 
Method Summary
 boolean accept(java.io.File arg0)
          Determines whether or not to display a given file in the file chooser.
 java.lang.String getDescription()
          Gets a description of this filter.
 void setMode(int mode)
          Changes which files will be accepted by this filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML

public static final int XML
Mode to accept .xml files

See Also:
Constant Field Values

TEXT

public static final int TEXT
Mode to accept .txt and .csv files

See Also:
Constant Field Values

PROJECT

public static final int PROJECT
Mode to accept .mcg and .mog files

See Also:
Constant Field Values

PNG

public static final int PNG
Mode to accept .png files

See Also:
Constant Field Values
Constructor Detail

GraphFileFilter

public GraphFileFilter()
Creates a GraphFileFilter in text mode (*.txt, *.csv).


GraphFileFilter

public GraphFileFilter(int mode)
Creates a GraphFileFilter with the specified mode. The mode must be one of GraphFileFilter.XML, GraphFileFilter.TEXT, or GraphFileFilter.PROJECT.

Parameters:
mode - the mode. Must be one of GraphFileFilter.XML, GraphFileFilter.TEXT, or GraphFileFilter.PROJECT.
Method Detail

setMode

public void setMode(int mode)
Changes which files will be accepted by this filter. If the mode is GraphFileFilter.XML, only files with a .xml extension will be accepted. If it's set to GraphFileFilter.TEXT, .txt and .csv files will be accepted. And if it's set to GraphFileFilter.PROJECT, .mcg and .mog files will be accepted.

Parameters:
mode - the mode
Throws:
java.security.InvalidParameterException - if the specified mode is not one of GraphFileFilter.XML, GraphFileFilter.TEXT, or GraphFileFilter.PROJECT.

accept

public boolean accept(java.io.File arg0)
Determines whether or not to display a given file in the file chooser. The types of files that are displayed are determined by the active mode. Folders will be displayed in both modes.

Specified by:
accept in class javax.swing.filechooser.FileFilter
Returns:
true if the given file should be displayed, false otherwise.

getDescription

public java.lang.String getDescription()
Gets a description of this filter. The description changes based on the mode.

Specified by:
getDescription in class javax.swing.filechooser.FileFilter
Returns:
a description of this filter/mode.