Ignore:
Timestamp:
2012-05-09T21:29:17+02:00 (12 years ago)
Author:
bastiK
Message:

improvements for custom projection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/widgets/AbstractTextComponentValidator.java

    r3083 r5226  
    1919
    2020import org.openstreetmap.josm.tools.CheckParameterUtil;
     21import org.openstreetmap.josm.tools.Utils;
    2122
    2223/**
     
    4142     */
    4243    private Boolean valid = null;
     44    // remember the message
     45    private String msg;
    4346
    4447    protected void feedbackInvalid(String msg) {
    45         if (valid == null || valid) {
     48        if (valid == null || valid || !Utils.equal(msg, this.msg)) {
    4649            // only provide feedback if the validity has changed. This avoids
    4750            // unnecessary UI updates.
     
    5053            tc.setToolTipText(msg);
    5154            valid = false;
     55            this.msg = msg;
    5256        }
    5357    }
     
    5862
    5963    protected void feedbackValid(String msg) {
    60         if (valid == null || !valid) {
     64        if (valid == null || !valid || !Utils.equal(msg, this.msg)) {
    6165            // only provide feedback if the validity has changed. This avoids
    6266            // unnecessary UI updates.
     
    6569            tc.setToolTipText(msg == null ? "" : msg);
    6670            valid = true;
     71            this.msg = msg;
    6772        }
    6873    }
     
    9297     */
    9398    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 {
    94103        CheckParameterUtil.ensureParameterNotNull(tc, "tc");
    95104        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        }
    98111        if (addActionListener) {
    99112            if (tc instanceof JTextField) {
Note: See TracChangeset for help on using the changeset viewer.