Changeset 12851 in josm for trunk/src/org
- Timestamp:
- 2017-09-14T01:59:34+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r12847 r12851 12 12 import java.io.PrintWriter; 13 13 import java.io.Reader; 14 import java.io.StringReader;15 14 import java.io.StringWriter; 16 15 import java.lang.annotation.Retention; … … 25 24 import java.util.HashSet; 26 25 import java.util.Iterator; 27 import java.util.LinkedHashMap;28 26 import java.util.LinkedList; 29 27 import java.util.List; 30 28 import java.util.Map; 31 29 import java.util.Map.Entry; 32 import java.util.Objects;33 30 import java.util.Optional; 34 31 import java.util.ResourceBundle; … … 43 40 import java.util.stream.Stream; 44 41 45 import javax.json.Json;46 import javax.json.JsonArray;47 import javax.json.JsonArrayBuilder;48 import javax.json.JsonObject;49 import javax.json.JsonObjectBuilder;50 import javax.json.JsonReader;51 import javax.json.JsonString;52 import javax.json.JsonValue;53 import javax.json.JsonWriter;54 42 import javax.swing.JOptionPane; 55 43 import javax.xml.stream.XMLStreamException; … … 77 65 import org.openstreetmap.josm.tools.ColorHelper; 78 66 import org.openstreetmap.josm.tools.I18n; 79 import org.openstreetmap.josm.tools.JosmRuntimeException;80 67 import org.openstreetmap.josm.tools.ListenerList; 81 68 import org.openstreetmap.josm.tools.Logging; 82 import org.openstreetmap.josm.tools.MultiMap;83 69 import org.openstreetmap.josm.tools.Utils; 84 70 import org.xml.sax.SAXException; … … 1212 1198 * @see #serializeStruct(java.lang.Object, java.lang.Class) 1213 1199 * @see #deserializeStruct(java.util.Map, java.lang.Class) 1214 */ 1200 * @deprecated use {@link StructUtils.StructEntry} 1201 */ 1202 @Deprecated 1215 1203 @Retention(RetentionPolicy.RUNTIME) // keep annotation at runtime 1216 1204 public @interface pref { } … … 1221 1209 * 1222 1210 * @see #serializeStruct(java.lang.Object, java.lang.Class) 1223 */ 1211 * @deprecated use {@link StructUtils.WriteExplicitly} 1212 */ 1213 @Deprecated 1224 1214 @Retention(RetentionPolicy.RUNTIME) // keep annotation at runtime 1225 1215 public @interface writeExplicitly { } … … 1233 1223 * @param klass The struct class 1234 1224 * @return a list of objects of type T or an empty list if nothing was found 1235 */ 1225 * @deprecated use {@link StructUtils#getListOfStructs(IPreferences, String, Class)} 1226 */ 1227 @Deprecated 1236 1228 public <T> List<T> getListOfStructs(String key, Class<T> klass) { 1237 return Optional.ofNullable(getListOfStructs(key, null, klass)).orElseGet(Collections::emptyList);1229 return StructUtils.getListOfStructs(this, key, klass); 1238 1230 } 1239 1231 … … 1245 1237 * @param klass The struct class 1246 1238 * @return a list of objects of type T or {@code def} if nothing was found 1247 */ 1239 * @deprecated use {@link StructUtils#getListOfStructs(IPreferences, String, Collection, Class)} 1240 */ 1241 @Deprecated 1248 1242 public <T> List<T> getListOfStructs(String key, Collection<T> def, Class<T> klass) { 1249 List<Map<String, String>> prop = 1250 getListOfMaps(key, def == null ? null : serializeListOfStructs(def, klass)); 1251 if (prop == null) 1252 return def == null ? null : new ArrayList<>(def); 1253 return prop.stream().map(p -> deserializeStruct(p, klass)).collect(Collectors.toList()); 1243 return StructUtils.getListOfStructs(this, key, def, klass); 1254 1244 } 1255 1245 … … 1269 1259 * @param klass The struct class 1270 1260 * @return true if something has changed 1271 */ 1261 * @deprecated use {@link StructUtils#putListOfStructs(IPreferences, String, Collection, Class)} 1262 */ 1263 @Deprecated 1272 1264 public <T> boolean putListOfStructs(String key, Collection<T> val, Class<T> klass) { 1273 return putListOfMaps(key, serializeListOfStructs(val, klass)); 1274 } 1275 1276 private static <T> List<Map<String, String>> serializeListOfStructs(Collection<T> l, Class<T> klass) { 1277 if (l == null) 1278 return null; 1279 List<Map<String, String>> vals = new ArrayList<>(); 1280 for (T struct : l) { 1281 if (struct != null) { 1282 vals.add(serializeStruct(struct, klass)); 1283 } 1284 } 1285 return vals; 1286 } 1287 1288 @SuppressWarnings("rawtypes") 1289 private static String mapToJson(Map map) { 1290 StringWriter stringWriter = new StringWriter(); 1291 try (JsonWriter writer = Json.createWriter(stringWriter)) { 1292 JsonObjectBuilder object = Json.createObjectBuilder(); 1293 for (Object o: map.entrySet()) { 1294 Entry e = (Entry) o; 1295 Object evalue = e.getValue(); 1296 object.add(e.getKey().toString(), evalue.toString()); 1297 } 1298 writer.writeObject(object.build()); 1299 } 1300 return stringWriter.toString(); 1301 } 1302 1303 @SuppressWarnings({ "rawtypes", "unchecked" }) 1304 private static Map mapFromJson(String s) { 1305 Map ret = null; 1306 try (JsonReader reader = Json.createReader(new StringReader(s))) { 1307 JsonObject object = reader.readObject(); 1308 ret = new HashMap(object.size()); 1309 for (Entry<String, JsonValue> e: object.entrySet()) { 1310 JsonValue value = e.getValue(); 1311 if (value instanceof JsonString) { 1312 // in some cases, when JsonValue.toString() is called, then additional quotation marks are left in value 1313 ret.put(e.getKey(), ((JsonString) value).getString()); 1314 } else { 1315 ret.put(e.getKey(), e.getValue().toString()); 1316 } 1317 } 1318 } 1319 return ret; 1320 } 1321 1322 @SuppressWarnings("rawtypes") 1323 private static String multiMapToJson(MultiMap map) { 1324 StringWriter stringWriter = new StringWriter(); 1325 try (JsonWriter writer = Json.createWriter(stringWriter)) { 1326 JsonObjectBuilder object = Json.createObjectBuilder(); 1327 for (Object o: map.entrySet()) { 1328 Entry e = (Entry) o; 1329 Set evalue = (Set) e.getValue(); 1330 JsonArrayBuilder a = Json.createArrayBuilder(); 1331 for (Object evo: evalue) { 1332 a.add(evo.toString()); 1333 } 1334 object.add(e.getKey().toString(), a.build()); 1335 } 1336 writer.writeObject(object.build()); 1337 } 1338 return stringWriter.toString(); 1339 } 1340 1341 @SuppressWarnings({ "rawtypes", "unchecked" }) 1342 private static MultiMap multiMapFromJson(String s) { 1343 MultiMap ret = null; 1344 try (JsonReader reader = Json.createReader(new StringReader(s))) { 1345 JsonObject object = reader.readObject(); 1346 ret = new MultiMap(object.size()); 1347 for (Entry<String, JsonValue> e: object.entrySet()) { 1348 JsonValue value = e.getValue(); 1349 if (value instanceof JsonArray) { 1350 for (JsonString js: ((JsonArray) value).getValuesAs(JsonString.class)) { 1351 ret.put(e.getKey(), js.getString()); 1352 } 1353 } else if (value instanceof JsonString) { 1354 // in some cases, when JsonValue.toString() is called, then additional quotation marks are left in value 1355 ret.put(e.getKey(), ((JsonString) value).getString()); 1356 } else { 1357 ret.put(e.getKey(), e.getValue().toString()); 1358 } 1359 } 1360 } 1361 return ret; 1265 return StructUtils.putListOfStructs(this, key, val, klass); 1362 1266 } 1363 1267 … … 1377 1281 * @param klass the class T 1378 1282 * @return the resulting map (same data content as <code>struct</code>) 1379 */ 1283 * @deprecated use {@link StructUtils#serializeStruct(java.lang.Object, java.lang.Class)} 1284 */ 1285 @Deprecated 1380 1286 public static <T> Map<String, String> serializeStruct(T struct, Class<T> klass) { 1381 T structPrototype; 1382 try { 1383 structPrototype = klass.getConstructor().newInstance(); 1384 } catch (ReflectiveOperationException ex) { 1385 throw new IllegalArgumentException(ex); 1386 } 1387 1388 Map<String, String> hash = new LinkedHashMap<>(); 1389 for (Field f : klass.getDeclaredFields()) { 1390 if (f.getAnnotation(pref.class) == null) { 1391 continue; 1392 } 1393 Utils.setObjectsAccessible(f); 1394 try { 1395 Object fieldValue = f.get(struct); 1396 Object defaultFieldValue = f.get(structPrototype); 1397 if (fieldValue != null && (f.getAnnotation(writeExplicitly.class) != null || !Objects.equals(fieldValue, defaultFieldValue))) { 1398 String key = f.getName().replace('_', '-'); 1399 if (fieldValue instanceof Map) { 1400 hash.put(key, mapToJson((Map<?, ?>) fieldValue)); 1401 } else if (fieldValue instanceof MultiMap) { 1402 hash.put(key, multiMapToJson((MultiMap<?, ?>) fieldValue)); 1403 } else { 1404 hash.put(key, fieldValue.toString()); 1405 } 1406 } 1407 } catch (IllegalAccessException ex) { 1408 throw new JosmRuntimeException(ex); 1409 } 1410 } 1411 return hash; 1287 return StructUtils.serializeStruct(struct, klass); 1412 1288 } 1413 1289 … … 1424 1300 * @param klass the class T 1425 1301 * @return an object of class T, initialized as described above 1426 */ 1302 * @deprecated use {@link StructUtils#deserializeStruct(java.util.Map, java.lang.Class)} 1303 */ 1304 @Deprecated 1427 1305 public static <T> T deserializeStruct(Map<String, String> hash, Class<T> klass) { 1428 T struct = null; 1429 try { 1430 struct = klass.getConstructor().newInstance(); 1431 } catch (ReflectiveOperationException ex) { 1432 throw new IllegalArgumentException(ex); 1433 } 1434 for (Entry<String, String> keyValue : hash.entrySet()) { 1435 Object value; 1436 Field f; 1437 try { 1438 f = klass.getDeclaredField(keyValue.getKey().replace('-', '_')); 1439 } catch (NoSuchFieldException ex) { 1440 Logging.trace(ex); 1441 continue; 1442 } 1443 if (f.getAnnotation(pref.class) == null) { 1444 continue; 1445 } 1446 Utils.setObjectsAccessible(f); 1447 if (f.getType() == Boolean.class || f.getType() == boolean.class) { 1448 value = Boolean.valueOf(keyValue.getValue()); 1449 } else if (f.getType() == Integer.class || f.getType() == int.class) { 1450 try { 1451 value = Integer.valueOf(keyValue.getValue()); 1452 } catch (NumberFormatException nfe) { 1453 continue; 1454 } 1455 } else if (f.getType() == Double.class || f.getType() == double.class) { 1456 try { 1457 value = Double.valueOf(keyValue.getValue()); 1458 } catch (NumberFormatException nfe) { 1459 continue; 1460 } 1461 } else if (f.getType() == String.class) { 1462 value = keyValue.getValue(); 1463 } else if (f.getType().isAssignableFrom(Map.class)) { 1464 value = mapFromJson(keyValue.getValue()); 1465 } else if (f.getType().isAssignableFrom(MultiMap.class)) { 1466 value = multiMapFromJson(keyValue.getValue()); 1467 } else 1468 throw new JosmRuntimeException("unsupported preference primitive type"); 1469 1470 try { 1471 f.set(struct, value); 1472 } catch (IllegalArgumentException ex) { 1473 throw new AssertionError(ex); 1474 } catch (IllegalAccessException ex) { 1475 throw new JosmRuntimeException(ex); 1476 } 1477 } 1478 return struct; 1306 return StructUtils.deserializeStruct(hash, klass); 1479 1307 } 1480 1308 -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r12846 r12851 27 27 import org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo; 28 28 import org.openstreetmap.josm.data.Bounds; 29 import org.openstreetmap.josm.data. Preferences.pref;29 import org.openstreetmap.josm.data.StructUtils.StructEntry; 30 30 import org.openstreetmap.josm.io.Capabilities; 31 31 import org.openstreetmap.josm.io.OsmApi; … … 214 214 */ 215 215 public static class ImageryPreferenceEntry { 216 @ prefString name;217 @ prefString d;218 @ prefString id;219 @ prefString type;220 @ prefString url;221 @ prefdouble pixel_per_eastnorth;222 @ prefString eula;223 @ prefString attribution_text;224 @ prefString attribution_url;225 @ prefString permission_reference_url;226 @ prefString logo_image;227 @ prefString logo_url;228 @ prefString terms_of_use_text;229 @ prefString terms_of_use_url;230 @ prefString country_code = "";231 @ prefString date;232 @ prefint max_zoom;233 @ prefint min_zoom;234 @ prefString cookies;235 @ prefString bounds;236 @ prefString shapes;237 @ prefString projections;238 @ prefString icon;239 @ prefString description;240 @ prefMultiMap<String, String> noTileHeaders;241 @ prefMultiMap<String, String> noTileChecksums;242 @ prefint tileSize = -1;243 @ prefMap<String, String> metadataHeaders;244 @ prefboolean valid_georeference;245 @ prefboolean bestMarked;216 @StructEntry String name; 217 @StructEntry String d; 218 @StructEntry String id; 219 @StructEntry String type; 220 @StructEntry String url; 221 @StructEntry double pixel_per_eastnorth; 222 @StructEntry String eula; 223 @StructEntry String attribution_text; 224 @StructEntry String attribution_url; 225 @StructEntry String permission_reference_url; 226 @StructEntry String logo_image; 227 @StructEntry String logo_url; 228 @StructEntry String terms_of_use_text; 229 @StructEntry String terms_of_use_url; 230 @StructEntry String country_code = ""; 231 @StructEntry String date; 232 @StructEntry int max_zoom; 233 @StructEntry int min_zoom; 234 @StructEntry String cookies; 235 @StructEntry String bounds; 236 @StructEntry String shapes; 237 @StructEntry String projections; 238 @StructEntry String icon; 239 @StructEntry String description; 240 @StructEntry MultiMap<String, String> noTileHeaders; 241 @StructEntry MultiMap<String, String> noTileChecksums; 242 @StructEntry int tileSize = -1; 243 @StructEntry Map<String, String> metadataHeaders; 244 @StructEntry boolean valid_georeference; 245 @StructEntry boolean bestMarked; 246 246 // TODO: disabled until change of layers is implemented 247 // @ prefString default_layers;247 // @StructEntry String default_layers; 248 248 249 249 /** -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
r12846 r12851 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.data.StructUtils; 21 22 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryPreferenceEntry; 22 23 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 86 87 public void load(boolean fastFail) { 87 88 clear(); 88 List<ImageryPreferenceEntry> entries = Main.pref.getListOfStructs("imagery.entries", null, ImageryPreferenceEntry.class); 89 List<ImageryPreferenceEntry> entries = StructUtils.getListOfStructs( 90 Config.getPref(), "imagery.entries", null, ImageryPreferenceEntry.class); 89 91 if (entries != null) { 90 92 for (ImageryPreferenceEntry prefEntry : entries) { … … 362 364 entries.add(new ImageryPreferenceEntry(info)); 363 365 } 364 Main.pref.putListOfStructs("imagery.entries", entries, ImageryPreferenceEntry.class);366 StructUtils.putListOfStructs(Config.getPref(), "imagery.entries", entries, ImageryPreferenceEntry.class); 365 367 } 366 368 -
trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
r12846 r12851 12 12 13 13 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.data. Preferences;15 import org.openstreetmap.josm.data. Preferences.pref;16 import org.openstreetmap.josm.data. Preferences.writeExplicitly;14 import org.openstreetmap.josm.data.StructUtils; 15 import org.openstreetmap.josm.data.StructUtils.StructEntry; 16 import org.openstreetmap.josm.data.StructUtils.WriteExplicitly; 17 17 import org.openstreetmap.josm.data.coor.EastNorth; 18 18 import org.openstreetmap.josm.data.coor.LatLon; … … 34 34 private static final List<OffsetBookmark> allBookmarks = new ArrayList<>(); 35 35 36 @ prefprivate String projection_code;37 @ prefprivate String imagery_name;38 @ prefprivate String name;39 @ pref @writeExplicitly private double dx, dy;40 @ prefprivate double center_lon, center_lat;36 @StructEntry private String projection_code; 37 @StructEntry private String imagery_name; 38 @StructEntry private String name; 39 @StructEntry @WriteExplicitly private double dx, dy; 40 @StructEntry private double center_lon, center_lat; 41 41 42 42 public boolean isUsable(ImageryLayer layer) { … … 167 167 168 168 public static void loadBookmarks() { 169 List<OffsetBookmark> bookmarks = Main.pref.getListOfStructs("imagery.offsetbookmarks", null, OffsetBookmark.class); 169 List<OffsetBookmark> bookmarks = StructUtils.getListOfStructs( 170 Config.getPref(), "imagery.offsetbookmarks", null, OffsetBookmark.class); 170 171 if (bookmarks == null) { 171 172 loadBookmarksOld(); … … 184 185 185 186 public static void saveBookmarks() { 186 Main.pref.putListOfStructs("imagery.offsetbookmarks", allBookmarks, OffsetBookmark.class);187 StructUtils.putListOfStructs(Config.getPref(), "imagery.offsetbookmarks", allBookmarks, OffsetBookmark.class); 187 188 } 188 189 … … 276 277 */ 277 278 public Map<String, String> toPropertiesMap() { 278 return Preferences.serializeStruct(this, OffsetBookmark.class);279 return StructUtils.serializeStruct(this, OffsetBookmark.class); 279 280 } 280 281 … … 287 288 */ 288 289 public static OffsetBookmark fromPropertiesMap(Map<String, String> properties) { 289 return Preferences.deserializeStruct(properties, OffsetBookmark.class);290 return StructUtils.deserializeStruct(properties, OffsetBookmark.class); 290 291 } 291 292 } -
trunk/src/org/openstreetmap/josm/data/osm/Filter.java
r12659 r12851 4 4 import java.util.Objects; 5 5 6 import org.openstreetmap.josm.data. Preferences.pref;7 import org.openstreetmap.josm.data. Preferences.writeExplicitly;6 import org.openstreetmap.josm.data.StructUtils.StructEntry; 7 import org.openstreetmap.josm.data.StructUtils.WriteExplicitly; 8 8 import org.openstreetmap.josm.data.osm.search.SearchMode; 9 9 import org.openstreetmap.josm.data.osm.search.SearchSetting; … … 71 71 72 72 public static class FilterPreferenceEntry { 73 @ writeExplicitly74 @ prefpublic String version = "1";73 @WriteExplicitly 74 @StructEntry public String version = "1"; 75 75 76 @ prefpublic String text;76 @StructEntry public String text; 77 77 78 78 /** … … 85 85 * @see SearchMode 86 86 */ 87 @ writeExplicitly88 @ prefpublic String mode = "add";87 @WriteExplicitly 88 @StructEntry public String mode = "add"; 89 89 90 @ prefpublic boolean case_sensitive;90 @StructEntry public boolean case_sensitive; 91 91 92 @ prefpublic boolean regex_search;92 @StructEntry public boolean regex_search; 93 93 94 @ prefpublic boolean mapCSS_search;94 @StructEntry public boolean mapCSS_search; 95 95 96 96 /** … … 98 98 * @see Filter#enable 99 99 */ 100 @ writeExplicitly101 @ prefpublic boolean enable = true;100 @WriteExplicitly 101 @StructEntry public boolean enable = true; 102 102 103 103 /** … … 106 106 * @see Filter#hiding 107 107 */ 108 @ writeExplicitly109 @ prefpublic boolean hiding;108 @WriteExplicitly 109 @StructEntry public boolean hiding; 110 110 111 111 /** … … 114 114 * @see Filter#inverted 115 115 */ 116 @ writeExplicitly117 @ prefpublic boolean inverted;116 @WriteExplicitly 117 @StructEntry public boolean inverted; 118 118 119 119 @Override -
trunk/src/org/openstreetmap/josm/data/osm/FilterModel.java
r12691 r12851 17 17 18 18 import org.openstreetmap.josm.Main; 19 import org.openstreetmap.josm.data.StructUtils; 19 20 import org.openstreetmap.josm.data.osm.Filter.FilterPreferenceEntry; 20 21 import org.openstreetmap.josm.data.osm.search.SearchParseError; … … 22 23 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 23 24 import org.openstreetmap.josm.gui.widgets.OSDLabel; 25 import org.openstreetmap.josm.spi.preferences.Config; 24 26 import org.openstreetmap.josm.tools.Logging; 25 27 import org.openstreetmap.josm.tools.Utils; … … 71 73 */ 72 74 public void loadPrefs(String prefEntry) { 73 List<FilterPreferenceEntry> entries = Main.pref.getListOfStructs(prefEntry, null, FilterPreferenceEntry.class); 75 List<FilterPreferenceEntry> entries = StructUtils.getListOfStructs( 76 Config.getPref(), prefEntry, null, FilterPreferenceEntry.class); 74 77 if (entries != null) { 75 78 for (FilterPreferenceEntry e : entries) { … … 89 92 entries.add(flt.getPreferenceEntry()); 90 93 } 91 Main.pref.putListOfStructs(prefEntry, entries, FilterPreferenceEntry.class);94 StructUtils.putListOfStructs(Config.getPref(), prefEntry, entries, FilterPreferenceEntry.class); 92 95 } 93 96 -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolutionUtil.java
r12620 r12851 15 15 import java.util.stream.Collectors; 16 16 17 import org.openstreetmap.josm. Main;18 import org.openstreetmap.josm.data. Preferences.pref;17 import org.openstreetmap.josm.data.StructUtils; 18 import org.openstreetmap.josm.data.StructUtils.StructEntry; 19 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 20 import org.openstreetmap.josm.data.osm.Tag; 21 21 import org.openstreetmap.josm.data.osm.TagCollection; 22 import org.openstreetmap.josm.spi.preferences.Config; 22 23 import org.openstreetmap.josm.tools.Logging; 23 24 import org.openstreetmap.josm.tools.Pair; … … 158 159 public static Collection<AutomaticTagConflictResolver> getAutomaticTagConflictResolvers() { 159 160 if (automaticTagConflictResolvers == null) { 160 Collection<AutomaticCombine> automaticTagConflictCombines = 161 Main.pref.getListOfStructs(161 Collection<AutomaticCombine> automaticTagConflictCombines = StructUtils.getListOfStructs( 162 Config.getPref(), 162 163 "automatic-tag-conflict-resolution.combine", 163 164 defaultAutomaticTagConflictCombines, AutomaticCombine.class); 164 165 Collection<AutomaticChoiceGroup> automaticTagConflictChoiceGroups = 165 AutomaticChoiceGroup.groupChoices(Main.pref.getListOfStructs( 166 AutomaticChoiceGroup.groupChoices(StructUtils.getListOfStructs( 167 Config.getPref(), 166 168 "automatic-tag-conflict-resolution.choice", 167 169 defaultAutomaticTagConflictChoices, AutomaticChoice.class)); … … 230 232 231 233 /** The Tag key to match */ 232 @ prefpublic String key;234 @StructEntry public String key; 233 235 234 236 /** A free description */ 235 @ prefpublic String description = "";237 @StructEntry public String description = ""; 236 238 237 239 /** If regular expression must be used to match the Tag key or the value. */ 238 @ prefpublic boolean isRegex;240 @StructEntry public boolean isRegex; 239 241 240 242 /** The separator to use to combine the values. */ 241 @ prefpublic String separator = ";";243 @StructEntry public String separator = ";"; 242 244 243 245 /** If the combined values must be sorted. … … 249 251 * </ul> 250 252 */ 251 @ prefpublic String sort;253 @StructEntry public String sort; 252 254 253 255 /** Default constructor. */ … … 317 319 318 320 /** The Tag key to match. */ 319 @ prefpublic String key;321 @StructEntry public String key; 320 322 321 323 /** The name of the {link AutomaticChoice group} this choice belongs to. */ 322 @ prefpublic String group;324 @StructEntry public String group; 323 325 324 326 /** A free description. */ 325 @ prefpublic String description = "";327 @StructEntry public String description = ""; 326 328 327 329 /** If regular expression must be used to match the Tag key or the value. */ 328 @ prefpublic boolean isRegex;330 @StructEntry public boolean isRegex; 329 331 330 332 /** The Tag value to match. */ 331 @ prefpublic String value;333 @StructEntry public String value; 332 334 333 335 /** … … 335 337 * Natural String ordering is used to identify the best score. 336 338 */ 337 @ prefpublic String score;339 @StructEntry public String score; 338 340 339 341 /** Default constructor. */ … … 404 406 405 407 /** The Tag key to match. */ 406 @ prefpublic String key;408 @StructEntry public String key; 407 409 408 410 /** The name of the group. */ … … 410 412 411 413 /** If regular expression must be used to match the Tag key. */ 412 @ prefpublic boolean isRegex;414 @StructEntry public boolean isRegex; 413 415 414 416 /** The list of choice to choose from. */ -
trunk/src/org/openstreetmap/josm/gui/io/importexport/WMSLayerExporter.java
r12671 r12851 7 7 import java.io.ObjectOutputStream; 8 8 9 import org.openstreetmap.josm.data. Preferences;9 import org.openstreetmap.josm.data.StructUtils; 10 10 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryPreferenceEntry; 11 11 import org.openstreetmap.josm.gui.MainApplication; … … 42 42 oos.writeObject(MainApplication.getMap().mapView.getCenter()); 43 43 ImageryPreferenceEntry entry = new ImageryPreferenceEntry(((AbstractTileSourceLayer) layer).getInfo()); 44 oos.writeObject( Preferences.serializeStruct(entry, ImageryPreferenceEntry.class));44 oos.writeObject(StructUtils.serializeStruct(entry, ImageryPreferenceEntry.class)); 45 45 } 46 46 } -
trunk/src/org/openstreetmap/josm/gui/io/importexport/WMSLayerImporter.java
r12671 r12851 12 12 13 13 import org.openstreetmap.josm.actions.ExtensionFileFilter; 14 import org.openstreetmap.josm.data. Preferences;14 import org.openstreetmap.josm.data.StructUtils; 15 15 import org.openstreetmap.josm.data.coor.EastNorth; 16 16 import org.openstreetmap.josm.data.imagery.ImageryInfo; … … 72 72 73 73 @SuppressWarnings("unchecked") 74 ImageryPreferenceEntry entry = Preferences.deserializeStruct(74 ImageryPreferenceEntry entry = StructUtils.deserializeStruct( 75 75 (Map<String, String>) ois.readObject(), 76 76 ImageryPreferenceEntry.class); -
trunk/src/org/openstreetmap/josm/io/session/ImagerySessionExporter.java
r12604 r12851 13 13 import javax.swing.SwingConstants; 14 14 15 import org.openstreetmap.josm.data. Preferences;15 import org.openstreetmap.josm.data.StructUtils; 16 16 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryPreferenceEntry; 17 17 import org.openstreetmap.josm.data.imagery.OffsetBookmark; … … 84 84 layerElem.setAttribute("version", "0.1"); 85 85 ImageryPreferenceEntry e = new ImageryPreferenceEntry(layer.getInfo()); 86 Map<String, String> data = new LinkedHashMap<>( Preferences.serializeStruct(e, ImageryPreferenceEntry.class));86 Map<String, String> data = new LinkedHashMap<>(StructUtils.serializeStruct(e, ImageryPreferenceEntry.class)); 87 87 Utils.instanceOfThen(layer, AbstractTileSourceLayer.class, tsLayer -> { 88 88 data.putAll(tsLayer.getDisplaySettings().toPropertiesMap()); -
trunk/src/org/openstreetmap/josm/io/session/ImagerySessionImporter.java
r12620 r12851 8 8 import java.util.Map; 9 9 10 import org.openstreetmap.josm.data. Preferences;10 import org.openstreetmap.josm.data.StructUtils; 11 11 import org.openstreetmap.josm.data.imagery.ImageryInfo; 12 12 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryPreferenceEntry; … … 42 42 Map<String, String> attributes = readProperties(elem); 43 43 44 ImageryPreferenceEntry prefEntry = Preferences.deserializeStruct(attributes, ImageryPreferenceEntry.class);44 ImageryPreferenceEntry prefEntry = StructUtils.deserializeStruct(attributes, ImageryPreferenceEntry.class); 45 45 ImageryInfo info = new ImageryInfo(prefEntry); 46 46 ImageryLayer layer = ImageryLayer.create(info); -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r12846 r12851 67 67 68 68 import org.openstreetmap.josm.Main; 69 import org.openstreetmap.josm.data.Preferences; 69 import org.openstreetmap.josm.data.StructUtils; 70 import org.openstreetmap.josm.data.StructUtils.StructEntry; 71 import org.openstreetmap.josm.data.StructUtils.WriteExplicitly; 70 72 import org.openstreetmap.josm.io.CertificateAmendment.CertAmend; 71 73 import org.openstreetmap.josm.spi.preferences.Config; … … 86 88 * The character subset. Basically a free identifier, but should be unique. 87 89 */ 88 @ Preferences.pref90 @StructEntry 89 91 public String charset; 90 92 … … 92 94 * Platform font name. 93 95 */ 94 @ Preferences.pref95 @ Preferences.writeExplicitly96 @StructEntry 97 @WriteExplicitly 96 98 public String name = ""; 97 99 … … 99 101 * File name. 100 102 */ 101 @ Preferences.pref102 @ Preferences.writeExplicitly103 @StructEntry 104 @WriteExplicitly 103 105 public String file = ""; 104 106 … … 525 527 os.write(content); 526 528 try (Writer w = new BufferedWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8))) { 527 Collection<FontEntry> extrasPref = Main.pref.getListOfStructs(529 Collection<FontEntry> extrasPref = StructUtils.getListOfStructs(Config.getPref(), 528 530 "font.extended-unicode.extra-items", getAdditionalFonts(), FontEntry.class); 529 531 Collection<FontEntry> extras = new ArrayList<>();
Note:
See TracChangeset
for help on using the changeset viewer.