Changeset 906 in josm
- Timestamp:
- 2008-09-02T18:22:40+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/PluginPreference.java
r873 r906 171 171 // refresh description 172 172 PluginDownloader.downloadDescription(); 173 refreshPluginPanel(gui); 173 174 174 175 Set<PluginDescription> toUpdate = new HashSet<PluginDescription>(); -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r895 r906 9 9 import java.awt.event.ActionEvent; 10 10 import java.io.BufferedReader; 11 import java.io. FileInputStream;11 import java.io.InputStreamReader; 12 12 import java.io.IOException; 13 import java.io.InputStream;14 import java.io.InputStreamReader;15 13 import java.io.UnsupportedEncodingException; 16 import java.net.URL;17 14 import java.util.Collection; 18 15 import java.util.HashMap; … … 22 19 import java.util.List; 23 20 import java.util.Set; 24 import java.util.StringTokenizer;25 21 26 22 import javax.swing.AbstractAction; … … 40 36 import org.openstreetmap.josm.data.osm.OsmPrimitive; 41 37 import org.openstreetmap.josm.data.osm.OsmUtils; 38 import org.openstreetmap.josm.io.MirroredInputStream; 42 39 import org.openstreetmap.josm.gui.QuadStateCheckBox; 43 40 import org.openstreetmap.josm.gui.tagging.TaggingPresetMenu; … … 326 323 */ 327 324 public Collection<Class<?>> types; 328 p rivateList<Item> data = new LinkedList<Item>();325 public List<Item> data = new LinkedList<Item>(); 329 326 private static HashMap<String,String> lastValue = new HashMap<String,String>(); 330 327 … … 386 383 } 387 384 388 public static List<TaggingPreset> readAll(InputStream inStream) throws SAXException { 389 BufferedReader in = null; 390 try { 391 in = new BufferedReader(new InputStreamReader(inStream, "UTF-8")); 392 } catch (UnsupportedEncodingException e) { 393 e.printStackTrace(); 394 in = new BufferedReader(new InputStreamReader(inStream)); 395 } 385 private static List<TaggingPreset> readAll(BufferedReader in) throws SAXException { 396 386 XmlObjectParser parser = new XmlObjectParser(); 397 387 parser.mapOnStart("item", TaggingPreset.class); … … 441 431 String allTaggingPresets = Main.pref.get("taggingpreset.sources"); 442 432 443 if (Main.pref.getBoolean("taggingpreset.enable-defaults", true)) { 444 InputStream in = Main.class.getResourceAsStream("/presets/presets.xml"); 433 if (Main.pref.getBoolean("taggingpreset.enable-defaults", true)) 434 { 435 allTaggingPresets = "resource://presets/presets.xml" 436 + (allTaggingPresets != null ? ";"+allTaggingPresets : ""); 437 } 438 439 for(String source : allTaggingPresets.split(";")) 440 { 445 441 try { 446 allPresets.addAll(TaggingPreset.readAll(in)); 447 } catch (SAXException x) { 448 JOptionPane.showMessageDialog(Main.parent, tr("Error parsing presets.xml: ")+x.getMessage()); 449 } 450 } 451 452 StringTokenizer st = new StringTokenizer(allTaggingPresets, ";"); 453 while (st.hasMoreTokens()) { 454 InputStream in = null; 455 String source = st.nextToken(); 456 try { 457 if (source.startsWith("http") || source.startsWith("ftp") || source.startsWith("file")) 458 in = new URL(source).openStream(); 459 else if (source.startsWith("resource://")) 460 in = Main.class.getResourceAsStream(source.substring("resource:/".length())); 461 else 462 in = new FileInputStream(source); 463 allPresets.addAll(TaggingPreset.readAll(in)); 464 in.close(); 442 MirroredInputStream s = new MirroredInputStream(source); 443 InputStreamReader r; 444 try 445 { 446 r = new InputStreamReader(s, "UTF-8"); 447 } 448 catch (UnsupportedEncodingException e) 449 { 450 r = new InputStreamReader(s); 451 } 452 allPresets.addAll(TaggingPreset.readAll(new BufferedReader(r))); 465 453 } catch (IOException e) { 466 454 e.printStackTrace();
Note:
See TracChangeset
for help on using the changeset viewer.