Ticket #12370: OsmFileFilter.3.patch
| File OsmFileFilter.3.patch, 11.9 KB (added by , 10 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/ExtensionFileFilter.java
diff --git a/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java b/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java index 01d74ad..1d3baf2 100644
a b public class ExtensionFileFilter extends FileFilter implements java.io.FileFilte 52 52 53 53 final List<Class<? extends FileImporter>> importerNames = Arrays.asList( 54 54 org.openstreetmap.josm.io.OsmImporter.class, 55 org.openstreetmap.josm.io.OsmGzipImporter.class,56 org.openstreetmap.josm.io.OsmZipImporter.class,57 55 org.openstreetmap.josm.io.OsmChangeImporter.class, 58 56 org.openstreetmap.josm.io.GpxImporter.class, 59 57 org.openstreetmap.josm.io.NMEAImporter.class, 60 58 org.openstreetmap.josm.io.NoteImporter.class, 61 org.openstreetmap.josm.io.OsmBzip2Importer.class,62 59 org.openstreetmap.josm.io.JpgImporter.class, 63 60 org.openstreetmap.josm.io.WMSLayerImporter.class, 64 61 org.openstreetmap.josm.io.AllFormatsImporter.class, … … public class ExtensionFileFilter extends FileFilter implements java.io.FileFilte 141 138 ); 142 139 } 143 140 141 public enum AddArchiveExtension { NONE, BASE, ALL } 142 144 143 /** 145 144 * Updates the {@link AllFormatsImporter} that is contained in the importers list. If 146 145 * you do not use the importers variable directly, you don’t need to call this. … … public class ExtensionFileFilter extends FileFilter implements java.io.FileFilte 295 294 * @param extensions The comma-separated list of file extensions 296 295 * @param defaultExtension The default extension 297 296 * @param description A short textual description of the file type without supported extensions in parentheses 298 * @param addArchiveExtensionsToDescription Whether to also add the archive extensions to the description 297 * @param addArchiveExtension Whether to also add the archive extensions to the description 298 * @param archiveExtensions List of extensions to be added 299 299 * @return The constructed filter 300 300 */ 301 301 public static ExtensionFileFilter newFilterWithArchiveExtensions( 302 String extensions, String defaultExtension, String description, boolean addArchiveExtensionsToDescription) {302 String extensions, String defaultExtension, String description, AddArchiveExtension addArchiveExtension, List<String> archiveExtensions) { 303 303 final Collection<String> extensionsPlusArchive = new LinkedHashSet<>(); 304 304 final Collection<String> extensionsForDescription = new LinkedHashSet<>(); 305 305 for (String e : extensions.split(",")) { 306 306 extensionsPlusArchive.add(e); 307 extensionsPlusArchive.add(e + ".gz"); 308 extensionsPlusArchive.add(e + ".bz2"); 309 extensionsForDescription.add("*." + e); 310 if (addArchiveExtensionsToDescription) { 311 extensionsForDescription.add("*." + e + ".gz"); 312 extensionsForDescription.add("*." + e + ".bz2"); 307 if (addArchiveExtension != AddArchiveExtension.NONE) { 308 extensionsForDescription.add("*." + e); 309 } 310 for (String extension : archiveExtensions) { 311 extensionsPlusArchive.add(e + '.' + extension); 312 if (addArchiveExtension == AddArchiveExtension.ALL) { 313 extensionsForDescription.add("*." + e + '.' + extension); 314 } 313 315 } 314 316 } 315 return new ExtensionFileFilter(Utils.join(",", extensionsPlusArchive), defaultExtension, 316 description + " (" + Utils.join(", ", extensionsForDescription) + ")"); 317 return new ExtensionFileFilter( 318 Utils.join(",", extensionsPlusArchive), 319 defaultExtension, 320 description + (!extensionsForDescription.isEmpty() 321 ? " (" + Utils.join(", ", extensionsForDescription) + ")" 322 : "") 323 ); 324 } 325 326 /** 327 * Construct an extension file filter with the extensions supported by {@link org.openstreetmap.josm.io.Compression} 328 * automatically added to the {@code extensions}. The specified {@code extensions} will be added to the description 329 * in the form {@code old-description (*.ext1, *.ext2)}. 330 * @param extensions The comma-separated list of file extensions 331 * @param defaultExtension The default extension 332 * @param description A short textual description of the file type without supported extensions in parentheses 333 * @param addArchiveExtensionsToDescription Whether to also add the archive extensions to the description 334 * @return The constructed filter 335 */ 336 public static ExtensionFileFilter newFilterWithArchiveExtensions( 337 String extensions, String defaultExtension, String description, boolean addArchiveExtensionsToDescription) { 338 339 List<String> archiveExtensions = Arrays.asList("gz", "bz2"); 340 return newFilterWithArchiveExtensions( 341 extensions, 342 defaultExtension, 343 description, 344 addArchiveExtensionsToDescription ? AddArchiveExtension.ALL : AddArchiveExtension.BASE, 345 archiveExtensions 346 ); 317 347 } 318 348 319 349 /** -
src/org/openstreetmap/josm/io/OsmBzip2Exporter.java
diff --git a/src/org/openstreetmap/josm/io/OsmBzip2Exporter.java b/src/org/openstreetmap/josm/io/OsmBzip2Exporter.java index a3dd2f6..38a6e1a 100644
a b 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.io; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import org.openstreetmap.josm.actions.ExtensionFileFilter; 7 4 8 /** 5 9 * OSM data exporter that compresses it in Bzip2 format. 6 10 */ … … public class OsmBzip2Exporter extends OsmExporter { 10 14 * Constructs a new {@code OsmBzip2Exporter}. 11 15 */ 12 16 public OsmBzip2Exporter() { 13 super(OsmBzip2Importer.FILE_FILTER); 17 super(new ExtensionFileFilter( 18 "osm.bz2,osm.bz", "osm.bz2", tr("OSM Server Files bzip2 compressed") + " (*.osm.bz2, *.osm.bz)")); 14 19 } 15 20 16 21 // compression handling is performed in super-class -
deleted file src/org/openstreetmap/josm/io/OsmBzip2Importer.java
diff --git a/src/org/openstreetmap/josm/io/OsmBzip2Importer.java b/src/org/openstreetmap/josm/io/OsmBzip2Importer.java deleted file mode 100644 index de84539..0000000
+ - 1 // License: GPL. For details, see LICENSE file.2 package org.openstreetmap.josm.io;3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 6 import org.openstreetmap.josm.actions.ExtensionFileFilter;7 8 /**9 * OSM data importer that uncompresses it from Bzip2 format.10 */11 public class OsmBzip2Importer extends OsmImporter {12 13 /**14 * File filter used to load/save Bzip2 compressed OSM files.15 */16 public static final ExtensionFileFilter FILE_FILTER = new ExtensionFileFilter(17 "osm.bz2,osm.bz", "osm.bz2", tr("OSM Server Files bzip2 compressed") + " (*.osm.bz2 *.osm.bz)");18 19 /**20 * Constructs a new {@code OsmBzip2Importer}.21 */22 public OsmBzip2Importer() {23 super(FILE_FILTER);24 }25 26 // compression handling is performed in super-class27 28 } -
src/org/openstreetmap/josm/io/OsmExporter.java
diff --git a/src/org/openstreetmap/josm/io/OsmExporter.java b/src/org/openstreetmap/josm/io/OsmExporter.java index 95d8ad3..40a7051 100644
a b public class OsmExporter extends FileExporter { 31 31 * Constructs a new {@code OsmExporter}. 32 32 */ 33 33 public OsmExporter() { 34 super(OsmImporter.FILE_FILTER); 34 super(new ExtensionFileFilter( 35 "osm,xml", "osm", tr("OSM Server Files") + " (*.osm)")); 35 36 } 36 37 37 38 /** -
src/org/openstreetmap/josm/io/OsmGzipExporter.java
diff --git a/src/org/openstreetmap/josm/io/OsmGzipExporter.java b/src/org/openstreetmap/josm/io/OsmGzipExporter.java index 77ca4e1..a2eea57 100644
a b 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.io; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import org.openstreetmap.josm.actions.ExtensionFileFilter; 7 4 8 /** 5 9 * OSM data exporter that compresses it in GZip format. 6 10 */ … … public class OsmGzipExporter extends OsmExporter { 10 14 * Constructs a new {@code OsmGzipExporter}. 11 15 */ 12 16 public OsmGzipExporter() { 13 super(OsmGzipImporter.FILE_FILTER); 17 super(new ExtensionFileFilter( 18 "osm.gz", "osm.gz", tr("OSM Server Files gzip compressed") + " (*.osm.gz)")); 14 19 } 15 20 16 21 // compression handling is performed in super-class -
deleted file src/org/openstreetmap/josm/io/OsmGzipImporter.java
diff --git a/src/org/openstreetmap/josm/io/OsmGzipImporter.java b/src/org/openstreetmap/josm/io/OsmGzipImporter.java deleted file mode 100644 index 9ab1df7..0000000
+ - 1 // License: GPL. For details, see LICENSE file.2 package org.openstreetmap.josm.io;3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 6 import org.openstreetmap.josm.actions.ExtensionFileFilter;7 8 /**9 * OSM data importer that uncompresses it from Gzip format.10 */11 public class OsmGzipImporter extends OsmImporter {12 13 /**14 * File filter used to load/save Gzip compressed OSM files.15 */16 public static final ExtensionFileFilter FILE_FILTER = new ExtensionFileFilter(17 "osm.gz", "osm.gz", tr("OSM Server Files gzip compressed") + " (*.osm.gz)");18 19 /**20 * Constructs a new {@code OsmGzipImporter}.21 */22 public OsmGzipImporter() {23 super(FILE_FILTER);24 }25 26 // compression handling is performed in super-class27 28 } -
src/org/openstreetmap/josm/io/OsmImporter.java
diff --git a/src/org/openstreetmap/josm/io/OsmImporter.java b/src/org/openstreetmap/josm/io/OsmImporter.java index fa54c0b..5e833c7 100644
a b import java.io.File; 7 7 import java.io.FileNotFoundException; 8 8 import java.io.IOException; 9 9 import java.io.InputStream; 10 import java.util.Arrays; 10 11 11 12 import javax.swing.JOptionPane; 12 13 … … public class OsmImporter extends FileImporter { 23 24 /** 24 25 * The OSM file filter (*.osm and *.xml files). 25 26 */ 26 public static final ExtensionFileFilter FILE_FILTER = new ExtensionFileFilter(27 "osm,xml", "osm", tr("OSM Server Files") + " (*.osm *.xml)");27 public static final ExtensionFileFilter FILE_FILTER = ExtensionFileFilter.newFilterWithArchiveExtensions( 28 "osm,xml", "osm", tr("OSM Server Files") + " (*.osm, *.osm.gz, *.osm.bz2, *.osm.zip, *.xml)", ExtensionFileFilter.AddArchiveExtension.NONE, Arrays.asList("gz", "bz", "bz2", "zip")); 28 29 29 30 /** 30 31 * Utility class containing imported OSM layer, and a task to run after it is added to MapView. -
deleted file src/org/openstreetmap/josm/io/OsmZipImporter.java
diff --git a/src/org/openstreetmap/josm/io/OsmZipImporter.java b/src/org/openstreetmap/josm/io/OsmZipImporter.java deleted file mode 100644 index d9b4e6d..0000000
+ - 1 // License: GPL. For details, see LICENSE file.2 package org.openstreetmap.josm.io;3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 6 import org.openstreetmap.josm.actions.ExtensionFileFilter;7 8 /**9 * OSM data importer that uncompresses it from Zip format.10 * @since 688211 */12 public class OsmZipImporter extends OsmImporter {13 14 /**15 * File filter used to load/save Zip compressed OSM files.16 */17 public static final ExtensionFileFilter FILE_FILTER = new ExtensionFileFilter(18 "osm.zip", "osm.zip", tr("OSM Server Files zip compressed") + " (*.osm.zip)");19 20 /**21 * Constructs a new {@code OsmZipImporter}.22 */23 public OsmZipImporter() {24 super(FILE_FILTER);25 }26 27 // compression handling is performed in super-class28 }
