Changeset 3718 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-12-12T12:55:57+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
r3715 r3718 15 15 16 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; 17 18 import org.openstreetmap.josm.io.MirroredInputStream; 18 19 … … 68 69 if(!defaults.contains(url)) { 69 70 for(ImageryInfo i : layers) { 70 if(url.equals(i.url)) { 71 if ((i.getImageryType() == ImageryType.WMS && url.equals(i.getURL())) 72 || url.equals(i.getFullURL())) { 71 73 force = false; 72 74 } -
trunk/src/org/openstreetmap/josm/gui/preferences/ImageryPreference.java
r3715 r3718 19 19 import java.util.List; 20 20 import java.util.Locale; 21 import java.util.Map;22 21 23 22 import javax.swing.BorderFactory; … … 62 61 ImageryProvidersPanel imageryProviders; 63 62 63 static ImagerySettingsMigration settingsMigration; 64 64 65 // Common settings 65 66 private Color colFadeColor; … … 87 88 this.colFadeColor = ImageryLayer.getFadeColor(); 88 89 this.btnFadeColor = new JButton(); 89 this.btnFadeColor.setBackground(colFadeColor);90 this.btnFadeColor.setText(ColorHelper.color2html(colFadeColor));91 90 92 91 this.btnFadeColor.addActionListener(new ActionListener() { … … 114 113 p.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL)); 115 114 p.add(this.fadeAmount, GBC.eol().fill(GBC.HORIZONTAL)); 116 this.fadeAmount.setValue(ImageryLayer.PROP_FADE_AMOUNT.get());117 115 118 116 this.sharpen = new JComboBox(new String[] { … … 122 120 p.add(new JLabel(tr("Sharpen (requires layer re-add): "))); 123 121 p.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL)); 124 p.add(this.sharpen, GBC.std().fill(GBC.HORIZONTAL)); 125 this.sharpen.setSelectedIndex(ImageryLayer.PROP_SHARPEN_LEVEL.get()); 126 122 p.add(this.sharpen, GBC.eol().fill(GBC.HORIZONTAL)); 123 124 if (settingsMigration != null) { 125 final JButton btnSettingsMigration = new JButton(tr("WMSPlugin/SlippyMap settings migration")); 126 btnSettingsMigration.addActionListener(new ActionListener() { 127 @Override 128 public void actionPerformed(ActionEvent e) { 129 if (settingsMigration == null) return; 130 settingsMigration.settingsMigrationDialog(gui); 131 loadSettings(); 132 imageryProviders.model.fireTableDataChanged(); 133 if (!settingsMigration.hasConflicts()) { 134 btnSettingsMigration.setEnabled(false); 135 settingsMigration = null; 136 } 137 } 138 }); 139 p.add(btnSettingsMigration,GBC.eol().insets(0,5,0,5)); 140 } 127 141 return p; 128 142 } … … 136 150 "webkit-image-gtk {0}"}); 137 151 browser.setEditable(true); 138 browser.setSelectedItem(HTMLGrabber.PROP_BROWSER.get());139 152 p.add(new JLabel(tr("Downloader:")), GBC.eol().fill(GBC.HORIZONTAL)); 140 153 p.add(browser); … … 143 156 p.add(Box.createHorizontalGlue(), GBC.eol().fill(GBC.HORIZONTAL)); 144 157 145 overlapCheckBox = new JCheckBox(tr("Overlap tiles") , WMSLayer.PROP_OVERLAP.get());158 overlapCheckBox = new JCheckBox(tr("Overlap tiles")); 146 159 JLabel labelEast = new JLabel(tr("% of east:")); 147 160 JLabel labelNorth = new JLabel(tr("% of north:")); … … 196 209 tmsTab.add(addToSlippyMapChosser, GBC.eol().fill(GBC.HORIZONTAL)); 197 210 198 this.autozoomActive.setSelected(TMSLayer.PROP_DEFAULT_AUTOZOOM.get());199 this.autoloadTiles.setSelected(TMSLayer.PROP_DEFAULT_AUTOLOAD.get());200 this.addToSlippyMapChosser.setSelected(TMSLayer.PROP_ADD_TO_SLIPPYMAP_CHOOSER.get());201 this.maxZoomLvl.setValue(TMSLayer.getMaxZoomLvl(null));202 this.minZoomLvl.setValue(TMSLayer.getMinZoomLvl(null));203 211 return tmsTab; 204 212 } … … 232 240 pane.add(buildSettingsPanel(gui)); 233 241 pane.add(new OffsetBookmarksPanel(gui)); 242 loadSettings(); 234 243 pane.setTitleAt(0, tr("Imagery providers")); 235 244 pane.setTitleAt(1, tr("Settings")); 236 245 pane.setTitleAt(2, tr("Offset bookmarks")); 237 246 p.add(pane,GBC.std().fill(GBC.BOTH)); 247 } 248 249 private void loadSettings() { 250 // Common settings 251 this.btnFadeColor.setBackground(colFadeColor); 252 this.btnFadeColor.setText(ColorHelper.color2html(colFadeColor)); 253 this.fadeAmount.setValue(ImageryLayer.PROP_FADE_AMOUNT.get()); 254 this.sharpen.setSelectedIndex(ImageryLayer.PROP_SHARPEN_LEVEL.get()); 255 256 // WMS Settings 257 this.browser.setSelectedItem(HTMLGrabber.PROP_BROWSER.get()); 258 this.overlapCheckBox.setSelected(WMSLayer.PROP_OVERLAP.get()); 259 this.spinEast.setValue(WMSLayer.PROP_OVERLAP_EAST.get()); 260 this.spinNorth.setValue(WMSLayer.PROP_OVERLAP_NORTH.get()); 261 this.spinSimConn.setValue(WMSLayer.PROP_SIMULTANEOUS_CONNECTIONS.get()); 262 263 // TMS Settings 264 this.autozoomActive.setSelected(TMSLayer.PROP_DEFAULT_AUTOZOOM.get()); 265 this.autoloadTiles.setSelected(TMSLayer.PROP_DEFAULT_AUTOLOAD.get()); 266 this.addToSlippyMapChosser.setSelected(TMSLayer.PROP_ADD_TO_SLIPPYMAP_CHOOSER.get()); 267 this.maxZoomLvl.setValue(TMSLayer.getMaxZoomLvl(null)); 268 this.minZoomLvl.setValue(TMSLayer.getMinZoomLvl(null)); 238 269 } 239 270 … … 707 738 708 739 public static void initialize() { 709 migrateWMSPlugin(); 710 migrateSlippyMapPlugin(); 740 settingsMigration = new ImagerySettingsMigration(); 741 settingsMigration.migrateSettings(); 742 if (!settingsMigration.hasConflicts()) { 743 settingsMigration = null; 744 } 711 745 ImageryLayerInfo.instance.load(); 712 746 OffsetBookmark.loadBookmarks(); … … 714 748 Main.main.menu.imageryMenuUpdater.refreshOffsetMenu(); 715 749 } 716 717 // Migration of WMSPlugin and SlippyMap settings718 static boolean wmsLayersConflict;719 static boolean wmsSettingsConflict;720 static boolean tmsSettingsConflict;721 722 static class SettingsConflictException extends Exception {723 }724 725 static void migrateProperty(String oldProp, String newProp)726 throws SettingsConflictException {727 String oldValue = Main.pref.get(oldProp, null);728 if (oldValue == null) return;729 String newValue = Main.pref.get(newProp, null);730 if (newValue != null && !oldValue.equals(newValue)) {731 System.out.println(tr("Imagery settings migration: conflict when moving property {0} -> {1}",732 oldProp, newProp));733 throw new SettingsConflictException();734 }735 Main.pref.put(newProp, oldValue);736 Main.pref.put(oldProp, null);737 }738 739 static void migrateWMSPlugin() {740 try {741 migrateProperty("wmslayers", "imagery.layers");742 } catch (SettingsConflictException e) {743 wmsLayersConflict = true;744 }745 try {746 Main.pref.put("wmslayers.default", null);747 migrateProperty("imagery.remotecontrol", "remotecontrol.permission.imagery");748 migrateProperty("wmsplugin.remotecontrol", "remotecontrol.permission.imagery");749 migrateProperty("wmsplugin.alpha_channel", "imagery.wms.alpha_channel");750 migrateProperty("wmsplugin.browser", "imagery.wms.browser");751 migrateProperty("wmsplugin.user_agent", "imagery.wms.user_agent");752 migrateProperty("wmsplugin.timeout.connect", "imagery.wms.timeout.connect");753 migrateProperty("wmsplugin.timeout.read", "imagery.wms.timeout.read");754 migrateProperty("wmsplugin.simultaneousConnections", "imagery.wms.simultaneousConnections");755 migrateProperty("wmsplugin.overlap", "imagery.wms.overlap");756 migrateProperty("wmsplugin.overlapEast", "imagery.wms.overlapEast");757 migrateProperty("wmsplugin.overlapNorth", "imagery.wms.overlapNorth");758 Map<String, String> unknownProps = Main.pref.getAllPrefix("wmsplugin");759 if (!unknownProps.isEmpty()) {760 System.out.println(tr("There are {0} unknown WMSPlugin settings", unknownProps.size()));761 wmsSettingsConflict = true;762 }763 } catch (SettingsConflictException e) {764 wmsSettingsConflict = true;765 }766 }767 768 static void migrateSlippyMapPlugin() {769 try {770 Main.pref.put("slippymap.tile_source", null);771 Main.pref.put("slippymap.last_zoom_lvl", null);772 migrateProperty("slippymap.draw_debug", "imagery.tms.draw_debug");773 migrateProperty("slippymap.autoload_tiles", "imagery.tms.autoload");774 migrateProperty("slippymap.autozoom", "imagery.tms.autozoom");775 migrateProperty("slippymap.min_zoom_lvl", "imagery.tms.min_zoom_lvl");776 migrateProperty("slippymap.max_zoom_lvl", "imagery.tms.max_zoom_lvl");777 if (Main.pref.get("slippymap.fade_background_100", null) == null) {778 try {779 Main.pref.putInteger("slippymap.fade_background_100", (int)Math.round(780 Double.valueOf(Main.pref.get("slippymap.fade_background", "0"))*100.0));781 } catch (NumberFormatException e) {782 }783 }784 Main.pref.put("slippymap.fade_background", null);785 migrateProperty("slippymap.fade_background_100", "imagery.fade_amount");786 Map<String, String> unknownProps = Main.pref.getAllPrefix("slippymap");787 if (!unknownProps.isEmpty()) {788 System.out.println(tr("There are {0} unknown slippymap plugin settings", unknownProps.size()));789 wmsSettingsConflict = true;790 }791 } catch (SettingsConflictException e) {792 tmsSettingsConflict = true;793 }794 }795 796 750 }
Note:
See TracChangeset
for help on using the changeset viewer.