Package org.openstreetmap.josm.actions
Class ExtensionFileFilter
java.lang.Object
javax.swing.filechooser.FileFilter
org.openstreetmap.josm.actions.ExtensionFileFilter
- All Implemented Interfaces:
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 ClassesModifier and TypeClassDescriptionstatic enumStrategy to determine if extensions must be added to the description. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate final Stringprivate static final ArrayList<FileExporter>List of supported formats for export.private final Stringprivate static final ArrayList<FileImporter>List of supported formats for import. -
Constructor Summary
ConstructorsConstructorDescriptionExtensionFileFilter(String extension, String defaultExtension, String description) Construct an extension file filter by giving the extension to check after. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanacceptName(String filename) Returns true if this file filter accepts the given filename.static voidaddExporter(FileExporter exporter) Adds a new file exporter at the end of the global list.static voidaddExporterFirst(FileExporter exporter) Adds a new file exporter at the beginning of the global list.static voidaddImporter(FileImporter importer) Adds a new file importer at the end of the global list.static voidaddImporterFirst(FileImporter importer) Adds a new file importer at the beginning of the global list.static voidapplyChoosableExportFileFilters(AbstractFileChooser fileChooser, String extension, Predicate<ExtensionFileFilter> additionalTypes) Applies the choosableFileFilterto aAbstractFileChooserbefore using the file chooser for selecting a file for writing.static voidapplyChoosableImportFileFilters(AbstractFileChooser fileChooser, String extension, Predicate<ExtensionFileFilter> additionalTypes) Applies the choosableFileFilterto aAbstractFileChooserbefore using the file chooser for selecting a file for reading.protected static Comparator<ExtensionFileFilter>booleanstatic ExtensionFileFiltergetDefaultExportExtensionFileFilter(String extension) Replies the defaultExtensionFileFilterfor a given extensionReplies the default file extension of this file filter.static ExtensionFileFiltergetDefaultImportExtensionFileFilter(String extension) Replies the defaultExtensionFileFilterfor a given extensionstatic List<FileExporter>Returns the list of file exporters.static List<ExtensionFileFilter>Replies an ordered list of enabledExtensionFileFilters for exporting.Replies the comma-separated list of file extensions of this file filter.static List<FileImporter>Returns the list of file importers.static List<ExtensionFileFilter>Replies an ordered list ofExtensionFileFilters for importing.inthashCode()static ExtensionFileFilternewFilterWithArchiveExtensions(String extensions, String defaultExtension, String description, boolean addArchiveExtensionsToDescription) Construct an extension file filter with the extensions supported byCompressionautomatically added to theextensions.static ExtensionFileFilternewFilterWithArchiveExtensions(String extensions, String defaultExtension, String description, ExtensionFileFilter.AddArchiveExtension addArchiveExtension, List<String> archiveExtensions) Construct an extension file filter with the extensions supported byCompressionautomatically added to theextensions.static voidUpdates theAllFormatsImporterthat is contained in the importers list.
-
Field Details
-
importers
List of supported formats for import.- Since:
- 4869
-
exporters
List of supported formats for export.- Since:
- 4869
-
extensions
-
description
-
defaultExtension
-
-
Constructor Details
-
ExtensionFileFilter
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 Details
-
comparator
-
addImporter
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
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
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
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
Returns the list of file importers.- Returns:
- unmodifiable list of file importers
- Since:
- 10407
-
getExporters
Returns the list of file exporters.- Returns:
- unmodifiable list of file exporters
- Since:
- 10407
-
updateAllFormatsImporter
Updates theAllFormatsImporterthat 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
Replies an ordered list ofExtensionFileFilters for importing. The list is ordered according to their description, anAllFormatsImporteris append at the end.- Returns:
- an ordered list of
ExtensionFileFilters for importing. - Since:
- 2029
-
getExportExtensionFileFilters
Replies an ordered list of enabledExtensionFileFilters for exporting. The list is ordered according to their description, anAllFormatsImporteris append at the end.- Returns:
- an ordered list of enabled
ExtensionFileFilters for exporting. - Since:
- 2029
-
getDefaultImportExtensionFileFilter
Replies the defaultExtensionFileFilterfor a given extension- Parameters:
extension- the extension- Returns:
- the default
ExtensionFileFilterfor a given extension - Since:
- 2029
-
getDefaultExportExtensionFileFilter
Replies the defaultExtensionFileFilterfor a given extension- Parameters:
extension- the extension- Returns:
- the default
ExtensionFileFilterfor a given extension - Since:
- 2029
-
applyChoosableImportFileFilters
public static void applyChoosableImportFileFilters(AbstractFileChooser fileChooser, String extension, Predicate<ExtensionFileFilter> additionalTypes) Applies the choosableFileFilterto aAbstractFileChooserbefore 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, String extension, Predicate<ExtensionFileFilter> additionalTypes) Applies the choosableFileFilterto aAbstractFileChooserbefore 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(String extensions, String defaultExtension, String description, ExtensionFileFilter.AddArchiveExtension addArchiveExtension, List<String> archiveExtensions) Construct an extension file filter with the extensions supported byCompressionautomatically added to theextensions. The specifiedextensionswill 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(String extensions, String defaultExtension, String description, boolean addArchiveExtensionsToDescription) Construct an extension file filter with the extensions supported byCompressionautomatically added to theextensions. The specifiedextensionswill 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
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
- Specified by:
acceptin interfaceFileFilter- Specified by:
acceptin classFileFilter
-
getDescription
- Specified by:
getDescriptionin classFileFilter
-
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
Replies the default file extension of this file filter.- Returns:
- the default file extension of this file filter
- Since:
- 2029
-
hashCode
-
equals
-