| 1 | ### Eclipse Workspace Patch 1.0
|
|---|
| 2 | #P josm
|
|---|
| 3 | Index: src/org/openstreetmap/josm/data/Preferences.java
|
|---|
| 4 | ===================================================================
|
|---|
| 5 | --- src/org/openstreetmap/josm/data/Preferences.java (revision 965)
|
|---|
| 6 | +++ src/org/openstreetmap/josm/data/Preferences.java (working copy)
|
|---|
| 7 | @@ -31,7 +31,14 @@
|
|---|
| 8 | * @author imi
|
|---|
| 9 | */
|
|---|
| 10 | public class Preferences {
|
|---|
| 11 | -
|
|---|
| 12 | +
|
|---|
| 13 | + /**
|
|---|
| 14 | + * Internal storage for the preferenced directory.
|
|---|
| 15 | + * Do not access this variable directly!
|
|---|
| 16 | + * @see #getPreferencesDirFile()
|
|---|
| 17 | + */
|
|---|
| 18 | + private File preferencesDirFile = null;
|
|---|
| 19 | +
|
|---|
| 20 | public static interface PreferenceChangedListener {
|
|---|
| 21 | void preferenceChanged(String key, String newValue);
|
|---|
| 22 | }
|
|---|
| 23 | @@ -79,12 +86,24 @@
|
|---|
| 24 | return path + File.separator;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | - public File getPreferencesDirFile() {
|
|---|
| 28 | - if (System.getenv("APPDATA") != null)
|
|---|
| 29 | - return new File(System.getenv("APPDATA"), "JOSM");
|
|---|
| 30 | - return new File(System.getProperty("user.home"), ".josm");
|
|---|
| 31 | - }
|
|---|
| 32 | -
|
|---|
| 33 | + public File getPreferencesDirFile() {
|
|---|
| 34 | + if (preferencesDirFile != null)
|
|---|
| 35 | + return preferencesDirFile;
|
|---|
| 36 | + String path;
|
|---|
| 37 | + path = System.getProperty("josm.home");
|
|---|
| 38 | + if (path != null) {
|
|---|
| 39 | + preferencesDirFile = new File(path);
|
|---|
| 40 | + } else {
|
|---|
| 41 | + path = System.getenv("APPDATA");
|
|---|
| 42 | + if (path != null) {
|
|---|
| 43 | + preferencesDirFile = new File(path, "JOSM");
|
|---|
| 44 | + } else {
|
|---|
| 45 | + preferencesDirFile = new File(System.getProperty("user.home"), ".josm");
|
|---|
| 46 | + }
|
|---|
| 47 | + }
|
|---|
| 48 | + return preferencesDirFile;
|
|---|
| 49 | + }
|
|---|
| 50 | +
|
|---|
| 51 | public File getPluginsDirFile() {
|
|---|
| 52 | return new File(getPreferencesDirFile(), "plugins");
|
|---|
| 53 | }
|
|---|