diff --git a/scripts/taginfoextract.groovy b/scripts/taginfoextract.groovy
index c61b46b..158d679 100644
|
a
|
b
|
|
| 6 | 6 | * |
| 7 | 7 | * groovy -cp dist/josm-custom.jar scripts/taginfoextract.groovy -t mappaint |
| 8 | 8 | * groovy -cp dist/josm-custom.jar scripts/taginfoextract.groovy -t presets |
| | 9 | * groovy -cp dist/josm-custom.jar scripts/taginfoextract.groovy -t external_presets |
| 9 | 10 | */ |
| 10 | 11 | import groovy.json.JsonBuilder |
| 11 | | |
| 12 | | import java.awt.image.BufferedImage |
| 13 | | import java.nio.file.FileSystems |
| 14 | | import java.nio.file.Files |
| 15 | | import java.nio.file.Path |
| 16 | | |
| 17 | | import javax.imageio.ImageIO |
| 18 | | |
| 19 | 12 | import org.openstreetmap.josm.Main |
| 20 | 13 | import org.openstreetmap.josm.data.Version |
| 21 | 14 | import org.openstreetmap.josm.data.coor.LatLon |
| … |
… |
import org.openstreetmap.josm.gui.NavigatableComponent
|
| 28 | 21 | import org.openstreetmap.josm.gui.mappaint.AreaElemStyle |
| 29 | 22 | import org.openstreetmap.josm.gui.mappaint.Environment |
| 30 | 23 | import org.openstreetmap.josm.gui.mappaint.LineElemStyle |
| 31 | | import org.openstreetmap.josm.gui.mappaint.MultiCascade |
| 32 | 24 | import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference |
| 33 | | import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource |
| | 25 | import org.openstreetmap.josm.gui.mappaint.MultiCascade |
| 34 | 26 | import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.SimpleKeyValueCondition |
| | 27 | import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource |
| 35 | 28 | import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.GeneralSelector |
| 36 | 29 | import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser |
| | 30 | import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference |
| 37 | 31 | import org.openstreetmap.josm.gui.tagging.TaggingPreset |
| 38 | 32 | import org.openstreetmap.josm.gui.tagging.TaggingPresetItems |
| 39 | 33 | import org.openstreetmap.josm.gui.tagging.TaggingPresetReader |
| … |
… |
import org.openstreetmap.josm.gui.tagging.TaggingPresetType
|
| 41 | 35 | import org.openstreetmap.josm.io.CachedFile |
| 42 | 36 | import org.openstreetmap.josm.tools.Utils |
| 43 | 37 | |
| | 38 | import javax.imageio.ImageIO |
| | 39 | import java.awt.image.BufferedImage |
| | 40 | import java.nio.file.FileSystems |
| | 41 | import java.nio.file.Files |
| | 42 | import java.nio.file.Path |
| | 43 | |
| 44 | 44 | class taginfoextract { |
| 45 | 45 | |
| 46 | 46 | static def options |
| … |
… |
class taginfoextract {
|
| 186 | 186 | script.run() |
| 187 | 187 | } else if (options.t == 'presets') { |
| 188 | 188 | script.run_presets() |
| | 189 | } else if (options.t == 'external_presets') { |
| | 190 | script.run_external_presets() |
| 189 | 191 | } else { |
| 190 | 192 | System.err.println 'Invalid type ' + options.t |
| 191 | 193 | System.exit(1) |
| … |
… |
class taginfoextract {
|
| 234 | 236 | |
| 235 | 237 | void run_presets() { |
| 236 | 238 | init() |
| 237 | | def tags = [] |
| 238 | 239 | def presets = TaggingPresetReader.readAll(input_file, true) |
| | 240 | def tags = convert_presets(presets. "", true) |
| | 241 | write_json("JOSM main presets", "Tags supported by the default presets in the OSM editor JOSM", tags) |
| | 242 | } |
| | 243 | |
| | 244 | def convert_presets(Iterable<TaggingPreset> presets, String descriptionPrefix, boolean addImages) { |
| | 245 | def tags = [] |
| 239 | 246 | for (TaggingPreset preset : presets) { |
| 240 | 247 | for (TaggingPresetItems.KeyedItem item : Utils.filteredCollection(preset.data, TaggingPresetItems.KeyedItem.class)) { |
| 241 | 248 | def values |
| … |
… |
class taginfoextract {
|
| 246 | 253 | } |
| 247 | 254 | for (String value : values) { |
| 248 | 255 | def tag = [ |
| 249 | | description: preset.name, |
| | 256 | description: descriptionPrefix + preset.name, |
| 250 | 257 | key: item.key, |
| 251 | 258 | value: value, |
| 252 | 259 | object_types: preset.types.collect {it == TaggingPresetType.CLOSEDWAY ? "area" : it.toString().toLowerCase()}, |
| 253 | 260 | ] |
| 254 | | if (preset.iconName) tag += [icon_url: find_image_url(preset.iconName)] |
| | 261 | if (addImages && preset.iconName) tag += [icon_url: find_image_url(preset.iconName)] |
| 255 | 262 | tags += tag |
| 256 | 263 | } |
| 257 | 264 | } |
| 258 | 265 | } |
| | 266 | return tags |
| | 267 | } |
| 259 | 268 | |
| 260 | | write_json("JOSM main presets", "Tags supported by the default presets in the OSM editor JOSM", tags) |
| | 269 | void run_external_presets() { |
| | 270 | init() |
| | 271 | def sources = new TaggingPresetPreference.TaggingPresetSourceEditor().loadAndGetAvailableSources() |
| | 272 | def tags = [] |
| | 273 | for (def source : sources) { |
| | 274 | if (source.url.startsWith("resource")) { |
| | 275 | // default presets |
| | 276 | continue; |
| | 277 | } |
| | 278 | try { |
| | 279 | println "Loading ${source.url}" |
| | 280 | def presets = TaggingPresetReader.readAll(source.url, false) |
| | 281 | def t = convert_presets(presets, source.title + " ", false) |
| | 282 | println "Converting ${t.size()} presets of ${source.title}" |
| | 283 | tags += t |
| | 284 | } catch (Exception ex) { |
| | 285 | System.err.println("Skipping ${source.url} due to error") |
| | 286 | ex.printStackTrace() |
| | 287 | } |
| | 288 | } |
| | 289 | write_json("JOSM user presets", "Tags supported by the user contributed presets in the OSM editor JOSM", tags) |
| 261 | 290 | } |
| 262 | 291 | |
| 263 | 292 | void run() { |
| … |
… |
class taginfoextract {
|
| 324 | 353 | */ |
| 325 | 354 | def init() { |
| 326 | 355 | Main.initApplicationPreferences() |
| | 356 | Main.determinePlatformHook() |
| 327 | 357 | Main.pref.enableSaveOnPut(false) |
| 328 | 358 | Main.setProjection(Projections.getProjectionByCode("EPSG:3857")) |
| 329 | 359 | Path tmpdir = Files.createTempDirectory(FileSystems.getDefault().getPath(base_dir), "pref") |
diff --git a/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java b/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
index 4d550dc..76b5c60 100644
|
a
|
b
|
public boolean hasActiveSourcesChanged() {
|
| 444 | 444 | return activeSourcesModel.getSources(); |
| 445 | 445 | } |
| 446 | 446 | |
| | 447 | /** |
| | 448 | * Synchronously loads available sources and returns the parsed list. |
| | 449 | */ |
| | 450 | Collection<ExtendedSourceEntry> loadAndGetAvailableSources() { |
| | 451 | try { |
| | 452 | final SourceLoader loader = new SourceLoader(availableSourcesUrl, sourceProviders); |
| | 453 | loader.realRun(); |
| | 454 | return loader.sources; |
| | 455 | } catch (Exception ex) { |
| | 456 | throw new RuntimeException(ex); |
| | 457 | } |
| | 458 | } |
| | 459 | |
| 447 | 460 | public void removeSources(Collection<Integer> idxs) { |
| 448 | 461 | activeSourcesModel.removeIdxs(idxs); |
| 449 | 462 | } |