Changeset 18886 in josm


Ignore:
Timestamp:
2023-10-30T20:42:22+01:00 (6 months ago)
Author:
taylor.smock
Message:

Fix #18866: Remove Potlatch2 from the built-in styles. It has been replaced with wiki:Styles/Potlatch2.

Users who have the built-in Potlatch2 style enabled when they upgrade to this
revision or later will automatically have wiki:Styles/Potlatch2 added to their
style list and enabled.

Location:
trunk
Files:
3 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/README

    r18166 r18886  
    103103                            resolution and vector versions)
    104104  - styles/                 files needed for map style maintenance
    105     - potlatch2/README      infos on how to update the Potlatch 2 style from upstream sources
    106105- README                    this file
    107106- resources/                resource files that will be included in the JOSM jar file
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r18292 r18886  
    901901            putInt("draw.rawgps.lines", -1);
    902902        }
     903        updateMapPaintKnownDefaults();
    903904        if (modifiedDefault) {
    904905            try {
     
    913914
    914915    /**
     916     * Update the known defaults for the map paintstyles.
     917     * This should be removed sometime after 2024-06-01.
     918     */
     919    private void updateMapPaintKnownDefaults() {
     920        final String url = "url";
     921        final String active = "active";
     922        final String potlatch2 = "resource://styles/standard/potlatch2.mapcss";
     923        final String remotePotlatch2 = "https://josm.openstreetmap.de/josmfile?page=Styles/Potlatch2&zip=1";
     924
     925        // Remove potlatch2 from the known defaults
     926        final List<String> knownDefaults = new ArrayList<>(getList("mappaint.style.known-defaults"));
     927        // See #18866: Potlatch 2 internal theme removed in favor of remote theme by Stereo
     928        knownDefaults.removeIf(potlatch2::equals);
     929
     930        // Moved from MapPaintPrefHelper for consistency
     931        // XML style is not bundled anymore
     932        knownDefaults.removeIf("resource://styles/standard/elemstyles.xml"::equals);
     933        putList("mappaint.style.known-defaults", knownDefaults);
     934
     935        // Replace potlatch2 in the current style entries, but only if it is enabled. Otherwise, remove it.
     936        final List<Map<String, String>> styleEntries = new ArrayList<>(getListOfMaps("mappaint.style.entries"));
     937        final boolean potlatchEnabled = styleEntries.stream().filter(map -> potlatch2.equals(map.get(url)))
     938                .anyMatch(map -> Boolean.parseBoolean(map.get(active)));
     939        final boolean remotePotlatch2Present = styleEntries.stream().anyMatch(map -> remotePotlatch2.equals(map.get(url)));
     940        // Remove potlatch2 if it is not enabled _or_ the remote potlatch2 version is present
     941        styleEntries.removeIf(map -> (!potlatchEnabled || remotePotlatch2Present) && potlatch2.equals(map.get(url)));
     942        styleEntries.replaceAll(HashMap::new); // The maps are initially immutable.
     943        for (Map<String, String> map : styleEntries) {
     944            if (potlatch2.equals(map.get(url))) {
     945                map.put(url, remotePotlatch2);
     946            }
     947        }
     948        putListOfMaps("mappaint.style.entries", styleEntries);
     949    }
     950
     951    /**
    915952     * Enables or not the preferences file auto-save mechanism (save each time a setting is changed).
    916953     * This behaviour is enabled by default.
  • trunk/src/org/openstreetmap/josm/data/preferences/sources/MapPaintPrefHelper.java

    r16468 r18886  
    55
    66import java.util.ArrayList;
    7 import java.util.Arrays;
    87import java.util.Collection;
     8import java.util.Collections;
    99import java.util.List;
    1010import java.util.Map;
     
    7373        Config.getPref().putList("mappaint.style.known-defaults", new ArrayList<>(knownDefaults));
    7474
    75         // XML style is not bundled anymore
    76         list.removeIf(se -> "resource://styles/standard/elemstyles.xml".equals(se.url));
    77 
    7875        return changed;
    7976    }
     
    8784        defJosmMapcss.title = tr("JOSM default (MapCSS)");
    8885        defJosmMapcss.description = tr("Internal style to be used as base for runtime switchable overlay styles");
    89         ExtendedSourceEntry defPL2 = new ExtendedSourceEntry(type, "potlatch2.mapcss", "resource://styles/standard/potlatch2.mapcss");
    90         defPL2.active = false;
    91         defPL2.name = "standard";
    92         defPL2.icon = new ImageProvider("dialogs/mappaint", "pl2_small").getResource();
    93         defPL2.title = tr("Potlatch 2");
    94         defPL2.description = tr("the main Potlatch 2 style");
    95 
    96         return Arrays.asList(defJosmMapcss, defPL2);
     86        return Collections.singletonList(defJosmMapcss);
    9787    }
    9888
  • trunk/test/unit/org/openstreetmap/josm/data/validation/ValidatorCLITest.java

    r18870 r18886  
    8888
    8989    @ParameterizedTest
    90     @ValueSource(strings = {"resources/styles/standard/elemstyles.mapcss", "resources/styles/standard/potlatch2.mapcss"})
     90    @ValueSource(strings = "resources/styles/standard/elemstyles.mapcss")
    9191    void testInternalMapcss(final String resourceLocation) {
    9292        validatorCLI.processArguments(new String[]{"--input", resourceLocation});
Note: See TracChangeset for help on using the changeset viewer.