- Timestamp:
- 2016-03-29T00:07:10+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/AdvancedChangesetQueryPanel.java
r9543 r10073 31 31 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 32 32 import org.openstreetmap.josm.gui.help.HelpUtil; 33 import org.openstreetmap.josm.gui.preferences.server.UserNameValidator; 33 34 import org.openstreetmap.josm.gui.util.GuiHelper; 34 35 import org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator; … … 380 381 private transient UidInputFieldValidator valUid; 381 382 private JosmTextField tfUserName; 382 private transient UserName InputValidator valUserName;383 private transient UserNameValidator valUserName; 383 384 private JMultilineLabel lblRestrictedToMyself; 384 385 … … 414 415 pnl.add(tfUserName = new JosmTextField(10), gc); 415 416 SelectAllOnFocusGainedDecorator.decorate(tfUserName); 416 valUserName = UserNameInputValidator.decorate(tfUserName);417 valUserName = new UserNameValidator(tfUserName); 417 418 418 419 // grab remaining space … … 1013 1014 } 1014 1015 1015 private static class UserNameInputValidator extends AbstractTextComponentValidator {1016 public static UserNameInputValidator decorate(JTextComponent tc) {1017 return new UserNameInputValidator(tc);1018 }1019 1020 UserNameInputValidator(JTextComponent tc) {1021 super(tc);1022 }1023 1024 @Override1025 public boolean isValid() {1026 return !getComponent().getText().trim().isEmpty();1027 }1028 1029 @Override1030 public void validate() {1031 String value = getComponent().getText();1032 if (value.trim().isEmpty()) {1033 feedbackInvalid(tr("<html>The current value is not a valid user name.<br>Please enter an non-empty user name.</html>"));1034 return;1035 }1036 feedbackValid(tr("Please enter an non-empty user name"));1037 }1038 }1039 1040 1016 /** 1041 1017 * Validates dates entered as text in a {@link JTextComponent}. Validates the input … … 1147 1123 @Override 1148 1124 public void validate() { 1149 1150 1125 if (!isValid()) { 1151 1126 String msg = "<html>The current value isn't a valid time.<br>" + getStandardTooltipText() + "</html>"; -
trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java
r9623 r10073 35 35 import org.openstreetmap.josm.gui.SideButton; 36 36 import org.openstreetmap.josm.gui.help.HelpUtil; 37 import org.openstreetmap.josm.gui.preferences.server.UserNameValidator; 37 38 import org.openstreetmap.josm.gui.util.GuiHelper; 38 import org.openstreetmap.josm.gui.widgets. AbstractTextComponentValidator;39 import org.openstreetmap.josm.gui.widgets.DefaultTextComponentValidator; 39 40 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 40 41 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; … … 390 391 } 391 392 392 private static class UserNameValidator extends AbstractTextComponentValidator { 393 UserNameValidator(JTextComponent tc) { 394 super(tc); 395 } 396 397 @Override 398 public boolean isValid() { 399 return !getComponent().getText().trim().isEmpty(); 400 } 401 402 @Override 403 public void validate() { 404 if (isValid()) { 405 feedbackValid(tr("Please enter your OSM user name")); 406 } else { 407 feedbackInvalid(tr("The user name cannot be empty. Please enter your OSM user name")); 408 } 409 } 410 } 411 412 private static class PasswordValidator extends AbstractTextComponentValidator { 413 393 static class PasswordValidator extends DefaultTextComponentValidator { 414 394 PasswordValidator(JTextComponent tc) { 415 super(tc); 416 } 417 418 @Override 419 public boolean isValid() { 420 return !getComponent().getText().trim().isEmpty(); 421 } 422 423 @Override 424 public void validate() { 425 if (isValid()) { 426 feedbackValid(tr("Please enter your OSM password")); 427 } else { 428 feedbackInvalid(tr("The password cannot be empty. Please enter your OSM password")); 429 } 395 super(tc, tr("Please enter your OSM password"), tr("The password cannot be empty. Please enter your OSM password")); 430 396 } 431 397 } -
trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticPropertiesPanel.java
r8836 r10073 11 11 import javax.swing.JLabel; 12 12 import javax.swing.JPanel; 13 import javax.swing.text.JTextComponent;14 13 15 import org.openstreetmap.josm.gui. widgets.AbstractTextComponentValidator;14 import org.openstreetmap.josm.gui.preferences.server.UserNameValidator; 16 15 import org.openstreetmap.josm.gui.widgets.JosmPasswordField; 17 16 import org.openstreetmap.josm.gui.widgets.JosmTextField; … … 73 72 add(new JPanel(), gc); 74 73 } 75 76 private static class UserNameValidator extends AbstractTextComponentValidator {77 78 UserNameValidator(JTextComponent tc) {79 super(tc);80 }81 82 @Override83 public boolean isValid() {84 return !getComponent().getText().trim().isEmpty();85 }86 87 @Override88 public void validate() {89 if (isValid()) {90 feedbackValid(tr("Please enter your OSM user name"));91 } else {92 feedbackInvalid(tr("The user name cannot be empty. Please enter your OSM user name"));93 }94 }95 }96 74 } -
trunk/src/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUI.java
r9623 r10073 27 27 import org.openstreetmap.josm.gui.SideButton; 28 28 import org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder; 29 import org.openstreetmap.josm.gui.widgets. AbstractTextComponentValidator;29 import org.openstreetmap.josm.gui.widgets.DefaultTextComponentValidator; 30 30 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 31 31 import org.openstreetmap.josm.gui.widgets.JosmTextField; … … 178 178 } 179 179 180 private static class AccessTokenKeyValidator extends AbstractTextComponentValidator { 181 180 private static class AccessTokenKeyValidator extends DefaultTextComponentValidator { 182 181 AccessTokenKeyValidator(JTextComponent tc) { 183 super(tc); 184 } 185 186 @Override 187 public boolean isValid() { 188 return !getComponent().getText().trim().isEmpty(); 189 } 190 191 @Override 192 public void validate() { 193 if (isValid()) { 194 feedbackValid(tr("Please enter an Access Token Key")); 195 } else { 196 feedbackInvalid(tr("The Access Token Key must not be empty. Please enter an Access Token Key")); 197 } 198 } 199 } 200 201 private static class AccessTokenSecretValidator extends AbstractTextComponentValidator { 182 super(tc, tr("Please enter an Access Token Key"), 183 tr("The Access Token Key must not be empty. Please enter an Access Token Key")); 184 } 185 } 186 187 private static class AccessTokenSecretValidator extends DefaultTextComponentValidator { 202 188 AccessTokenSecretValidator(JTextComponent tc) { 203 super(tc); 204 } 205 206 @Override 207 public boolean isValid() { 208 return !getComponent().getText().trim().isEmpty(); 209 } 210 211 @Override 212 public void validate() { 213 if (isValid()) { 214 feedbackValid(tr("Please enter an Access Token Secret")); 215 } else { 216 feedbackInvalid(tr("The Access Token Secret must not be empty. Please enter an Access Token Secret")); 217 } 189 super(tc, tr("Please enter an Access Token Secret"), 190 tr("The Access Token Secret must not be empty. Please enter an Access Token Secret")); 218 191 } 219 192 } -
trunk/src/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUI.java
r9623 r10073 110 110 repaint(); 111 111 pnlShowAccessToken.setAccessToken(getAccessToken()); 112 } 113 114 static class StepLabel extends JLabel { 115 StepLabel(String text) { 116 super(text); 117 setFont(getFont().deriveFont(16f)); 118 } 112 119 } 113 120 … … 199 206 protected final void build() { 200 207 setLayout(new BorderLayout(0, 5)); 201 JLabel lbl = new JLabel(tr("<html>Step 1/3: Retrieve an OAuth Request Token</html>")); 202 lbl.setFont(lbl.getFont().deriveFont(16f)); 203 add(lbl, BorderLayout.NORTH); 208 add(new StepLabel(tr("<html>Step 1/3: Retrieve an OAuth Request Token</html>")), BorderLayout.NORTH); 204 209 add(buildAdvancedParametersPanel(), BorderLayout.CENTER); 205 210 add(buildCommandPanel(), BorderLayout.SOUTH); … … 223 228 protected JPanel buildTitlePanel() { 224 229 JPanel pnl = new JPanel(new BorderLayout()); 225 JLabel lbl = new JLabel(tr("<html>Step 2/3: Authorize and retrieve an Access Token</html>")); 226 lbl.setFont(lbl.getFont().deriveFont(16f)); 227 pnl.add(lbl, BorderLayout.CENTER); 230 pnl.add(new StepLabel(tr("<html>Step 2/3: Authorize and retrieve an Access Token</html>")), BorderLayout.CENTER); 228 231 return pnl; 229 232 } … … 266 269 protected JPanel buildActionPanel() { 267 270 JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT)); 268 269 271 pnl.add(new SideButton(new BackAction())); 270 272 pnl.add(new SideButton(new RetrieveAccessTokenAction())); … … 314 316 protected JPanel buildTitlePanel() { 315 317 JPanel pnl = new JPanel(new BorderLayout()); 316 JLabel lbl = new JLabel(tr("<html>Step 3/3: Successfully retrieved an Access Token</html>")); 317 lbl.setFont(lbl.getFont().deriveFont(16f)); 318 pnl.add(lbl, BorderLayout.CENTER); 318 pnl.add(new StepLabel(tr("<html>Step 3/3: Successfully retrieved an Access Token</html>")), BorderLayout.CENTER); 319 319 return pnl; 320 320 } -
trunk/src/org/openstreetmap/josm/gui/preferences/server/UserNameValidator.java
r8461 r10073 6 6 import javax.swing.text.JTextComponent; 7 7 8 import org.openstreetmap.josm.gui.widgets. AbstractTextComponentValidator;8 import org.openstreetmap.josm.gui.widgets.DefaultTextComponentValidator; 9 9 10 10 /** 11 11 * Validator for OSM username. 12 12 */ 13 public class UserNameValidator extends AbstractTextComponentValidator {13 public class UserNameValidator extends DefaultTextComponentValidator { 14 14 15 15 /** … … 18 18 */ 19 19 public UserNameValidator(JTextComponent tc) { 20 super(tc); 21 } 22 23 @Override 24 public boolean isValid() { 25 return !getComponent().getText().trim().isEmpty(); 26 } 27 28 @Override 29 public void validate() { 30 if (isValid()) { 31 feedbackValid(tr("Please enter your OSM user name")); 32 } else { 33 feedbackInvalid(tr("The user name cannot be empty. Please enter your OSM user name")); 34 } 20 super(tc, tr("Please enter your OSM user name"), tr("The user name cannot be empty. Please enter your OSM user name")); 35 21 } 36 22 }
Note:
See TracChangeset
for help on using the changeset viewer.