Changeset 17161 in josm for trunk


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

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

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java

    r16932 r17161  
    105105     * Action that opens the map paint preferences.
    106106     */
    107     public static final JosmAction PREFERENCE_ACTION = PreferencesAction.forPreferenceSubTab(
     107    public static final JosmAction PREFERENCE_ACTION = PreferencesAction.forPreferenceTab(
    108108            tr("Map paint preferences..."), null, MapPaintPreference.class, /* ICON */ "dialogs/mappaintpreference");
    109109
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r17099 r17161  
    5454import javax.swing.JScrollPane;
    5555import javax.swing.JSeparator;
     56import javax.swing.JTabbedPane;
    5657import javax.swing.JTable;
    5758import javax.swing.JToolBar;
     
    16581659     */
    16591660    public final void deferLoading(final DefaultTabPreferenceSetting tab, final Component component) {
    1660         tab.getTabPane().addChangeListener(e -> {
    1661             if (tab.getTabPane().getSelectedComponent() == component) {
     1661        deferLoading(tab.getTabPane(), component);
     1662    }
     1663
     1664    /**
     1665     * Defers loading of sources to the first time the adequate tab is selected.
     1666     * @param tab The tabbed pane
     1667     * @param component The tab component
     1668     * @since 17161
     1669     */
     1670    public final void deferLoading(final JTabbedPane tab, final Component component) {
     1671        tab.addChangeListener(e -> {
     1672            if (tab.getSelectedComponent() == component) {
    16621673                initiallyLoadAvailableSources();
    16631674            }
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/BackupPreference.java

    r12634 r17161  
    1212import javax.swing.JLabel;
    1313import javax.swing.JPanel;
    14 import javax.swing.JScrollPane;
    1514import javax.swing.JSeparator;
    1615
    1716import org.openstreetmap.josm.data.preferences.BooleanProperty;
    1817import org.openstreetmap.josm.gui.layer.AutosaveTask;
     18import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    1919import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    2020import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    21 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    22 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    23 import org.openstreetmap.josm.gui.util.GuiHelper;
    2421import org.openstreetmap.josm.gui.widgets.HtmlPanel;
    2522import org.openstreetmap.josm.gui.widgets.JosmTextField;
     
    3027 * Preference settings for data layer autosave.
    3128 */
    32 public class BackupPreference implements SubPreferenceSetting {
     29public class BackupPreference extends DefaultTabPreferenceSetting {
    3330
    3431    /**
     
    4845    private final JosmTextField autosaveInterval = new JosmTextField(8);
    4946    private final JosmTextField backupPerLayer = new JosmTextField(8);
     47
     48    BackupPreference() {
     49        super(null, tr("File backup"), tr("Configure whether to create backup files"));
     50    }
    5051
    5152    @Override
     
    111112
    112113        panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
    113         JScrollPane sp = GuiHelper.embedInVerticalScrollPane(panel);
    114 
    115         gui.getMapPreference().addSubTab(this, tr("File backup"), sp, tr("Configure whether to create backup files"));
     114        gui.createPreferenceTab(this).add(panel, GBC.eol().fill(GBC.BOTH));
    116115    }
    117116
     
    133132    }
    134133
    135     @Override
    136     public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
    137         return gui.getMapPreference();
    138     }
    139134}
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java

    r14119 r17161  
    2222import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
    2323import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
     24import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    2425import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    2526import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    2627import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     28import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.PreferencePanel;
    2729import org.openstreetmap.josm.gui.preferences.SourceEditor;
    28 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    29 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    3030import org.openstreetmap.josm.spi.preferences.Config;
    3131import org.openstreetmap.josm.tools.GBC;
     
    3535 * Preference settings for map paint styles.
    3636 */
    37 public class MapPaintPreference implements SubPreferenceSetting {
     37public class MapPaintPreference extends DefaultTabPreferenceSetting {
    3838    private SourceEditor sources;
    3939    private JCheckBox enableIconDefault;
     40
     41    MapPaintPreference() {
     42        super(null, tr("Map Paint Styles"), tr("Map Paint Styles"));
     43    }
    4044
    4145    private static final List<SourceProvider> styleSourceProviders = new ArrayList<>();
     
    7579        panel.add(enableIconDefault, GBC.eol().insets(11, 2, 5, 0));
    7680
    77         final MapPreference mapPref = gui.getMapPreference();
    78         mapPref.addSubTab(this, tr("Map Paint Styles"), panel);
    79         sources.deferLoading(mapPref, panel);
     81        PreferencePanel preferencePanel = gui.createPreferenceTab(this);
     82        preferencePanel.add(panel, GBC.std().fill());
     83        sources.deferLoading(gui, preferencePanel);
    8084    }
    8185
     
    193197    }
    194198
    195     @Override
    196     public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
    197         return gui.getMapPreference();
    198     }
    199199}
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreference.java

    r15582 r17161  
    2424import org.openstreetmap.josm.gui.ExtendedDialog;
    2525import org.openstreetmap.josm.gui.MainApplication;
     26import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    2627import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    2728import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    2829import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     30import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.PreferencePanel;
    2931import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.ValidationListener;
    3032import org.openstreetmap.josm.gui.preferences.SourceEditor;
    31 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    32 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    3333import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;
    3434import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
     
    4343 * Preference settings for tagging presets.
    4444 */
    45 public final class TaggingPresetPreference implements SubPreferenceSetting {
     45public final class TaggingPresetPreference extends DefaultTabPreferenceSetting {
    4646
    4747    private final class TaggingPresetValidationListener implements ValidationListener {
     
    146146
    147147    private TaggingPresetPreference() {
    148         super();
     148        super(null, tr("Tagging Presets"), tr("Tagging Presets"));
    149149    }
    150150
     
    177177        sources = new TaggingPresetSourceEditor();
    178178        panel.add(sources, GBC.eol().fill(GBC.BOTH));
    179         final MapPreference mapPref = gui.getMapPreference();
    180         mapPref.addSubTab(this, tr("Tagging Presets"), panel);
    181         sources.deferLoading(mapPref, panel);
     179        PreferencePanel preferencePanel = gui.createPreferenceTab(this);
     180        preferencePanel.add(panel, GBC.eol().fill(GBC.BOTH));
     181        sources.deferLoading(gui, preferencePanel);
    182182        gui.addValidationListener(validationListener);
    183183    }
     
    262262    }
    263263
    264     @Override
    265     public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
    266         return gui.getMapPreference();
    267     }
    268264}
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java

    r16985 r17161  
    3636import org.openstreetmap.josm.gui.ExtendedDialog;
    3737import org.openstreetmap.josm.gui.MainApplication;
     38import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    3839import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    3940import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    4041import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    41 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    42 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    4342import org.openstreetmap.josm.gui.widgets.JosmComboBox;
    4443import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
     
    6463 *    if possible.
    6564 */
    66 public class ProjectionPreference implements SubPreferenceSetting {
     65public class ProjectionPreference extends DefaultTabPreferenceSetting {
    6766
    6867    /**
     
    344343
    345344    public ProjectionPreference() {
     345        super(null, tr("Map Projection"), tr("Map Projection"));
    346346        this.projectionCombo = new JosmComboBox<>(
    347347            projectionChoices.toArray(new ProjectionChoice[0]));
     
    404404        projPanel.add(GBC.glue(1, 1), GBC.std().fill(GBC.HORIZONTAL).weight(1.0, 1.0));
    405405
    406         gui.getMapPreference().addSubTab(this, tr("Map Projection"), projPanel.getVerticalScrollPane());
     406        gui.createPreferenceTab(this).add(projPanel.getVerticalScrollPane(), GBC.std().fill());
    407407
    408408        selectedProjectionChanged(pc);
     
    562562    }
    563563
    564     @Override
    565     public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
    566         return gui.getMapPreference();
    567     }
    568 
    569564    /**
    570565     * Selects the given projection.
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java

    r16304 r17161  
    7171            MainMenu.add(presetsMenu, mainMenu.presetSearchAction);
    7272            MainMenu.add(presetsMenu, mainMenu.presetSearchPrimitiveAction);
    73             MainMenu.add(presetsMenu, PreferencesAction.forPreferenceSubTab(tr("Preset preferences..."),
     73            MainMenu.add(presetsMenu, PreferencesAction.forPreferenceTab(tr("Preset preferences..."),
    7474                    tr("Click to open the tagging presets tab in the preferences"), TaggingPresetPreference.class));
    7575            presetsMenu.addSeparator();
Note: See TracChangeset for help on using the changeset viewer.