Changeset 11270 in josm
- Timestamp:
- 2016-11-17T20:25:06+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r10791 r11270 36 36 import org.openstreetmap.josm.actions.ExpertToggleAction; 37 37 import org.openstreetmap.josm.data.Bounds; 38 import org.openstreetmap.josm.data.preferences.BooleanProperty; 39 import org.openstreetmap.josm.data.preferences.IntegerProperty; 38 40 import org.openstreetmap.josm.gui.MapView; 39 41 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; … … 47 49 import org.openstreetmap.josm.tools.InputMapUtils; 48 50 import org.openstreetmap.josm.tools.OsmUrlToBounds; 51 import org.openstreetmap.josm.tools.Utils; 49 52 import org.openstreetmap.josm.tools.WindowGeometry; 50 53 … … 53 56 */ 54 57 public class DownloadDialog extends JDialog { 58 private static IntegerProperty DOWNLOAD_TAB = new IntegerProperty("download.tab", 0); 59 60 private static BooleanProperty DOWNLOAD_AUTORUN = new BooleanProperty("download.autorun", false); 61 private static BooleanProperty DOWNLOAD_OSM = new BooleanProperty("download.osm", true); 62 private static BooleanProperty DOWNLOAD_GPS = new BooleanProperty("download.gps", false); 63 private static BooleanProperty DOWNLOAD_NOTES = new BooleanProperty("download.notes", false); 64 private static BooleanProperty DOWNLOAD_NEWLAYER = new BooleanProperty("download.newlayer", false); 65 55 66 /** the unique instance of the download dialog */ 56 67 private static DownloadDialog instance; … … 131 142 132 143 try { 133 tpDownloadAreaSelectors.setSelectedIndex( Main.pref.getInteger("download.tab", 0));144 tpDownloadAreaSelectors.setSelectedIndex(DOWNLOAD_TAB.get()); 134 145 } catch (IndexOutOfBoundsException ex) { 135 146 Main.trace(ex); 136 Main.pref.putInteger("download.tab",0);147 DOWNLOAD_TAB.put(0); 137 148 } 138 149 … … 148 159 tr("<html>Autostart ''Download from OSM'' dialog every time JOSM is started.<br>" + 149 160 "You can open it manually from File menu or toolbar.</html>")); 150 cbStartup.addActionListener(e -> Main.pref.put("download.autorun",cbStartup.isSelected()));161 cbStartup.addActionListener(e -> DOWNLOAD_AUTORUN.put(cbStartup.isSelected())); 151 162 152 163 pnl.add(cbNewLayer, GBC.std().anchor(GBC.WEST).insets(5, 5, 5, 5)); … … 351 362 */ 352 363 public void rememberSettings() { 353 Main.pref.put("download.tab", Integer.toString(tpDownloadAreaSelectors.getSelectedIndex()));354 Main.pref.put("download.osm",cbDownloadOsmData.isSelected());355 Main.pref.put("download.gps",cbDownloadGpxData.isSelected());356 Main.pref.put("download.notes",cbDownloadNotes.isSelected());357 Main.pref.put("download.newlayer",cbNewLayer.isSelected());364 DOWNLOAD_TAB.put(tpDownloadAreaSelectors.getSelectedIndex()); 365 DOWNLOAD_OSM.put(cbDownloadOsmData.isSelected()); 366 DOWNLOAD_GPS.put(cbDownloadGpxData.isSelected()); 367 DOWNLOAD_NOTES.put(cbDownloadNotes.isSelected()); 368 DOWNLOAD_NEWLAYER.put(cbNewLayer.isSelected()); 358 369 if (currentBounds != null) { 359 370 Main.pref.put("osm-download.bounds", currentBounds.encodeAsString(";")); … … 365 376 */ 366 377 public void restoreSettings() { 367 cbDownloadOsmData.setSelected( Main.pref.getBoolean("download.osm", true));368 cbDownloadGpxData.setSelected( Main.pref.getBoolean("download.gps", false));369 cbDownloadNotes.setSelected( Main.pref.getBoolean("download.notes", false));370 cbNewLayer.setSelected( Main.pref.getBoolean("download.newlayer", false));378 cbDownloadOsmData.setSelected(DOWNLOAD_OSM.get()); 379 cbDownloadGpxData.setSelected(DOWNLOAD_GPS.get()); 380 cbDownloadNotes.setSelected(DOWNLOAD_NOTES.get()); 381 cbNewLayer.setSelected(DOWNLOAD_NEWLAYER.get()); 371 382 cbStartup.setSelected(isAutorunEnabled()); 372 int idx = Main.pref.getInteger("download.tab", 0); 373 if (idx < 0 || idx > tpDownloadAreaSelectors.getTabCount()) { 374 idx = 0; 375 } 383 int idx = Utils.clamp(DOWNLOAD_TAB.get(), 0, tpDownloadAreaSelectors.getTabCount() - 1); 376 384 tpDownloadAreaSelectors.setSelectedIndex(idx); 377 385 … … 414 422 */ 415 423 public static boolean isAutorunEnabled() { 416 return Main.pref.getBoolean("download.autorun", false);424 return DOWNLOAD_AUTORUN.get(); 417 425 } 418 426
Note: See TracChangeset
for help on using the changeset viewer.