Changeset 5773 in josm
- Timestamp:
- 2013-03-13T09:55:42+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/properties
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r5726 r5773 545 545 presets.setSize(scrollPane.getSize()); 546 546 547 editHelper.loadTagsIfNeeded(); 547 548 // -- help action 548 549 // … … 731 732 @Override 732 733 public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) { 734 if (newLayer == null) editHelper.saveTagsIfNeeded(); 735 // it is time to save history of tags 736 733 737 updateSelection(); 734 738 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r5704 r5773 191 191 } 192 192 193 /** 194 * Load recently used tags from preferences if needed 195 */ 196 public void loadTagsIfNeeded() { 197 if (PROPERTY_REMEMBER_TAGS.get() && recentTags.isEmpty()) { 198 recentTags.clear(); 199 Collection<String> c = Main.pref.getCollection("properties.recent-tags"); 200 Iterator<String> it = c.iterator(); 201 String key, value; 202 while (it.hasNext()) { 203 key = it.next(); 204 value = it.next(); 205 recentTags.put(new Tag(key, value), null); 206 } 207 } 208 } 209 210 /** 211 * Store recently used tags in preferences if needed 212 */ 213 public void saveTagsIfNeeded() { 214 if (PROPERTY_REMEMBER_TAGS.get() && !recentTags.isEmpty()) { 215 List<String> c = new ArrayList<String>( recentTags.size()*2 ); 216 for (Tag t: recentTags.keySet()) { 217 c.add(t.getKey()); 218 c.add(t.getValue()); 219 } 220 Main.pref.putCollection("properties.recent-tags", c); 221 } 222 } 223 193 224 public class EditTagDialog extends AbstractTagsDialog { 194 225 final String key; … … 376 407 377 408 public static final BooleanProperty PROPERTY_FIX_TAG_LOCALE = new BooleanProperty("properties.fix-tag-combobox-locale", false); 409 public static final BooleanProperty PROPERTY_REMEMBER_TAGS = new BooleanProperty("properties.remember-recently-added-tags", false); 378 410 public static final IntegerProperty PROPERTY_RECENT_TAGS_NUMBER = new IntegerProperty("properties.recently-added-tags", DEFAULT_LRU_TAGS_NUMBER); 379 411 … … 589 621 } 590 622 }); 623 JCheckBoxMenuItem rememberLastTags = new JCheckBoxMenuItem( 624 new AbstractAction(tr("Remember last used tags")){ 625 public void actionPerformed(ActionEvent e) { 626 boolean sel=((JCheckBoxMenuItem) e.getSource()).getState(); 627 PROPERTY_REMEMBER_TAGS.put(sel); 628 if (sel) saveTagsIfNeeded(); 629 } 630 }); 631 rememberLastTags.setState(PROPERTY_REMEMBER_TAGS.get()); 632 popupMenu.add(rememberLastTags); 591 633 } 592 634
Note:
See TracChangeset
for help on using the changeset viewer.