Ticket #8180: 8180v1.patch
File 8180v1.patch, 4.0 KB (added by , 11 years ago) |
---|
-
core/data/defaultpresets.xml
35 35 default: default string to display (defaults to "") 36 36 use_last_as_default: true/false/force (default is "false") 37 37 match: none/key/key!/keyvalue (default is "none", see below for more information) 38 length: length of input box (number of characters allowed) 38 39 39 40 combo: combo box, with multiple choices and possible to enter free form text 40 41 key: key to set -
core/data/tagging-preset.xsd
117 117 <attribute name="default" type="string" /> 118 118 <attribute name="use_last_as_default" type="tns:last_default" /> 119 119 <attribute name="match" type="tns:match" /> 120 <attribute name="length" type="positiveInteger" /> 120 121 121 122 <attribute name="type" use="prohibited" /> 122 123 <attribute name="name" use="prohibited" /> -
core/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
377 377 public String default_; 378 378 public String originalValue; 379 379 public String use_last_as_default = "false"; 380 public String length; 380 381 381 382 private JComponent value; 382 383 … … 386 387 Usage usage = determineTextUsage(sel, key); 387 388 AutoCompletingTextField textField = new AutoCompletingTextField(); 388 389 initAutoCompletionField(textField, key); 390 if (length != null && !length.isEmpty()) { 391 textField.setMaxChars(new Integer(length)); 392 } 389 393 if (usage.unused()){ 390 394 if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) { 391 395 // selected osm primitives are untagged or filling default values feature is enabled -
core/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingTextField.java
32 32 * 33 33 */ 34 34 public class AutoCompletingTextField extends JTextField implements ComboBoxEditor, TableCellEditor { 35 36 private Integer maxChars; 37 35 38 /** 36 39 * The document model for the editor 37 40 */ … … 43 46 */ 44 47 @Override 45 48 public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { 49 50 // If a maximum number of characters is specified, avoid to exceed it 51 if (maxChars != null && str != null && getLength() + str.length() > maxChars) { 52 int allowedLength = maxChars-getLength(); 53 if (allowedLength > 0) { 54 str = str.substring(0, allowedLength); 55 } else { 56 return; 57 } 58 } 59 46 60 if (autoCompletionList == null) { 47 61 super.insertString(offs, str, a); 48 62 return; … … 194 208 } 195 209 } 196 210 211 /** 212 * Sets the maximum number of characters allowed. 213 * @param max maximum number of characters allowed 214 * @since 5577 215 */ 216 public void setMaxChars(Integer max) { 217 maxChars = max; 218 } 219 197 220 /* ------------------------------------------------------------------------------------ */ 198 221 /* TableCellEditor interface */ 199 222 /* ------------------------------------------------------------------------------------ */