Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r3530 r3531 601 601 synchronized private void putCollectionDefault(String key, Collection<String> val) { 602 602 String s = null; 603 if(val != null)603 for(String a : val) 604 604 { 605 for(String a : val) 606 { 607 if(s != null) { 608 s += "\u001e" + a; 609 } else { 610 s = a; 611 } 605 if(s != null) { 606 s += "\u001e" + a; 607 } else { 608 s = a; 612 609 } 613 610 } … … 616 613 synchronized public Collection<Collection<String>> getArray(String key, 617 614 Collection<Collection<String>> def) { 618 if(def != null) { 619 for(String k : getAllPrefixDefault(key + ".").keySet()) 620 put(k, null); 621 int num = 0; 622 for(Collection<String> c : def) 623 putCollectionDefault(key+"."+num++, c); 624 } 625 String s = get(key+".0"); 626 if(s != null && s.length() != 0) 627 { 628 Collection<Collection<String>> col = new LinkedList<Collection<String>>(); 629 for(int num = 0; ; ++num) { 630 Collection<String> c = getCollection(key+"."+num, null); 631 if(c == null) 632 break; 633 col.add(c); 634 } 635 return col; 636 } 637 return def; 615 if(def != null) 616 putArrayDefault(key, def); 617 key += "."; 618 int num = 0; 619 Collection<Collection<String>> col = new LinkedList<Collection<String>>(); 620 while(properties.containsKey(key+num)) 621 col.add(getCollection(key+num++, null)); 622 return num == 0 && def != null ? def : col; 638 623 } 639 624 synchronized public boolean putArray(String key, Collection<Collection<String>> val) { 640 625 boolean res = true; 626 key += "."; 641 627 Collection<String> keys = getAllPrefix(key).keySet(); 642 key += ".";643 628 if(val != null) { 644 String s = null;645 629 int num = 0; 646 630 for(Collection<String> c : val) { … … 661 645 } 662 646 647 synchronized private void putArrayDefault(String key, Collection<Collection<String>> val) { 648 key += "."; 649 Collection<String> keys = getAllPrefixDefault(key).keySet(); 650 int num = 0; 651 for(Collection<String> c : val) { 652 keys.remove(key+num); 653 putCollectionDefault(key+num++, c); 654 } 655 int l = key.length(); 656 for(String k : keys) { 657 try { 658 Integer.valueOf(k.substring(l)); 659 defaults.remove(k); 660 } catch(Exception e) { 661 } 662 } 663 } 664 663 665 /** 664 666 * Updates system properties with the current values in the preferences. -
trunk/src/org/openstreetmap/josm/gui/preferences/AdvancedPreference.java
r3029 r3531 216 216 } 217 217 218 private void removePreference(final PreferenceTabbedPane gui, final JTable list) { 219 if (list.getSelectedRowCount() == 0) { 220 JOptionPane.showMessageDialog( 221 gui, 222 tr("Please select the row to delete."), 223 tr("Warning"), 224 JOptionPane.WARNING_MESSAGE 225 ); 226 return; 227 } 228 for(int row: list.getSelectedRows()) { 229 data.put((String) model.getValueAt(row, 0), ""); 230 model.setValueAt("", row, 1); 231 } 232 } 233 234 private void addPreference(final PreferenceTabbedPane gui) { 235 String s[] = showEditDialog(gui, tr("Enter a new key/value pair"), 236 null, null); 237 if(s != null && !s[0].isEmpty() && !s[1].isEmpty()) { 238 data.put(s[0], s[1]); 239 dataToModel(); 240 } 241 } 242 218 243 private void editPreference(final PreferenceTabbedPane gui, final JTable list) { 219 244 if (list.getSelectedRowCount() != 1) { … … 226 251 return; 227 252 } 228 String v = (String) JOptionPane.showInputDialog( 229 Main.parent, 230 tr("New value for {0}", model.getValueAt(list.getSelectedRow(), 0)), 231 tr("New value"), 232 JOptionPane.QUESTION_MESSAGE, 233 null, 234 null, 235 model.getValueAt(list.getSelectedRow(), 1) 236 ); 237 if (v != null) { 238 data.put((String) model.getValueAt(list.getSelectedRow(), 0), v); 239 model.setValueAt(v, list.getSelectedRow(), 1); 240 } 241 } 242 243 private void removePreference(final PreferenceTabbedPane gui, final JTable list) { 244 if (list.getSelectedRowCount() == 0) { 245 JOptionPane.showMessageDialog( 246 gui, 247 tr("Please select the row to delete."), 248 tr("Warning"), 249 JOptionPane.WARNING_MESSAGE 250 ); 251 return; 252 } 253 for(int row: list.getSelectedRows()) { 254 data.put((String) model.getValueAt(row, 0), ""); 255 model.setValueAt("", row, 1); 256 } 257 } 258 259 private void addPreference(final PreferenceTabbedPane gui) { 253 String key = (String)model.getValueAt(list.getSelectedRow(), 0); 254 String value = data.get(key); 255 if(value.isEmpty()) 256 value = defaults.get(key); 257 String s[] = showEditDialog(gui, tr("Change a key/value pair"), 258 key, value); 259 if(s != null && !s[0].isEmpty()) { 260 data.put(s[0], s[1]); 261 if(!s[0].equals(key)) 262 data.put(key,""); 263 dataToModel(); 264 } 265 } 266 267 private String[] showEditDialog(final PreferenceTabbedPane gui, String title, 268 String key, String value) { 260 269 JPanel p = new JPanel(new GridBagLayout()); 261 270 p.add(new JLabel(tr("Key")), GBC.std().insets(0,0,5,0)); 262 JTextField key = new JTextField(10);263 JTextField value = new JTextField(10);264 p.add( key, GBC.eop().insets(5,0,0,0).fill(GBC.HORIZONTAL));271 JTextField tkey = new JTextField(key, 50); 272 JTextField tvalue = new JTextField(value, 50); 273 p.add(tkey, GBC.eop().insets(5,0,0,0).fill(GBC.HORIZONTAL)); 265 274 p.add(new JLabel(tr("Value")), GBC.std().insets(0,0,5,0)); 266 p.add(value, GBC.eol().insets(5,0,0,0).fill(GBC.HORIZONTAL)); 275 /* TODO: Split value at "\u001e" and present a table with automatic added lines */ 276 p.add(tvalue, GBC.eol().insets(5,0,0,0).fill(GBC.HORIZONTAL)); 267 277 int answer = JOptionPane.showConfirmDialog( 268 278 gui, p, 269 t r("Enter a new key/value pair"),279 title, 270 280 JOptionPane.OK_CANCEL_OPTION, 271 281 JOptionPane.PLAIN_MESSAGE 272 282 ); 273 if 274 data.put(key.getText(), value.getText());275 model.addRow(new String[]{key.getText(), value.getText()});276 }283 if(answer == JOptionPane.OK_OPTION) { 284 return new String[]{tkey.getText(), tvalue.getText()}; 285 } 286 return null; 277 287 } 278 288 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/EllipsoidTest.java
r3480 r3531 12 12 13 13 final double EPSILON = 1e-8; 14 14 15 15 /** 16 16 * convert latlon to cartesian coordinates back and forth … … 30 30 double[] cart = ellips.latLon2Cart(ll); 31 31 ll = ellips.cart2LatLon(cart); 32 32 33 33 if (!(Math.abs(lat - ll.lat())<EPSILON && Math.abs(lon - ll.lon())<EPSILON)) { 34 34 String error = String.format("point: %s iterations: %s current: %s errorLat: %s errorLon %s",
Note:
See TracChangeset
for help on using the changeset viewer.