Ignore:
Timestamp:
2013-12-22T18:18:43+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #9459 - initialize default center view of MapView to last download location, if any, instead of (0,0)

File:
1 edited

Legend:

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

    r6380 r6509  
    307307   
    308308    /**
    309      * Remembers the current settings in the download dialog
    310      *
     309     * Remembers the current settings in the download dialog.
    311310     */
    312311    public void rememberSettings() {
     
    320319    }
    321320
     321    /**
     322     * Restores the previous settings in the download dialog.
     323     */
    322324    public void restoreSettings() {
    323325        cbDownloadOsmData.setSelected(Main.pref.getBoolean("download.osm", true));
     
    339341            boundingBoxChanged(currentBounds,null);
    340342        }
    341         else if (!Main.pref.get("osm-download.bounds").isEmpty()) {
    342             // read the bounding box from the preferences
     343        else {
     344            Bounds bounds = getSavedDownloadBounds();
     345            if (bounds != null) {
     346                currentBounds = bounds;
     347                boundingBoxChanged(currentBounds, null);
     348            }
     349        }
     350    }
     351   
     352    /**
     353     * Returns the previously saved bounding box from preferences.
     354     * @return The bounding box saved in preferences if any, {@code null} otherwise
     355     * @since 6509
     356     */
     357    public static Bounds getSavedDownloadBounds() {
     358        String value = Main.pref.get("osm-download.bounds");
     359        if (!value.isEmpty()) {
    343360            try {
    344                 currentBounds = new Bounds(Main.pref.get("osm-download.bounds"), ";");
    345                 boundingBoxChanged(currentBounds,null);
    346             }
    347             catch (Exception e) {
    348                 e.printStackTrace();
    349             }
    350         }
    351     }
    352 
     361                return new Bounds(value, ";");
     362            } catch (IllegalArgumentException e) {
     363                Main.warn(e);
     364            }
     365        }
     366        return null;
     367    }
     368
     369    /**
     370     * Determines if the dialog autorun is enabled in preferences.
     371     * @return {@code true} if the download dialog must be open at startup, {@code false} otherwise
     372     */
    353373    public static boolean isAutorunEnabled() {
    354374        return Main.pref.getBoolean("download.autorun",false);
     
    362382
    363383    /**
    364      * Replies the currently selected download area. May be null, if no download area is selected yet.
     384     * Replies the currently selected download area.
     385     * @return the currently selected download area. May be {@code null}, if no download area is selected yet.
    365386     */
    366387    public Bounds getSelectedDownloadArea() {
Note: See TracChangeset for help on using the changeset viewer.