org.openstreetmap.josm.actions
Class ExtensionFileFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by org.openstreetmap.josm.actions.ExtensionFileFilter

public class ExtensionFileFilter
extends javax.swing.filechooser.FileFilter

A file filter that filters after the extension. Also includes a list of file filters used in JOSM.

Since:
32

Field Summary
private  java.lang.String defaultExtension
           
private  java.lang.String description
           
static java.util.ArrayList<FileExporter> exporters
          List of supported formats for export.
private  java.lang.String extensions
           
static java.util.ArrayList<FileImporter> importers
          List of supported formats for import.
 
Constructor Summary
ExtensionFileFilter(java.lang.String extension, java.lang.String defaultExtension, java.lang.String description)
          Construct an extension file filter by giving the extension to check after.
 
Method Summary
 boolean accept(java.io.File pathname)
           
 boolean acceptName(java.lang.String filename)
          Returns true if this file filter accepts the given filename.
static void applyChoosableExportFileFilters(javax.swing.JFileChooser fileChooser, java.lang.String extension, boolean allTypes)
          Applies the choosable FileFilter to a JFileChooser before using the file chooser for selecting a file for writing.
static void applyChoosableImportFileFilters(javax.swing.JFileChooser fileChooser, java.lang.String extension, boolean allTypes)
          Applies the choosable FileFilter to a JFileChooser before using the file chooser for selecting a file for reading.
 boolean equals(java.lang.Object obj)
           
static ExtensionFileFilter getDefaultExportExtensionFileFilter(java.lang.String extension)
          Replies the default ExtensionFileFilter for a given extension
 java.lang.String getDefaultExtension()
          Replies the default file extension of this file filter.
static ExtensionFileFilter getDefaultImportExtensionFileFilter(java.lang.String extension)
          Replies the default ExtensionFileFilter for a given extension
 java.lang.String getDescription()
           
static java.util.List<ExtensionFileFilter> getExportExtensionFileFilters()
          Replies an ordered list of enabled ExtensionFileFilters for exporting.
 java.lang.String getExtensions()
          Replies the comma-separated list of file extensions of this file filter.
static java.util.List<ExtensionFileFilter> getImportExtensionFileFilters()
          Replies an ordered list of ExtensionFileFilters for importing.
 int hashCode()
           
protected static void sort(java.util.List<ExtensionFileFilter> filters)
           
static void updateAllFormatsImporter()
          Updates the AllFormatsImporter that is contained in the importers list.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

importers

public static final java.util.ArrayList<FileImporter> importers
List of supported formats for import.

Since:
4869

exporters

public static final java.util.ArrayList<FileExporter> exporters
List of supported formats for export.

Since:
4869

extensions

private final java.lang.String extensions

description

private final java.lang.String description

defaultExtension

private final java.lang.String defaultExtension
Constructor Detail

ExtensionFileFilter

public ExtensionFileFilter(java.lang.String extension,
                           java.lang.String defaultExtension,
                           java.lang.String description)
Construct an extension file filter by giving the extension to check after.

Parameters:
extension - The comma-separated list of file extensions
defaultExtension - The default extension
description - A short textual description of the file type
Since:
1169
Method Detail

sort

protected static void sort(java.util.List<ExtensionFileFilter> filters)

updateAllFormatsImporter

public static void updateAllFormatsImporter()
Updates the AllFormatsImporter that is contained in the importers list. If you do not use the importers variable directly, you don???t need to call this.

Updating the AllFormatsImporter is required when plugins add new importers that support new file extensions. The old AllFormatsImporter doesn???t include the new extensions and thus will not display these files.

Since:
5131

getImportExtensionFileFilters

public static java.util.List<ExtensionFileFilter> getImportExtensionFileFilters()
Replies an ordered list of ExtensionFileFilters for importing. The list is ordered according to their description, an AllFormatsImporter is append at the end.

Returns:
an ordered list of ExtensionFileFilters for importing.
Since:
2029

getExportExtensionFileFilters

public static java.util.List<ExtensionFileFilter> getExportExtensionFileFilters()
Replies an ordered list of enabled ExtensionFileFilters for exporting. The list is ordered according to their description, an AllFormatsImporter is append at the end.

Returns:
an ordered list of enabled ExtensionFileFilters for exporting.
Since:
2029

getDefaultImportExtensionFileFilter

public static ExtensionFileFilter getDefaultImportExtensionFileFilter(java.lang.String extension)
Replies the default ExtensionFileFilter for a given extension

Parameters:
extension - the extension
Returns:
the default ExtensionFileFilter for a given extension
Since:
2029

getDefaultExportExtensionFileFilter

public static ExtensionFileFilter getDefaultExportExtensionFileFilter(java.lang.String extension)
Replies the default ExtensionFileFilter for a given extension

Parameters:
extension - the extension
Returns:
the default ExtensionFileFilter for a given extension
Since:
2029

applyChoosableImportFileFilters

public static void applyChoosableImportFileFilters(javax.swing.JFileChooser fileChooser,
                                                   java.lang.String extension,
                                                   boolean allTypes)
Applies the choosable FileFilter to a JFileChooser before using the file chooser for selecting a file for reading.

Parameters:
fileChooser - the file chooser
extension - the default extension
allTypes - If true, all the files types known by JOSM will be proposed in the "file type" combobox. If false, only the file filters that include extension will be proposed
Since:
5438

applyChoosableExportFileFilters

public static void applyChoosableExportFileFilters(javax.swing.JFileChooser fileChooser,
                                                   java.lang.String extension,
                                                   boolean allTypes)
Applies the choosable FileFilter to a JFileChooser before using the file chooser for selecting a file for writing.

Parameters:
fileChooser - the file chooser
extension - the default extension
allTypes - If true, all the files types known by JOSM will be proposed in the "file type" combobox. If false, only the file filters that include extension will be proposed
Since:
5438

acceptName

public boolean acceptName(java.lang.String filename)
Returns true if this file filter accepts the given filename.

Parameters:
filename - The filename to check after
Returns:
true if this file filter accepts the given filename (i.e if this filename ends with one of the extensions)
Since:
1169

accept

public boolean accept(java.io.File pathname)
Specified by:
accept in class javax.swing.filechooser.FileFilter

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in class javax.swing.filechooser.FileFilter

getExtensions

public java.lang.String getExtensions()
Replies the comma-separated list of file extensions of this file filter.

Returns:
the comma-separated list of file extensions of this file filter, as a String
Since:
5131

getDefaultExtension

public java.lang.String getDefaultExtension()
Replies the default file extension of this file filter.

Returns:
the default file extension of this file filter
Since:
2029

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


JOSM