Changeset 3848 in josm for trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
- Timestamp:
- 2011-02-02T23:03:00+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r3843 r3848 14 14 15 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 17 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 16 18 import org.openstreetmap.josm.gui.mappaint.xml.XmlStyleSource; 17 19 import org.openstreetmap.josm.gui.preferences.SourceEntry; 18 20 import org.openstreetmap.josm.gui.preferences.MapPaintPreference.MapPaintPrefMigration; 21 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 19 22 import org.openstreetmap.josm.io.MirroredInputStream; 20 23 import org.openstreetmap.josm.tools.ImageProvider; … … 83 86 84 87 for (SourceEntry entry : sourceEntries) { 85 StyleSource style = n ew XmlStyleSource(entry);88 StyleSource style = null; 86 89 try { 87 90 MirroredInputStream in = new MirroredInputStream(entry.url); 88 91 InputStream zip = in.getZipEntry("xml","style"); 89 92 if (zip != null) { 90 style.zipIcons = in.getFile(); 91 } 93 style = new XmlStyleSource(entry); 94 continue; 95 } 96 zip = in.getZipEntry("mapcss","style"); 97 if (zip != null) { 98 style = new MapCSSStyleSource(entry); 99 continue; 100 } 101 if (entry.url.toLowerCase().endsWith(".mapcss")) { 102 style = new MapCSSStyleSource(entry); 103 } else { 104 style = new XmlStyleSource(entry); 105 } 92 106 } catch(IOException e) { 93 107 System.err.println(tr("Warning: failed to load Mappaint styles from ''{0}''. Exception was: {1}", entry.url, e.toString())); 94 108 e.printStackTrace(); 95 style.hasError = true; 109 if (style != null) { 110 style.hasError = true; 111 } 96 112 } 97 styles.add(style); 113 if (style != null) { 114 styles.add(style); 115 } 98 116 } 99 117 for (StyleSource s : styles.getStyleSources()) { … … 101 119 } 102 120 } 121 122 public static class MapPaintStyleLoader extends PleaseWaitRunnable { 123 private boolean canceled; 124 private List<StyleSource> sources; 125 126 public MapPaintStyleLoader(List<StyleSource> sources) { 127 super(tr("Reloading style sources")); 128 this.sources = sources; 129 } 130 131 @Override 132 protected void cancel() { 133 canceled = true; 134 } 135 136 @Override 137 protected void finish() { 138 } 139 140 @Override 141 protected void realRun() { 142 ProgressMonitor monitor = getProgressMonitor(); 143 monitor.setTicksCount(sources.size()); 144 for (StyleSource s : sources) { 145 if (canceled) 146 return; 147 monitor.subTask(tr("loading style ''{0}''...", s.getDisplayString())); 148 s.loadStyleSource(); 149 monitor.worked(1); 150 } 151 } 152 } 153 103 154 }
Note:
See TracChangeset
for help on using the changeset viewer.