- Timestamp:
- 2012-11-13T21:18:57+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/tagging
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.