Changeset 614 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2008-04-19T17:55:29+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/TaggingPresetPreference.java
r582 r614 9 9 import java.awt.event.ActionListener; 10 10 import java.util.Collection; 11 import java.util.HashMap; 11 12 import java.util.StringTokenizer; 12 13 … … 19 20 import javax.swing.JLabel; 20 21 import javax.swing.JList; 22 import javax.swing.JMenu; 21 23 import javax.swing.JMenuItem; 22 24 import javax.swing.JOptionPane; … … 125 127 else 126 128 { 129 HashMap<String,JMenu> submenus = new HashMap<String,JMenu>(); 127 130 for (final TaggingPreset p : taggingPresets) { 128 131 if (p.getValue(Action.NAME).equals(" ")) { 129 132 Main.main.menu.presetsMenu.add(new JSeparator()); 130 133 } else { 131 Main.main.menu.presetsMenu.add(new JMenuItem(p)); 134 String name = (String) p.getValue(Action.NAME); 135 String[] sp = name.split("/"); 136 if (sp.length <= 1) { 137 Main.main.menu.presetsMenu.add(new JMenuItem(p)); 138 } else { 139 p.setName(sp[1]); 140 JMenu submenu = submenus.get(sp[0]); 141 if (submenu == null) { 142 submenu = new JMenu(sp[0]); 143 submenus.put(sp[0], submenu); 144 Main.main.menu.presetsMenu.add(submenu); 145 } 146 submenu.add(new JMenuItem(p)); 147 } 132 148 } 133 149 } -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r593 r614 16 16 import java.net.URL; 17 17 import java.util.Collection; 18 import java.util.HashMap; 18 19 import java.util.HashSet; 19 20 import java.util.LinkedHashMap; … … 44 45 import org.xml.sax.SAXException; 45 46 46 47 47 /** 48 48 * This class read encapsulate one tagging preset. A class method can … … 53 53 */ 54 54 public class TaggingPreset extends AbstractAction { 55 55 56 56 public static abstract class Item { 57 57 public boolean focus = false; … … 71 71 returnValue.values = new HashSet<String>(); 72 72 for (OsmPrimitive s : sel) { 73 returnValue.values.add(s.get(key)); 73 String v = s.get(key); 74 /* if (v != null) */ returnValue.values.add(v); 74 75 } 75 76 return returnValue; … … 94 95 95 96 public static class Text extends Item { 97 96 98 public String key; 97 99 public String text; 98 100 public String default_; 99 101 public String originalValue; 102 public boolean use_last_as_default = false; 100 103 public boolean delete_if_empty = false; 101 104 … … 106 109 // find out if our key is already used in the selection. 107 110 Usage usage = determineTextUsage(sel, key); 108 109 if (usage.values.size() == 1) { 111 if (usage.values.size() == 1 && usage.values.toArray()[0] == null) { 112 value = new JTextField(); 113 if (use_last_as_default && lastValue.containsKey(key)) { 114 ((JTextField)value).setText(lastValue.get(key)); 115 } else { 116 ((JTextField)value).setText(default_); 117 } 118 } else if (usage.values.size() == 1) { 110 119 // all objects use the same value 111 120 value = new JTextField(); … … 130 139 ((JTextField)value).getText(); 131 140 141 if (use_last_as_default) lastValue.put(key, v); 132 142 if (v.equals(originalValue) || (originalValue == null && v.length() == 0)) return; 133 143 … … 144 154 public String text; 145 155 public boolean default_ = false; // not used! 156 public boolean use_last_as_default = false; 146 157 147 158 private QuadStateCheckBox check; … … 205 216 public boolean delete_if_empty = false; 206 217 public boolean editable = true; 218 public boolean use_last_as_default = false; 207 219 208 220 private JComboBox combo; … … 285 297 public Collection<Class<?>> types; 286 298 private List<Item> data = new LinkedList<Item>(); 299 private static HashMap<String,String> lastValue = new HashMap<String,String>(); 287 300 288 301 /**
Note:
See TracChangeset
for help on using the changeset viewer.