Changeset 7085 in josm for trunk/src


Ignore:
Timestamp:
2014-05-09T06:41:29+02:00 (6 years ago)
Author:
Don-vip
Message:

allow to disable auto-save of preferences file for unit tests (ant chmod does not seem to work from Jenkins)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r7083 r7085  
    8686     */
    8787    private File preferencesDirFile = null;
     88
    8889    /**
    8990     * Internal storage for the cache directory.
    9091     */
    9192    private File cacheDirFile = null;
     93
     94    /**
     95     * Determines if preferences file is saved each time a property is changed.
     96     */
     97    private boolean saveOnPut = true;
    9298
    9399    /**
     
    10361042                settingsMap.put(key, settingCopy);
    10371043            }
    1038             try {
    1039                 save();
    1040             } catch (IOException e){
    1041                 Main.warn(tr("Failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
     1044            if (saveOnPut) {
     1045                try {
     1046                    save();
     1047                } catch (IOException e){
     1048                    Main.warn(tr("Failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
     1049                }
    10421050            }
    10431051        }
     
    16421650        return a.equals(b);
    16431651    }
     1652
     1653    /**
     1654     * Enables or not the preferences file auto-save mechanism (save each time a setting is changed).
     1655     * This behaviour is enabled by default.
     1656     * @param enable if {@code true}, makes JOSM save preferences file each time a setting is changed
     1657     * @since 7085
     1658     */
     1659    public final void enableSaveOnPut(boolean enable) {
     1660        synchronized (this) {
     1661            saveOnPut = enable;
     1662        }
     1663    }
    16441664}
Note: See TracChangeset for help on using the changeset viewer.