Changeset 5226 in josm for trunk/src/org/openstreetmap/josm/gui/widgets/AbstractTextComponentValidator.java
- Timestamp:
- 2012-05-09T21:29:17+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/widgets/AbstractTextComponentValidator.java
r3083 r5226 19 19 20 20 import org.openstreetmap.josm.tools.CheckParameterUtil; 21 import org.openstreetmap.josm.tools.Utils; 21 22 22 23 /** … … 41 42 */ 42 43 private Boolean valid = null; 44 // remember the message 45 private String msg; 43 46 44 47 protected void feedbackInvalid(String msg) { 45 if (valid == null || valid ) {48 if (valid == null || valid || !Utils.equal(msg, this.msg)) { 46 49 // only provide feedback if the validity has changed. This avoids 47 50 // unnecessary UI updates. … … 50 53 tc.setToolTipText(msg); 51 54 valid = false; 55 this.msg = msg; 52 56 } 53 57 } … … 58 62 59 63 protected void feedbackValid(String msg) { 60 if (valid == null || !valid ) {64 if (valid == null || !valid || !Utils.equal(msg, this.msg)) { 61 65 // only provide feedback if the validity has changed. This avoids 62 66 // unnecessary UI updates. … … 65 69 tc.setToolTipText(msg == null ? "" : msg); 66 70 valid = true; 71 this.msg = msg; 67 72 } 68 73 } … … 92 97 */ 93 98 public AbstractTextComponentValidator(JTextComponent tc, boolean addActionListener) throws IllegalArgumentException { 99 this(tc, true, true, addActionListener); 100 } 101 102 public AbstractTextComponentValidator(JTextComponent tc, boolean addFocusListener, boolean addDocumentListener, boolean addActionListener) throws IllegalArgumentException { 94 103 CheckParameterUtil.ensureParameterNotNull(tc, "tc"); 95 104 this.tc = tc; 96 tc.addFocusListener(this); 97 tc.getDocument().addDocumentListener(this); 105 if (addFocusListener) { 106 tc.addFocusListener(this); 107 } 108 if (addDocumentListener) { 109 tc.getDocument().addDocumentListener(this); 110 } 98 111 if (addActionListener) { 99 112 if (tc instanceof JTextField) {
Note:
See TracChangeset
for help on using the changeset viewer.