| 1 |
|
| 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 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
public class FullyAutomaticPropertiesPanel extends JPanel { |
| 26 |
|
| 27 |
private final JosmTextField tfUserName = new JosmTextField(); |
| 28 |
private final JosmPasswordField tfPassword = new JosmPasswordField(); |
| 29 |
|
| 30 |
|
| 31 |
|
| 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 |
} |