Package org.openstreetmap.josm.actions
Class ExtensionFileFilter
- java.lang.Object
-
- javax.swing.filechooser.FileFilter
-
- org.openstreetmap.josm.actions.ExtensionFileFilter
-
- All Implemented Interfaces:
java.io.FileFilter
public class ExtensionFileFilter extends javax.swing.filechooser.FileFilter implements java.io.FileFilter
A file filter that filters after the extension. Also includes a list of file filters used in JOSM.- Since:
- 32
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExtensionFileFilter.AddArchiveExtension
Strategy to determine if extensions must be added to the description.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
defaultExtension
private java.lang.String
description
private static java.util.ArrayList<FileExporter>
exporters
List of supported formats for export.private java.lang.String
extensions
private static java.util.ArrayList<FileImporter>
importers
List of supported formats for import.
-
Constructor Summary
Constructors Constructor Description 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(java.io.File pathname)
boolean
acceptName(java.lang.String filename)
Returns true if this file filter accepts the given filename.static void
addExporter(FileExporter exporter)
Adds a new file exporter at the end of the global list.static void
addExporterFirst(FileExporter exporter)
Adds a new file exporter at the beginning of the global list.static void
addImporter(FileImporter importer)
Adds a new file importer at the end of the global list.static void
addImporterFirst(FileImporter importer)
Adds a new file importer at the beginning of the global list.static void
applyChoosableExportFileFilters(AbstractFileChooser fileChooser, java.lang.String extension, java.util.function.Predicate<ExtensionFileFilter> additionalTypes)
Applies the choosableFileFilter
to aAbstractFileChooser
before using the file chooser for selecting a file for writing.static void
applyChoosableImportFileFilters(AbstractFileChooser fileChooser, java.lang.String extension, java.util.function.Predicate<ExtensionFileFilter> additionalTypes)
Applies the choosableFileFilter
to aAbstractFileChooser
before using the file chooser for selecting a file for reading.protected static java.util.Comparator<ExtensionFileFilter>
comparator()
boolean
equals(java.lang.Object obj)
static ExtensionFileFilter
getDefaultExportExtensionFileFilter(java.lang.String extension)
Replies the defaultExtensionFileFilter
for a given extensionjava.lang.String
getDefaultExtension()
Replies the default file extension of this file filter.static ExtensionFileFilter
getDefaultImportExtensionFileFilter(java.lang.String extension)
Replies the defaultExtensionFileFilter
for a given extensionjava.lang.String
getDescription()
static java.util.List<FileExporter>
getExporters()
Returns the list of file exporters.static java.util.List<ExtensionFileFilter>
getExportExtensionFileFilters()
Replies an ordered list of enabledExtensionFileFilter
s for exporting.java.lang.String
getExtensions()
Replies the comma-separated list of file extensions of this file filter.static java.util.List<FileImporter>
getImporters()
Returns the list of file importers.static java.util.List<ExtensionFileFilter>
getImportExtensionFileFilters()
Replies an ordered list ofExtensionFileFilter
s for importing.int
hashCode()
static ExtensionFileFilter
newFilterWithArchiveExtensions(java.lang.String extensions, java.lang.String defaultExtension, java.lang.String description, boolean addArchiveExtensionsToDescription)
Construct an extension file filter with the extensions supported byCompression
automatically added to theextensions
.static ExtensionFileFilter
newFilterWithArchiveExtensions(java.lang.String extensions, java.lang.String defaultExtension, java.lang.String description, ExtensionFileFilter.AddArchiveExtension addArchiveExtension, java.util.List<java.lang.String> archiveExtensions)
Construct an extension file filter with the extensions supported byCompression
automatically added to theextensions
.static void
updateAllFormatsImporter()
Updates theAllFormatsImporter
that is contained in the importers list.
-
-
-
Field Detail
-
importers
private static final java.util.ArrayList<FileImporter> importers
List of supported formats for import.- Since:
- 4869
-
exporters
private 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 extensionsdefaultExtension
- The default extensiondescription
- A short textual description of the file type- Since:
- 1169
-
-
Method Detail
-
comparator
protected static java.util.Comparator<ExtensionFileFilter> comparator()
-
addImporter
public static void addImporter(FileImporter importer)
Adds a new file importer at the end of the global list. This importer will be evaluated after core ones.- Parameters:
importer
- new file importer- Since:
- 10407
-
addImporterFirst
public static void addImporterFirst(FileImporter importer)
Adds a new file importer at the beginning of the global list. This importer will be evaluated before core ones.- Parameters:
importer
- new file importer- Since:
- 10407
-
addExporter
public static void addExporter(FileExporter exporter)
Adds a new file exporter at the end of the global list. This exporter will be evaluated after core ones.- Parameters:
exporter
- new file exporter- Since:
- 10407
-
addExporterFirst
public static void addExporterFirst(FileExporter exporter)
Adds a new file exporter at the beginning of the global list. This exporter will be evaluated before core ones.- Parameters:
exporter
- new file exporter- Since:
- 10407
-
getImporters
public static java.util.List<FileImporter> getImporters()
Returns the list of file importers.- Returns:
- unmodifiable list of file importers
- Since:
- 10407
-
getExporters
public static java.util.List<FileExporter> getExporters()
Returns the list of file exporters.- Returns:
- unmodifiable list of file exporters
- Since:
- 10407
-
updateAllFormatsImporter
public static void updateAllFormatsImporter()
Updates theAllFormatsImporter
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 ofExtensionFileFilter
s for importing. The list is ordered according to their description, anAllFormatsImporter
is append at the end.- Returns:
- an ordered list of
ExtensionFileFilter
s for importing. - Since:
- 2029
-
getExportExtensionFileFilters
public static java.util.List<ExtensionFileFilter> getExportExtensionFileFilters()
Replies an ordered list of enabledExtensionFileFilter
s for exporting. The list is ordered according to their description, anAllFormatsImporter
is append at the end.- Returns:
- an ordered list of enabled
ExtensionFileFilter
s for exporting. - Since:
- 2029
-
getDefaultImportExtensionFileFilter
public static ExtensionFileFilter getDefaultImportExtensionFileFilter(java.lang.String extension)
Replies the defaultExtensionFileFilter
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 defaultExtensionFileFilter
for a given extension- Parameters:
extension
- the extension- Returns:
- the default
ExtensionFileFilter
for a given extension - Since:
- 2029
-
applyChoosableImportFileFilters
public static void applyChoosableImportFileFilters(AbstractFileChooser fileChooser, java.lang.String extension, java.util.function.Predicate<ExtensionFileFilter> additionalTypes)
Applies the choosableFileFilter
to aAbstractFileChooser
before using the file chooser for selecting a file for reading.- Parameters:
fileChooser
- the file chooserextension
- the default extensionadditionalTypes
- matching types will additionally be added to the "file type" combobox.- Since:
- 14668 (signature)
-
applyChoosableExportFileFilters
public static void applyChoosableExportFileFilters(AbstractFileChooser fileChooser, java.lang.String extension, java.util.function.Predicate<ExtensionFileFilter> additionalTypes)
Applies the choosableFileFilter
to aAbstractFileChooser
before using the file chooser for selecting a file for writing.- Parameters:
fileChooser
- the file chooserextension
- the default extensionadditionalTypes
- matching types will additionally be added to the "file type" combobox.- Since:
- 14668 (signature)
-
newFilterWithArchiveExtensions
public static ExtensionFileFilter newFilterWithArchiveExtensions(java.lang.String extensions, java.lang.String defaultExtension, java.lang.String description, ExtensionFileFilter.AddArchiveExtension addArchiveExtension, java.util.List<java.lang.String> archiveExtensions)
Construct an extension file filter with the extensions supported byCompression
automatically added to theextensions
. The specifiedextensions
will be added to the description in the formold-description (*.ext1, *.ext2)
.- Parameters:
extensions
- The comma-separated list of file extensionsdefaultExtension
- The default extensiondescription
- A short textual description of the file type without supported extensions in parenthesesaddArchiveExtension
- Whether to also add the archive extensions to the descriptionarchiveExtensions
- List of extensions to be added- Returns:
- The constructed filter
-
newFilterWithArchiveExtensions
public static ExtensionFileFilter newFilterWithArchiveExtensions(java.lang.String extensions, java.lang.String defaultExtension, java.lang.String description, boolean addArchiveExtensionsToDescription)
Construct an extension file filter with the extensions supported byCompression
automatically added to theextensions
. The specifiedextensions
will be added to the description in the formold-description (*.ext1, *.ext2)
.- Parameters:
extensions
- The comma-separated list of file extensionsdefaultExtension
- The default extensiondescription
- A short textual description of the file type without supported extensions in parenthesesaddArchiveExtensionsToDescription
- Whether to also add the archive extensions to the description- Returns:
- The constructed filter
-
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 interfacejava.io.FileFilter
- Specified by:
accept
in classjavax.swing.filechooser.FileFilter
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in classjavax.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 classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-