Changeset 17160 in josm


Ignore:
Timestamp:
2020-10-11T11:23:04+02:00 (2 weeks ago)
Author:
simon04
Message:

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

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  
    13541354
    13551355                if (ed.showDialog().getValue() == 1) {
    1356                     PreferencesAction.forPreferenceSubTab(null, null, ProxyPreference.class).run();
     1356                    PreferencesAction.forPreferenceTab(null, null, ProxyPreference.class).run();
    13571357                }
    13581358            }
  • trunk/src/org/openstreetmap/josm/gui/preferences/DefaultTabPreferenceSetting.java

    r17159 r17160  
    77
    88import javax.swing.JPanel;
    9 import javax.swing.JScrollPane;
    109import javax.swing.JTabbedPane;
    1110
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java

    r17159 r17160  
    5656import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
    5757import org.openstreetmap.josm.gui.preferences.remotecontrol.RemoteControlPreference;
    58 import org.openstreetmap.josm.gui.preferences.server.AuthenticationPreference;
     58import org.openstreetmap.josm.gui.preferences.server.ConnectionPreference;
    5959import org.openstreetmap.josm.gui.preferences.server.OverpassServerPreference;
    6060import org.openstreetmap.josm.gui.preferences.server.ProxyPreference;
     
    582582        SETTINGS_FACTORIES.add(new LafPreference.Factory());
    583583        SETTINGS_FACTORIES.add(new LanguagePreference.Factory());
     584
     585        SETTINGS_FACTORIES.add(new ConnectionPreference.Factory());
    584586        SETTINGS_FACTORIES.add(new ServerAccessPreference.Factory());
    585         SETTINGS_FACTORIES.add(new AuthenticationPreference.Factory());
    586587        SETTINGS_FACTORIES.add(new ProxyPreference.Factory());
    587588        SETTINGS_FACTORIES.add(new OverpassServerPreference.Factory());
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java

    r12931 r17160  
    1616import javax.swing.JPanel;
    1717import javax.swing.JRadioButton;
    18 import javax.swing.JSeparator;
    1918
    2019import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder;
     
    4241    /** the panel for the OAuth authentication parameters */
    4342    private OAuthAuthenticationPreferencesPanel pnlOAuthPreferences;
    44     /** the panel for messages notifier preferences */
    45     private FeaturesPanel pnlFeaturesPreferences;
    4643
    4744    /**
     
    10299        rbBasicAuthentication.setSelected(true);
    103100        pnlAuthenticationParameteters.add(pnlBasicAuthPreferences, BorderLayout.CENTER);
    104 
    105         gc.gridy = 2;
    106         add(new JSeparator(), gc);
    107 
    108         //-- the panel for API feature preferences
    109         gc.gridy = 3;
    110         gc.fill = GridBagConstraints.NONE;
    111         pnlFeaturesPreferences = new FeaturesPanel();
    112         add(pnlFeaturesPreferences, gc);
    113101    }
    114102
     
    129117        pnlBasicAuthPreferences.initFromPreferences();
    130118        pnlOAuthPreferences.initFromPreferences();
    131         pnlFeaturesPreferences.initFromPreferences();
    132119    }
    133120
     
    155142            pnlOAuthPreferences.saveToPreferences();
    156143        }
    157         // save message notifications preferences. To be done after authentication preferences.
    158         pnlFeaturesPreferences.saveToPreferences();
    159144    }
    160145
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/FeaturesPanel.java

    r14259 r17160  
    4141
    4242        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));
    4444        notifier.addChangeListener(e -> updateEnabledState());
    4545
    4646        intervalLabel = new JLabel(tr("Check interval (minutes):"));
    4747        intervalLabel.setLabelFor(notifierInterval);
    48         add(intervalLabel, GBC.std().insets(25, 0, 0, 0));
     48        add(intervalLabel, GBC.std(0, 1));
    4949
    5050        notifierInterval.setToolTipText(tr("Default value: {0}", MessageNotifier.PROP_INTERVAL.getDefaultValue()));
    5151        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));
    5353
    5454        final JLabel notesDaysClosedLabel = new JLabel(tr("Max age for closed notes (days):"));
    5555        notesDaysClosedLabel.setLabelFor(notesDaysClosed);
    5656        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));
    5858        notesDaysClosed.setToolTipText(tr("Default value: {0}", DownloadNotesTask.DAYS_CLOSED.getDefaultValue()));
    5959        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));
    6161    }
    6262
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java

    r15020 r17160  
    55
    66import java.awt.Font;
    7 import java.awt.GridBagConstraints;
    87import java.awt.GridBagLayout;
    9 import java.awt.Insets;
    108import java.awt.event.ActionEvent;
    119import java.awt.event.ActionListener;
     
    3836import org.openstreetmap.josm.spi.preferences.Config;
    3937import org.openstreetmap.josm.spi.preferences.IUrls;
     38import org.openstreetmap.josm.tools.GBC;
    4039import org.openstreetmap.josm.tools.ImageProvider;
    4140import org.openstreetmap.josm.tools.Logging;
     
    8281    protected final void build() {
    8382        setLayout(new GridBagLayout());
    84         GridBagConstraints gc = new GridBagConstraints();
    8583
    8684        // 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));
    9486
    9587        // 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));
    10690        lblApiUrl.setLabelFor(tfOsmServerUrl);
    10791        SelectAllOnFocusGainedDecorator.decorate(tfOsmServerUrl.getEditorComponent());
     
    11296        tfOsmServerUrl.addFocusListener(propagator);
    11397
    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
    120100        ValidateApiUrlAction actTest = new ValidateApiUrlAction();
    121101        tfOsmServerUrl.getEditorComponent().getDocument().addDocumentListener(actTest);
    122102        btnTest = new JButton(actTest);
    123         add(btnTest, gc);
     103        add(btnTest, GBC.eop());
    124104    }
    125105
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OverpassServerPreference.java

    r13173 r17160  
    1212import javax.swing.JPanel;
    1313
     14import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    1415import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    1516import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    1617import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    17 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    18 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    1918import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
    2019import org.openstreetmap.josm.io.OverpassDownloadReader;
     
    2625 * @since 9142
    2726 */
    28 public class OverpassServerPreference implements SubPreferenceSetting {
     27public class OverpassServerPreference extends DefaultTabPreferenceSetting {
    2928
    3029    private final HistoryComboBox overpassServer = new HistoryComboBox();
     
    4140    }
    4241
    43     @Override
    44     public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {
    45         return gui.getServerPreference();
     42    OverpassServerPreference() {
     43        super(null, tr("Overpass server"), tr("Configure Overpass server"));
    4644    }
    4745
     
    6058
    6159        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());
    6461    }
    6562
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreference.java

    r16913 r17160  
    77import java.util.Set;
    88
     9import javax.swing.Box;
     10
     11import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    912import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    1013import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    1114import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    12 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    13 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
     15import org.openstreetmap.josm.tools.GBC;
    1416
    1517/**
     
    1719 * @since 6523
    1820 */
    19 public final class ProxyPreference implements SubPreferenceSetting {
     21public final class ProxyPreference extends DefaultTabPreferenceSetting {
    2022
    2123    /**
     
    3436
    3537    private ProxyPreference() {
    36         super();
     38        super(null, tr("Proxy settings"), tr("Configure whether to use a proxy server"));
    3739    }
    3840
     
    4042    public void addGui(PreferenceTabbedPane gui) {
    4143        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());
    4546    }
    4647
     
    5758    public boolean isExpert() {
    5859        return false;
    59     }
    60 
    61     @Override
    62     public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {
    63         return gui.getServerPreference();
    6460    }
    6561
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/ServerAccessPreference.java

    r13431 r17160  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.BorderLayout;
    7 import java.awt.GridBagConstraints;
    86import java.awt.GridBagLayout;
    9 import java.awt.Insets;
    107import java.beans.PropertyChangeListener;
    118
     9import javax.swing.Box;
    1210import javax.swing.JPanel;
     11import javax.swing.JSeparator;
    1312import javax.swing.JTabbedPane;
    1413
     
    1817import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    1918import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     19import org.openstreetmap.josm.tools.GBC;
    2020
    2121/**
     
    3636    /** indicates whether to use the default OSM URL or not */
    3737    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();
    3841
    3942    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());
    8144    }
    8245
     
    9255    @Override
    9356    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));
    10063
    10164        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());
    10272    }
    10373
     
    10878    public boolean ok() {
    10979        pnlApiUrlPreferences.saveToPreferences();
     80        pnlAuthPreferences.saveToPreferences();
     81        // save message notifications preferences. To be done after authentication preferences.
     82        pnlFeaturesPreferences.saveToPreferences();
    11083        return false;
    11184    }
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/ConnectionPreferenceTest.java

    r17159 r17160  
    1212
    1313/**
    14  * Unit tests of {@link AuthenticationPreference} class.
     14 * Unit tests of {@link ConnectionPreference} class.
    1515 */
    16 public class AuthenticationPreferenceTest {
     16public class ConnectionPreferenceTest {
    1717
    1818    /**
     
    2424
    2525    /**
    26      * Unit test of {@link AuthenticationPreference#AuthenticationPreference}.
     26     * Unit test of {@link ConnectionPreference#AuthenticationPreference}.
    2727     */
    2828    @Test
    2929    public void testAuthenticationPreference() {
    30         assertNotNull(new AuthenticationPreference.Factory().createPreferenceSetting());
     30        assertNotNull(new ConnectionPreference.Factory().createPreferenceSetting());
    3131    }
    3232
    3333    /**
    34      * Unit test of {@link AuthenticationPreference#addGui}.
     34     * Unit test of {@link ConnectionPreference#addGui}.
    3535     */
    3636    @Test
    3737    public void testAddGui() {
    38         PreferencesTestUtils.doTestPreferenceSettingAddGui(new AuthenticationPreference.Factory(), ServerAccessPreference.class);
     38        PreferencesTestUtils.doTestPreferenceSettingAddGui(new ConnectionPreference.Factory(), ServerAccessPreference.class);
    3939    }
    4040}
Note: See TracChangeset for help on using the changeset viewer.