Changeset 4968 in josm


Ignore:
Timestamp:
2012-02-17T22:27:06+01:00 (8 years ago)
Author:
Don-vip
Message:

fix #7386 - Major rework of preferences GUI settings in order to speed up preferences dialog startup time. The building of each preferences tab is delayed until this tab is selected. Plugins that use preferences will need to make some (minor) changes.

Location:
trunk/src/org/openstreetmap/josm
Files:
8 added
20 edited
13 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r4932 r4968  
    6666import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    6767import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener;
    68 import org.openstreetmap.josm.gui.preferences.ImageryPreference;
    69 import org.openstreetmap.josm.gui.preferences.MapPaintPreference;
    70 import org.openstreetmap.josm.gui.preferences.ProjectionPreference;
    71 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference;
    7268import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
     69import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference;
     70import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference;
     71import org.openstreetmap.josm.gui.preferences.map.ProjectionPreference;
     72import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
    7373import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
    7474import org.openstreetmap.josm.gui.progress.ProgressMonitorExecutor;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java

    r4874 r4968  
    1818import org.openstreetmap.josm.data.validation.Test;
    1919import org.openstreetmap.josm.data.validation.TestError;
    20 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference;
     20import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
    2121import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    2222import org.openstreetmap.josm.gui.tagging.TaggingPreset.PresetType;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r4869 r4968  
    5353import org.openstreetmap.josm.data.validation.TestError;
    5454import org.openstreetmap.josm.data.validation.util.Entities;
    55 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference;
    5655import org.openstreetmap.josm.gui.preferences.ValidatorPreference;
     56import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
    5757import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    5858import org.openstreetmap.josm.gui.tagging.TaggingPreset;
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r4897 r4968  
    4242import org.openstreetmap.josm.data.projection.Projections;
    4343import org.openstreetmap.josm.gui.help.Helpful;
    44 import org.openstreetmap.josm.gui.preferences.ProjectionPreference;
     44import org.openstreetmap.josm.gui.preferences.map.ProjectionPreference;
    4545import org.openstreetmap.josm.tools.Predicate;
    4646
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PresetListPanel.java

    r4407 r4968  
    2222import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2323import org.openstreetmap.josm.data.osm.Tag;
    24 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference;
     24import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
    2525import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    2626import org.openstreetmap.josm.gui.tagging.TaggingPreset.Check;
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r4872 r4968  
    8989import org.openstreetmap.josm.gui.layer.markerlayer.AudioMarker;
    9090import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    91 import org.openstreetmap.josm.gui.preferences.GPXSettingsPanel;
     91import org.openstreetmap.josm.gui.preferences.display.GPXSettingsPanel;
    9292import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    9393import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r4960 r4968  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.Dimension;
    76import java.io.IOException;
    87import java.io.InputStream;
     
    2221import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    2322import org.openstreetmap.josm.gui.mappaint.xml.XmlStyleSource;
    24 import org.openstreetmap.josm.gui.preferences.MapPaintPreference.MapPaintPrefHelper;
     23import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference.MapPaintPrefHelper;
    2524import org.openstreetmap.josm.gui.preferences.SourceEntry;
    2625import org.openstreetmap.josm.gui.progress.ProgressMonitor;
  • trunk/src/org/openstreetmap/josm/gui/preferences/AudioPreference.java

    r4282 r4968  
    1010
    1111import org.openstreetmap.josm.Main;
     12import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.PreferencePanel;
    1213import org.openstreetmap.josm.tools.GBC;
    1314
     
    2425 */
    2526
    26 public class AudioPreference implements PreferenceSetting {
     27public class AudioPreference extends DefaultTabPreferenceSetting {
    2728
    2829    public static class Factory implements PreferenceSettingFactory {
     
    3031            return new AudioPreference();
    3132        }
     33    }
     34   
     35    private AudioPreference() {
     36        super("audio", tr("Audio Settings"), tr("Settings for the audio player and audio markers."));
    3237    }
    3338
     
    4954
    5055    public void addGui(PreferenceTabbedPane gui) {
     56        PreferencePanel audio = gui.createPreferenceTab(this);
     57       
    5158        // audioMenuVisible
    5259        audioMenuVisible.setSelected(! Main.pref.getBoolean("audio.menuinvisible"));
    5360        audioMenuVisible.setToolTipText(tr("Show or hide the audio menu entry on the main menu bar."));
    54         gui.audio.add(audioMenuVisible, GBC.eol().insets(0,0,0,0));
     61        audio.add(audioMenuVisible, GBC.eol().insets(0,0,0,0));
    5562
    5663        // audioTraceVisible
    5764        markerAudioTraceVisible.setSelected(Main.pref.getBoolean("marker.traceaudio", true));
    5865        markerAudioTraceVisible.setToolTipText(tr("Display a moving icon representing the point on the synchronized track where the audio currently playing was recorded."));
    59         gui.audio.add(markerAudioTraceVisible, GBC.eol().insets(0,0,0,0));
     66        audio.add(markerAudioTraceVisible, GBC.eol().insets(0,0,0,0));
    6067
    6168        // buttonLabels
    6269        markerButtonLabels.setSelected(Main.pref.getBoolean("marker.buttonlabels", true));
    6370        markerButtonLabels.setToolTipText(tr("Put text labels against audio (and image and web) markers as well as their button icons."));
    64         gui.audio.add(markerButtonLabels, GBC.eol().insets(0,0,0,0));
     71        audio.add(markerButtonLabels, GBC.eol().insets(0,0,0,0));
    6572
    66         gui.audio.add(new JLabel(tr("When importing audio, make markers from...")), GBC.eol());
     73        audio.add(new JLabel(tr("When importing audio, make markers from...")), GBC.eol());
    6774
    6875        // audioMarkersFromExplicitWaypoints
    6976        audioMarkersFromExplicitWaypoints.setSelected(Main.pref.getBoolean("marker.audiofromexplicitwaypoints", true));
    7077        audioMarkersFromExplicitWaypoints.setToolTipText(tr("When importing audio, apply it to any waypoints in the GPX layer."));
    71         gui.audio.add(audioMarkersFromExplicitWaypoints, GBC.eol().insets(10,0,0,0));
     78        audio.add(audioMarkersFromExplicitWaypoints, GBC.eol().insets(10,0,0,0));
    7279
    7380        // audioMarkersFromUntimedWaypoints
    7481        audioMarkersFromUntimedWaypoints.setSelected(Main.pref.getBoolean("marker.audiofromuntimedwaypoints", true));
    7582        audioMarkersFromUntimedWaypoints.setToolTipText(tr("When importing audio, apply it to any waypoints in the GPX layer."));
    76         gui.audio.add(audioMarkersFromUntimedWaypoints, GBC.eol().insets(10,0,0,0));
     83        audio.add(audioMarkersFromUntimedWaypoints, GBC.eol().insets(10,0,0,0));
    7784
    7885        // audioMarkersFromNamedTrackpoints
    7986        audioMarkersFromNamedTrackpoints.setSelected(Main.pref.getBoolean("marker.audiofromnamedtrackpoints", false));
    8087        audioMarkersFromNamedTrackpoints.setToolTipText(tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions."));
    81         gui.audio.add(audioMarkersFromNamedTrackpoints, GBC.eol().insets(10,0,0,0));
     88        audio.add(audioMarkersFromNamedTrackpoints, GBC.eol().insets(10,0,0,0));
    8289
    8390        // audioMarkersFromWavTimestamps
    8491        audioMarkersFromWavTimestamps.setSelected(Main.pref.getBoolean("marker.audiofromwavtimestamps", false));
    8592        audioMarkersFromWavTimestamps.setToolTipText(tr("Create audio markers at the position on the track corresponding to the modified time of each audio WAV file imported."));
    86         gui.audio.add(audioMarkersFromWavTimestamps, GBC.eol().insets(10,0,0,0));
     93        audio.add(audioMarkersFromWavTimestamps, GBC.eol().insets(10,0,0,0));
    8794
    8895        // audioMarkersFromStart
    8996        audioMarkersFromStart.setSelected(Main.pref.getBoolean("marker.audiofromstart"));
    9097        audioMarkersFromStart.setToolTipText(tr("Automatically create audio markers from trackpoints (rather than explicit waypoints) with names or descriptions."));
    91         gui.audio.add(audioMarkersFromStart, GBC.eol().insets(10,0,0,0));
     98        audio.add(audioMarkersFromStart, GBC.eol().insets(10,0,0,0));
    9299
    93100        audioForwardBackAmount.setText(Main.pref.get("audio.forwardbackamount", "10.0"));
    94101        audioForwardBackAmount.setToolTipText(tr("The number of seconds to jump forward or back when the relevant button is pressed"));
    95         gui.audio.add(new JLabel(tr("Forward/back time (seconds)")), GBC.std());
    96         gui.audio.add(audioForwardBackAmount, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
     102        audio.add(new JLabel(tr("Forward/back time (seconds)")), GBC.std());
     103        audio.add(audioForwardBackAmount, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    97104
    98105        audioFastForwardMultiplier.setText(Main.pref.get("audio.fastfwdmultiplier", "1.3"));
    99106        audioFastForwardMultiplier.setToolTipText(tr("The amount by which the speed is multiplied for fast forwarding"));
    100         gui.audio.add(new JLabel(tr("Fast forward multiplier")), GBC.std());
    101         gui.audio.add(audioFastForwardMultiplier, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
     107        audio.add(new JLabel(tr("Fast forward multiplier")), GBC.std());
     108        audio.add(audioFastForwardMultiplier, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    102109
    103110        audioLeadIn.setText(Main.pref.get("audio.leadin", "1.0"));
    104111        audioLeadIn.setToolTipText(tr("Playback starts this number of seconds before (or after, if negative) the audio track position requested"));
    105         gui.audio.add(new JLabel(tr("Lead-in time (seconds)")), GBC.std());
    106         gui.audio.add(audioLeadIn, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
     112        audio.add(new JLabel(tr("Lead-in time (seconds)")), GBC.std());
     113        audio.add(audioLeadIn, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    107114
    108115        audioCalibration.setText(Main.pref.get("audio.calibration", "1.0"));
    109116        audioCalibration.setToolTipText(tr("The ratio of voice recorder elapsed time to true elapsed time"));
    110         gui.audio.add(new JLabel(tr("Voice recorder calibration")), GBC.std());
    111         gui.audio.add(audioCalibration, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
     117        audio.add(new JLabel(tr("Voice recorder calibration")), GBC.std());
     118        audio.add(audioCalibration, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    112119
    113         gui.audio.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
     120        audio.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
    114121    }
    115122
  • trunk/src/org/openstreetmap/josm/gui/preferences/PluginPreference.java

    r4191 r4968  
    4343import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
    4444import org.openstreetmap.josm.gui.help.HelpUtil;
     45import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.PreferencePanel;
    4546import org.openstreetmap.josm.gui.preferences.plugin.PluginListPanel;
    4647import org.openstreetmap.josm.gui.preferences.plugin.PluginPreferencesModel;
     
    5455import org.openstreetmap.josm.tools.ImageProvider;
    5556
    56 public class PluginPreference implements PreferenceSetting {
     57public class PluginPreference extends DefaultTabPreferenceSetting {
    5758    public static class Factory implements PreferenceSettingFactory {
    5859        public PreferenceSetting createPreferenceSetting() {
    5960            return new PluginPreference();
    6061        }
     62    }
     63   
     64    private PluginPreference() {
     65        super("plugin", tr("Plugins"), tr("Configure available plugins."));
    6166    }
    6267
     
    178183        gc.anchor = GridBagConstraints.NORTHWEST;
    179184        gc.fill = GridBagConstraints.BOTH;
    180         gui.plugins.add(buildContentPanel(), gc);
     185        PreferencePanel plugins = gui.createPreferenceTab(this);
     186        plugins.add(buildContentPanel(), gc);
    181187        pnlPluginPreferences.refreshView();
    182         gui.addChangeListener(new PluginPreferenceActivationListener(gui.plugins));
     188        gui.addChangeListener(new PluginPreferenceActivationListener(plugins));
    183189    }
    184190
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java

    r4913 r4968  
    3232import org.openstreetmap.josm.gui.help.HelpUtil;
    3333import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.ValidationListener;
     34import org.openstreetmap.josm.gui.preferences.map.MapPreference;
    3435import org.openstreetmap.josm.tools.GBC;
    3536import org.openstreetmap.josm.tools.ImageProvider;
     
    167168
    168169    public void selectMapPaintPreferenceTab() {
    169         tpPreferences.setSelectedComponent(tpPreferences.map);
    170         tpPreferences.mapcontent.setSelectedIndex(1);
     170        tpPreferences.selectTabByPref(MapPreference.class);
     171        tpPreferences.getMapPreference().mapcontent.setSelectedIndex(1);
    171172    }
    172173}
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceSetting.java

    r2745 r4968  
    1414     */
    1515    boolean ok();
     16   
     17    /**
     18     * Called to know if the preferences tab has only to be displayed in expert mode.
     19     * @return true if the tab has only to be displayed in expert mode, false otherwise.
     20     */
     21    public boolean isExpert();
    1622}
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java

    r4874 r4968  
    77import java.awt.Font;
    88import java.awt.GridBagLayout;
    9 import java.awt.ScrollPane;
    109import java.awt.event.MouseWheelEvent;
    1110import java.awt.event.MouseWheelListener;
    1211import java.util.ArrayList;
    1312import java.util.Collection;
    14 import java.util.Iterator;
    1513import java.util.LinkedList;
    1614import java.util.List;
    1715
    1816import javax.swing.BorderFactory;
    19 import javax.swing.JComponent;
     17import javax.swing.Icon;
     18import javax.swing.ImageIcon;
    2019import javax.swing.JLabel;
    2120import javax.swing.JOptionPane;
     
    2423import javax.swing.JTabbedPane;
    2524import javax.swing.SwingUtilities;
     25import javax.swing.event.ChangeEvent;
     26import javax.swing.event.ChangeListener;
    2627
    2728import org.openstreetmap.josm.Main;
     
    2930import org.openstreetmap.josm.actions.ExpertToggleAction.ExpertModeChangeListener;
    3031import org.openstreetmap.josm.gui.preferences.advanced.AdvancedPreference;
     32import org.openstreetmap.josm.gui.preferences.display.ColorPreference;
     33import org.openstreetmap.josm.gui.preferences.display.DisplayPreference;
     34import org.openstreetmap.josm.gui.preferences.display.DrawingPreference;
     35import org.openstreetmap.josm.gui.preferences.display.LafPreference;
     36import org.openstreetmap.josm.gui.preferences.display.LanguagePreference;
     37import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference;
     38import org.openstreetmap.josm.gui.preferences.map.BackupPreference;
     39import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference;
     40import org.openstreetmap.josm.gui.preferences.map.MapPreference;
     41import org.openstreetmap.josm.gui.preferences.map.ProjectionPreference;
     42import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
     43import org.openstreetmap.josm.gui.preferences.shortcut.ShortcutPreference;
    3144import org.openstreetmap.josm.plugins.PluginDownloadTask;
    3245import org.openstreetmap.josm.plugins.PluginHandler;
    3346import org.openstreetmap.josm.plugins.PluginInformation;
    3447import org.openstreetmap.josm.tools.BugReportExceptionHandler;
     48import org.openstreetmap.josm.tools.CheckParameterUtil;
    3549import org.openstreetmap.josm.tools.GBC;
    36 import org.openstreetmap.josm.tools.I18n;
    3750import org.openstreetmap.josm.tools.ImageProvider;
    3851
     
    4255 * @author imi
    4356 */
    44 public class PreferenceTabbedPane extends JTabbedPane implements MouseWheelListener, ExpertModeChangeListener {
     57public class PreferenceTabbedPane extends JTabbedPane implements MouseWheelListener, ExpertModeChangeListener, ChangeListener {
    4558    /**
    4659     * Allows PreferenceSettings to do validation of entered values when ok was pressed.
     
    5568        boolean validatePreferences();
    5669    }
    57 
    58     private static class TabData {
    59         public String icon;
    60         public JComponent tab;
    61         public String toolTip;
    62         public boolean isExpert;
     70   
     71    private static interface PreferenceTab {
     72        public TabPreferenceSetting getTabPreferenceSetting();
     73        public Component getComponent();
     74    }
     75   
     76    public static class PreferencePanel extends JPanel implements PreferenceTab {
     77        private final TabPreferenceSetting preferenceSetting;
     78
     79        private PreferencePanel(TabPreferenceSetting preferenceSetting) {
     80            super(new GridBagLayout());
     81            CheckParameterUtil.ensureParameterNotNull(preferenceSetting);
     82            this.preferenceSetting = preferenceSetting;
     83            buildPanel();
     84        }
     85       
     86        protected void buildPanel() {
     87            setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     88            add(new JLabel(preferenceSetting.getTitle()), GBC.eol().insets(0,5,0,10).anchor(GBC.NORTHWEST));
     89
     90            JLabel descLabel = new JLabel("<html>"+preferenceSetting.getDescription()+"</html>");
     91            descLabel.setFont(descLabel.getFont().deriveFont(Font.ITALIC));
     92            add(descLabel, GBC.eol().insets(5,0,5,20).fill(GBC.HORIZONTAL));
     93        }
     94
     95        @Override
     96        public final TabPreferenceSetting getTabPreferenceSetting() {
     97            return preferenceSetting;
     98        }
     99
     100        @Override
     101        public Component getComponent() {
     102            return this;
     103        }
     104    }
     105
     106    public static class PreferenceScrollPane extends JScrollPane implements PreferenceTab {
     107        private final TabPreferenceSetting preferenceSetting;
     108
     109        private PreferenceScrollPane(Component view, TabPreferenceSetting preferenceSetting) {
     110            super(view);
     111            this.preferenceSetting = preferenceSetting;
     112        }
     113
     114        private PreferenceScrollPane(PreferencePanel preferencePanel) {
     115            super(preferencePanel.getComponent());
     116            this.preferenceSetting = preferencePanel.getTabPreferenceSetting();
     117        }
     118
     119        @Override
     120        public final TabPreferenceSetting getTabPreferenceSetting() {
     121            return preferenceSetting;
     122        }
     123
     124        @Override
     125        public Component getComponent() {
     126            return this;
     127        }
    63128    }
    64129
    65130    // all created tabs
    66     private final List<TabData> tabs = new ArrayList<TabData>();
     131    private final List<PreferenceTab> tabs = new ArrayList<PreferenceTab>();
    67132    private final static Collection<PreferenceSettingFactory> settingsFactory = new LinkedList<PreferenceSettingFactory>();
    68133    private final List<PreferenceSetting> settings = new ArrayList<PreferenceSetting>();
    69 
    70     // some common tabs
    71     public final JPanel display = createPreferenceTab("display", tr("Display Settings"), tr("Various settings that influence the visual representation of the whole program."));
    72     public final JPanel connection = createPreferenceTab("connection", I18n.tr("Connection Settings"), I18n.tr("Connection Settings for the OSM server."),false);
    73     public final JPanel map = createPreferenceTab("map", I18n.tr("Map Settings"), I18n.tr("Settings for the map projection and data interpretation."));
    74     public final JPanel audio = createPreferenceTab("audio", I18n.tr("Audio Settings"), I18n.tr("Settings for the audio player and audio markers."));
    75     public final JPanel plugins = createPreferenceTab("plugin", tr("Plugins"), tr("Configure available plugins."), false);
    76 
    77     public final javax.swing.JTabbedPane displaycontent = new javax.swing.JTabbedPane();
    78     public final javax.swing.JTabbedPane mapcontent = new javax.swing.JTabbedPane();
     134   
     135    // distinct list of tabs that have been initialized (we do not initialize tabs until they are displayed to speed up dialog startup)
     136    private final List<PreferenceSetting> settingsInitialized = new ArrayList<PreferenceSetting>();
    79137
    80138    List<ValidationListener> validationListeners = new ArrayList<ValidationListener>();
     
    90148
    91149    /**
    92      * Construct a JPanel for the preference settings. Layout is GridBagLayout
    93      * and a centered title label and the description are added. The panel
    94      * will be shown inside a {@link ScrollPane}
    95      * @param icon The name of the icon.
    96      * @param title The title of this preference tab.
    97      * @param desc A description in one sentence for this tab. Will be displayed
    98      *      italic under the title.
     150     * Construct a PreferencePanel for the preference settings. Layout is GridBagLayout
     151     * and a centered title label and the description are added.
    99152     * @return The created panel ready to add other controls.
    100153     */
    101     public JPanel createPreferenceTab(String icon, String title, String desc) {
    102         return createPreferenceTab(icon, title, desc, false);
    103     }
    104 
    105     public JPanel createPreferenceTab(String icon, String title, String desc, boolean inScrollPane) {
    106         return createPreferenceTab(icon, title, desc, inScrollPane, false);
    107     }
    108 
    109     /**
    110      * Construct a JPanel for the preference settings. Layout is GridBagLayout
     154    public PreferencePanel createPreferenceTab(TabPreferenceSetting caller) {
     155        return createPreferenceTab(caller, false);
     156    }
     157
     158    /**
     159     * Construct a PreferencePanel for the preference settings. Layout is GridBagLayout
    111160     * and a centered title label and the description are added.
    112      * @param icon The name of the icon.
    113      * @param title The title of this preference tab.
    114      * @param desc A description in one sentence for this tab. Will be displayed
    115      *      italic under the title.
    116161     * @param inScrollPane if <code>true</code> the added tab will show scroll bars
    117162     *        if the panel content is larger than the available space
    118163     * @return The created panel ready to add other controls.
    119164     */
    120     public JPanel createPreferenceTab(String icon, String title, String desc, boolean inScrollPane, boolean isExpert) {
    121         JPanel p = new JPanel(new GridBagLayout());
    122         p.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    123         p.add(new JLabel(title), GBC.eol().insets(0,5,0,10).anchor(GBC.NORTHWEST));
    124 
    125         JLabel descLabel = new JLabel("<html>"+desc+"</html>");
    126         descLabel.setFont(descLabel.getFont().deriveFont(Font.ITALIC));
    127         p.add(descLabel, GBC.eol().insets(5,0,5,20).fill(GBC.HORIZONTAL));
    128 
    129         JComponent tab = p;
     165    public PreferencePanel createPreferenceTab(TabPreferenceSetting caller, boolean inScrollPane) {
     166        CheckParameterUtil.ensureParameterNotNull(caller);
     167        PreferencePanel p = new PreferencePanel(caller);
     168
     169        PreferenceTab tab = p;
    130170        if (inScrollPane) {
    131             JScrollPane sp = new JScrollPane(p);
     171            PreferenceScrollPane sp = new PreferenceScrollPane(p);
    132172            tab = sp;
    133173        }
    134         TabData data = new TabData();
    135         data.icon = icon;
    136         data.tab = tab;
    137         data.isExpert = isExpert;
    138         data.toolTip = "<html>"+desc+"</html>";
    139         tabs.add(data);
     174        tabs.add(tab);
    140175        return p;
    141176    }
    142177
     178    private static interface TabIdentifier {
     179        public boolean identify(TabPreferenceSetting tps, Object param);
     180    }
     181   
     182    private void selectTabBy(TabIdentifier method, Object param) {
     183        for (int i=0; i<getTabCount(); i++) {
     184            Component c = getComponentAt(i);
     185            if (c instanceof PreferenceTab) {
     186                PreferenceTab tab = (PreferenceTab) c;
     187                if (method.identify(tab.getTabPreferenceSetting(), param)) {
     188                    setSelectedIndex(i);
     189                    return;
     190                }
     191            }
     192        }
     193    }
     194   
    143195    public void selectTabByName(String name) {
    144         for (TabData data : tabs) {
    145             if (data.icon.equals(name)) {
    146                 Component c = data.tab;
    147                 if (c != null) {
    148                     setSelectedComponent(c);
    149                 }
    150                 return;
    151             }
    152         }
    153     }
    154 
    155     protected PluginPreference getPluginPreference() {
    156         for (PreferenceSetting setting: settings) {
    157             if (setting instanceof PluginPreference)
    158                 return (PluginPreference) setting;
    159         }
    160         return null;
     196        selectTabBy(new TabIdentifier(){
     197            @Override
     198            public boolean identify(TabPreferenceSetting tps, Object name) {
     199                return tps.getIconName().equals(name);
     200            }}, name);
     201    }
     202
     203    public void selectTabByPref(Class<? extends TabPreferenceSetting> clazz) {
     204        selectTabBy(new TabIdentifier(){
     205            @Override
     206            public boolean identify(TabPreferenceSetting tps, Object clazz) {
     207                return tps.getClass().isAssignableFrom((Class<?>) clazz);
     208            }}, clazz);
     209    }
     210   
     211    public final DisplayPreference getDisplayPreference() {
     212        return getSetting(DisplayPreference.class);
     213    }
     214   
     215    public final MapPreference getMapPreference() {
     216        return getSetting(MapPreference.class);
     217    }
     218   
     219    public final PluginPreference getPluginPreference() {
     220        return getSetting(PluginPreference.class);
    161221    }
    162222
     
    248308        super(JTabbedPane.LEFT, JTabbedPane.SCROLL_TAB_LAYOUT);
    249309        super.addMouseWheelListener(this);
     310        super.getModel().addChangeListener(this);
    250311        ExpertToggleAction.addExpertModeChangeListener(this);
    251312    }
     
    258319            }
    259320        }
    260 
    261         display.add(displaycontent, GBC.eol().fill(GBC.BOTH));
    262         map.add(mapcontent, GBC.eol().fill(GBC.BOTH));
     321/*
    263322        for (Iterator<PreferenceSetting> it = settings.iterator(); it.hasNext();) {
    264323            try {
    265                 PreferenceSetting settings = it.next();
    266                 settings.addGui(this);
     324                PreferenceSetting ps = it.next();
     325                long start = System.currentTimeMillis();
     326                ps.addGui(this);
     327                System.out.println(ps.getClass()+" -> "+(System.currentTimeMillis()-start));
    267328            } catch (SecurityException e) {
    268329                it.remove();
    269330            } catch (Throwable e) {
    270                 /* allow to change most settings even if e.g. a plugin fails */
     331                // allow to change most settings even if e.g. a plugin fails
    271332                BugReportExceptionHandler.handleException(e);
    272333            }
    273         }
     334        }*/
    274335        addGUITabs(false);
    275336    }
    276337
     338    private void addGUITabsForSetting(Icon icon, TabPreferenceSetting tps) {
     339        for (PreferenceTab tab : tabs) {
     340            if (tab.getTabPreferenceSetting().equals(tps)) {
     341                insertGUITabsForSetting(icon, tps, getTabCount());
     342            }
     343        }
     344    }
     345   
     346    private void insertGUITabsForSetting(Icon icon, TabPreferenceSetting tps, int index) {
     347        int position = index;
     348        for (PreferenceTab tab : tabs) {
     349            if (tab.getTabPreferenceSetting().equals(tps)) {
     350                insertTab(null, icon, tab.getComponent(), tps.getTooltip(), position++);
     351            }
     352        }
     353    }
     354   
    277355    private void addGUITabs(boolean clear) {
    278356        boolean expert = ExpertToggleAction.isExpert();
     
    281359            removeAll();
    282360        }
    283         for (TabData data : tabs) {
    284             if (expert || !data.isExpert) {
    285                 addTab(null, ImageProvider.get("preferences", data.icon), data.tab, data.toolTip);
    286             }
    287         }
     361        // Inspect each tab setting
     362        for (PreferenceSetting setting : settings) {
     363            if (setting instanceof TabPreferenceSetting) {
     364                TabPreferenceSetting tps = (TabPreferenceSetting) setting;
     365                if (expert || !tps.isExpert()) {
     366                    // Get icon
     367                    ImageIcon icon = ImageProvider.get("preferences", tps.getIconName());
     368                    if (settingsInitialized.contains(tps)) {
     369                        // If it has been initialized, add corresponding tab(s)
     370                        addGUITabsForSetting(icon, tps);
     371                    } else {
     372                        // If it has not been initialized, create an empty tab with only icon and tooltip
     373                        addTab(null, icon, new PreferencePanel(tps), tps.getTooltip());
     374                    }
     375                }
     376            }
     377        }
     378        /*for (PreferenceTab tab : tabs) {
     379            TabPreferenceSetting s = tab.getTabPreferenceSetting();
     380            if (expert || !s.isExpert()) {
     381                addTab(null, ImageProvider.get("preferences", s.getIconName()), tab.getComponent(), "<html>"+s.getTooltip()+"</html>");
     382            }
     383        }*/
    288384        try {
    289             setSelectedComponent(sel);
     385            if (sel != null) {
     386                setSelectedComponent(sel);
     387            }
    290388        } catch (IllegalArgumentException e) {}
    291389    }
    292 
     390   
    293391    @Override
    294392    public void expertChanged(boolean isExpert) {
     
    311409    static {
    312410        // order is important!
     411        settingsFactory.add(new DisplayPreference.Factory());
    313412        settingsFactory.add(new DrawingPreference.Factory());
    314413        settingsFactory.add(new ColorPreference.Factory());
     
    316415        settingsFactory.add(new LanguagePreference.Factory());
    317416        settingsFactory.add(new ServerAccessPreference.Factory());
     417        settingsFactory.add(new MapPreference.Factory());
    318418        settingsFactory.add(new ProjectionPreference.Factory());
    319419        settingsFactory.add(new MapPaintPreference.Factory());
     
    355455        super.setSelectedIndex(newTab);
    356456    }
     457
     458    @Override
     459    public void stateChanged(ChangeEvent e) {
     460        int index = getSelectedIndex();
     461        Component sel = getSelectedComponent();
     462        if (index > -1 && sel instanceof PreferenceTab) {
     463            PreferenceTab tab = (PreferenceTab) sel;
     464            TabPreferenceSetting preferenceSettings = tab.getTabPreferenceSetting();
     465            //System.out.println(preferenceSettings);
     466            if (!settingsInitialized.contains(preferenceSettings)) {
     467                try {
     468                    //System.out.println("adding GUI for "+preferenceSettings);
     469                    getModel().removeChangeListener(this);
     470                    preferenceSettings.addGui(this);
     471                    // Add GUI for sub preferences
     472                    for (PreferenceSetting setting : settings) {
     473                        if (setting instanceof SubPreferenceSetting) {
     474                            SubPreferenceSetting sps = (SubPreferenceSetting) setting;
     475                            if (sps.getTabPreferenceSetting(this) == preferenceSettings) {
     476                                //System.out.println("adding GUI for "+sps);
     477                                sps.addGui(this);
     478                            }
     479                        }
     480                    }
     481                    Icon icon = getIconAt(index);
     482                    remove(index);
     483                    insertGUITabsForSetting(icon, preferenceSettings, index);
     484                    setSelectedIndex(index);
     485                } catch (SecurityException ex) {
     486                    ex.printStackTrace();
     487                } catch (Throwable ex) {
     488                    // allow to change most settings even if e.g. a plugin fails
     489                    BugReportExceptionHandler.handleException(ex);
     490                } finally {
     491                    settingsInitialized.add(preferenceSettings);
     492                    getModel().addChangeListener(this);
     493                }
     494            }
     495        }
     496    }
    357497}
  • trunk/src/org/openstreetmap/josm/gui/preferences/RemoteControlPreference.java

    r4883 r4968  
    3434 * @author Frederik Ramm
    3535 */
    36 public class RemoteControlPreference implements PreferenceSetting
     36public class RemoteControlPreference extends DefaultTabPreferenceSetting
    3737{
    3838    public static class Factory implements PreferenceSettingFactory {
     
    4141            return new RemoteControlPreference();
    4242        }
     43    }
     44   
     45    private RemoteControlPreference() {
     46        super("remotecontrol", tr("Remote Control"), tr("Settings for the remote control feature."));
    4347    }
    4448
     
    5761    public void addGui(final PreferenceTabbedPane gui) {
    5862
    59         JPanel remote = gui.createPreferenceTab("remotecontrol", tr("Remote Control"), tr("Settings for the remote control feature."));
     63        JPanel remote = gui.createPreferenceTab(this);
    6064
    6165        remote.add(enableRemoteControl = new JCheckBox(tr("Enable remote control"), RemoteControl.PROP_REMOTECONTROL_ENABLED.get()), GBC.eol());
  • trunk/src/org/openstreetmap/josm/gui/preferences/ServerAccessPreference.java

    r3463 r4968  
    1818import org.openstreetmap.josm.gui.preferences.server.ProxyPreferencesPanel;
    1919import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
    20 public class ServerAccessPreference implements PreferenceSetting {
     20public class ServerAccessPreference extends DefaultTabPreferenceSetting {
    2121
    2222    public static class Factory implements PreferenceSettingFactory {
     
    2424            return new ServerAccessPreference();
    2525        }
     26    }
     27   
     28    private ServerAccessPreference() {
     29        super("connection", tr("Connection Settings"), tr("Connection Settings for the OSM server."));
    2630    }
    2731
     
    109113        gc.weighty = 1.0;
    110114        gc.anchor = GridBagConstraints.NORTHWEST;
    111         gui.connection.add(buildContentPanel(), gc);
     115        gui.createPreferenceTab(this).add(buildContentPanel(), gc);
    112116
    113117        initFromPreferences();
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r4936 r4968  
    3232import java.util.EventObject;
    3333import java.util.Iterator;
    34 import java.util.LinkedList;
    3534import java.util.List;
    3635import java.util.concurrent.CopyOnWriteArrayList;
     
    372371     * Identifiers for strings that need to be provided.
    373372     */
    374     protected enum I18nString { AVAILABLE_SOURCES, ACTIVE_SOURCES, NEW_SOURCE_ENTRY_TOOLTIP, NEW_SOURCE_ENTRY,
     373    public enum I18nString { AVAILABLE_SOURCES, ACTIVE_SOURCES, NEW_SOURCE_ENTRY_TOOLTIP, NEW_SOURCE_ENTRY,
    375374        REMOVE_SOURCE_TOOLTIP, EDIT_SOURCE_TOOLTIP, ACTIVATE_TOOLTIP, RELOAD_ALL_AVAILABLE,
    376375        LOADING_SOURCES_FROM, FAILED_TO_LOAD_SOURCES_FROM, FAILED_TO_LOAD_SOURCES_FROM_HELP_TOPIC,
  • trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    r4613 r4968  
    410410    }
    411411
    412     public class Settings implements PreferenceSetting {
     412    public class Settings extends DefaultTabPreferenceSetting {
    413413
    414414        private final class Move implements ActionListener {
     
    497497
    498498        public Settings(DefaultMutableTreeNode rootActionsNode) {
     499            super("toolbar", tr("Toolbar customization"), tr("Customize the elements on the toolbar."));
    499500            actionsTreeModel = new DefaultTreeModel(rootActionsNode);
    500501            actionsTree = new JTree(actionsTreeModel);
     
    766767            actionParametersPanel.setVisible(false);
    767768
    768             JPanel panel = gui.createPreferenceTab("toolbar", tr("Toolbar customization"),
    769                     tr("Customize the elements on the toolbar."), false);
     769            JPanel panel = gui.createPreferenceTab(this);
    770770            panel.add(p, GBC.eol().fill(GBC.BOTH));
    771771            panel.add(actionParametersPanel, GBC.eol().fill(GBC.HORIZONTAL));
  • trunk/src/org/openstreetmap/josm/gui/preferences/ValidatorPreference.java

    r3944 r4968  
    2525 * @author frsantos
    2626 */
    27 public class ValidatorPreference implements PreferenceSetting {
     27public class ValidatorPreference extends DefaultTabPreferenceSetting {
    2828
    2929    public static class Factory implements PreferenceSettingFactory {
     
    3232            return new ValidatorPreference();
    3333        }
     34    }
     35   
     36    private ValidatorPreference() {
     37        super("validator", tr("Data validator"),
     38                tr("An OSM data validator that checks for common errors made by users and editor programs."));
    3439    }
    3540
     
    112117        testPane.setBorder(null);
    113118
    114         String description = tr("An OSM data validator that checks for common errors made by users and editor programs.");
    115         JPanel tab = gui.createPreferenceTab("validator", tr("Data validator"), description);
     119        JPanel tab = gui.createPreferenceTab(this);
    116120        tab.add(testPane, GBC.eol().fill(GBC.BOTH));
    117121        tab.add(GBC.glue(0,10), a);
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java

    r4965 r4968  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    2 package org.openstreetmap.josm.gui.preferences;
     2package org.openstreetmap.josm.gui.preferences.display;
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     
    4141import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    4242import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
     43import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     44import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     45import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     46import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
     47import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    4348import org.openstreetmap.josm.tools.ColorHelper;
    4449import org.openstreetmap.josm.tools.GBC;
    4550
    46 public class ColorPreference implements PreferenceSetting {
     51public class ColorPreference implements SubPreferenceSetting {
    4752
    4853    public static class Factory implements PreferenceSettingFactory {
     
    234239        buttonPanel.add(defaultAll, GBC.std().insets(0,5,0,0));
    235240        buttonPanel.add(remove, GBC.std().insets(0,5,0,0));
    236         gui.displaycontent.addTab(tr("Colors"), panel);
     241        gui.getDisplayPreference().displaycontent.addTab(tr("Colors"), panel);
    237242    }
    238243
     
    271276            }
    272277        }
    273         org.openstreetmap.josm.gui.layer.OsmDataLayer.createHatchTexture();
     278        OsmDataLayer.createHatchTexture();
    274279        return ret;
    275280    }
     281
     282    @Override
     283    public boolean isExpert() {
     284        return false;
     285    }
     286
     287    @Override
     288    public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
     289        return gui.getDisplayPreference();
     290    }
    276291}
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java

    r4965 r4968  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    2 package org.openstreetmap.josm.gui.preferences;
     2package org.openstreetmap.josm.gui.preferences.display;
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.Dimension;
    76import java.awt.GridBagLayout;
    87import java.awt.event.ActionEvent;
     
    1817import org.openstreetmap.josm.Main;
    1918import org.openstreetmap.josm.actions.ExpertToggleAction;
     19import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     20import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     21import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     22import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
     23import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    2024import org.openstreetmap.josm.tools.GBC;
    2125
    22 public class DrawingPreference implements PreferenceSetting {
     26public class DrawingPreference implements SubPreferenceSetting {
    2327
    2428    public static class Factory implements PreferenceSettingFactory {
     
    4448
    4549    public void addGui(PreferenceTabbedPane gui) {
    46         gui.display.setPreferredSize(new Dimension(400,600));
     50        //gui.display.setPreferredSize(new Dimension(400,600));
    4751        gpxPanel = new GPXSettingsPanel();
    4852        gui.addValidationListener(gpxPanel);
     
    5155        JScrollPane scrollpane = new JScrollPane(panel);
    5256        scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
    53         gui.displaycontent.addTab(tr("GPS Points"), scrollpane);
     57        gui.getDisplayPreference().displaycontent.addTab(tr("GPS Points"), scrollpane);
    5458        panel = new JPanel(new GridBagLayout());
    5559        panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     
    131135        scrollpane = new JScrollPane(panel);
    132136        scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
    133         gui.displaycontent.addTab(tr("OSM Data"), scrollpane);
     137        gui.getDisplayPreference().displaycontent.addTab(tr("OSM Data"), scrollpane);
    134138    }
    135139
     
    158162        return false;
    159163    }
     164
     165    @Override
     166    public boolean isExpert() {
     167        return false;
     168    }
     169
     170    @Override
     171    public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
     172        return gui.getDisplayPreference();
     173    }
    160174}
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java

    r4965 r4968  
    1 package org.openstreetmap.josm.gui.preferences;
     1package org.openstreetmap.josm.gui.preferences.display;
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java

    r4965 r4968  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    2 package org.openstreetmap.josm.gui.preferences;
     2package org.openstreetmap.josm.gui.preferences.display;
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     
    2222import org.openstreetmap.josm.Main;
    2323import org.openstreetmap.josm.actions.ExpertToggleAction;
     24import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     25import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     26import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     27import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
     28import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    2429import org.openstreetmap.josm.tools.GBC;
    2530
    26 public class LafPreference implements PreferenceSetting {
     31public class LafPreference implements SubPreferenceSetting {
    2732
    2833    public static class Factory implements PreferenceSettingFactory {
     
    111116        JScrollPane scrollpane = new JScrollPane(panel);
    112117        scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
    113         gui.displaycontent.addTab(tr("Look and Feel"), scrollpane);
     118        gui.getDisplayPreference().displaycontent.addTab(tr("Look and Feel"), scrollpane);
    114119    }
    115120
     
    124129        return mod;
    125130    }
     131
     132    @Override
     133    public boolean isExpert() {
     134        return false;
     135    }
     136
     137    @Override
     138    public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
     139        return gui.getDisplayPreference();
     140    }
    126141}
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/LanguagePreference.java

    r4965 r4968  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.preferences;
     2package org.openstreetmap.josm.gui.preferences.display;
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     
    2020
    2121import org.openstreetmap.josm.Main;
     22import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     23import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     24import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     25import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
     26import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    2227import org.openstreetmap.josm.tools.GBC;
    2328import org.openstreetmap.josm.tools.I18n;
    2429
    25 public class LanguagePreference implements PreferenceSetting {
     30public class LanguagePreference implements SubPreferenceSetting {
    2631    public static class Factory implements PreferenceSettingFactory {
    2732        public PreferenceSetting createPreferenceSetting() {
     
    107112        }
    108113    }
     114
     115    @Override
     116    public boolean isExpert() {
     117        return false;
     118    }
     119
     120    @Override
     121    public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
     122        return gui.getDisplayPreference();
     123    }
    109124}
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMSLayerPanel.java

    r4965 r4968  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.preferences;
     2package org.openstreetmap.josm.gui.preferences.imagery;
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java

    r4965 r4968  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.preferences;
     2package org.openstreetmap.josm.gui.preferences.imagery;
    33
    44import static org.openstreetmap.josm.tools.I18n.marktr;
     
    7676import org.openstreetmap.josm.gui.layer.TMSLayer;
    7777import org.openstreetmap.josm.gui.layer.WMSLayer;
     78import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
     79import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     80import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     81import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    7882import org.openstreetmap.josm.io.imagery.HTMLGrabber;
    7983import org.openstreetmap.josm.io.imagery.OffsetServer;
     
    8387import org.openstreetmap.josm.tools.ImageProvider;
    8488
    85 public class ImageryPreference implements PreferenceSetting {
     89public class ImageryPreference extends DefaultTabPreferenceSetting {
    8690    public static class Factory implements PreferenceSettingFactory {
    8791        @Override
     
    9094        }
    9195    }
     96   
     97    private ImageryPreference() {
     98        super("imagery", tr("Imagery Preferences"), tr("Modify list of imagery layers displayed in the Imagery menu"));
     99    }
     100   
    92101    private ImageryProvidersPanel imageryProviders;
    93102    private ImageryLayerInfo layerInfo;
     
    269278    @Override
    270279    public void addGui(final PreferenceTabbedPane gui) {
    271         JPanel p = gui.createPreferenceTab("imagery", tr("Imagery Preferences"), tr("Modify list of imagery layers displayed in the Imagery menu"));
     280        JPanel p = gui.createPreferenceTab(this);
    272281        JTabbedPane pane = new JTabbedPane();
    273282        layerInfo = new ImageryLayerInfo(ImageryLayerInfo.instance);
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/BackupPreference.java

    r4965 r4968  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.preferences;
     2package org.openstreetmap.josm.gui.preferences.map;
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     
    1919import org.openstreetmap.josm.data.AutosaveTask;
    2020import org.openstreetmap.josm.data.preferences.BooleanProperty;
     21import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     22import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     23import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
     24import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    2125import org.openstreetmap.josm.gui.widgets.HtmlPanel;
    2226import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
    2327import org.openstreetmap.josm.tools.GBC;
    2428
    25 public class BackupPreference implements PreferenceSetting {
     29public class BackupPreference implements SubPreferenceSetting {
    2630
    2731    public static class Factory implements PreferenceSettingFactory {
     
    97101        sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    98102
    99         gui.mapcontent.addTab(tr("File backup"), null, sp, tr("Configure whether to create backup files"));
     103        gui.getMapPreference().mapcontent.addTab(tr("File backup"), null, sp, tr("Configure whether to create backup files"));
    100104    }
    101105
     
    110114        return restartRequired;
    111115    }
     116
     117    @Override
     118    public boolean isExpert() {
     119        return false;
     120    }
     121
     122    @Override
     123    public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
     124        return gui.getMapPreference();
     125    }
    112126}
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java

    r4965 r4968  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    2 package org.openstreetmap.josm.gui.preferences;
     2package org.openstreetmap.josm.gui.preferences.map;
    33
    44import static org.openstreetmap.josm.tools.I18n.marktr;
     
    2020import org.openstreetmap.josm.Main;
    2121import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     22import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     23import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     24import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     25import org.openstreetmap.josm.gui.preferences.SourceEditor;
     26import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    2227import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry;
     28import org.openstreetmap.josm.gui.preferences.SourceEntry;
     29import org.openstreetmap.josm.gui.preferences.SourceProvider;
     30import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    2331import org.openstreetmap.josm.tools.GBC;
    2432import org.openstreetmap.josm.tools.Predicate;
    2533import org.openstreetmap.josm.tools.Utils;
    2634
    27 public class MapPaintPreference implements PreferenceSetting {
     35public class MapPaintPreference implements SubPreferenceSetting {
    2836    private SourceEditor sources;
    2937    private JCheckBox enableIconDefault;
     
    5563        panel.add(enableIconDefault, GBC.eol().insets(11,2,5,0));
    5664
    57         gui.mapcontent.addTab(tr("Map Paint Styles"), panel);
     65        gui.getMapPreference().mapcontent.addTab(tr("Map Paint Styles"), panel);
    5866
    5967        // this defers loading of style sources to the first time the tab
    6068        // with the map paint preferences is selected by the user
    6169        //
    62         gui.mapcontent.addChangeListener(
     70        gui.getMapPreference().mapcontent.addChangeListener(
    6371                new ChangeListener() {
    6472                    public void stateChanged(ChangeEvent e) {
    65                         if (gui.mapcontent.getSelectedComponent() == panel) {
     73                        if (gui.getMapPreference().mapcontent.getSelectedComponent() == panel) {
    6674                            sources.initiallyLoadAvailableSources();
    6775                        }
     
    263271        }
    264272    }
     273
     274    @Override
     275    public boolean isExpert() {
     276        return false;
     277    }
     278
     279    @Override
     280    public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
     281        return gui.getMapPreference();
     282    }
    265283}
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/ProjectionPreference.java

    r4965 r4968  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    2 package org.openstreetmap.josm.gui.preferences;
     2package org.openstreetmap.josm.gui.preferences.map;
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     
    2929import org.openstreetmap.josm.data.projection.Projections;
    3030import org.openstreetmap.josm.gui.NavigatableComponent;
     31import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     32import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     33import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     34import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
     35import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    3136import org.openstreetmap.josm.plugins.PluginHandler;
    3237import org.openstreetmap.josm.tools.GBC;
    3338
    34 public class ProjectionPreference implements PreferenceSetting {
     39public class ProjectionPreference implements SubPreferenceSetting {
    3540
    3641    public static class Factory implements PreferenceSettingFactory {
     
    136141
    137142        JScrollPane scrollpane = new JScrollPane(projPanel);
    138         gui.mapcontent.addTab(tr("Map Projection"), scrollpane);
     143        gui.getMapPreference().mapcontent.addTab(tr("Map Projection"), scrollpane);
    139144
    140145        updateMeta(Main.getProjection());
     
    288293        });
    289294    }
     295
     296    @Override
     297    public boolean isExpert() {
     298        return false;
     299    }
     300
     301    @Override
     302    public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
     303        return gui.getMapPreference();
     304    }
    290305}
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreference.java

    r4965 r4968  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    2 package org.openstreetmap.josm.gui.preferences;
     2package org.openstreetmap.josm.gui.preferences.map;
    33
    44import static org.openstreetmap.josm.tools.I18n.marktr;
     
    1212import java.util.Collections;
    1313import java.util.HashMap;
    14 import java.util.Iterator;
    1514import java.util.List;
    1615
     
    2827import org.openstreetmap.josm.Main;
    2928import org.openstreetmap.josm.gui.ExtendedDialog;
     29import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     30import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     31import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     32import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    3033import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.ValidationListener;
     34import org.openstreetmap.josm.gui.preferences.SourceEditor;
    3135import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry;
     36import org.openstreetmap.josm.gui.preferences.SourceEntry;
     37import org.openstreetmap.josm.gui.preferences.SourceProvider;
     38import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    3239import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    3340import org.openstreetmap.josm.gui.tagging.TaggingPresetMenu;
     
    3845import org.xml.sax.SAXParseException;
    3946
    40 public class TaggingPresetPreference implements PreferenceSetting {
     47public class TaggingPresetPreference implements SubPreferenceSetting {
    4148
    4249    public static class Factory implements PreferenceSettingFactory {
     
    4451            return new TaggingPresetPreference();
    4552        }
     53    }
     54   
     55    private TaggingPresetPreference() {
     56        super();
    4657    }
    4758
     
    152163        sources = new TaggingPresetSourceEditor();
    153164        panel.add(sources, GBC.eol().fill(GBC.BOTH));
    154         gui.mapcontent.addTab(tr("Tagging Presets"), panel);
     165        gui.getMapPreference().mapcontent.addTab(tr("Tagging Presets"), panel);
    155166
    156167        // this defers loading of tagging preset sources to the first time the tab
    157168        // with the tagging presets is selected by the user
    158169        //
    159         gui.mapcontent.addChangeListener(
     170        gui.getMapPreference().mapcontent.addChangeListener(
    160171                new ChangeListener() {
    161172                    public void stateChanged(ChangeEvent e) {
    162                         if (gui.mapcontent.getSelectedComponent() == panel) {
     173                        if (gui.getMapPreference().mapcontent.getSelectedComponent() == panel) {
    163174                            sources.initiallyLoadAvailableSources();
    164175                        }
     
    327338        }
    328339    }
     340
     341    @Override
     342    public boolean isExpert() {
     343        return false;
     344    }
     345
     346    @Override
     347    public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
     348        return gui.getMapPreference();
     349    }
    329350}
  • trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/PrefJPanel.java

    r4965 r4968  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.preferences;
     2package org.openstreetmap.josm.gui.preferences.shortcut;
    33
    44import java.awt.Dimension;
  • trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/ShortcutPreference.java

    r4965 r4968  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    2 package org.openstreetmap.josm.gui.preferences;
     2package org.openstreetmap.josm.gui.preferences.shortcut;
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     
    99import javax.swing.table.AbstractTableModel;
    1010
     11import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
     12import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     13import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     14import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    1115import org.openstreetmap.josm.tools.GBC;
    1216import org.openstreetmap.josm.tools.Shortcut;
    1317
    14 public class ShortcutPreference implements PreferenceSetting {
     18public class ShortcutPreference extends DefaultTabPreferenceSetting {
    1519
    1620    public static class Factory implements PreferenceSettingFactory {
     
    1923        }
    2024    }
    21 
    22     public void addGui(PreferenceTabbedPane gui) {
     25   
     26    private ShortcutPreference() {
    2327        // icon source: http://www.iconfinder.net/index.php?q=key&page=icondetails&iconid=8553&size=128&q=key&s12=on&s16=on&s22=on&s32=on&s48=on&s64=on&s128=on
    2428        // icon licence: GPL
     
    2731        // icon original size: 128x128
    2832        // modifications: icon was cropped, then resized
    29         JPanel p = gui.createPreferenceTab("shortcuts", tr("Shortcut Preferences"),
    30                 tr("Changing keyboard shortcuts manually."), false);
     33        super("shortcuts", tr("Shortcut Preferences"), tr("Changing keyboard shortcuts manually."));
     34    }
     35
     36    public void addGui(PreferenceTabbedPane gui) {
     37        JPanel p = gui.createPreferenceTab(this);
    3138
    3239        PrefJPanel prefpanel = new PrefJPanel(new scListModel());
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r4936 r4968  
    6767import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    6868import org.openstreetmap.josm.gui.preferences.SourceEntry;
    69 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference.PresetPrefHelper;
     69import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference.PresetPrefHelper;
    7070import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
    7171import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPritority;
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSearchDialog.java

    r4286 r4968  
    4242import org.openstreetmap.josm.data.preferences.BooleanProperty;
    4343import org.openstreetmap.josm.gui.ExtendedDialog;
    44 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference;
     44import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
    4545import org.openstreetmap.josm.gui.tagging.TaggingPreset.Check;
    4646import org.openstreetmap.josm.gui.tagging.TaggingPreset.Combo;
  • trunk/src/org/openstreetmap/josm/tools/TaggingPresetNameTemplateList.java

    r4837 r4968  
    77import org.openstreetmap.josm.data.osm.OsmPrimitive;
    88import org.openstreetmap.josm.data.osm.Way;
    9 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference;
     9import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
    1010import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    1111import org.openstreetmap.josm.gui.tagging.TaggingPreset.Check;
Note: See TracChangeset for help on using the changeset viewer.