Changeset 21280 in osm for applications/editors/josm


Ignore:
Timestamp:
2010-05-15T14:41:06+02:00 (15 years ago)
Author:
stoecker
Message:

fixed a lot

Location:
applications/editors/josm/plugins/tagging-preset-tester
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/tagging-preset-tester/build.xml

    r19481 r21280  
    2929
    3030        <property name="commit.message" value="Changed the constructor signature of the plugin main class" />
    31         <property name="plugin.main.version" value="2830" />
     31        <property name="plugin.main.version" value="3250" />
    3232
    3333
  • applications/editors/josm/plugins/tagging-preset-tester/src/org/openstreetmap/josm/plugins/taggingpresettester/TaggingPresetTester.java

    r19481 r21280  
    1212import java.io.BufferedReader;
    1313import java.net.URL;
     14import java.util.Arrays;
    1415import java.util.Collection;
    1516import java.util.Collections;
     
    2728import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2829import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    29 import org.openstreetmap.josm.plugins.PluginInformation;
    3030import org.xml.sax.SAXException;
    3131
     
    3838
    3939    public void reload() {
    40         Vector<TaggingPreset> allPresets = new Vector<TaggingPreset>();
    41         for (String source : args) {
    42             InputStream in = null;
    43             try {
    44                 if (source.startsWith("http") || source.startsWith("ftp") || source.startsWith("file"))
    45                     in = new URL(source).openStream();
    46                 else
    47                     in = new FileInputStream(source);
    48                 allPresets.addAll(TaggingPreset.readAll(new BufferedReader(new InputStreamReader(in))));
    49             } catch (IOException e) {
    50                 e.printStackTrace();
    51                 JOptionPane.showMessageDialog(null, tr("Could not read tagging preset source: {0}",source));
    52             } catch (SAXException e) {
    53                 e.printStackTrace();
    54                 JOptionPane.showMessageDialog(null, tr("Error parsing {0}: {1}",source,e.getMessage()));
    55             }
    56 
    57             try {
    58                 if (in != null)
    59                     in.close();
    60             } catch (IOException e) {
    61             }
    62         }
     40        Vector<TaggingPreset> allPresets = new Vector<TaggingPreset>(TaggingPreset.readAll(Arrays.asList(args)));
    6341        taggingPresets.setModel(new DefaultComboBoxModel(allPresets));
    6442    }
     
    7856    }
    7957   
    80     public TaggingPresetTester(PluginInformation info) {
    81         this(new String[]{});
    82     }
    83    
    8458    public TaggingPresetTester(String[] args) {
    8559        super(tr("Tagging Preset Tester"));
  • applications/editors/josm/plugins/tagging-preset-tester/src/org/openstreetmap/josm/plugins/taggingpresettester/TaggingPresetTesterAction.java

    r13497 r21280  
    55import java.awt.event.ActionEvent;
    66import java.awt.event.KeyEvent;
     7import java.util.Collection;
     8import java.util.Collections;
    79
    810import javax.swing.JOptionPane;
     
    1113import org.openstreetmap.josm.actions.JosmAction;
    1214import org.openstreetmap.josm.gui.MainMenu;
     15import org.openstreetmap.josm.gui.tagging.TaggingPreset;
     16import org.openstreetmap.josm.plugins.PluginInformation;
    1317import org.openstreetmap.josm.tools.Shortcut;
    1418
     
    2933    }
    3034
     35    public TaggingPresetTesterAction(PluginInformation info) {
     36        this();
     37    }
     38
    3139    public void actionPerformed(ActionEvent e) {
    32         String taggingPresetSources = Main.pref.get("taggingpreset.sources");
    33         if (taggingPresetSources.equals("")) {
     40        Collection<String> coll = TaggingPreset.getPresetSources();
     41
     42        if (coll.size() == 0) {
    3443            JOptionPane.showMessageDialog(Main.parent, tr("You have to specify tagging preset sources in the preferences first."));
    3544            return;
    3645        }
    37         String[] args = taggingPresetSources.split(";");
    38         new TaggingPresetTester(args);
     46
     47        String[] taggingPresetSources = new String [coll.size()];
     48        coll.toArray(taggingPresetSources);
     49        new TaggingPresetTester(taggingPresetSources);
    3950    }
    4051}
Note: See TracChangeset for help on using the changeset viewer.