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

Last change on this file since 321 was 298, checked in by imi, 17 years ago
  • added license description to head of each source file
File size: 2.4 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.gui.preferences;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Font;
7
8import javax.swing.JLabel;
9import javax.swing.JPasswordField;
10import javax.swing.JTextField;
11
12import org.openstreetmap.josm.Main;
13import org.openstreetmap.josm.tools.GBC;
14
15public 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 void ok() {
54 Main.pref.put("osm-server.url", osmDataServer.getText());
55 Main.pref.put("osm-server.username", osmDataUsername.getText());
56 String pwd = String.valueOf(osmDataPassword.getPassword());
57 if (pwd.equals(""))
58 pwd = null;
59 Main.pref.put("osm-server.password", pwd);
60 }
61}
Note: See TracBrowser for help on using the repository browser.