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

Last change on this file since 8509 was 8509, checked in by Don-vip, 9 years ago

fix many checkstyle violations

  • 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"),
38 tr("Connection Settings for the OSM server."), false, new JTabbedPane());
39 }
40
41 /** indicates whether to use the default OSM URL or not */
42 private OsmApiUrlInputPanel pnlApiUrlPreferences;
43
44 /**
45 * Builds the tabbed pane with the server preferences
46 *
47 * @return panel with server preferences tabs
48 */
49 protected JPanel buildTabbedServerPreferences() {
50 JPanel pnl = new JPanel(new BorderLayout());
51 pnl.add(getTabPane(), BorderLayout.CENTER);
52 return pnl;
53 }
54
55 /**
56 * Builds the panel for entering the server access preferences
57 *
58 * @return preferences panel for server settings
59 */
60 protected JPanel buildContentPanel() {
61 JPanel pnl = new JPanel(new GridBagLayout());
62 GridBagConstraints gc = new GridBagConstraints();
63
64 // the checkbox for the default UL
65 gc.fill = GridBagConstraints.HORIZONTAL;
66 gc.anchor = GridBagConstraints.NORTHWEST;
67 gc.weightx = 1.0;
68 gc.insets = new Insets(0,0,0,0);
69 pnlApiUrlPreferences = new OsmApiUrlInputPanel();
70 pnl.add(pnlApiUrlPreferences, gc);
71
72 // the remaining access properties
73 gc.gridy = 1;
74 gc.fill = GridBagConstraints.BOTH;
75 gc.weightx = 1.0;
76 gc.weighty = 1.0;
77 gc.insets = new Insets(10,0,3,3);
78 pnl.add(buildTabbedServerPreferences(), gc);
79
80 HelpUtil.setHelpContext(pnl, HelpUtil.ht("/Preferences/Connection"));
81 return pnl;
82 }
83
84 /**
85 * Adds a listener that will be notified of API URL change.
86 * @param listener the listener
87 * @since 6523
88 */
89 public final void addApiUrlChangeListener(PropertyChangeListener listener) {
90 pnlApiUrlPreferences.addPropertyChangeListener(listener);
91 }
92
93 @Override
94 public void addGui(PreferenceTabbedPane gui) {
95 GridBagConstraints gc = new GridBagConstraints();
96 gc.fill = GridBagConstraints.BOTH;
97 gc.weightx = 1.0;
98 gc.weighty = 1.0;
99 gc.anchor = GridBagConstraints.NORTHWEST;
100 gui.createPreferenceTab(this).add(buildContentPanel(), gc);
101
102 pnlApiUrlPreferences.initFromPreferences();
103 }
104
105 /**
106 * Saves the values to the preferences
107 */
108 @Override
109 public boolean ok() {
110 pnlApiUrlPreferences.saveToPreferences();
111 return false;
112 }
113}
Note: See TracBrowser for help on using the repository browser.