Last change
on this file since 7248 was 5131, checked in by xeen, 13 years ago |
automatically add file extensions added by plugins to the "All Formats" importer.
If you have the PBF plugin installed it should now be possible to open .osm.pbf
files without selecting the PBF importer first.
|
-
Property svn:eol-style
set to
native
|
File size:
1.3 KB
|
Line | |
---|
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 java.io.File;
|
---|
7 | import java.util.Iterator;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.actions.ExtensionFileFilter;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Dummy importer that adds the "All Formats"-Filter when opening files
|
---|
13 | */
|
---|
14 | public class AllFormatsImporter extends FileImporter {
|
---|
15 | public AllFormatsImporter() {
|
---|
16 | super(new ExtensionFileFilter(getAllExtensions(), "", tr("All Formats")
|
---|
17 | + " (*.gpx *.osm *.nmea *.jpg ...)"));
|
---|
18 | }
|
---|
19 |
|
---|
20 | @Override public boolean acceptFile(File pathname) {
|
---|
21 | return false;
|
---|
22 | }
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Builds list of all supported extensions by the registered FileImporters.
|
---|
26 | * @return String comma separated list of supported file extensions
|
---|
27 | */
|
---|
28 | private static String getAllExtensions() {
|
---|
29 | Iterator<FileImporter> imp = ExtensionFileFilter.importers.iterator();
|
---|
30 | StringBuilder ext = new StringBuilder();
|
---|
31 | while(imp.hasNext()) {
|
---|
32 | FileImporter fi = imp.next();
|
---|
33 | if(fi instanceof AllFormatsImporter) {
|
---|
34 | continue;
|
---|
35 | }
|
---|
36 | ext.append(fi.filter.getExtensions());
|
---|
37 | ext.append(",");
|
---|
38 | }
|
---|
39 | // remove last comma
|
---|
40 | return ext.substring(0, ext.length()-1).toString();
|
---|
41 | }
|
---|
42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.