- Timestamp:
- 2008-08-18T16:15:04+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r804 r807 21 21 import org.openstreetmap.josm.tools.ColorHelper; 22 22 23 24 23 /** 25 24 * This class holds all preferences for JOSM. 26 * 25 * 27 26 * Other classes can register their beloved properties here. All properties will be 28 27 * saved upon set-access. 29 * 28 * 30 29 * @author imi 31 30 */ … … 82 81 */ 83 82 public Collection<String> getAllPossiblePreferenceDirs() { 84 LinkedList<String> locations = new LinkedList<String>(); 85 locations.add(Main.pref.getPreferencesDir()); 86 String s; 87 if ((s = System.getenv("JOSM_RESOURCES")) != null) { 88 if (!s.endsWith("/") && !s.endsWith("\\")) 89 s = s + "/"; 90 locations.add(s); 91 } 92 if ((s = System.getProperty("josm.resources")) != null) { 93 if (!s.endsWith("/") && !s.endsWith("\\")) 94 s = s + "/"; 95 locations.add(s); 96 } 97 String appdata = System.getenv("APPDATA"); 98 if (System.getenv("ALLUSERSPROFILE") != null && appdata != null && appdata.lastIndexOf("\\") != -1) { 99 appdata = appdata.substring(appdata.lastIndexOf("\\")); 100 locations.add(System.getenv("ALLUSERSPROFILE")+appdata+"/JOSM/"); 101 } 102 locations.add("/usr/local/share/josm/"); 103 locations.add("/usr/local/lib/josm/"); 104 locations.add("/usr/share/josm/"); 105 locations.add("/usr/lib/josm/"); 106 return locations; 107 } 108 83 LinkedList<String> locations = new LinkedList<String>(); 84 locations.add(Main.pref.getPreferencesDir()); 85 String s; 86 if ((s = System.getenv("JOSM_RESOURCES")) != null) { 87 if (!s.endsWith("/") && !s.endsWith("\\")) 88 s = s + "/"; 89 locations.add(s); 90 } 91 if ((s = System.getProperty("josm.resources")) != null) { 92 if (!s.endsWith("/") && !s.endsWith("\\")) 93 s = s + "/"; 94 locations.add(s); 95 } 96 String appdata = System.getenv("APPDATA"); 97 if (System.getenv("ALLUSERSPROFILE") != null && appdata != null && appdata.lastIndexOf("\\") != -1) { 98 appdata = appdata.substring(appdata.lastIndexOf("\\")); 99 locations.add(System.getenv("ALLUSERSPROFILE")+appdata+"/JOSM/"); 100 } 101 locations.add("/usr/local/share/josm/"); 102 locations.add("/usr/local/lib/josm/"); 103 locations.add("/usr/share/josm/"); 104 locations.add("/usr/lib/josm/"); 105 return locations; 106 } 109 107 110 108 synchronized public boolean hasKey(final String key) { 111 109 return override.containsKey(key) ? override.get(key) != null : properties.containsKey(key); 112 110 } 111 113 112 synchronized public String get(final String key) { 114 113 putDefault(key, null); … … 119 118 return properties.get(key); 120 119 } 120 121 121 synchronized public String get(final String key, final String def) { 122 122 putDefault(key, def); 123 if (override.containsKey(key)) 123 if (override.containsKey(key)) 124 124 return override.get(key); 125 125 final String prop = properties.get(key); … … 128 128 return prop; 129 129 } 130 130 131 synchronized public Map<String, String> getAllPrefix(final String prefix) { 131 132 final Map<String,String> all = new TreeMap<String,String>(); … … 141 142 return all; 142 143 } 143 144 144 145 synchronized public Map<String, String> getDefaults() 145 146 { 146 147 return defaults; 147 148 } 149 148 150 synchronized public void putDefault(final String key, final String def) { 149 151 if(!defaults.containsKey(key) || defaults.get(key) == null) … … 152 154 System.out.println("Defaults for " + key + " differ: " + def + " != " + defaults.get(key)); 153 155 } 154 156 155 157 synchronized public boolean getBoolean(final String key) { 156 158 putDefault(key, null); … … 159 161 return properties.containsKey(key) ? Boolean.parseBoolean(properties.get(key)) : false; 160 162 } 163 161 164 synchronized public boolean getBoolean(final String key, final boolean def) { 162 165 putDefault(key, Boolean.toString(def)); … … 174 177 firePreferenceChanged(key, value); 175 178 } 179 176 180 synchronized public void put(final String key, final boolean value) { 177 181 properties.put(key, Boolean.toString(value)); … … 201 205 // do not message anything, since this can be called from strange 202 206 // places. 203 } 207 } 204 208 } 205 209 … … 279 283 out.close(); 280 284 } 281 285 282 286 /** 283 287 * Convenience method for accessing colour preferences. 284 * 288 * 285 289 * @param colName name of the colour 286 290 * @param def default value … … 295 299 return ColorHelper.html2color(colStr); 296 300 } 301 297 302 // only for compatibility. Don't use any more. 303 @Deprecated 298 304 public static Color getPreferencesColor(String colName, Color def) 299 305 { … … 322 328 return ColorHelper.html2color(colStr); 323 329 } 330 324 331 synchronized public void putColor(String colName, Color val) { 325 332 put("color."+colName, ColorHelper.color2html(val)); 326 333 } 327 334 328 public int getInteger(String key, int def) { 329 String v = get(key); 330 if(null == v) 331 return def; 332 333 try { 334 return Integer.parseInt(v); 335 } catch(NumberFormatException e) { 336 // fall out 337 } 338 339 return def; 340 } 335 synchronized public int getInteger(String key, int def) { 336 String v = get(key); 337 if(null == v) 338 return def; 339 340 try { 341 return Integer.parseInt(v); 342 } catch(NumberFormatException e) { 343 // fall out 344 } 345 return def; 346 } 341 347 } -
trunk/src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
r733 r807 41 41 new JTextField(11) }; 42 42 final JTextArea osmUrl = new JTextArea(); 43 String noteUrl = tr("You can paste an URL here to download the area."); 43 44 String oldUrl = ""; 44 45 … … 48 49 49 50 JPanel dlg = new JPanel(new GridBagLayout()); 50 osmUrl.setText( tr("You can paste an URL here to download the area."));51 osmUrl.setText(noteUrl); 51 52 52 53 final FocusListener dialogUpdater = new FocusAdapter() { … … 169 170 } 170 171 // setting old URL prevents refresh based on this URL 171 oldUrl = "http://www.openstreetmap.org/index.html?mlat="+lat+"&mlon="+lon+"&zoom="+zoom;172 oldUrl = noteUrl+"\n"+"http://www.openstreetmap.org/index.html?mlat="+lat+"&mlon="+lon+"&zoom="+zoom; 172 173 osmUrl.setText(oldUrl); 173 174 }
Note:
See TracChangeset
for help on using the changeset viewer.