Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
r8509 r8510 87 87 88 88 // cache the parsing of types using a LRU cache (http://java-planet.blogspot.com/2005/08/how-to-set-up-simple-lru-cache-using.html) 89 private static final Map<String, Set<TaggingPresetType>> TYPE_CACHE = new LinkedHashMap<>(16, 1.1f, true);89 private static final Map<String, Set<TaggingPresetType>> TYPE_CACHE = new LinkedHashMap<>(16, 1.1f, true); 90 90 91 91 /** 92 92 * Last value of each key used in presets, used for prefilling corresponding fields 93 93 */ 94 private static final Map<String, String> LAST_VALUES = new HashMap<>();94 private static final Map<String, String> LAST_VALUES = new HashMap<>(); 95 95 96 96 public static class PresetListEntry implements Comparable<PresetListEntry> { … … 196 196 197 197 public void setRequisite(String str) throws SAXException { 198 if ("required".equals(str)) {198 if ("required".equals(str)) { 199 199 required = true; 200 } else if (!"optional".equals(str))200 } else if (!"optional".equals(str)) 201 201 throw new SAXException(tr("Unknown requisite: {0}", str)); 202 202 } … … 232 232 if (count > 0 && !required) { 233 233 cstring = "0,"+count; 234 } else if (count > 0) {234 } else if (count > 0) { 235 235 cstring = String.valueOf(count); 236 } else if (!required) {236 } else if (!required) { 237 237 cstring = "0-..."; 238 238 } else { … … 242 242 locale_text = getLocaleText(text, text_context, null); 243 243 } 244 p.add(new JLabel(locale_text+":"), GBC.std().insets(0, 0,10,0));245 p.add(new JLabel(key), GBC.std().insets(0, 0,10,0));246 p.add(new JLabel(cstring), types == null ? GBC.eol() : GBC.std().insets(0, 0,10,0));244 p.add(new JLabel(locale_text+":"), GBC.std().insets(0, 0, 10, 0)); 245 p.add(new JLabel(key), GBC.std().insets(0, 0, 10, 0)); 246 p.add(new JLabel(cstring), types == null ? GBC.eol() : GBC.std().insets(0, 0, 10, 0)); 247 247 if (types != null) { 248 248 JPanel pp = new JPanel(); 249 for (TaggingPresetType t : types) {249 for (TaggingPresetType t : types) { 250 250 pp.add(new JLabel(ImageProvider.get(t.getIconName()))); 251 251 } … … 553 553 554 554 public abstract MatchType getDefaultMatch(); 555 555 556 public abstract Collection<String> getValues(); 556 557 … … 650 651 textField.setMaxChars(Integer.valueOf(length)); 651 652 } 652 if (usage.unused()) {653 if (usage.unused()) { 653 654 if (auto_increment_selected != 0 && auto_increment != null) { 654 655 try { … … 681 682 comboBox.setEditor(textField); 682 683 comboBox.getEditor().setItem(DIFFERENT); 683 value =comboBox;684 value = comboBox; 684 685 originalValue = DIFFERENT; 685 686 } … … 702 703 JToggleButton aibutton = new JToggleButton(ai); 703 704 aibutton.setToolTipText(tr("Select auto-increment of {0} for this field", ai)); 704 aibutton.setMargin(new java.awt.Insets(0, 0,0,0));705 aibutton.setMargin(new java.awt.Insets(0, 0, 0, 0)); 705 706 aibutton.setFocusable(false); 706 707 saveHorizontalSpace(aibutton); … … 732 733 JButton releasebutton = new JButton("X"); 733 734 releasebutton.setToolTipText(tr("Cancel auto-increment for this field")); 734 releasebutton.setMargin(new java.awt.Insets(0, 0,0,0));735 releasebutton.setMargin(new java.awt.Insets(0, 0, 0, 0)); 735 736 releasebutton.setFocusable(false); 736 737 releasebutton.addActionListener(new ActionListener() { … … 745 746 value = pnl; 746 747 } 747 p.add(new JLabel(locale_text+":"), GBC.std().insets(0, 0,10,0));748 p.add(new JLabel(locale_text+":"), GBC.std().insets(0, 0, 10, 0)); 748 749 p.add(value, GBC.eol().fill(GBC.HORIZONTAL)); 749 750 return true; … … 765 766 return ((JosmTextField) comp).getText(); 766 767 } else if (comp instanceof JPanel) { 767 return getValue(((JPanel) comp).getComponent(0));768 return getValue(((JPanel) comp).getComponent(0)); 768 769 } else { 769 770 return null; … … 996 997 997 998 protected abstract Object getSelectedItem(); 999 998 1000 protected abstract void addToPanelAnchor(JPanel p, String def, boolean presetInitiallyMatches); 999 1001 … … 1414 1416 private static class ConcatenatingJList extends JList<PresetListEntry> { 1415 1417 private String delimiter; 1418 1416 1419 public ConcatenatingJList(String del, PresetListEntry[] o) { 1417 1420 super(o); … … 1431 1434 final String value = lm.getElementAt(i).value; 1432 1435 if (parts.contains(value)) { 1433 intParts[j++] =i;1436 intParts[j++] = i; 1434 1437 parts.remove(value); 1435 1438 } … … 1447 1450 int[] si = getSelectedIndices(); 1448 1451 StringBuilder builder = new StringBuilder(); 1449 for (int i =0; i<si.length; i++) {1450 if (i >0) {1452 for (int i = 0; i < si.length; i++) { 1453 if (i > 0) { 1451 1454 builder.append(delimiter); 1452 1455 } … … 1474 1477 1475 1478 static String fixPresetString(String s) { 1476 return s == null ? s : s.replaceAll("'", "''");1479 return s == null ? s : s.replaceAll("'", "''"); 1477 1480 } 1478 1481 … … 1500 1503 boolean backslash = false; 1501 1504 StringBuilder item = new StringBuilder(); 1502 for (int i =0; i<s.length(); i++) {1505 for (int i = 0; i < s.length(); i++) { 1503 1506 char ch = s.charAt(i); 1504 1507 if (backslash) { … … 1530 1533 returnValue.hadEmpty = true; 1531 1534 } 1532 if (s.hasKeys()) {1535 if (s.hasKeys()) { 1533 1536 returnValue.hadKeys = true; 1534 1537 }
Note:
See TracChangeset
for help on using the changeset viewer.