1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.oauth;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.GridBagConstraints;
|
---|
7 | import java.awt.GridBagLayout;
|
---|
8 | import java.awt.Insets;
|
---|
9 |
|
---|
10 | import javax.swing.BorderFactory;
|
---|
11 | import javax.swing.JLabel;
|
---|
12 | import javax.swing.JPanel;
|
---|
13 |
|
---|
14 | import org.openstreetmap.josm.gui.preferences.server.UserNameValidator;
|
---|
15 | import org.openstreetmap.josm.gui.widgets.JosmPasswordField;
|
---|
16 | import org.openstreetmap.josm.gui.widgets.JosmTextField;
|
---|
17 | import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
|
---|
18 |
|
---|
19 | public class FullyAutomaticPropertiesPanel extends JPanel {
|
---|
20 |
|
---|
21 | private final JosmTextField tfUserName = new JosmTextField();
|
---|
22 | private final JosmPasswordField tfPassword = new JosmPasswordField();
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Constructs a new {@code FullyAutomaticPropertiesPanel}.
|
---|
26 | */
|
---|
27 | public FullyAutomaticPropertiesPanel() {
|
---|
28 | setLayout(new GridBagLayout());
|
---|
29 | GridBagConstraints gc = new GridBagConstraints();
|
---|
30 | setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
|
---|
31 |
|
---|
32 | gc.anchor = GridBagConstraints.NORTHWEST;
|
---|
33 | gc.fill = GridBagConstraints.HORIZONTAL;
|
---|
34 | gc.weightx = 1.0;
|
---|
35 | add(buildUserNamePasswordPanel(), gc);
|
---|
36 |
|
---|
37 | gc.gridy = 1;
|
---|
38 | gc.weighty = 1.0;
|
---|
39 | gc.fill = GridBagConstraints.BOTH;
|
---|
40 | add(new JPanel(), gc);
|
---|
41 | }
|
---|
42 |
|
---|
43 | protected final JPanel buildUserNamePasswordPanel() {
|
---|
44 | JPanel pnl = new JPanel(new GridBagLayout());
|
---|
45 | GridBagConstraints gc = new GridBagConstraints();
|
---|
46 |
|
---|
47 | gc.anchor = GridBagConstraints.NORTHWEST;
|
---|
48 | gc.fill = GridBagConstraints.HORIZONTAL;
|
---|
49 | gc.weightx = 0.0;
|
---|
50 | gc.insets = new Insets(0, 0, 3, 3);
|
---|
51 | pnl.add(new JLabel(tr("Username: ")), gc);
|
---|
52 |
|
---|
53 | gc.gridx = 1;
|
---|
54 | gc.weightx = 1.0;
|
---|
55 | pnl.add(tfUserName, gc);
|
---|
56 | SelectAllOnFocusGainedDecorator.decorate(tfUserName);
|
---|
57 | UserNameValidator valUserName = new UserNameValidator(tfUserName);
|
---|
58 | valUserName.validate();
|
---|
59 |
|
---|
60 | gc.anchor = GridBagConstraints.NORTHWEST;
|
---|
61 | gc.fill = GridBagConstraints.HORIZONTAL;
|
---|
62 | gc.gridy = 1;
|
---|
63 | gc.gridx = 0;
|
---|
64 | gc.weightx = 0.0;
|
---|
65 | pnl.add(new JLabel(tr("Password: ")), gc);
|
---|
66 |
|
---|
67 | gc.gridx = 1;
|
---|
68 | gc.weightx = 1.0;
|
---|
69 | pnl.add(tfPassword, gc);
|
---|
70 | SelectAllOnFocusGainedDecorator.decorate(tfPassword);
|
---|
71 |
|
---|
72 | return pnl;
|
---|
73 | }
|
---|
74 | }
|
---|