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

Last change on this file since 12490 was 10183, checked in by Don-vip, 8 years ago

sonar - squid:AssignmentInSubExpressionCheck - Assignments should not be made from within sub-expressions

  • Property svn:eol-style set to native
File size: 2.4 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
19public 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}
Note: See TracBrowser for help on using the repository browser.