Changeset 17162 in josm for trunk/src


Ignore:
Timestamp:
2020-10-11T12:39:49+02:00 (4 years ago)
Author:
simon04
Message:

see #7548 - Re-organize the preference dialog (connection preferences)

Location:
trunk/src/org/openstreetmap/josm/gui/preferences
Files:
1 deleted
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java

    r17160 r17162  
    5656import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
    5757import org.openstreetmap.josm.gui.preferences.remotecontrol.RemoteControlPreference;
    58 import org.openstreetmap.josm.gui.preferences.server.ConnectionPreference;
    59 import org.openstreetmap.josm.gui.preferences.server.OverpassServerPreference;
    6058import org.openstreetmap.josm.gui.preferences.server.ProxyPreference;
    6159import org.openstreetmap.josm.gui.preferences.server.ServerAccessPreference;
     
    583581        SETTINGS_FACTORIES.add(new LanguagePreference.Factory());
    584582
    585         SETTINGS_FACTORIES.add(new ConnectionPreference.Factory());
    586583        SETTINGS_FACTORIES.add(new ServerAccessPreference.Factory());
    587584        SETTINGS_FACTORIES.add(new ProxyPreference.Factory());
    588         SETTINGS_FACTORIES.add(new OverpassServerPreference.Factory());
    589585        SETTINGS_FACTORIES.add(new MapPreference.Factory());
    590586        SETTINGS_FACTORIES.add(new ProjectionPreference.Factory());
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OverpassServerPanel.java

    r17161 r17162  
    1212import javax.swing.JPanel;
    1313
    14 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    15 import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    16 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    17 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     14import org.openstreetmap.josm.actions.ExpertToggleAction;
    1815import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
    1916import org.openstreetmap.josm.io.OverpassDownloadReader;
     
    2320 * Preferences related to Overpass API servers.
    2421 *
    25  * @since 9142
     22 * @since 17162
    2623 */
    27 public class OverpassServerPreference extends DefaultTabPreferenceSetting {
     24public class OverpassServerPanel extends JPanel {
    2825
    2926    private final HistoryComboBox overpassServer = new HistoryComboBox();
    3027    private final JCheckBox forMultiFetch = new JCheckBox(tr("Use Overpass server for object downloads"));
    3128
    32     /**
    33      * Factory used to create a new {@link OverpassServerPreference}.
    34      */
    35     public static class Factory implements PreferenceSettingFactory {
    36         @Override
    37         public PreferenceSetting createPreferenceSetting() {
    38             return new OverpassServerPreference();
    39         }
    40     }
    41 
    42     OverpassServerPreference() {
    43         super(null, tr("Overpass server"), tr("Configure Overpass server"));
    44     }
    45 
    46     @Override
    47     public void addGui(PreferenceTabbedPane gui) {
    48         final JPanel panel = new JPanel(new GridBagLayout());
    49 
     29    OverpassServerPanel() {
     30        super(new GridBagLayout());
     31        ExpertToggleAction.addVisibilitySwitcher(this);
     32        final JPanel panel = this;
    5033        panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    5134        panel.add(new JLabel(tr("Overpass server: ")), GBC.std().insets(5, 5, 5, 5));
    5235        panel.add(overpassServer, GBC.eop().fill(GBC.HORIZONTAL));
     36        panel.add(forMultiFetch, GBC.eop());
     37        panel.add(Box.createVerticalGlue(), GBC.eol().fill());
     38    }
     39
     40    /**
     41     * Initializes the panel from preferences
     42     */
     43    public final void initFromPreferences() {
    5344        overpassServer.setPossibleItems(OverpassDownloadReader.OVERPASS_SERVER_HISTORY.get());
    5445        overpassServer.setText(OverpassDownloadReader.OVERPASS_SERVER.get());
    55 
    56         panel.add(forMultiFetch, GBC.eop());
    5746        forMultiFetch.setSelected(OverpassDownloadReader.FOR_MULTI_FETCH.get());
    58 
    59         panel.add(Box.createVerticalGlue(), GBC.eol().fill());
    60         gui.createPreferenceTab(this).add(panel, GBC.eol().fill());
    6147    }
    6248
    63     @Override
    64     public boolean ok() {
     49    /**
     50     * Saves the current values to the preferences
     51     */
     52    public final void saveToPreferences() {
    6553        OverpassDownloadReader.OVERPASS_SERVER.put(overpassServer.getText());
    6654        OverpassDownloadReader.OVERPASS_SERVER_HISTORY.put(overpassServer.getHistory());
    6755        OverpassDownloadReader.FOR_MULTI_FETCH.put(forMultiFetch.isSelected());
    68         return false;
    69     }
    70 
    71     @Override
    72     public boolean isExpert() {
    73         return true;
    7456    }
    7557}
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java

    r16438 r17162  
    192192
    193193        // radio button "No proxy"
    194         gc.gridx = 0;
    195         gc.gridy = 0;
    196         gc.fill = GridBagConstraints.HORIZONTAL;
    197         gc.anchor = GridBagConstraints.NORTHWEST;
    198         gc.weightx = 0.0;
    199         pnl.add(rbProxyPolicy.get(ProxyPolicy.NO_PROXY), gc);
    200 
    201         gc.gridx = 1;
    202         gc.weightx = 1.0;
    203         pnl.add(new JLabel(tr("No proxy")), gc);
     194        rbProxyPolicy.get(ProxyPolicy.NO_PROXY).setText(tr("No proxy"));
     195        pnl.add(rbProxyPolicy.get(ProxyPolicy.NO_PROXY), GBC.eop().anchor(GBC.NORTHWEST));
    204196
    205197        // radio button "System settings"
    206         gc.gridx = 0;
    207         gc.gridy = 1;
    208         gc.weightx = 0.0;
    209         pnl.add(rbProxyPolicy.get(ProxyPolicy.USE_SYSTEM_SETTINGS), gc);
    210 
    211         gc.gridx = 1;
    212         gc.weightx = 1.0;
    213         String msg;
    214         if (DefaultProxySelector.willJvmRetrieveSystemProxies()) {
    215             msg = tr("Use standard system settings");
    216         } else {
    217             msg = tr("Use standard system settings (disabled. Start JOSM with <tt>-Djava.net.useSystemProxies=true</tt> to enable)");
    218         }
    219         pnl.add(new JMultilineLabel("<html>" + msg + "</html>"), gc);
     198        pnl.add(rbProxyPolicy.get(ProxyPolicy.USE_SYSTEM_SETTINGS), GBC.eol());
     199        rbProxyPolicy.get(ProxyPolicy.USE_SYSTEM_SETTINGS).setText(tr("Use standard system settings"));
     200        if (!DefaultProxySelector.willJvmRetrieveSystemProxies()) {
     201            String msg = tr("Use standard system settings (disabled. Start JOSM with <tt>-Djava.net.useSystemProxies=true</tt> to enable)");
     202            pnl.add(new JMultilineLabel("<html>" + msg + "</html>"), GBC.eop());
     203        }
    220204
    221205        // radio button http proxy
    222         gc.gridx = 0;
    223         gc.gridy = 2;
    224         gc.weightx = 0.0;
    225         pnl.add(rbProxyPolicy.get(ProxyPolicy.USE_HTTP_PROXY), gc);
    226 
    227         gc.gridx = 1;
    228         gc.weightx = 1.0;
    229         pnl.add(new JLabel(tr("Manually configure a HTTP proxy")), gc);
     206        rbProxyPolicy.get(ProxyPolicy.USE_HTTP_PROXY).setText(tr("Manually configure a HTTP proxy"));
     207        pnl.add(rbProxyPolicy.get(ProxyPolicy.USE_HTTP_PROXY), GBC.eol());
    230208
    231209        // the panel with the http proxy configuration parameters
    232         gc.gridx = 1;
    233         gc.gridy = 3;
    234         gc.fill = GridBagConstraints.HORIZONTAL;
    235         gc.weightx = 1.0;
    236         gc.weighty = 0.0;
    237210        pnlHttpProxyConfigurationPanel = buildHttpProxyConfigurationPanel();
    238         pnl.add(pnlHttpProxyConfigurationPanel, gc);
     211        pnl.add(pnlHttpProxyConfigurationPanel, GBC.eop().fill(GBC.HORIZONTAL));
    239212
    240213        // radio button SOCKS proxy
    241         gc.gridx = 0;
    242         gc.gridy = 4;
    243         gc.weightx = 0.0;
    244         pnl.add(rbProxyPolicy.get(ProxyPolicy.USE_SOCKS_PROXY), gc);
    245 
    246         gc.gridx = 1;
    247         gc.weightx = 1.0;
    248         pnl.add(new JLabel(tr("Use a SOCKS proxy")), gc);
     214        pnl.add(rbProxyPolicy.get(ProxyPolicy.USE_SOCKS_PROXY), GBC.eol());
     215        rbProxyPolicy.get(ProxyPolicy.USE_SOCKS_PROXY).setText(tr("Use a SOCKS proxy"));
    249216
    250217        // the panel with the SOCKS configuration parameters
    251         gc.gridx = 1;
    252         gc.gridy = 5;
    253         gc.fill = GridBagConstraints.BOTH;
    254         gc.anchor = GridBagConstraints.WEST;
    255         gc.weightx = 1.0;
    256         gc.weighty = 0.0;
    257218        pnlSocksProxyConfigurationPanel = buildSocksProxyConfigurationPanel();
    258         pnl.add(pnlSocksProxyConfigurationPanel, gc);
     219        pnl.add(pnlSocksProxyConfigurationPanel, GBC.eop().fill(GBC.HORIZONTAL));
    259220
    260221        return pnl;
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/ServerAccessPreference.java

    r17160 r17162  
    1010import javax.swing.JPanel;
    1111import javax.swing.JSeparator;
    12 import javax.swing.JTabbedPane;
    1312
    1413import org.openstreetmap.josm.gui.help.HelpUtil;
     
    3938    /** the panel for messages notifier preferences */
    4039    private final FeaturesPanel pnlFeaturesPreferences = new FeaturesPanel();
     40    private final OverpassServerPanel pnlOverpassPreferences = new OverpassServerPanel();
    4141
    4242    private ServerAccessPreference() {
    43         super(null, tr("OSM Server"), tr("Connection Settings for the OSM server."), false, new JTabbedPane());
     43        super(/* ICON(preferences/) */ "connection", tr("OSM Server"), tr("Connection Settings for the OSM server."));
    4444    }
    4545
     
    6161        panel.add(new JSeparator(), GBC.eop().fill(GBC.HORIZONTAL));
    6262        panel.add(pnlFeaturesPreferences, GBC.eop().fill(GBC.HORIZONTAL));
     63        panel.add(new JSeparator(), GBC.eop().fill(GBC.HORIZONTAL));
     64        panel.add(pnlOverpassPreferences, GBC.eop().fill(GBC.HORIZONTAL));
    6365
    6466        pnlApiUrlPreferences.initFromPreferences();
    6567        pnlAuthPreferences.initFromPreferences();
    6668        pnlFeaturesPreferences.initFromPreferences();
     69        pnlOverpassPreferences.initFromPreferences();
    6770        addApiUrlChangeListener(pnlAuthPreferences);
    6871
     
    8184        // save message notifications preferences. To be done after authentication preferences.
    8285        pnlFeaturesPreferences.saveToPreferences();
     86        pnlOverpassPreferences.saveToPreferences();
    8387        return false;
    8488    }
Note: See TracChangeset for help on using the changeset viewer.