source: josm/trunk/src/org/openstreetmap/josm/io/AllFormatsImporter.java@ 9059

Last change on this file since 9059 was 8510, checked in by Don-vip, 9 years ago

checkstyle: enable relevant whitespace checks and fix them

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.io.File;
7import java.util.Iterator;
8
9import org.openstreetmap.josm.actions.ExtensionFileFilter;
10
11/**
12 * Dummy importer that adds the "All Formats"-Filter when opening files
13 */
14public class AllFormatsImporter extends FileImporter {
15 /**
16 * Constructs a new {@code AllFormatsImporter}.
17 */
18 public AllFormatsImporter() {
19 super(new ExtensionFileFilter(getAllExtensions(), "", tr("All Formats")
20 + " (*.gpx *.osm *.nmea *.jpg ...)"));
21 }
22
23 @Override
24 public boolean acceptFile(File pathname) {
25 return false;
26 }
27
28 /**
29 * Builds list of all supported extensions by the registered FileImporters.
30 * @return String comma separated list of supported file extensions
31 */
32 private static String getAllExtensions() {
33 Iterator<FileImporter> imp = ExtensionFileFilter.importers.iterator();
34 StringBuilder ext = new StringBuilder();
35 while (imp.hasNext()) {
36 FileImporter fi = imp.next();
37 if (fi instanceof AllFormatsImporter) {
38 continue;
39 }
40 ext.append(fi.filter.getExtensions()).append(',');
41 }
42 // remove last comma
43 return ext.substring(0, ext.length()-1).toString();
44 }
45}
Note: See TracBrowser for help on using the repository browser.