Changeset 2367 in josm for trunk/src


Ignore:
Timestamp:
2009-11-01T02:42:01+01:00 (15 years ago)
Author:
framm
Message:

make file types optional so that JOSM still works if certain importers/exporters are not available. allows building .jar files e.g. without bzip2 support

File:
1 edited

Legend:

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

    r2288 r2367  
    3737     * list of supported formats
    3838     */
    39     public static ArrayList<FileImporter> importers = new ArrayList<FileImporter>(Arrays.asList(new OsmImporter(),
    40             new OsmGzipImporter(), new OsmBzip2Importer(), new GpxImporter(), new NMEAImporter(), new AllFormatsImporter()));
    41 
    42     public static ArrayList<FileExporter> exporters = new ArrayList<FileExporter>(Arrays.asList(new GpxExporter(),
    43             new OsmExporter(), new OsmGzipExporter(), new OsmBzip2Exporter()));
    44 
     39    public static ArrayList<FileImporter> importers;
     40   
     41    public static ArrayList<FileExporter> exporters;
     42   
     43    // add some file types only if the relevant classes are there;
     44    // this gives us the option to painlessly drop them from the .jar
     45    // and build JOSM versions without support for these formats
     46
     47    static {
     48
     49        importers = new ArrayList<FileImporter>();
     50       
     51        String[] importerNames = {
     52            "org.openstreetmap.josm.io.OsmImporter",
     53            "org.openstreetmap.josm.io.OsmGzipImporter",
     54            "org.openstreetmap.josm.io.GpxImporter",
     55            "org.openstreetmap.josm.io.NMEAImporter",
     56            "org.openstreetmap.josm.io.OsmBzip2Importer",
     57            "org.openstreetmap.josm.io.AllFormatsImporter"
     58        };
     59
     60        for (String classname : importerNames) {
     61            try {
     62                Class klass = Class.forName(classname);
     63                importers.add((FileImporter)klass.newInstance());
     64            } catch (Exception e) {}
     65        }
     66
     67        exporters = new ArrayList<FileExporter>();
     68
     69        String[] exporterNames = {
     70            "org.openstreetmap.josm.io.GpxExporter",
     71            "org.openstreetmap.josm.io.OsmExporter",
     72            "org.openstreetmap.josm.io.OsmGzipExporter",
     73            "org.openstreetmap.josm.io.OsmBzip2Exporter"
     74        };
     75
     76        for (String classname : exporterNames) {
     77            try {
     78                Class klass = Class.forName(classname);
     79                exporters.add((FileExporter)klass.newInstance());
     80            } catch (Exception e) {}
     81        }
     82    }
    4583
    4684    private final String extensions;
Note: See TracChangeset for help on using the changeset viewer.