Ignore:
Timestamp:
2011-04-06T14:57:45+02:00 (10 years ago)
Author:
Upliner
Message:

fix #5863 add ability to cancel changes in Imagery providers list

File:
1 edited

Legend:

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

    r3978 r4016  
    2323    public static final ImageryLayerInfo instance = new ImageryLayerInfo();
    2424    ArrayList<ImageryInfo> layers = new ArrayList<ImageryInfo>();
    25     ArrayList<ImageryInfo> defaultLayers = new ArrayList<ImageryInfo>();
     25    static ArrayList<ImageryInfo> defaultLayers = new ArrayList<ImageryInfo>();
    2626
    2727    private final static String[] DEFAULT_LAYER_SITES = {
     
    2929    };
    3030
    31     public void load(boolean clearCache) {
     31    private ImageryLayerInfo() {
     32    }
     33
     34    public ImageryLayerInfo(ImageryLayerInfo info) {
     35        layers.addAll(info.layers);
     36    }
     37
     38    public void load() {
    3239        layers.clear();
    33         defaultLayers.clear();
    34         Collection<String> defaults = Main.pref.getCollection(
    35                 "imagery.layers.default", Collections.<String>emptySet());
    3640        for(Collection<String> c : Main.pref.getArray("imagery.layers",
    3741                Collections.<Collection<String>>emptySet())) {
    3842            add(new ImageryInfo(c));
    3943        }
     44        Collections.sort(layers);
     45    }
    4046
     47    public void loadDefaults(boolean clearCache) {
     48        defaultLayers.clear();
     49        Collection<String> defaults = Main.pref.getCollection(
     50                "imagery.layers.default", Collections.<String>emptySet());
    4151        ArrayList<String> defaultsSave = new ArrayList<String>();
    4252        for(String source : Main.pref.getCollection("imagery.layers.sites", Arrays.asList(DEFAULT_LAYER_SITES)))
     
    97107        }
    98108
     109        Collections.sort(defaultLayers);
    99110        Main.pref.putCollection("imagery.layers.default", defaultsSave.size() > 0
    100111                ? defaultsSave : defaults);
    101         Collections.sort(layers);
    102         Collections.sort(defaultLayers);
    103         save();
    104112    }
    105113
Note: See TracChangeset for help on using the changeset viewer.