Changeset 12853 in josm


Ignore:
Timestamp:
2017-09-14T02:25:27+02:00 (10 days ago)
Author:
bastiK
Message:

see #15229 - include support for the long type in IPreferences

Location:
trunk/src/org/openstreetmap/josm
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r12846 r12853  
    321321    private BoundingXYVisitor modeDownload(BoundingXYVisitor v) {
    322322        if (lastZoomTime > 0 &&
    323                 System.currentTimeMillis() - lastZoomTime > Main.pref.getLong("zoom.bounds.reset.time", TimeUnit.SECONDS.toMillis(10))) {
     323                System.currentTimeMillis() - lastZoomTime > Config.getPref().getLong("zoom.bounds.reset.time", TimeUnit.SECONDS.toMillis(10))) {
    324324            lastZoomTime = -1;
    325325        }
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r12851 r12853  
    585585     * @return {@code true}, if something has changed (i.e. value is different than before)
    586586     * @see LongProperty#put(Long)
    587      */
     587     * @deprecated use {@link IPreferences#putLong(java.lang.String, long)}
     588     */
     589    @Deprecated
    588590    public boolean putLong(final String key, final Long value) {
    589591        return put(key, Long.toString(value));
     
    961963
    962964    /**
    963      * Gets a long preference
    964      * @param key The preference key
    965      * @param def The default value to use
    966      * @return The long value or the default value if it could not be parsed
    967      * @see LongProperty#get()
    968      */
    969     public synchronized long getLong(String key, long def) {
    970         String v = get(key, Long.toString(def));
    971         if (null == v)
    972             return def;
    973 
    974         try {
    975             return Long.parseLong(v);
    976         } catch (NumberFormatException e) {
    977             // fall out
    978             Logging.trace(e);
    979         }
    980         return def;
    981     }
    982 
    983     /**
    984965     * Get a list of values for a certain key
    985966     * @param key the identifier for the setting
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r12846 r12853  
    656656        Collection<String> history = Config.getPref().getList(historyKey, def);
    657657        int age = (int) (System.currentTimeMillis() / 1000 - Config.getPref().getInt(BasicUploadSettingsPanel.HISTORY_LAST_USED_KEY, 0));
    658         if (history != null && age < Main.pref.getLong(BasicUploadSettingsPanel.HISTORY_MAX_AGE_KEY, TimeUnit.HOURS.toMillis(4))
     658        if (history != null && age < Config.getPref().getLong(BasicUploadSettingsPanel.HISTORY_MAX_AGE_KEY, TimeUnit.HOURS.toMillis(4))
    659659                && !history.isEmpty()) {
    660660            return history.iterator().next();
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/DateFilterPanel.java

    r12846 r12853  
    1616import javax.swing.event.ChangeListener;
    1717
    18 import org.openstreetmap.josm.Main;
    1918import org.openstreetmap.josm.gui.layer.GpxLayer;
    2019import org.openstreetmap.josm.gui.widgets.DateEditorWithSlider;
     
    104103     */
    105104    public void saveInPrefs() {
    106         Main.pref.putLong(prefDateMin, dateFrom.getDate().getTime());
    107         Main.pref.putLong(prefDateMax, dateTo.getDate().getTime());
     105        Config.getPref().putLong(prefDateMin, dateFrom.getDate().getTime());
     106        Config.getPref().putLong(prefDateMax, dateTo.getDate().getTime());
    108107        Config.getPref().putBoolean(prefDate0, noTimestampCb.isSelected());
    109108    }
     
    114113     */
    115114    public void loadFromPrefs() {
    116         long t1 = Main.pref.getLong(prefDateMin, 0);
     115        long t1 = Config.getPref().getLong(prefDateMin, 0);
    117116        if (t1 != 0) dateFrom.setDate(new Date(t1));
    118         long t2 = Main.pref.getLong(prefDateMax, 0);
     117        long t2 = Config.getPref().getLong(prefDateMax, 0);
    119118        if (t2 != 0) dateTo.setDate(new Date(t2));
    120119        noTimestampCb.setSelected(Config.getPref().getBoolean(prefDate0, false));
  • trunk/src/org/openstreetmap/josm/io/CachedFile.java

    r12846 r12853  
    436436                        || maxAge <= 0 // arbitrary value <= 0 is deprecated
    437437                ) {
    438                     maxAgeMillis = TimeUnit.SECONDS.toMillis(Main.pref.getLong("mirror.maxtime", TimeUnit.DAYS.toSeconds(7)));
     438                    maxAgeMillis = TimeUnit.SECONDS.toMillis(Config.getPref().getLong("mirror.maxtime", TimeUnit.DAYS.toSeconds(7)));
    439439                }
    440440                age = System.currentTimeMillis() - Long.parseLong(localPathEntry.get(0));
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r12846 r12853  
    434434        } else {
    435435            long tim = System.currentTimeMillis();
    436             long last = Main.pref.getLong("pluginmanager.lastupdate", 0);
     436            long last = Config.getPref().getLong("pluginmanager.lastupdate", 0);
    437437            Integer maxTime = Config.getPref().getInt("pluginmanager.time-based-update.interval", DEFAULT_TIME_BASED_UPDATE_INTERVAL);
    438438            long d = TimeUnit.MILLISECONDS.toDays(tim - last);
  • trunk/src/org/openstreetmap/josm/spi/preferences/AbstractPreferences.java

    r12847 r12853  
    5656    public boolean putInt(String key, int value) {
    5757        return put(key, Integer.toString(value));
     58    }
     59
     60    @Override
     61    public long getLong(String key, long def) {
     62        String v = get(key, Long.toString(def));
     63        if (null == v)
     64            return def;
     65
     66        try {
     67            return Long.parseLong(v);
     68        } catch (NumberFormatException e) {
     69            // fall out
     70            Logging.trace(e);
     71        }
     72        return def;
     73    }
     74
     75    @Override
     76    public boolean putLong(final String key, final long value) {
     77        return put(key, Long.toString(value));
    5878    }
    5979
  • trunk/src/org/openstreetmap/josm/spi/preferences/IPreferences.java

    r12847 r12853  
    105105
    106106    /**
    107      * Set a boolean value for a certain setting.
     107     * Set an integer value for a certain setting.
    108108     * @param key the unique identifier for the setting
    109109     * @param value The new value
     
    112112     */
    113113    boolean putInt(String key, int value);
     114
     115    /**
     116     * Gets a long preference
     117     * @param key The preference key
     118     * @param def The default value to use
     119     * @return The long value or the default value if it could not be parsed
     120     */
     121    long getLong(String key, long def);
     122
     123    /**
     124     * Set a long value for a certain setting.
     125     * @param key the unique identifier for the setting
     126     * @param value The new value
     127     * @return {@code true}, if something has changed (i.e. value is different than before)
     128     */
     129    boolean putLong(String key, long value);
    114130
    115131    /**
Note: See TracChangeset for help on using the changeset viewer.