Last change
on this file since 18061 was 18061, checked in by Don-vip, 4 years ago |
see #21131 - Improve GPX image correlation: direction detection and position shift
|
-
Property svn:eol-style
set to
native
|
File size:
1.2 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.widgets;
|
---|
3 |
|
---|
4 | import javax.swing.text.JTextComponent;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Default text component validator that only checks that an input field is not empty.
|
---|
8 | * @since 10073
|
---|
9 | */
|
---|
10 | public class DefaultTextComponentValidator extends AbstractTextComponentValidator {
|
---|
11 |
|
---|
12 | private final String validFeedback;
|
---|
13 | private final String invalidFeedback;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Constructs a new {@code DefaultTextComponentValidator}.
|
---|
17 | * @param tc the text component. Must not be null.
|
---|
18 | * @param validFeedback text displayed for valid feedback
|
---|
19 | * @param invalidFeedback text displayed for invalid feedback
|
---|
20 | */
|
---|
21 | public DefaultTextComponentValidator(JTextComponent tc, String validFeedback, String invalidFeedback) {
|
---|
22 | super(tc);
|
---|
23 | this.validFeedback = validFeedback;
|
---|
24 | this.invalidFeedback = invalidFeedback;
|
---|
25 | }
|
---|
26 |
|
---|
27 | @Override
|
---|
28 | public boolean isValid() {
|
---|
29 | return !getComponent().getText().trim().isEmpty();
|
---|
30 | }
|
---|
31 |
|
---|
32 | @Override
|
---|
33 | public void validate() {
|
---|
34 | if (isValid()) {
|
---|
35 | feedbackValid(validFeedback);
|
---|
36 | } else {
|
---|
37 | feedbackInvalid(invalidFeedback);
|
---|
38 | }
|
---|
39 | }
|
---|
40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.