Changeset 17314 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2020-11-16T16:45:58+01:00 (3 years ago)
Author:
Don-vip
Message:

see #7548 - make clear which preferences settings allow new tabs from plugins. Make color preferences extensible. Hide tab area if a single tab is defined.

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 added
6 edited

Legend:

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

    r17237 r17314  
    22package org.openstreetmap.josm.gui.preferences.display;
    33
     4import static java.awt.GridBagConstraints.BOTH;
     5import static java.awt.GridBagConstraints.HORIZONTAL;
    46import static org.openstreetmap.josm.tools.I18n.tr;
    57
     
    4850import org.openstreetmap.josm.gui.layer.gpx.GpxDrawHelper;
    4951import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    50 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
     52import org.openstreetmap.josm.gui.preferences.ExtensibleTabPreferenceSetting;
    5153import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    5254import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     
    5961import org.openstreetmap.josm.tools.ColorHelper;
    6062import org.openstreetmap.josm.tools.GBC;
     63import org.openstreetmap.josm.tools.I18n;
    6164import org.openstreetmap.josm.tools.ImageProvider;
    62 import org.openstreetmap.josm.tools.I18n;
    6365
    6466/**
     
    6870 * @see NamedColorProperty
    6971 */
    70 public class ColorPreference extends DefaultTabPreferenceSetting implements ListSelectionListener, TableModelListener {
     72public class ColorPreference extends ExtensibleTabPreferenceSetting implements ListSelectionListener, TableModelListener {
    7173
    7274    /**
     
    370372        JPanel panel = new JPanel(new GridBagLayout());
    371373        panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    372         panel.add(colorFilter, GBC.eol().fill(GBC.HORIZONTAL));
     374        panel.add(colorFilter, GBC.eol().fill(HORIZONTAL));
    373375        JScrollPane scrollpane = new JScrollPane(colors);
    374376        scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    375         panel.add(scrollpane, GBC.eol().fill(GBC.BOTH));
     377        panel.add(scrollpane, GBC.eol().fill(BOTH));
    376378        JPanel buttonPanel = new JPanel(new GridBagLayout());
    377         panel.add(buttonPanel, GBC.eol().insets(5, 0, 5, 5).fill(GBC.HORIZONTAL));
    378         buttonPanel.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
     379        panel.add(buttonPanel, GBC.eol().insets(5, 0, 5, 5).fill(HORIZONTAL));
     380        buttonPanel.add(Box.createHorizontalGlue(), GBC.std().fill(HORIZONTAL));
    379381        buttonPanel.add(colorEdit, GBC.std().insets(0, 5, 0, 0));
    380382        buttonPanel.add(defaultSet, GBC.std().insets(5, 5, 5, 0));
     
    382384        buttonPanel.add(remove, GBC.std().insets(0, 5, 0, 0));
    383385
    384         createPreferenceTabWithScrollPane(gui, panel);
     386        getTabPane().addTab(tr("Colors"), panel);
     387        super.addGui(gui);
    385388    }
    386389
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/DisplayPreference.java

    r17311 r17314  
    55import static org.openstreetmap.josm.tools.I18n.trc;
    66
    7 import javax.swing.JTabbedPane;
    8 
    97import org.openstreetmap.josm.gui.help.HelpUtil;
    10 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
     8import org.openstreetmap.josm.gui.preferences.ExtensibleTabPreferenceSetting;
    119import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    1210import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    13 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    14 import org.openstreetmap.josm.tools.GBC;
    1511
    1612/**
     
    1814 * @since 4969
    1915 */
    20 public final class DisplayPreference extends DefaultTabPreferenceSetting {
     16public final class DisplayPreference extends ExtensibleTabPreferenceSetting {
    2117
    2218    /**
     
    3228    private DisplayPreference() {
    3329        super(/* ICON(preferences/) */ "display", trc("gui", "Display"),
    34                 tr("Various settings that influence the visual representation of the whole program."), false, new JTabbedPane());
     30                tr("Various settings that influence the visual representation of the whole program."), false);
    3531    }
    3632
     
    3834    public boolean ok() {
    3935        return false;
    40     }
    41 
    42     @Override
    43     public void addGui(PreferenceTabbedPane gui) {
    44         gui.createPreferenceTab(this).add(getTabPane(), GBC.eol().fill(GBC.BOTH));
    4536    }
    4637
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java

    r17227 r17314  
    22package org.openstreetmap.josm.gui.preferences.imagery;
    33
     4import static java.awt.GridBagConstraints.BOTH;
     5import static java.awt.GridBagConstraints.HORIZONTAL;
    46import static org.openstreetmap.josm.tools.I18n.tr;
    57
     
    911import java.awt.Font;
    1012import java.awt.GraphicsEnvironment;
    11 import java.awt.GridBagConstraints;
    1213import java.awt.GridBagLayout;
    1314import java.awt.event.MouseEvent;
     
    3637import org.openstreetmap.josm.gui.download.DownloadDialog;
    3738import org.openstreetmap.josm.gui.help.HelpUtil;
    38 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
     39import org.openstreetmap.josm.gui.preferences.ExtensibleTabPreferenceSetting;
    3940import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    4041import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     
    5051 * @since 3715
    5152 */
    52 public final class ImageryPreference extends DefaultTabPreferenceSetting {
     53public final class ImageryPreference extends ExtensibleTabPreferenceSetting {
    5354
    5455    private ImageryProvidersPanel imageryProviders;
     
    7273    private ImageryPreference() {
    7374        super(/* ICON(preferences/) */ "imagery", tr("Imagery"),
    74                 tr("Modify list of imagery layers displayed in the Imagery menu"),
    75                 false, new JTabbedPane());
     75                tr("Modify list of imagery layers displayed in the Imagery menu"), false);
    7676    }
    7777
     
    8585        lbl.setLabelFor(section);
    8686        p.add(lbl, GBC.std());
    87         p.add(new JSeparator(), GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 0));
     87        p.add(new JSeparator(), GBC.eol().fill(HORIZONTAL).insets(5, 0, 0, 0));
    8888        p.add(section, gbc.insets(20, 5, 0, 10));
    8989    }
     
    9494
    9595        addSettingsSection(p, tr("Common Settings"), commonSettings);
    96         addSettingsSection(p, tr("WMS Settings"), wmsSettings,
    97                 GBC.eol().fill(GBC.HORIZONTAL));
    98         addSettingsSection(p, tr("TMS Settings"), tmsSettings,
    99                 GBC.eol().fill(GBC.HORIZONTAL));
    100 
    101         p.add(new JPanel(), GBC.eol().fill(GBC.BOTH));
     96        addSettingsSection(p, tr("WMS Settings"), wmsSettings, GBC.eol().fill(HORIZONTAL));
     97        addSettingsSection(p, tr("TMS Settings"), tmsSettings, GBC.eol().fill(HORIZONTAL));
     98
     99        p.add(new JPanel(), GBC.eol().fill(BOTH));
    102100        return GuiHelper.setDefaultIncrement(new JScrollPane(p));
    103101    }
    104102
    105103    @Override
    106     public void addGui(final PreferenceTabbedPane gui) {
    107         JPanel p = gui.createPreferenceTab(this);
     104    public void addGui(PreferenceTabbedPane gui) {
    108105        JTabbedPane pane = getTabPane();
    109106        layerInfo = new ImageryLayerInfo(ImageryLayerInfo.instance);
     
    114111        pane.addTab(tr("Cache"), cacheSettingsPanel);
    115112        loadSettings();
    116         p.add(pane, GBC.std().fill(GBC.BOTH));
     113        super.addGui(gui);
    117114    }
    118115
     
    202199            TableHelper.setFont(list, getClass());
    203200            JScrollPane scroll = new JScrollPane(list);
    204             add(scroll, GBC.eol().fill(GridBagConstraints.BOTH));
     201            add(scroll, GBC.eol().fill(BOTH));
    205202            scroll.setPreferredSize(new Dimension(200, 200));
    206203
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPreference.java

    r17229 r17314  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import javax.swing.JTabbedPane;
    7 
    86import org.openstreetmap.josm.gui.help.HelpUtil;
    9 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
     7import org.openstreetmap.josm.gui.preferences.ExtensibleTabPreferenceSetting;
    108import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    119import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    12 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    13 import org.openstreetmap.josm.tools.GBC;
    1410
    1511/**
    1612 * Map preferences, including map paint styles, tagging presets and autosave sub-preferences.
    1713 */
    18 public final class MapPreference extends DefaultTabPreferenceSetting {
     14public final class MapPreference extends ExtensibleTabPreferenceSetting {
    1915
    2016    /**
     
    3026    private MapPreference() {
    3127        super(/* ICON(preferences/) */ "map", tr("Map"),
    32                 tr("Settings for the map projection and data interpretation."), false, new JTabbedPane());
     28                tr("Settings for the map projection and data interpretation."), false);
    3329    }
    3430
     
    3632    public boolean ok() {
    3733        return false;
    38     }
    39 
    40     @Override
    41     public void addGui(PreferenceTabbedPane gui) {
    42         gui.createPreferenceTab(this).add(getTabPane(), GBC.eol().fill(GBC.BOTH));
    4334    }
    4435
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java

    r17036 r17314  
    22package org.openstreetmap.josm.gui.preferences.plugin;
    33
     4import static java.awt.GridBagConstraints.HORIZONTAL;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56import static org.openstreetmap.josm.tools.I18n.trc;
     
    5051import org.openstreetmap.josm.gui.MainApplication;
    5152import org.openstreetmap.josm.gui.help.HelpUtil;
    52 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
     53import org.openstreetmap.josm.gui.preferences.ExtensibleTabPreferenceSetting;
    5354import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    5455import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    5556import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    56 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.PreferencePanel;
    5757import org.openstreetmap.josm.gui.util.GuiHelper;
    5858import org.openstreetmap.josm.gui.widgets.FilterField;
     
    7171 * @since 168
    7272 */
    73 public final class PluginPreference extends DefaultTabPreferenceSetting {
     73public final class PluginPreference extends ExtensibleTabPreferenceSetting {
    7474
    7575    /**
     
    9494
    9595    private PluginPreference() {
    96         super(/* ICON(preferences/) */ "plugin", tr("Plugins"), tr("Configure available plugins."), false, new JTabbedPane());
     96        super(/* ICON(preferences/) */ "plugin", tr("Plugins"), tr("Configure available plugins."), false);
    9797    }
    9898
     
    247247    }
    248248
    249     private JTabbedPane buildContentPane() {
     249    @Override
     250    public void addGui(final PreferenceTabbedPane gui) {
    250251        JTabbedPane pane = getTabPane();
    251252        pnlPluginUpdatePolicy = new PluginUpdatePolicyPanel();
    252253        pane.addTab(tr("Plugins"), buildPluginListPanel());
    253254        pane.addTab(tr("Plugin update policy"), pnlPluginUpdatePolicy);
    254         return pane;
    255     }
    256 
    257     @Override
    258     public void addGui(final PreferenceTabbedPane gui) {
    259         GridBagConstraints gc = new GridBagConstraints();
    260         gc.weightx = 1.0;
    261         gc.weighty = 1.0;
    262         gc.anchor = GridBagConstraints.NORTHWEST;
    263         gc.fill = GridBagConstraints.BOTH;
    264         PreferencePanel plugins = gui.createPreferenceTab(this);
    265         plugins.add(buildContentPane(), gc);
     255        super.addGui(gui);
    266256        readLocalPluginInformation();
    267257        pluginPreferencesActivated = true;
     
    585575                    }
    586576                }
    587             }), GBC.eol().fill(GBC.HORIZONTAL));
     577            }), GBC.eol().fill(HORIZONTAL));
    588578            buttons.add(new JButton(new AbstractAction(tr("Edit")) {
    589579                @Override
     
    611601                    }
    612602                }
    613             }), GBC.eol().fill(GBC.HORIZONTAL));
     603            }), GBC.eol().fill(HORIZONTAL));
    614604            buttons.add(new JButton(new AbstractAction(tr("Delete")) {
    615605                @Override
     
    626616                    model.removeElement(list.getSelectedValue());
    627617                }
    628             }), GBC.eol().fill(GBC.HORIZONTAL));
     618            }), GBC.eol().fill(HORIZONTAL));
    629619            add(buttons, GBC.eol());
    630620        }
  • trunk/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorPreference.java

    r13431 r17314  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import javax.swing.JTabbedPane;
    7 
    86import org.openstreetmap.josm.gui.help.HelpUtil;
    9 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
     7import org.openstreetmap.josm.gui.preferences.ExtensibleTabPreferenceSetting;
    108import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    119import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    12 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    13 import org.openstreetmap.josm.tools.GBC;
    1410
    1511/**
     
    1814 * @author frsantos
    1915 */
    20 public final class ValidatorPreference extends DefaultTabPreferenceSetting {
     16public final class ValidatorPreference extends ExtensibleTabPreferenceSetting {
    2117
    2218    /**
     
    3228    private ValidatorPreference() {
    3329        super(/* ICON(preferences/) */ "validator", tr("Data validator"),
    34                 tr("An OSM data validator that checks for common errors made by users and editor programs."),
    35                 false, new JTabbedPane());
    36     }
    37 
    38     @Override
    39     public void addGui(PreferenceTabbedPane gui) {
    40         gui.createPreferenceTab(this).add(getTabPane(), GBC.eol().fill(GBC.BOTH));
     30                tr("An OSM data validator that checks for common errors made by users and editor programs."), false);
    4131    }
    4232
Note: See TracChangeset for help on using the changeset viewer.