Changeset 2832 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2010-01-12T20:02:54+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r2827 r2832 1 1 package org.openstreetmap.josm.gui.mappaint; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 import java.io.IOException; 3 6 import java.util.Collection; 4 7 import java.util.Collections; … … 12 15 import org.openstreetmap.josm.tools.ImageProvider; 13 16 import org.xml.sax.InputSource; 17 import org.xml.sax.SAXException; 14 18 import org.xml.sax.XMLReader; 15 19 import org.xml.sax.helpers.XMLReaderFactory; … … 31 35 { 32 36 String[] a; 33 if(fileset.indexOf("=") >= 0) 37 if(fileset.indexOf("=") >= 0) { 34 38 a = fileset.split("=", 2); 35 else39 } else { 36 40 a = new String[] {"", fileset}; 41 } 37 42 38 43 /* non-prefixed path is generic path, always take it */ 39 if(a[0].length() == 0 || styleName.equals(a[0])) 44 if(a[0].length() == 0 || styleName.equals(a[0])) { 40 45 dirs.add(a[1]); 46 } 41 47 } 42 48 ImageIcon i = ImageProvider.getIfAvailable(dirs, "mappaint."+styleName, null, name); … … 61 67 62 68 Collection<String> files = Main.pref.getCollection("mappaint.style.sources", Collections.<String>emptySet()); 63 if(Main.pref.getBoolean("mappaint.style.enable-defaults", true)) 64 { 69 if (Main.pref.getBoolean("mappaint.style.enable-defaults", true)) { 65 70 LinkedList<String> f = new LinkedList<String>(); 66 71 f.add("resource://data/elemstyles.xml"); … … 69 74 } 70 75 71 for(String fileset : files) 72 { 76 for (String file : files) { 73 77 String[] a = null; 74 try 75 {76 if(fileset.indexOf("=") >= 0)77 a = fileset.split("=", 2);78 else79 a = new String[] {null, fileset};78 try { 79 if (file.indexOf("=") >= 0) { 80 a = file.split("=", 2); 81 } else { 82 a = new String[] { null, file }; 83 } 80 84 XMLReader xmlReader = XMLReaderFactory.createXMLReader(); 81 85 ElemStyleHandler handler = new ElemStyleHandler(a[0]); 82 86 xmlReader.setContentHandler(handler); 83 87 xmlReader.setErrorHandler(handler); 84 xmlReader.parse(new InputSource(new MirroredInputStream(a[1]))); 85 } 86 catch (Exception e) 87 { 88 System.out.println("Mappaint-Style \"" + a[0] + "\" file \"" + a[1] + "\""); 89 System.out.println("Mappaint-Style problems: " + e); 88 MirroredInputStream in = new MirroredInputStream(a[1]); 89 xmlReader.parse(new InputSource(in)); 90 } catch(IOException e) { 91 System.err.println(tr("Warning: failed to load Mappaint-Styles from ''{0}''. Exception was: {1}", a[1], e.toString())); 92 e.printStackTrace(); 93 } catch(SAXException e) { 94 System.err.println(tr("Warning: failed to parse Mappaint-Styles from ''{0}''. Exception was: {1}", a[1], e.toString())); 90 95 e.printStackTrace(); 91 96 } … … 93 98 iconDirs = null; 94 99 } 95 96 100 }
Note:
See TracChangeset
for help on using the changeset viewer.