[168] | 1 | package org.openstreetmap.josm.gui.preferences;
|
---|
| 2 |
|
---|
| 3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
| 4 |
|
---|
| 5 | import java.awt.Font;
|
---|
| 6 |
|
---|
| 7 | import javax.swing.JLabel;
|
---|
| 8 | import javax.swing.JPasswordField;
|
---|
| 9 | import javax.swing.JTextField;
|
---|
| 10 |
|
---|
| 11 | import org.openstreetmap.josm.Main;
|
---|
| 12 | import org.openstreetmap.josm.tools.GBC;
|
---|
| 13 |
|
---|
| 14 | public class ServerAccessPreference implements PreferenceSetting {
|
---|
| 15 |
|
---|
| 16 | /**
|
---|
| 17 | * Editfield for the Base url to the REST API from OSM.
|
---|
| 18 | */
|
---|
| 19 | private JTextField osmDataServer = new JTextField(20);
|
---|
| 20 | /**
|
---|
| 21 | * Editfield for the username to the OSM account.
|
---|
| 22 | */
|
---|
| 23 | private JTextField osmDataUsername = new JTextField(20);
|
---|
| 24 | /**
|
---|
| 25 | * Passwordfield for the userpassword of the REST API.
|
---|
| 26 | */
|
---|
| 27 | private JPasswordField osmDataPassword = new JPasswordField(20);
|
---|
| 28 |
|
---|
| 29 | public void addGui(PreferenceDialog gui) {
|
---|
| 30 | osmDataServer.setText(Main.pref.get("osm-server.url"));
|
---|
| 31 | osmDataUsername.setText(Main.pref.get("osm-server.username"));
|
---|
| 32 | osmDataPassword.setText(Main.pref.get("osm-server.password"));
|
---|
| 33 |
|
---|
| 34 | osmDataServer.setToolTipText(tr("The base URL to the OSM server (REST API)"));
|
---|
| 35 | osmDataUsername.setToolTipText(tr("Login name (email) to the OSM account."));
|
---|
| 36 | osmDataPassword.setToolTipText(tr("Login password to the OSM account. Leave blank to not store any password."));
|
---|
| 37 |
|
---|
| 38 | gui.connection.add(new JLabel(tr("Base Server URL")), GBC.std());
|
---|
| 39 | gui.connection.add(osmDataServer, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
|
---|
| 40 | gui.connection.add(new JLabel(tr("OSM username (email)")), GBC.std());
|
---|
| 41 | gui.connection.add(osmDataUsername, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
|
---|
| 42 | gui.connection.add(new JLabel(tr("OSM password")), GBC.std());
|
---|
| 43 | gui.connection.add(osmDataPassword, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,0));
|
---|
| 44 | JLabel warning = new JLabel(tr("<html>" +
|
---|
| 45 | "WARNING: The password is stored in plain text in the preferences file.<br>" +
|
---|
| 46 | "The password is transfered in plain text to the server, encoded in the url.<br>" +
|
---|
| 47 | "<b>Do not use a valuable Password.</b></html>"));
|
---|
| 48 | warning.setFont(warning.getFont().deriveFont(Font.ITALIC));
|
---|
| 49 | gui.connection.add(warning, GBC.eop().fill(GBC.HORIZONTAL));
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | public void ok() {
|
---|
| 53 | Main.pref.put("osm-server.url", osmDataServer.getText());
|
---|
| 54 | Main.pref.put("osm-server.username", osmDataUsername.getText());
|
---|
| 55 | String pwd = String.valueOf(osmDataPassword.getPassword());
|
---|
| 56 | if (pwd.equals(""))
|
---|
| 57 | pwd = null;
|
---|
| 58 | Main.pref.put("osm-server.password", pwd);
|
---|
| 59 | }
|
---|
| 60 | }
|
---|