Ignore:
Timestamp:
2017-01-25T14:12:07+01:00 (8 years ago)
Author:
Don-vip
Message:

see #12627, see #14289 - add non regression unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r11401 r11493  
    290290
    291291    private static StyleSource fromSourceEntry(SourceEntry entry) {
     292        if (entry.url == null && entry instanceof MapCSSStyleSource) {
     293            return (MapCSSStyleSource) entry;
     294        }
    292295        Set<String> mimes = new HashSet<>(Arrays.asList(MapCSSStyleSource.MAPCSS_STYLE_MIME_TYPES.split(", ")));
    293296        try (CachedFile cf = new CachedFile(entry.url).setHttpAccept(Utils.join(", ", mimes))) {
     
    419422        styles.add(source);
    420423        loadStyleForFirstTime(source);
     424        refreshStyles();
     425        return source;
     426    }
     427
     428    /**
     429     * Remove a map paint style.
     430     * @param entry map paint style
     431     * @since 11493
     432     */
     433    public static void removeStyle(SourceEntry entry) {
     434        StyleSource source = fromSourceEntry(entry);
     435        if (styles.remove(source)) {
     436            refreshStyles();
     437        }
     438    }
     439
     440    private static void refreshStyles() {
    421441        MapPaintPrefHelper.INSTANCE.put(styles.getStyleSources());
    422442        fireMapPaintSylesUpdated();
     
    425445            Main.map.mapView.repaint();
    426446        }
    427         return source;
    428447    }
    429448
Note: See TracChangeset for help on using the changeset viewer.