Changeset 17160 in josm
- Timestamp:
- 2020-10-11T11:23:04+02:00 (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 9 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r17079 r17160 1354 1354 1355 1355 if (ed.showDialog().getValue() == 1) { 1356 PreferencesAction.forPreference SubTab(null, null, ProxyPreference.class).run();1356 PreferencesAction.forPreferenceTab(null, null, ProxyPreference.class).run(); 1357 1357 } 1358 1358 } -
trunk/src/org/openstreetmap/josm/gui/preferences/DefaultTabPreferenceSetting.java
r17159 r17160 7 7 8 8 import javax.swing.JPanel; 9 import javax.swing.JScrollPane;10 9 import javax.swing.JTabbedPane; 11 10 -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r17159 r17160 56 56 import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference; 57 57 import org.openstreetmap.josm.gui.preferences.remotecontrol.RemoteControlPreference; 58 import org.openstreetmap.josm.gui.preferences.server. AuthenticationPreference;58 import org.openstreetmap.josm.gui.preferences.server.ConnectionPreference; 59 59 import org.openstreetmap.josm.gui.preferences.server.OverpassServerPreference; 60 60 import org.openstreetmap.josm.gui.preferences.server.ProxyPreference; … … 582 582 SETTINGS_FACTORIES.add(new LafPreference.Factory()); 583 583 SETTINGS_FACTORIES.add(new LanguagePreference.Factory()); 584 585 SETTINGS_FACTORIES.add(new ConnectionPreference.Factory()); 584 586 SETTINGS_FACTORIES.add(new ServerAccessPreference.Factory()); 585 SETTINGS_FACTORIES.add(new AuthenticationPreference.Factory());586 587 SETTINGS_FACTORIES.add(new ProxyPreference.Factory()); 587 588 SETTINGS_FACTORIES.add(new OverpassServerPreference.Factory()); -
trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java
r12931 r17160 16 16 import javax.swing.JPanel; 17 17 import javax.swing.JRadioButton; 18 import javax.swing.JSeparator;19 18 20 19 import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder; … … 42 41 /** the panel for the OAuth authentication parameters */ 43 42 private OAuthAuthenticationPreferencesPanel pnlOAuthPreferences; 44 /** the panel for messages notifier preferences */45 private FeaturesPanel pnlFeaturesPreferences;46 43 47 44 /** … … 102 99 rbBasicAuthentication.setSelected(true); 103 100 pnlAuthenticationParameteters.add(pnlBasicAuthPreferences, BorderLayout.CENTER); 104 105 gc.gridy = 2;106 add(new JSeparator(), gc);107 108 //-- the panel for API feature preferences109 gc.gridy = 3;110 gc.fill = GridBagConstraints.NONE;111 pnlFeaturesPreferences = new FeaturesPanel();112 add(pnlFeaturesPreferences, gc);113 101 } 114 102 … … 129 117 pnlBasicAuthPreferences.initFromPreferences(); 130 118 pnlOAuthPreferences.initFromPreferences(); 131 pnlFeaturesPreferences.initFromPreferences();132 119 } 133 120 … … 155 142 pnlOAuthPreferences.saveToPreferences(); 156 143 } 157 // save message notifications preferences. To be done after authentication preferences.158 pnlFeaturesPreferences.saveToPreferences();159 144 } 160 145 -
trunk/src/org/openstreetmap/josm/gui/preferences/server/FeaturesPanel.java
r14259 r17160 41 41 42 42 notifier = new JCheckBox(tr("Periodically check for new messages")); 43 add(notifier, GBC. eol());43 add(notifier, GBC.std(0, 0).span(2).fill(GBC.HORIZONTAL)); 44 44 notifier.addChangeListener(e -> updateEnabledState()); 45 45 46 46 intervalLabel = new JLabel(tr("Check interval (minutes):")); 47 47 intervalLabel.setLabelFor(notifierInterval); 48 add(intervalLabel, GBC.std( ).insets(25, 0, 0, 0));48 add(intervalLabel, GBC.std(0, 1)); 49 49 50 50 notifierInterval.setToolTipText(tr("Default value: {0}", MessageNotifier.PROP_INTERVAL.getDefaultValue())); 51 51 notifierInterval.setMinimumSize(notifierInterval.getPreferredSize()); 52 add(notifierInterval, GBC. eol().insets(5, 0, 0, 0));52 add(notifierInterval, GBC.std(1, 1).insets(5, 0, 0, 0)); 53 53 54 54 final JLabel notesDaysClosedLabel = new JLabel(tr("Max age for closed notes (days):")); 55 55 notesDaysClosedLabel.setLabelFor(notesDaysClosed); 56 56 notesDaysClosedLabel.setToolTipText(tr("Specifies the number of days a note needs to be closed to no longer be downloaded")); 57 add(notesDaysClosedLabel, GBC.std( ).insets(0, 20, 0, 0));57 add(notesDaysClosedLabel, GBC.std(0, 2).insets(0, 20, 0, 0)); 58 58 notesDaysClosed.setToolTipText(tr("Default value: {0}", DownloadNotesTask.DAYS_CLOSED.getDefaultValue())); 59 59 notesDaysClosed.setMinimumSize(notesDaysClosed.getPreferredSize()); 60 add(notesDaysClosed, GBC. eol().insets(5, 20, 0, 0));60 add(notesDaysClosed, GBC.std(1, 2).insets(5, 20, 0, 0)); 61 61 } 62 62 -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java
r15020 r17160 5 5 6 6 import java.awt.Font; 7 import java.awt.GridBagConstraints;8 7 import java.awt.GridBagLayout; 9 import java.awt.Insets;10 8 import java.awt.event.ActionEvent; 11 9 import java.awt.event.ActionListener; … … 38 36 import org.openstreetmap.josm.spi.preferences.Config; 39 37 import org.openstreetmap.josm.spi.preferences.IUrls; 38 import org.openstreetmap.josm.tools.GBC; 40 39 import org.openstreetmap.josm.tools.ImageProvider; 41 40 import org.openstreetmap.josm.tools.Logging; … … 82 81 protected final void build() { 83 82 setLayout(new GridBagLayout()); 84 GridBagConstraints gc = new GridBagConstraints();85 83 86 84 // the checkbox for the default UL 87 gc.fill = GridBagConstraints.HORIZONTAL; 88 gc.anchor = GridBagConstraints.NORTHWEST; 89 gc.weightx = 1.0; 90 gc.insets = new Insets(0, 0, 0, 0); 91 gc.gridwidth = 4; 92 add(buildDefaultServerUrlPanel(), gc); 93 85 add(buildDefaultServerUrlPanel(), GBC.eop().fill(GBC.HORIZONTAL)); 94 86 95 87 // the input field for the URL 96 gc.gridx = 0; 97 gc.gridy = 1; 98 gc.gridwidth = 1; 99 gc.weightx = 0.0; 100 gc.insets = new Insets(0, 0, 0, 3); 101 add(lblApiUrl, gc); 102 103 gc.gridx = 1; 104 gc.weightx = 1.0; 105 add(tfOsmServerUrl, gc); 88 add(lblApiUrl, GBC.std().insets(0, 0, 3, 0)); 89 add(tfOsmServerUrl, GBC.std().fill(GBC.HORIZONTAL).insets(0, 0, 3, 0)); 106 90 lblApiUrl.setLabelFor(tfOsmServerUrl); 107 91 SelectAllOnFocusGainedDecorator.decorate(tfOsmServerUrl.getEditorComponent()); … … 112 96 tfOsmServerUrl.addFocusListener(propagator); 113 97 114 gc.gridx = 2; 115 gc.weightx = 0.0; 116 add(lblValid, gc); 117 118 gc.gridx = 3; 119 gc.weightx = 0.0; 98 add(lblValid, GBC.std().insets(0, 0, 3, 0)); 99 120 100 ValidateApiUrlAction actTest = new ValidateApiUrlAction(); 121 101 tfOsmServerUrl.getEditorComponent().getDocument().addDocumentListener(actTest); 122 102 btnTest = new JButton(actTest); 123 add(btnTest, gc);103 add(btnTest, GBC.eop()); 124 104 } 125 105 -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OverpassServerPreference.java
r13173 r17160 12 12 import javax.swing.JPanel; 13 13 14 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 14 15 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 15 16 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 16 17 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 17 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;18 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;19 18 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 20 19 import org.openstreetmap.josm.io.OverpassDownloadReader; … … 26 25 * @since 9142 27 26 */ 28 public class OverpassServerPreference implements SubPreferenceSetting {27 public class OverpassServerPreference extends DefaultTabPreferenceSetting { 29 28 30 29 private final HistoryComboBox overpassServer = new HistoryComboBox(); … … 41 40 } 42 41 43 @Override 44 public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) { 45 return gui.getServerPreference(); 42 OverpassServerPreference() { 43 super(null, tr("Overpass server"), tr("Configure Overpass server")); 46 44 } 47 45 … … 60 58 61 59 panel.add(Box.createVerticalGlue(), GBC.eol().fill()); 62 63 getTabPreferenceSetting(gui).addSubTab(this, tr("Overpass server"), panel); 60 gui.createPreferenceTab(this).add(panel, GBC.eol().fill()); 64 61 } 65 62 -
trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreference.java
r16913 r17160 7 7 import java.util.Set; 8 8 9 import javax.swing.Box; 10 11 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 9 12 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 10 13 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 11 14 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 12 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; 13 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 15 import org.openstreetmap.josm.tools.GBC; 14 16 15 17 /** … … 17 19 * @since 6523 18 20 */ 19 public final class ProxyPreference implements SubPreferenceSetting {21 public final class ProxyPreference extends DefaultTabPreferenceSetting { 20 22 21 23 /** … … 34 36 35 37 private ProxyPreference() { 36 super( );38 super(null, tr("Proxy settings"), tr("Configure whether to use a proxy server")); 37 39 } 38 40 … … 40 42 public void addGui(PreferenceTabbedPane gui) { 41 43 pnlProxyPreferences = new ProxyPreferencesPanel(); 42 gui.getServerPreference().addSubTab(this, tr("Proxy settings"), 43 pnlProxyPreferences.getVerticalScrollPane(), 44 tr("Configure whether to use a proxy server")); 44 pnlProxyPreferences.add(Box.createVerticalGlue(), GBC.eol().fill()); 45 gui.createPreferenceTab(this).add(pnlProxyPreferences, GBC.eol().fill()); 45 46 } 46 47 … … 57 58 public boolean isExpert() { 58 59 return false; 59 }60 61 @Override62 public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {63 return gui.getServerPreference();64 60 } 65 61 -
trunk/src/org/openstreetmap/josm/gui/preferences/server/ServerAccessPreference.java
r13431 r17160 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.BorderLayout;7 import java.awt.GridBagConstraints;8 6 import java.awt.GridBagLayout; 9 import java.awt.Insets;10 7 import java.beans.PropertyChangeListener; 11 8 9 import javax.swing.Box; 12 10 import javax.swing.JPanel; 11 import javax.swing.JSeparator; 13 12 import javax.swing.JTabbedPane; 14 13 … … 18 17 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 19 18 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 19 import org.openstreetmap.josm.tools.GBC; 20 20 21 21 /** … … 36 36 /** indicates whether to use the default OSM URL or not */ 37 37 private final OsmApiUrlInputPanel pnlApiUrlPreferences = new OsmApiUrlInputPanel(); 38 private final AuthenticationPreferencesPanel pnlAuthPreferences = new AuthenticationPreferencesPanel(); 39 /** the panel for messages notifier preferences */ 40 private final FeaturesPanel pnlFeaturesPreferences = new FeaturesPanel(); 38 41 39 42 private ServerAccessPreference() { 40 super(/* ICON(preferences/) */ "connection", tr("Connection Settings"), 41 tr("Connection Settings for the OSM server."), false, new JTabbedPane()); 42 } 43 44 /** 45 * Builds the tabbed pane with the server preferences 46 * 47 * @return panel with server preferences tabs 48 */ 49 private 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 private 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 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; 43 super(null, tr("OSM Server"), tr("Connection Settings for the OSM server."), false, new JTabbedPane()); 81 44 } 82 45 … … 92 55 @Override 93 56 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);57 JPanel panel = new JPanel(new GridBagLayout()); 58 panel.add(pnlApiUrlPreferences, GBC.eop().fill(GBC.HORIZONTAL)); 59 panel.add(new JSeparator(), GBC.eop().fill(GBC.HORIZONTAL)); 60 panel.add(pnlAuthPreferences, GBC.eop().fill(GBC.HORIZONTAL)); 61 panel.add(new JSeparator(), GBC.eop().fill(GBC.HORIZONTAL)); 62 panel.add(pnlFeaturesPreferences, GBC.eop().fill(GBC.HORIZONTAL)); 100 63 101 64 pnlApiUrlPreferences.initFromPreferences(); 65 pnlAuthPreferences.initFromPreferences(); 66 pnlFeaturesPreferences.initFromPreferences(); 67 addApiUrlChangeListener(pnlAuthPreferences); 68 69 HelpUtil.setHelpContext(panel, HelpUtil.ht("/Preferences/Connection")); 70 panel.add(Box.createVerticalGlue(), GBC.eol().fill()); 71 gui.createPreferenceTab(this).add(panel, GBC.eol().fill()); 102 72 } 103 73 … … 108 78 public boolean ok() { 109 79 pnlApiUrlPreferences.saveToPreferences(); 80 pnlAuthPreferences.saveToPreferences(); 81 // save message notifications preferences. To be done after authentication preferences. 82 pnlFeaturesPreferences.saveToPreferences(); 110 83 return false; 111 84 } -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/ConnectionPreferenceTest.java
r17159 r17160 12 12 13 13 /** 14 * Unit tests of {@link AuthenticationPreference} class.14 * Unit tests of {@link ConnectionPreference} class. 15 15 */ 16 public class AuthenticationPreferenceTest {16 public class ConnectionPreferenceTest { 17 17 18 18 /** … … 24 24 25 25 /** 26 * Unit test of {@link AuthenticationPreference#AuthenticationPreference}.26 * Unit test of {@link ConnectionPreference#AuthenticationPreference}. 27 27 */ 28 28 @Test 29 29 public void testAuthenticationPreference() { 30 assertNotNull(new AuthenticationPreference.Factory().createPreferenceSetting());30 assertNotNull(new ConnectionPreference.Factory().createPreferenceSetting()); 31 31 } 32 32 33 33 /** 34 * Unit test of {@link AuthenticationPreference#addGui}.34 * Unit test of {@link ConnectionPreference#addGui}. 35 35 */ 36 36 @Test 37 37 public void testAddGui() { 38 PreferencesTestUtils.doTestPreferenceSettingAddGui(new AuthenticationPreference.Factory(), ServerAccessPreference.class);38 PreferencesTestUtils.doTestPreferenceSettingAddGui(new ConnectionPreference.Factory(), ServerAccessPreference.class); 39 39 } 40 40 }
Note:
See TracChangeset
for help on using the changeset viewer.