Changeset 9617 in josm


Ignore:
Timestamp:
2016-01-24T19:08:31+01:00 (8 years ago)
Author:
stoecker
Message:

see #12437 - support new Map<String, List<String>> type in preferences

Location:
trunk/src/org/openstreetmap/josm/data
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r9371 r9617  
    4444
    4545import javax.json.Json;
     46import javax.json.JsonArray;
     47import javax.json.JsonArrayBuilder;
    4648import javax.json.JsonObject;
    4749import javax.json.JsonObjectBuilder;
     
    14131415            for (Object o: map.entrySet()) {
    14141416                Entry e = (Entry) o;
    1415                 object.add(e.getKey().toString(), e.getValue().toString());
     1417                Object evalue = e.getValue();
     1418                if (evalue instanceof Collection) {
     1419                    JsonArrayBuilder a = Json.createArrayBuilder();
     1420                    for (Object evo : (Collection)evalue) {
     1421                        a.add(evo.toString());
     1422                    }
     1423                    object.add(e.getKey().toString(), a.build());
     1424                } else {
     1425                    object.add(e.getKey().toString(), evalue.toString());
     1426                }
    14161427            }
    14171428            writer.writeObject(object.build());
     
    14281439            for (Entry<String, JsonValue> e: object.entrySet()) {
    14291440                JsonValue value = e.getValue();
    1430                 if (value instanceof JsonString) {
     1441                if (value instanceof JsonArray) {
     1442                    List <String> finalList = new ArrayList<String>();
     1443                    for(JsonString js: ((JsonArray)value).getValuesAs(JsonString.class)) {
     1444                        finalList.add(js.getString());
     1445                    }
     1446                    ret.put(e.getKey(), finalList);
     1447                } else if (value instanceof JsonString) {
    14311448                    // in some cases, when JsonValue.toString() is called, then additional quotation marks are left in value
    14321449                    ret.put(e.getKey(), ((JsonString) value).getString());
     
    14971514     *
    14981515     * The map value (a String) is converted to the field type. Supported
    1499      * types are: boolean, Boolean, int, Integer, double, Double, String and
    1500      * Map&lt;String, String&gt;.
     1516     * types are: boolean, Boolean, int, Integer, double, Double, String,
     1517     * Map&lt;String, String&gt; and Map&lt;String, List&lt;String&gt;&gt;.
    15011518     *
    15021519     * Only fields with annotation {@link pref} are taken into account.
  • trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java

    r9176 r9617  
    8080        handleTemplate();
    8181        initProjection();
    82         // FIXME: remove in September 2015, when ImageryPreferenceEntry.tileSize will be initialized to -1 instead to 256
    83         // need to leave it as it is to keep compatibility between tested and latest JOSM versions
    84         tileSize = WMSLayer.PROP_IMAGE_SIZE.get();
    8582    }
    8683
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r9603 r9617  
    625625    }
    626626
    627     // FIXME: remove in September 2015, when ImageryPreferenceEntry.tileSize will be initialized to -1 instead to 256
    628     // need to leave it as it is to keep compatiblity between tested and latest JOSM versions
    629     @Override
    630     public int getTileSize() {
    631         TileMatrix matrix = getTileMatrix(1);
    632         if (matrix == null) {
    633             return 1;
    634         }
    635         return matrix.tileHeight;
    636     }
    637 
    638627    @Override
    639628    public String getTileUrl(int zoom, int tilex, int tiley) {
Note: See TracChangeset for help on using the changeset viewer.