Ignore:
Timestamp:
2015-10-18T12:48:44+02:00 (9 years ago)
Author:
simon04
Message:

fix #7058 - Ability to load gz and bz2 zipped NMEA files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java

    r8813 r8894  
    55import java.util.ArrayList;
    66import java.util.Arrays;
     7import java.util.Collection;
    78import java.util.Collections;
    89import java.util.Comparator;
     10import java.util.LinkedHashSet;
    911import java.util.LinkedList;
    1012import java.util.List;
     
    279281
    280282    /**
     283     * Construct an extension file filter with the extensions supported by {@link org.openstreetmap.josm.io.Compression}
     284     * automatically added to the {@code extensions}. The specified {@code extensions} will be added to the description
     285     * in the form {@code old-description (*.ext1, *.ext2)}.
     286     * @param extensions The comma-separated list of file extensions
     287     * @param defaultExtension The default extension
     288     * @param description A short textual description of the file type without supported extensions in parentheses
     289     * @return The constructed filter
     290     */
     291    public static ExtensionFileFilter newFilterWithArchiveExtensions(String extensions, String defaultExtension, String description) {
     292        final Collection<String> extensionsPlusArchive = new LinkedHashSet<>();
     293        final Collection<String> extensionsForDescription = new LinkedHashSet<>();
     294        for (String e : extensions.split(",")) {
     295            extensionsPlusArchive.add(e);
     296            extensionsPlusArchive.add(e + ".gz");
     297            extensionsPlusArchive.add(e + ".bz2");
     298            extensionsForDescription.add("*." + e);
     299            // intentionally do not add [e].gz and [e].bz2 to extensionsForDescription in order to avoid long texts
     300        }
     301        return new ExtensionFileFilter(Utils.join(",", extensionsPlusArchive), defaultExtension,
     302                description + " (" + Utils.join(", ", extensionsForDescription) + ")");
     303    }
     304
     305    /**
    281306     * Returns true if this file filter accepts the given filename.
    282307     * @param filename The filename to check after
Note: See TracChangeset for help on using the changeset viewer.