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