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

Last change on this file since 7668 was 7668, checked in by stoecker, 11 years ago

cleanup icons, mark undetected icons, set proper mimetype, delete unused icons, update geticons script

  • Property svn:eol-style set to native
File size: 3.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.server;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.BorderLayout;
7import java.awt.GridBagConstraints;
8import java.awt.GridBagLayout;
9import java.awt.Insets;
10import java.beans.PropertyChangeListener;
11
12import javax.swing.JPanel;
13import javax.swing.JTabbedPane;
14
15import org.openstreetmap.josm.gui.help.HelpUtil;
16import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
17import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
18import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
19import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
20
21/**
22 * Connection preferences, including authentication and proxy sub-preferences.
23 */
24public final class ServerAccessPreference extends DefaultTabPreferenceSetting {
25
26 /**
27 * Factory used to create a new {@code ServerAccessPreference}.
28 */
29 public static class Factory implements PreferenceSettingFactory {
30 @Override
31 public PreferenceSetting createPreferenceSetting() {
32 return new ServerAccessPreference();
33 }
34 }
35
36 private ServerAccessPreference() {
37 super(/* ICON(preferences/) */ "connection", tr("Connection Settings"), tr("Connection Settings for the OSM server."), false, new JTabbedPane());
38 }
39
40 /** indicates whether to use the default OSM URL or not */
41 private OsmApiUrlInputPanel pnlApiUrlPreferences;
42
43 /**
44 * Builds the tabbed pane with the server preferences
45 *
46 * @return panel with server preferences tabs
47 */
48 protected JPanel buildTabbedServerPreferences() {
49 JPanel pnl = new JPanel(new BorderLayout());
50 pnl.add(getTabPane(), BorderLayout.CENTER);
51 return pnl;
52 }
53
54 /**
55 * Builds the panel for entering the server access preferences
56 *
57 * @return preferences panel for server settings
58 */
59 protected JPanel buildContentPanel() {
60 JPanel pnl = new JPanel(new GridBagLayout());
61 GridBagConstraints gc = new GridBagConstraints();
62
63 // the checkbox for the default UL
64 gc.fill = GridBagConstraints.HORIZONTAL;
65 gc.anchor = GridBagConstraints.NORTHWEST;
66 gc.weightx = 1.0;
67 gc.insets = new Insets(0,0,0,0);
68 pnlApiUrlPreferences = new OsmApiUrlInputPanel();
69 pnl.add(pnlApiUrlPreferences, gc);
70
71 // the remaining access properties
72 gc.gridy = 1;
73 gc.fill = GridBagConstraints.BOTH;
74 gc.weightx = 1.0;
75 gc.weighty = 1.0;
76 gc.insets = new Insets(10,0,3,3);
77 pnl.add(buildTabbedServerPreferences(), gc);
78
79 HelpUtil.setHelpContext(pnl, HelpUtil.ht("/Preferences/Connection"));
80 return pnl;
81 }
82
83 /**
84 * Adds a listener that will be notified of API URL change.
85 * @param listener the listener
86 * @since 6523
87 */
88 public final void addApiUrlChangeListener(PropertyChangeListener listener) {
89 pnlApiUrlPreferences.addPropertyChangeListener(listener);
90 }
91
92 @Override
93 public void addGui(PreferenceTabbedPane gui) {
94 GridBagConstraints gc = new GridBagConstraints();
95 gc.fill = GridBagConstraints.BOTH;
96 gc.weightx = 1.0;
97 gc.weighty = 1.0;
98 gc.anchor = GridBagConstraints.NORTHWEST;
99 gui.createPreferenceTab(this).add(buildContentPanel(), gc);
100
101 pnlApiUrlPreferences.initFromPreferences();
102 }
103
104 /**
105 * Saves the values to the preferences
106 */
107 @Override
108 public boolean ok() {
109 pnlApiUrlPreferences.saveToPreferences();
110 return false;
111 }
112}
Note: See TracBrowser for help on using the repository browser.