Changeset 9537 in josm
- Timestamp:
- 2016-01-19T11:20:23+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java
r9466 r9537 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, … … 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 … … 287 286 this.defaultExtension = defaultExtension; 288 287 this.description = description; 288 } 289 290 /** 291 * Construct an extension file filter with the extensions supported by {@link org.openstreetmap.josm.io.Compression} 292 * automatically added to the {@code extensions}. The specified {@code extensions} will be added to the description 293 * in the form {@code old-description (*.ext1, *.ext2)}. 294 * @param extensions The comma-separated list of file extensions 295 * @param defaultExtension The default extension 296 * @param description A short textual description of the file type without supported extensions in parentheses 297 * @param addArchiveExtension Whether to also add the archive extensions to the description 298 * @param archiveExtensions List of extensions to be added 299 * @return The constructed filter 300 */ 301 public static ExtensionFileFilter newFilterWithArchiveExtensions( 302 String extensions, String defaultExtension, String description, AddArchiveExtension addArchiveExtension, List<String> archiveExtensions) { 303 final Collection<String> extensionsPlusArchive = new LinkedHashSet<>(); 304 final Collection<String> extensionsForDescription = new LinkedHashSet<>(); 305 for (String e : extensions.split(",")) { 306 extensionsPlusArchive.add(e); 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 } 315 } 316 } 317 return new ExtensionFileFilter( 318 Utils.join(",", extensionsPlusArchive), 319 defaultExtension, 320 description + (!extensionsForDescription.isEmpty() 321 ? " (" + Utils.join(", ", extensionsForDescription) + ")" 322 : "") 323 ); 289 324 } 290 325 … … 301 336 public static ExtensionFileFilter newFilterWithArchiveExtensions( 302 337 String extensions, String defaultExtension, String description, boolean addArchiveExtensionsToDescription) { 303 final Collection<String> extensionsPlusArchive = new LinkedHashSet<>(); 304 final Collection<String> extensionsForDescription = new LinkedHashSet<>(); 305 for (String e : extensions.split(",")) { 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"); 313 } 314 } 315 return new ExtensionFileFilter(Utils.join(",", extensionsPlusArchive), defaultExtension, 316 description + " (" + Utils.join(", ", extensionsForDescription) + ")"); 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 -
trunk/src/org/openstreetmap/josm/io/OsmBzip2Exporter.java
r6718 r9537 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.io; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import org.openstreetmap.josm.actions.ExtensionFileFilter; 3 7 4 8 /** … … 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 -
trunk/src/org/openstreetmap/josm/io/OsmExporter.java
r9296 r9537 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 -
trunk/src/org/openstreetmap/josm/io/OsmGzipExporter.java
r6718 r9537 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.io; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import org.openstreetmap.josm.actions.ExtensionFileFilter; 3 7 4 8 /** … … 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 -
trunk/src/org/openstreetmap/josm/io/OsmImporter.java
r8929 r9537 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; … … 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 /**
Note:
See TracChangeset
for help on using the changeset viewer.