source: josm/src/org/openstreetmap/josm/gui/preferences/ServerAccessPreference.java@ 168

Last change on this file since 168 was 168, checked in by imi, 18 years ago
  • added plugin-support for preferences
  • added advanced tab to preferences dialog
File size: 2.4 KB
Line 
1package org.openstreetmap.josm.gui.preferences;
2
3import static org.openstreetmap.josm.tools.I18n.tr;
4
5import java.awt.Font;
6
7import javax.swing.JLabel;
8import javax.swing.JPasswordField;
9import javax.swing.JTextField;
10
11import org.openstreetmap.josm.Main;
12import org.openstreetmap.josm.tools.GBC;
13
14public 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}
Note: See TracBrowser for help on using the repository browser.