- Timestamp:
- 2012-11-13T21:18:57+01:00 (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/defaultpresets.xml
r5559 r5579 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 -
trunk/data/tagging-preset.xsd
r5180 r5579 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" /> -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r5563 r5579 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; … … 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)) { -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingTextField.java
r5266 r5579 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 … … 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); … … 195 209 } 196 210 211 /** 212 * Sets the maximum number of characters allowed. 213 * @param max maximum number of characters allowed 214 * @since 5579 215 */ 216 public void setMaxChars(Integer max) { 217 maxChars = max; 218 } 219 197 220 /* ------------------------------------------------------------------------------------ */ 198 221 /* TableCellEditor interface */
Note:
See TracChangeset
for help on using the changeset viewer.