source: josm/trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticPropertiesPanel.java@ 12646

Last change on this file since 12646 was 12646, checked in by bastiK, 7 years ago

see #14794 - javadoc

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.oauth;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.GridBagConstraints;
7import java.awt.GridBagLayout;
8import java.awt.Insets;
9
10import javax.swing.BorderFactory;
11import javax.swing.JLabel;
12import javax.swing.JPanel;
13
14import org.openstreetmap.josm.gui.preferences.server.UserNameValidator;
15import org.openstreetmap.josm.gui.widgets.JosmPasswordField;
16import org.openstreetmap.josm.gui.widgets.JosmTextField;
17import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
18
19/**
20 * Panel to enter username and password for the "fully automatic" authorization
21 * procedure.
22 *
23 * @see AuthorizationProcedure#FULLY_AUTOMATIC
24 */
25public class FullyAutomaticPropertiesPanel extends JPanel {
26
27 private final JosmTextField tfUserName = new JosmTextField();
28 private final JosmPasswordField tfPassword = new JosmPasswordField();
29
30 /**
31 * Constructs a new {@code FullyAutomaticPropertiesPanel}.
32 */
33 public FullyAutomaticPropertiesPanel() {
34 setLayout(new GridBagLayout());
35 GridBagConstraints gc = new GridBagConstraints();
36 setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
37
38 gc.anchor = GridBagConstraints.NORTHWEST;
39 gc.fill = GridBagConstraints.HORIZONTAL;
40 gc.weightx = 1.0;
41 add(buildUserNamePasswordPanel(), gc);
42
43 gc.gridy = 1;
44 gc.weighty = 1.0;
45 gc.fill = GridBagConstraints.BOTH;
46 add(new JPanel(), gc);
47 }
48
49 protected final JPanel buildUserNamePasswordPanel() {
50 JPanel pnl = new JPanel(new GridBagLayout());
51 GridBagConstraints gc = new GridBagConstraints();
52
53 gc.anchor = GridBagConstraints.NORTHWEST;
54 gc.fill = GridBagConstraints.HORIZONTAL;
55 gc.weightx = 0.0;
56 gc.insets = new Insets(0, 0, 3, 3);
57 pnl.add(new JLabel(tr("Username: ")), gc);
58
59 gc.gridx = 1;
60 gc.weightx = 1.0;
61 pnl.add(tfUserName, gc);
62 SelectAllOnFocusGainedDecorator.decorate(tfUserName);
63 UserNameValidator valUserName = new UserNameValidator(tfUserName);
64 valUserName.validate();
65
66 gc.anchor = GridBagConstraints.NORTHWEST;
67 gc.fill = GridBagConstraints.HORIZONTAL;
68 gc.gridy = 1;
69 gc.gridx = 0;
70 gc.weightx = 0.0;
71 pnl.add(new JLabel(tr("Password: ")), gc);
72
73 gc.gridx = 1;
74 gc.weightx = 1.0;
75 pnl.add(tfPassword, gc);
76 SelectAllOnFocusGainedDecorator.decorate(tfPassword);
77
78 return pnl;
79 }
80}
Note: See TracBrowser for help on using the repository browser.