Changeset 9965 in josm for trunk/src/org
- Timestamp:
- 2016-03-12T00:10:24+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r9911 r9965 1434 1434 */ 1435 1435 private void removeObsolete(int loadedVersion) { 1436 // drop this block march 20161437 // update old style JOSM server links to use zip now, see #10581, #121891438 // actually also cache and mirror entries should be cleared1439 if (loadedVersion < 9216) {1440 for (String key: new String[]{"mappaint.style.entries", "taggingpreset.entries"}) {1441 Collection<Map<String, String>> data = getListOfStructs(key, (Collection<Map<String, String>>) null);1442 if (data != null) {1443 List<Map<String, String>> newlist = new ArrayList<>();1444 boolean modified = false;1445 for (Map<String, String> map : data) {1446 Map<String, String> newmap = new LinkedHashMap<>();1447 for (Entry<String, String> entry : map.entrySet()) {1448 String val = entry.getValue();1449 String mkey = entry.getKey();1450 if ("url".equals(mkey) && val.contains("josm.openstreetmap.de/josmfile") && !val.contains("zip=1")) {1451 val += "&zip=1";1452 modified = true;1453 }1454 if ("url".equals(mkey) && val.contains("http://josm.openstreetmap.de/josmfile")) {1455 val = val.replace("http://", "https://");1456 modified = true;1457 }1458 newmap.put(mkey, val);1459 }1460 newlist.add(newmap);1461 }1462 if (modified) {1463 putListOfStructs(key, newlist);1464 }1465 }1466 }1467 }1468 1436 /* drop in October 2016 */ 1469 1437 if (loadedVersion < 9715) { … … 1491 1459 } 1492 1460 } 1461 // drop in November 2016 1462 if (loadedVersion < 9965) { 1463 Setting<?> setting = settingsMap.get("mappaint.style.entries"); 1464 if (setting != null && setting instanceof MapListSetting) { 1465 List<Map<String, String>> l = new LinkedList<>(); 1466 boolean modified = false; 1467 for (Map<String, String> map: ((MapListSetting) setting).getValue()) { 1468 String url = map.get("url"); 1469 if (url != null && url.contains("josm.openstreetmap.de/josmfile?page=Styles/LegacyStandard")) { 1470 modified = true; 1471 } else { 1472 l.add(map); 1473 } 1474 } 1475 if (modified) { 1476 putListOfStructs("mappaint.style.entries", l); 1477 } 1478 } 1479 } 1493 1480 1494 1481 for (String key : OBSOLETE_PREF_KEYS) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
r9284 r9965 39 39 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 40 40 import org.openstreetmap.josm.gui.mappaint.Cascade; 41 import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;42 41 import org.openstreetmap.josm.gui.mappaint.ElemStyles; 43 42 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; … … 47 46 import org.openstreetmap.josm.gui.mappaint.StyleSource; 48 47 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 49 import org.openstreetmap.josm.gui.mappaint. xml.XmlStyleSource;48 import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement; 50 49 import org.openstreetmap.josm.gui.util.GuiHelper; 51 50 import org.openstreetmap.josm.gui.widgets.JosmTextArea; … … 423 422 424 423 private static String getSort(StyleSource s) { 425 if (s instanceof XmlStyleSource) { 426 return tr("xml"); 427 } else if (s instanceof MapCSSStyleSource) { 424 if (s instanceof MapCSSStyleSource) { 428 425 return tr("mapcss"); 429 426 } else { -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r9799 r9965 18 18 19 19 import javax.swing.ImageIcon; 20 import javax.swing.JOptionPane; 20 21 import javax.swing.SwingUtilities; 21 22 … … 25 26 import org.openstreetmap.josm.data.osm.Node; 26 27 import org.openstreetmap.josm.data.osm.Tag; 28 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 27 29 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 30 import org.openstreetmap.josm.gui.help.HelpUtil; 28 31 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 29 32 import org.openstreetmap.josm.gui.mappaint.styleelement.MapImage; 30 33 import org.openstreetmap.josm.gui.mappaint.styleelement.NodeElement; 31 34 import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement; 32 import org.openstreetmap.josm.gui.mappaint.xml.XmlStyleSource;33 35 import org.openstreetmap.josm.gui.preferences.SourceEntry; 34 36 import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference.MapPaintPrefHelper; 35 37 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 36 38 import org.openstreetmap.josm.io.CachedFile; 39 import org.openstreetmap.josm.io.IllegalDataException; 37 40 import org.openstreetmap.josm.tools.ImageProvider; 38 41 import org.openstreetmap.josm.tools.Utils; … … 46 49 */ 47 50 public final class MapPaintStyles { 51 52 /** To remove in November 2016 */ 53 private static final String XML_STYLE_MIME_TYPES = 54 "application/xml, text/xml, text/plain; q=0.8, application/zip, application/octet-stream; q=0.5"; 48 55 49 56 private static ElemStyles styles = new ElemStyles(); … … 280 287 281 288 private static StyleSource fromSourceEntry(SourceEntry entry) { 282 CachedFile cf = null; 283 try { 284 Set<String> mimes = new HashSet<>(); 285 mimes.addAll(Arrays.asList(XmlStyleSource.XML_STYLE_MIME_TYPES.split(", "))); 286 mimes.addAll(Arrays.asList(MapCSSStyleSource.MAPCSS_STYLE_MIME_TYPES.split(", "))); 287 cf = new CachedFile(entry.url).setHttpAccept(Utils.join(", ", mimes)); 289 // TODO: Method to clean up in November 2016: remove XML detection completely 290 Set<String> mimes = new HashSet<>(Arrays.asList(MapCSSStyleSource.MAPCSS_STYLE_MIME_TYPES.split(", "))); 291 mimes.addAll(Arrays.asList(XML_STYLE_MIME_TYPES.split(", "))); 292 try (CachedFile cf = new CachedFile(entry.url).setHttpAccept(Utils.join(", ", mimes))) { 288 293 String zipEntryPath = cf.findZipEntryPath("mapcss", "style"); 289 294 if (zipEntryPath != null) { … … 293 298 } 294 299 zipEntryPath = cf.findZipEntryPath("xml", "style"); 295 if (zipEntryPath != null )296 return new XmlStyleSource(entry);300 if (zipEntryPath != null || Utils.hasExtension(entry.url, "xml")) 301 throw new IllegalDataException("XML style"); 297 302 if (Utils.hasExtension(entry.url, "mapcss")) 298 303 return new MapCSSStyleSource(entry); 299 if (Utils.hasExtension(entry.url, "xml")) 300 return new XmlStyleSource(entry); 301 else { 302 try (InputStreamReader reader = new InputStreamReader(cf.getInputStream(), StandardCharsets.UTF_8)) { 303 WHILE: while (true) { 304 int c = reader.read(); 305 switch (c) { 306 case -1: 307 break WHILE; 308 case ' ': 309 case '\t': 310 case '\n': 311 case '\r': 312 continue; 313 case '<': 314 return new XmlStyleSource(entry); 315 default: 316 return new MapCSSStyleSource(entry); 317 } 304 try (InputStreamReader reader = new InputStreamReader(cf.getInputStream(), StandardCharsets.UTF_8)) { 305 WHILE: while (true) { 306 int c = reader.read(); 307 switch (c) { 308 case -1: 309 break WHILE; 310 case ' ': 311 case '\t': 312 case '\n': 313 case '\r': 314 continue; 315 case '<': 316 throw new IllegalDataException("XML style"); 317 default: 318 return new MapCSSStyleSource(entry); 318 319 } 319 320 } 320 Main.warn("Could not detect style type. Using default (xml).");321 return new XmlStyleSource(entry);322 }321 } 322 Main.warn("Could not detect style type. Using default (mapcss)."); 323 return new MapCSSStyleSource(entry); 323 324 } catch (IOException e) { 324 325 Main.warn(tr("Failed to load Mappaint styles from ''{0}''. Exception was: {1}", entry.url, e.toString())); 325 326 Main.error(e); 326 } finally { 327 if (cf != null) { 328 cf.close(); 329 } 327 } catch (IllegalDataException e) { 328 String msg = tr("JOSM does no longer support mappaint styles written in the old XML format.\nPlease update ''{0}'' to MapCSS", 329 entry.url); 330 Main.error(msg); 331 HelpAwareOptionPane.showOptionDialog(Main.parent, msg, tr("Warning"), JOptionPane.WARNING_MESSAGE, 332 HelpUtil.ht("/Styles/MapCSSImplementation")); 330 333 } 331 334 return null; -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r9570 r9965 1390 1390 } 1391 1391 readFile(); 1392 for (Iterator<ExtendedSourceEntry> it = sources.iterator(); it.hasNext();) { 1393 if ("xml".equals(it.next().styleType)) { 1394 Main.debug("Removing XML source entry"); 1395 it.remove(); 1396 } 1397 } 1392 1398 } catch (IOException e) { 1393 1399 if (canceled)
Note:
See TracChangeset
for help on using the changeset viewer.