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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.