Changeset 11270 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2016-11-17T20:25:06+01:00 (7 years ago)
Author:
michael2402
Message:

See #13309: Make download dialog use preferences interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r10791 r11270  
    3636import org.openstreetmap.josm.actions.ExpertToggleAction;
    3737import org.openstreetmap.josm.data.Bounds;
     38import org.openstreetmap.josm.data.preferences.BooleanProperty;
     39import org.openstreetmap.josm.data.preferences.IntegerProperty;
    3840import org.openstreetmap.josm.gui.MapView;
    3941import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
     
    4749import org.openstreetmap.josm.tools.InputMapUtils;
    4850import org.openstreetmap.josm.tools.OsmUrlToBounds;
     51import org.openstreetmap.josm.tools.Utils;
    4952import org.openstreetmap.josm.tools.WindowGeometry;
    5053
     
    5356 */
    5457public 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
    5566    /** the unique instance of the download dialog */
    5667    private static DownloadDialog instance;
     
    131142
    132143        try {
    133             tpDownloadAreaSelectors.setSelectedIndex(Main.pref.getInteger("download.tab", 0));
     144            tpDownloadAreaSelectors.setSelectedIndex(DOWNLOAD_TAB.get());
    134145        } catch (IndexOutOfBoundsException ex) {
    135146            Main.trace(ex);
    136             Main.pref.putInteger("download.tab", 0);
     147            DOWNLOAD_TAB.put(0);
    137148        }
    138149
     
    148159                tr("<html>Autostart ''Download from OSM'' dialog every time JOSM is started.<br>" +
    149160                        "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()));
    151162
    152163        pnl.add(cbNewLayer, GBC.std().anchor(GBC.WEST).insets(5, 5, 5, 5));
     
    351362     */
    352363    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());
    358369        if (currentBounds != null) {
    359370            Main.pref.put("osm-download.bounds", currentBounds.encodeAsString(";"));
     
    365376     */
    366377    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());
    371382        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);
    376384        tpDownloadAreaSelectors.setSelectedIndex(idx);
    377385
     
    414422     */
    415423    public static boolean isAutorunEnabled() {
    416         return Main.pref.getBoolean("download.autorun", false);
     424        return DOWNLOAD_AUTORUN.get();
    417425    }
    418426
Note: See TracChangeset for help on using the changeset viewer.