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

Last change on this file since 1688 was 1688, checked in by stoecker, 15 years ago

fixed #2744 - server url defaults

  • Property svn:eol-style set to native
File size: 2.6 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", "http://api.openstreetmap.org/api"));
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 (e-mail) 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 (e-mail)")), 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 transferred 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}
Note: See TracBrowser for help on using the repository browser.