Changeset 4016 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2011-04-06T14:57:45+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
r3978 r4016 23 23 public static final ImageryLayerInfo instance = new ImageryLayerInfo(); 24 24 ArrayList<ImageryInfo> layers = new ArrayList<ImageryInfo>(); 25 ArrayList<ImageryInfo> defaultLayers = new ArrayList<ImageryInfo>();25 static ArrayList<ImageryInfo> defaultLayers = new ArrayList<ImageryInfo>(); 26 26 27 27 private final static String[] DEFAULT_LAYER_SITES = { … … 29 29 }; 30 30 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() { 32 39 layers.clear(); 33 defaultLayers.clear();34 Collection<String> defaults = Main.pref.getCollection(35 "imagery.layers.default", Collections.<String>emptySet());36 40 for(Collection<String> c : Main.pref.getArray("imagery.layers", 37 41 Collections.<Collection<String>>emptySet())) { 38 42 add(new ImageryInfo(c)); 39 43 } 44 Collections.sort(layers); 45 } 40 46 47 public void loadDefaults(boolean clearCache) { 48 defaultLayers.clear(); 49 Collection<String> defaults = Main.pref.getCollection( 50 "imagery.layers.default", Collections.<String>emptySet()); 41 51 ArrayList<String> defaultsSave = new ArrayList<String>(); 42 52 for(String source : Main.pref.getCollection("imagery.layers.sites", Arrays.asList(DEFAULT_LAYER_SITES))) … … 97 107 } 98 108 109 Collections.sort(defaultLayers); 99 110 Main.pref.putCollection("imagery.layers.default", defaultsSave.size() > 0 100 111 ? defaultsSave : defaults); 101 Collections.sort(layers);102 Collections.sort(defaultLayers);103 save();104 112 } 105 113 -
trunk/src/org/openstreetmap/josm/gui/preferences/ImageryPreference.java
r3978 r4016 71 71 } 72 72 ImageryProvidersPanel imageryProviders; 73 ImageryLayerInfo layerInfo; 73 74 74 75 static ImagerySettingsMigration settingsMigration; … … 269 270 JPanel p = gui.createPreferenceTab("imagery", tr("Imagery Preferences"), tr("Modify list of imagery layers displayed in the Imagery menu")); 270 271 JTabbedPane pane = new JTabbedPane(); 271 imageryProviders = new ImageryProvidersPanel(gui, ImageryLayerInfo.instance); 272 layerInfo = new ImageryLayerInfo(ImageryLayerInfo.instance); 273 imageryProviders = new ImageryProvidersPanel(gui, layerInfo); 272 274 pane.add(imageryProviders); 273 275 pane.add(buildSettingsPanel(gui)); … … 308 310 public boolean ok() { 309 311 boolean restartRequired = false; 310 ImageryLayerInfo.instance.save(); 312 layerInfo.save(); 313 ImageryLayerInfo.instance.load(); 311 314 Main.main.menu.imageryMenu.refreshImageryMenu(); 312 315 Main.main.menu.imageryMenu.refreshOffsetMenu(); … … 567 570 568 571 public void actionPerformed(ActionEvent evt) { 569 layerInfo.load (true);572 layerInfo.loadDefaults(true); 570 573 modeldef.fireTableDataChanged(); 571 574 } … … 857 860 settingsMigration = null; 858 861 } 859 ImageryLayerInfo.instance.load(false); 862 ImageryLayerInfo.instance.load(); 863 ImageryLayerInfo.instance.loadDefaults(false); 860 864 OffsetBookmark.loadBookmarks(); 861 865 Main.main.menu.imageryMenu.refreshImageryMenu();
Note:
See TracChangeset
for help on using the changeset viewer.