Ticket #7548: 7548_2014_v2.patch

File 7548_2014_v2.patch, 85.3 KB (added by simon04, 10 years ago)
  • src/org/openstreetmap/josm/gui/MainApplication.java

    diff --git a/src/org/openstreetmap/josm/gui/MainApplication.java b/src/org/openstreetmap/josm/gui/MainApplication.java
    index 9d8f4dc..ca68af7 100644
    a b import org.openstreetmap.josm.data.Preferences;  
    4444import org.openstreetmap.josm.data.Version;
    4545import org.openstreetmap.josm.gui.download.DownloadDialog;
    4646import org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder;
    47 import org.openstreetmap.josm.gui.preferences.server.ProxyPreference;
     47import org.openstreetmap.josm.gui.preferences.server.ServerAccessPreference;
    4848import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    4949import org.openstreetmap.josm.gui.util.GuiHelper;
    5050import org.openstreetmap.josm.io.DefaultProxySelector;
    public class MainApplication extends Main {  
    515515                ed.setContent(message);
    516516
    517517                if (ed.showDialog().getValue() == 1) {
    518                     PreferencesAction.forPreferenceSubTab(null, null, ProxyPreference.class).run();
     518                    PreferencesAction.forPreferenceTab(null, null, ServerAccessPreference.class).run();
    519519                }
    520520            }
    521521            return hasErrors;
  • src/org/openstreetmap/josm/gui/MainMenu.java

    diff --git a/src/org/openstreetmap/josm/gui/MainMenu.java b/src/org/openstreetmap/josm/gui/MainMenu.java
    index ce51a59..6a95064 100644
    a b public class MainMenu extends JMenuBar {  
    708708
    709709        add(presetsMenu, presetSearchAction);
    710710        add(presetsMenu, presetSearchPrimitiveAction);
    711         add(presetsMenu, PreferencesAction.forPreferenceSubTab(tr("Preset preferences"),
     711        add(presetsMenu, PreferencesAction.forPreferenceTab(tr("Preset preferences"),
    712712                tr("Click to open the tagging presets tab in the preferences"), TaggingPresetPreference.class));
    713713        presetsMenu.addSeparator();
    714714
  • src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java

    diff --git a/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java b/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
    index bb96cf4..e32d480 100644
    a b import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.MapPaintStyleLoader;  
    6969import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.MapPaintSylesUpdateListener;
    7070import org.openstreetmap.josm.gui.mappaint.StyleSource;
    7171import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
     72import org.openstreetmap.josm.gui.preferences.PreferenceDialog;
    7273import org.openstreetmap.josm.gui.preferences.SourceEntry;
    7374import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference;
    7475import org.openstreetmap.josm.gui.util.FileFilterAllFiles;
    public class MapPaintDialog extends ToggleDialog implements Main.WindowSwitchLis  
    9495    protected MoveUpDownAction downAction;
    9596    protected JCheckBox cbWireframe;
    9697
    97     public static final JosmAction PREFERENCE_ACTION = PreferencesAction.forPreferenceSubTab(
     98    public static final JosmAction PREFERENCE_ACTION = PreferencesAction.forPreferenceTab(
    9899            tr("Map paint preferences"), null, MapPaintPreference.class, "dialogs/mappaintpreference");
    99100
    100101    /**
  • src/org/openstreetmap/josm/gui/preferences/DefaultTabPreferenceSetting.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/DefaultTabPreferenceSetting.java b/src/org/openstreetmap/josm/gui/preferences/DefaultTabPreferenceSetting.java
    index ddadb97..8916e6a 100644
    a b  
    1 // License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.preferences;
    3 
    4 import java.awt.Component;
    5 import java.util.HashMap;
    6 import java.util.Map;
    7 
    8 import javax.swing.JPanel;
    9 import javax.swing.JScrollPane;
    10 import javax.swing.JTabbedPane;
    11 
    12 import org.openstreetmap.josm.Main;
    13 import org.openstreetmap.josm.tools.GBC;
    14 
    15 public abstract class DefaultTabPreferenceSetting extends DefaultPreferenceSetting implements TabPreferenceSetting {
    16 
    17     private final String iconName;
    18     private final String description;
    19     private final String title;
    20     private final JTabbedPane tabpane;
    21     private final Map<SubPreferenceSetting, Component> subSettingMap;
    22    
    23     /**
    24      * Constructs a new {@code DefaultTabPreferenceSetting}.
    25      */
    26     public DefaultTabPreferenceSetting() {
    27         this(null, null, null);
    28     }
    29 
    30     public DefaultTabPreferenceSetting(String iconName, String title, String description) {
    31         this(iconName, title, description, false);
    32     }
    33 
    34     public DefaultTabPreferenceSetting(String iconName, String title, String description, boolean isExpert) {
    35         this(iconName, title, description, isExpert, null);
    36     }
    37 
    38     public DefaultTabPreferenceSetting(String iconName, String title, String description, boolean isExpert, JTabbedPane tabpane) {
    39         super(isExpert);
    40         this.iconName = iconName;
    41         this.description = description;
    42         this.title = title;
    43         this.tabpane = tabpane;
    44         this.subSettingMap = tabpane != null ? new HashMap<SubPreferenceSetting, Component>() : null;
    45     }
    46 
    47     @Override
    48     public String getIconName() {
    49         return iconName;
    50     }
    51 
    52     @Override
    53     public String getTooltip() {
    54         if (getDescription() != null) {
    55             return "<html>"+getDescription()+"</html>";
    56         } else {
    57             return null;
    58         }
    59     }
    60 
    61     @Override
    62     public String getDescription() {
    63         return description;
    64     }
    65 
    66     @Override
    67     public String getTitle() {
    68         return title;
    69     }
    70 
    71     /**
    72      * Get the inner tab pane, if any.
    73      * @return The JTabbedPane contained in this tab preference settings, or null if none is set.
    74      * @since 5631
    75      */
    76     public final JTabbedPane getTabPane() {
    77         return tabpane;
    78     }
    79    
    80     protected final void createPreferenceTabWithScrollPane(PreferenceTabbedPane gui, JPanel panel) {
    81         GBC a = GBC.eol().insets(-5,0,0,0);
    82         a.anchor = GBC.EAST;
    83        
    84         JScrollPane scrollPane = new JScrollPane(panel);
    85         scrollPane.setBorder(null);
    86 
    87         JPanel tab = gui.createPreferenceTab(this);
    88         tab.add(scrollPane, GBC.eol().fill(GBC.BOTH));
    89         tab.add(GBC.glue(0,10), a);
    90     }
    91 
    92     @Override
    93     public boolean selectSubTab(SubPreferenceSetting subPref) {
    94         if (tabpane != null && subPref != null) {
    95             Component tab = getSubTab(subPref);
    96             if (tab != null) {
    97                 try {
    98                     tabpane.setSelectedComponent(tab);
    99                     return true;
    100                 } catch (IllegalArgumentException e) {
    101                     // Ignore exception and return false below
    102                     Main.debug(Main.getErrorMessage(e));
    103                 }
    104             }
    105         }
    106         return false;
    107     }
    108    
    109     @Override
    110     public final void addSubTab(SubPreferenceSetting sub, String title, Component component) {
    111         addSubTab(sub, title, component, null);
    112     }
    113    
    114     @Override
    115     public final void addSubTab(SubPreferenceSetting sub, String title, Component component, String tip) {
    116         if (tabpane != null && component != null) {
    117             tabpane.addTab(title, null, component, tip);
    118             registerSubTab(sub, component);
    119         }
    120     }
    121    
    122     @Override
    123     public final void registerSubTab(SubPreferenceSetting sub, Component component) {
    124         if (subSettingMap != null && sub != null && component != null) {
    125             subSettingMap.put(sub, component);
    126         }
    127     }
    128    
    129     @Override
    130     public final Component getSubTab(SubPreferenceSetting sub) {
    131         return subSettingMap != null ? subSettingMap.get(sub) : null;
    132     }
    133 }
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.gui.preferences;
     3
     4import org.openstreetmap.josm.Main;
     5import org.openstreetmap.josm.tools.GBC;
     6
     7import javax.swing.*;
     8import java.awt.*;
     9import java.util.HashMap;
     10import java.util.Map;
     11
     12
     13public abstract class DefaultTabPreferenceSetting extends DefaultPreferenceSetting implements TabPreferenceSetting {
     14
     15    private final String iconName;
     16    private final String description;
     17    private final String title;
     18    private final JTabbedPane tabpane;
     19    private final Map<SubPreferenceSetting, Component> subSettingMap;
     20
     21    /**
     22     * Constructs a new {@code DefaultTabPreferenceSetting}.
     23     */
     24    public DefaultTabPreferenceSetting() {
     25        this(null, null, null);
     26    }
     27
     28    public DefaultTabPreferenceSetting(String iconName, String title, String description) {
     29        this(iconName, title, description, false);
     30    }
     31
     32    public DefaultTabPreferenceSetting(String iconName, String title, String description, boolean isExpert) {
     33        this(iconName, title, description, isExpert, null);
     34    }
     35
     36    public DefaultTabPreferenceSetting(String iconName, String title, String description, boolean isExpert, JTabbedPane tabpane) {
     37        super(isExpert);
     38        this.iconName = iconName;
     39        this.description = description;
     40        this.title = title;
     41        this.tabpane = tabpane;
     42        this.subSettingMap = tabpane != null ? new HashMap<SubPreferenceSetting, Component>() : null;
     43    }
     44
     45    @Override
     46    public String getIconName() {
     47        return iconName;
     48    }
     49
     50    @Override
     51    public String getTooltip() {
     52        if (getDescription() != null) {
     53            return "<html>"+getDescription()+"</html>";
     54        } else {
     55            return null;
     56        }
     57    }
     58
     59    @Override
     60    public String getDescription() {
     61        return description;
     62    }
     63
     64    @Override
     65    public String getTitle() {
     66        return title;
     67    }
     68
     69    /**
     70     * Get the inner tab pane, if any.
     71     * @return The JTabbedPane contained in this tab preference settings, or null if none is set.
     72     * @since 5631
     73     */
     74    public final JTabbedPane getTabPane() {
     75        return tabpane;
     76    }
     77
     78    protected final void createPreferenceTabWithScrollPane(PreferenceTabbedPane gui, JPanel panel) {
     79        GBC a = GBC.eol().insets(-5,0,0,0);
     80        a.anchor = GBC.EAST;
     81
     82        JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
     83        scrollPane.setBorder(null);
     84
     85        JPanel tab = gui.createPreferenceTab(this);
     86        tab.add(scrollPane, GBC.eol().fill(GBC.BOTH));
     87        tab.add(GBC.glue(0,10), a);
     88    }
     89
     90    @Override
     91    public boolean selectSubTab(SubPreferenceSetting subPref) {
     92        if (tabpane != null && subPref != null) {
     93            Component tab = getSubTab(subPref);
     94            if (tab != null) {
     95                try {
     96                    tabpane.setSelectedComponent(tab);
     97                    return true;
     98                } catch (IllegalArgumentException e) {
     99                    // Ignore exception and return false below
     100                    Main.debug(Main.getErrorMessage(e));
     101                }
     102            }
     103        }
     104        return false;
     105    }
     106
     107    @Override
     108    public final void addSubTab(SubPreferenceSetting sub, String title, Component component) {
     109        addSubTab(sub, title, component, null);
     110    }
     111
     112    @Override
     113    public final void addSubTab(SubPreferenceSetting sub, String title, Component component, String tip) {
     114        if (tabpane != null && component != null) {
     115            tabpane.addTab(title, null, component, tip);
     116            registerSubTab(sub, component);
     117        }
     118    }
     119
     120    @Override
     121    public final void registerSubTab(SubPreferenceSetting sub, Component component) {
     122        if (subSettingMap != null && sub != null && component != null) {
     123            subSettingMap.put(sub, component);
     124        }
     125    }
     126
     127    @Override
     128    public final Component getSubTab(SubPreferenceSetting sub) {
     129        return subSettingMap != null ? subSettingMap.get(sub) : null;
     130    }
     131}
  • src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java b/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
    index ea5b74c..56946c7 100644
    a b import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;  
    3535import org.openstreetmap.josm.gui.preferences.advanced.AdvancedPreference;
    3636import org.openstreetmap.josm.gui.preferences.audio.AudioPreference;
    3737import org.openstreetmap.josm.gui.preferences.display.ColorPreference;
    38 import org.openstreetmap.josm.gui.preferences.display.DisplayPreference;
    3938import org.openstreetmap.josm.gui.preferences.display.DrawingPreference;
     39import org.openstreetmap.josm.gui.preferences.display.GPXSettingsPanel;
    4040import org.openstreetmap.josm.gui.preferences.display.LafPreference;
    4141import org.openstreetmap.josm.gui.preferences.display.LanguagePreference;
    4242import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference;
    4343import org.openstreetmap.josm.gui.preferences.map.BackupPreference;
    4444import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference;
    45 import org.openstreetmap.josm.gui.preferences.map.MapPreference;
    4645import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
    4746import org.openstreetmap.josm.gui.preferences.plugin.PluginPreference;
     47import org.openstreetmap.josm.gui.preferences.plugin.PluginUpdatePolicyPanel;
    4848import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
     49import org.openstreetmap.josm.gui.preferences.server.ProxyPreferencesPanel;
    4950import org.openstreetmap.josm.gui.preferences.remotecontrol.RemoteControlPreference;
    50 import org.openstreetmap.josm.gui.preferences.server.AuthenticationPreference;
    51 import org.openstreetmap.josm.gui.preferences.server.ProxyPreference;
    5251import org.openstreetmap.josm.gui.preferences.server.ServerAccessPreference;
    5352import org.openstreetmap.josm.gui.preferences.shortcut.ShortcutPreference;
    5453import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference;
    5554import org.openstreetmap.josm.gui.preferences.validator.ValidatorTagCheckerRulesPreference;
    56 import org.openstreetmap.josm.gui.preferences.validator.ValidatorTestsPreference;
    5755import org.openstreetmap.josm.plugins.PluginDownloadTask;
    5856import org.openstreetmap.josm.plugins.PluginHandler;
    5957import org.openstreetmap.josm.plugins.PluginInformation;
    public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee  
    238236    }
    239237
    240238    /**
    241      * Returns the {@code DisplayPreference} object.
    242      * @return the {@code DisplayPreference} object.
     239     * Returns the {@code DrawingPreference} object.
     240     * @return the {@code DrawingPreference} object.
    243241     */
    244     public final DisplayPreference getDisplayPreference() {
    245         return getSetting(DisplayPreference.class);
    246     }
    247 
    248     /**
    249      * Returns the {@code MapPreference} object.
    250      * @return the {@code MapPreference} object.
    251      */
    252     public final MapPreference getMapPreference() {
    253         return getSetting(MapPreference.class);
     242    public final DrawingPreference getDrawingPreference() {
     243        return getSetting(DrawingPreference.class);
    254244    }
    255245
    256246    /**
    public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee  
    427417        int position = index;
    428418        for (PreferenceTab tab : tabs) {
    429419            if (tab.getTabPreferenceSetting().equals(tps)) {
    430                 insertTab(null, icon, tab.getComponent(), tps.getTooltip(), position++);
     420                if (tps instanceof IconPreferenceSetting) {
     421                    insertTab(null, icon, tab.getComponent(), tps.getTooltip(), position++);
     422                } else {
     423                    insertTab(tps.getTitle(), null, tab.getComponent(), tps.getTooltip(), position++);
     424                }
    431425            }
    432426        }
    433427    }
    public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee  
    455449                        addGUITabsForSetting(icon, tps);
    456450                    } else {
    457451                        // If it has not been initialized, create an empty tab with only icon and tooltip
    458                         addTab(null, icon, new PreferencePanel(tps), tps.getTooltip());
     452                        if (tps instanceof IconPreferenceSetting) {
     453                            addTab(null, icon, new PreferencePanel(tps), tps.getTooltip());
     454                        } else {
     455                            addTab(tps.getTitle(), null, new PreferencePanel(tps), tps.getTooltip());
     456                        }
    459457                    }
    460458                }
    461459            } else if (!(setting instanceof SubPreferenceSetting)) {
    public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee  
    489487        return null;
    490488    }
    491489
     490    static class IconPreferenceSetting extends DefaultTabPreferenceSetting {
     491
     492        public static class Factory implements PreferenceSettingFactory {
     493
     494            private final String iconName, title, description;
     495
     496            public Factory(String iconName, String title, String description) {
     497                this.iconName = iconName;
     498                this.title = title;
     499                this.description = description;
     500            }
     501
     502            @Override
     503            public PreferenceSetting createPreferenceSetting() {
     504                return new IconPreferenceSetting(iconName, title, description);
     505            }
     506        }
     507
     508        public IconPreferenceSetting(String iconName, String title, String description) {
     509            super(iconName, title, description);
     510        }
     511
     512        @Override
     513        public void addGui(PreferenceTabbedPane gui) {
     514            createPreferenceTabWithScrollPane(gui, new JPanel());
     515        }
     516
     517        @Override
     518        public boolean ok() {
     519            return false;
     520        }
     521    }
     522
    492523    static {
     524
    493525        // order is important!
    494         settingsFactory.add(new DisplayPreference.Factory());
     526        settingsFactory.add(new IconPreferenceSetting.Factory("map", tr("Mapping"), tr("Various settings that influence the visual representation of geodata.")));
    495527        settingsFactory.add(new DrawingPreference.Factory());
    496         settingsFactory.add(new ColorPreference.Factory());
    497         settingsFactory.add(new LafPreference.Factory());
    498         settingsFactory.add(new LanguagePreference.Factory());
    499         settingsFactory.add(new ServerAccessPreference.Factory());
    500         settingsFactory.add(new AuthenticationPreference.Factory());
    501         settingsFactory.add(new ProxyPreference.Factory());
    502         settingsFactory.add(new MapPreference.Factory());
     528        settingsFactory.add(new GPXSettingsPanel.Factory());
    503529        settingsFactory.add(new ProjectionPreference.Factory());
    504530        settingsFactory.add(new MapPaintPreference.Factory());
    505531        settingsFactory.add(new TaggingPresetPreference.Factory());
     532        settingsFactory.add(new ImageryPreference.Factory());
     533
     534        settingsFactory.add(new IconPreferenceSetting.Factory("connection", tr("Server"), tr("Connection Settings for the OSM server.")));
     535        settingsFactory.add(new ServerAccessPreference.Factory());
     536        settingsFactory.add(new ProxyPreferencesPanel.Factory());
     537
     538        settingsFactory.add(new IconPreferenceSetting.Factory("display", tr("User Interface"), tr("Various settings that influence the visual representation of the whole program.")));
     539        settingsFactory.add(new ColorPreference.Factory());
     540        settingsFactory.add(new LafPreference.Factory());
     541        settingsFactory.add(new LanguagePreference.Factory());
    506542        settingsFactory.add(new BackupPreference.Factory());
    507         settingsFactory.add(new PluginPreference.Factory());
    508543        settingsFactory.add(Main.toolbar);
    509         settingsFactory.add(new AudioPreference.Factory());
    510544        settingsFactory.add(new ShortcutPreference.Factory());
     545
     546        settingsFactory.add(new IconPreferenceSetting.Factory("advanced", tr("Advanced Preferences"), tr("Modify advanced JOSM configuration.")));
     547        settingsFactory.add(new AudioPreference.Factory());
    511548        settingsFactory.add(new ValidatorPreference.Factory());
    512         settingsFactory.add(new ValidatorTestsPreference.Factory());
    513549        settingsFactory.add(new ValidatorTagCheckerRulesPreference.Factory());
    514550        settingsFactory.add(new RemoteControlPreference.Factory());
    515         settingsFactory.add(new ImageryPreference.Factory());
    516 
    517         PluginHandler.getPreferenceSetting(settingsFactory);
    518 
    519         // always the last: advanced tab
    520551        settingsFactory.add(new AdvancedPreference.Factory());
     552
     553        settingsFactory.add(new IconPreferenceSetting.Factory("plugin", tr("Plugins"), tr("Install new plugins or configure installed plugins.")));
     554        settingsFactory.add(new PluginPreference.Factory());
     555        settingsFactory.add(new PluginUpdatePolicyPanel.Factory());
     556        PluginHandler.getPreferenceSetting(settingsFactory);
     557
    521558    }
    522559
    523560    /**
  • src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java b/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
    index e9dc2ea..5f1a048 100644
    a b public class ToolbarPreferences implements PreferenceSettingFactory {  
    569569        private String movingComponent;
    570570
    571571        public Settings(DefaultMutableTreeNode rootActionsNode) {
    572             super("toolbar", tr("Toolbar customization"), tr("Customize the elements on the toolbar."));
     572            super("toolbar", tr("Toolbar"), tr("Customize the elements on the toolbar."));
    573573            actionsTreeModel = new DefaultTreeModel(rootActionsNode);
    574574            actionsTree = new JTree(actionsTreeModel);
    575575        }
  • src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java b/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java
    index d77879e..1073514 100644
    a b import org.openstreetmap.josm.gui.layer.GpxLayer;  
    4141import org.openstreetmap.josm.gui.layer.ImageryLayer;
    4242import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    4343import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
     44import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    4445import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    4546import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    4647import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    47 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    48 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    4948import org.openstreetmap.josm.tools.ColorHelper;
    5049import org.openstreetmap.josm.tools.GBC;
    5150
    5251/**
    5352 * Color preferences.
    5453 */
    55 public class ColorPreference implements SubPreferenceSetting {
     54public class ColorPreference extends DefaultTabPreferenceSetting {
    5655
    5756    /**
    5857     * Factory used to create a new {@code ColorPreference}.
    public class ColorPreference implements SubPreferenceSetting {  
    7271    private JButton defaultSet;
    7372    private JButton remove;
    7473
     74    public ColorPreference() {
     75        super(null, tr("Colors"), tr("Change colors used in program dialogs and in map paint styles."));
     76    }
     77
    7578    /**
    7679     * Set the colors to be shown in the preference table. This method creates a table model if
    7780     * none exists and overwrites all existing values.
    public class ColorPreference implements SubPreferenceSetting {  
    250253        buttonPanel.add(defaultSet, GBC.std().insets(5,5,5,0));
    251254        buttonPanel.add(defaultAll, GBC.std().insets(0,5,0,0));
    252255        buttonPanel.add(remove, GBC.std().insets(0,5,0,0));
    253         gui.getDisplayPreference().addSubTab(this, tr("Colors"), panel);
     256
     257        createPreferenceTabWithScrollPane(gui, panel);
    254258    }
    255259
    256260    Boolean isRemoveColor(int row) {
    public class ColorPreference implements SubPreferenceSetting {  
    296300    public boolean isExpert() {
    297301        return false;
    298302    }
    299 
    300     @Override
    301     public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
    302         return gui.getDisplayPreference();
    303     }
    304303}
  • src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java b/src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java
    index ea83113..6d678cb 100644
    a b import javax.swing.Box;  
    1212import javax.swing.JCheckBox;
    1313import javax.swing.JLabel;
    1414import javax.swing.JPanel;
    15 import javax.swing.JScrollPane;
    1615
    1716import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.actions.ExpertToggleAction;
     18import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    1919import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    2020import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    2121import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    22 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    23 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    2422import org.openstreetmap.josm.tools.GBC;
    2523
    2624/**
    2725 * Map drawing preferences.
    2826 */
    29 public class DrawingPreference implements SubPreferenceSetting {
     27public class DrawingPreference extends DefaultTabPreferenceSetting {
    3028
    3129    /**
    3230     * Factory used to create a new {@code DrawingPreference}.
    public class DrawingPreference implements SubPreferenceSetting {  
    3836        }
    3937    }
    4038
    41     private GPXSettingsPanel gpxPanel;
    4239    private JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows"));
    4340    private JCheckBox headArrow = new JCheckBox(tr("Only on the head of a way."));
    4441    private JCheckBox onewayArrow = new JCheckBox(tr("Draw oneway arrows."));
    public class DrawingPreference implements SubPreferenceSetting {  
    5552    private JCheckBox useWireframeAntialiasing = new JCheckBox(tr("Smooth map graphics in wireframe mode (antialiasing)"));
    5653    private JCheckBox outlineOnly = new JCheckBox(tr("Draw only outlines of areas"));
    5754
    58     @Override
     55    public DrawingPreference() {
     56        super(null, tr("OSM Data"), tr("Settings that control the drawing of OSM data."));
     57    }
     58
    5959    public void addGui(PreferenceTabbedPane gui) {
    60         gpxPanel = new GPXSettingsPanel();
    61         gui.addValidationListener(gpxPanel);
    62         JPanel panel = gpxPanel;
    6360
    64         JScrollPane scrollpane = new JScrollPane(panel);
    65         scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
    66         gui.getDisplayPreference().addSubTab(this, tr("GPS Points"), scrollpane);
    67         panel = new JPanel(new GridBagLayout());
     61        JPanel panel = new JPanel(new GridBagLayout());
    6862        panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    6963
    7064        // directionHint
    public class DrawingPreference implements SubPreferenceSetting {  
    164158        ExpertToggleAction.addVisibilitySwitcher(discardableKeys);
    165159
    166160        panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
    167         scrollpane = new JScrollPane(panel);
    168         scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
    169         gui.getDisplayPreference().addSubTab(this, tr("OSM Data"), scrollpane);
     161        createPreferenceTabWithScrollPane(gui, panel);
    170162    }
    171163
    172164    @Override
    173165    public boolean ok() {
    174         boolean restart = gpxPanel.savePreferences();
    175166        Main.pref.put("draw.data.area_outline_only", outlineOnly.isSelected());
    176167        Main.pref.put("draw.segment.direction", directionHint.isSelected());
    177168        Main.pref.put("draw.segment.head_only", headArrow.isSelected());
    public class DrawingPreference implements SubPreferenceSetting {  
    194185            vn = 0;
    195186        }
    196187        Main.pref.putInteger("mappaint.node.virtual-size", vn);
    197         return restart;
     188        return false;
    198189    }
    199190
    200191    @Override
    201192    public boolean isExpert() {
    202193        return false;
    203194    }
    204 
    205     @Override
    206     public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
    207         return gui.getDisplayPreference();
    208     }
    209195}
  • src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java b/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java
    index 039d28f..9cb1619 100644
    a b import org.openstreetmap.josm.Main;  
    2424import org.openstreetmap.josm.actions.ExpertToggleAction;
    2525import org.openstreetmap.josm.gui.layer.markerlayer.Marker;
    2626import org.openstreetmap.josm.gui.layer.markerlayer.Marker.TemplateEntryProperty;
     27import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
     28import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     29import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     30import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    2731import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.ValidationListener;
    2832import org.openstreetmap.josm.gui.widgets.JosmComboBox;
    2933import org.openstreetmap.josm.gui.widgets.JosmTextField;
    import org.openstreetmap.josm.tools.template_engine.TemplateParser;  
    3640 */
    3741public class GPXSettingsPanel extends JPanel implements ValidationListener {
    3842
     43    public static class Factory implements PreferenceSettingFactory {
     44
     45        @Override
     46        public PreferenceSetting createPreferenceSetting() {
     47            return new DefaultTabPreferenceSetting(null, tr("GPS Points"), tr("Settings that control the drawing of GPS tracks.")) {
     48
     49                private GPXSettingsPanel gpx;
     50
     51                @Override
     52                public void addGui(PreferenceTabbedPane gui) {
     53                    gpx = new GPXSettingsPanel();
     54                    createPreferenceTabWithScrollPane(gui, gpx);
     55                    gui.addValidationListener(gpx);
     56                }
     57
     58                @Override
     59                public boolean ok() {
     60                    gpx.savePreferences();
     61                    return false;
     62                }
     63            };
     64        }
     65    }
     66
    3967    private static final int WAYPOINT_LABEL_CUSTOM = 6;
    4068    private static final String[] LABEL_PATTERN_TEMPLATE = new String[] {Marker.LABEL_PATTERN_AUTO, Marker.LABEL_PATTERN_NAME,
    4169        Marker.LABEL_PATTERN_DESC, "{special:everything}", "?{ '{name}' | '{desc}' | '{formattedWaypointOffset}' }", ""};
  • src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java b/src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java
    index bd52c7b..1b7e230 100644
    a b import javax.swing.JCheckBox;  
    1313import javax.swing.JLabel;
    1414import javax.swing.JList;
    1515import javax.swing.JPanel;
    16 import javax.swing.JScrollPane;
    1716import javax.swing.ListCellRenderer;
    1817import javax.swing.LookAndFeel;
    1918import javax.swing.UIManager;
    import javax.swing.UIManager.LookAndFeelInfo;  
    2120
    2221import org.openstreetmap.josm.Main;
    2322import org.openstreetmap.josm.actions.ExpertToggleAction;
     23import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    2424import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
    2525import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    2626import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    2727import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    28 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    29 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    3028import org.openstreetmap.josm.gui.widgets.JosmComboBox;
    3129import org.openstreetmap.josm.tools.GBC;
    3230
    3331/**
    3432 * Look-and-feel preferences.
    3533 */
    36 public class LafPreference implements SubPreferenceSetting {
     34public class LafPreference extends DefaultTabPreferenceSetting {
    3735
    3836    /**
    3937     * Factory used to create a new {@code LafPreference}.
    public class LafPreference implements SubPreferenceSetting {  
    5654    private JCheckBox modeless = new JCheckBox(tr("Modeless working (Potlatch style)"));
    5755    private JCheckBox dynamicButtons = new JCheckBox(tr("Dynamic buttons in side menus"));
    5856
     57    public LafPreference() {
     58        super(null, tr("Look and Feel"), tr("Change the Look and Feel of the program"));
     59    }
     60
    5961    @Override
    6062    public void addGui(PreferenceTabbedPane gui) {
    6163        lafCombo = new JosmComboBox<>(UIManager.getInstalledLookAndFeels());
    public class LafPreference implements SubPreferenceSetting {  
    127129        panel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL));
    128130        panel.add(lafCombo, GBC.eol().fill(GBC.HORIZONTAL));
    129131
    130         JScrollPane scrollpane = new JScrollPane(panel);
    131         scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
    132         gui.getDisplayPreference().addSubTab(this, tr("Look and Feel"), scrollpane);
     132        panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
     133
     134        createPreferenceTabWithScrollPane(gui, panel);
    133135    }
    134136
    135137    @Override
    public class LafPreference implements SubPreferenceSetting {  
    148150    public boolean isExpert() {
    149151        return false;
    150152    }
    151 
    152     @Override
    153     public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
    154         return gui.getDisplayPreference();
    155     }
    156153}
  • src/org/openstreetmap/josm/gui/preferences/display/LanguagePreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/display/LanguagePreference.java b/src/org/openstreetmap/josm/gui/preferences/display/LanguagePreference.java
    index 6e48d83..5654275 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.preferences.display;
    33
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    5 
    6 import java.awt.Component;
    7 import java.util.ArrayList;
    8 import java.util.Arrays;
    9 import java.util.List;
    10 import java.util.Locale;
    11 
    12 import javax.swing.Box;
    13 import javax.swing.DefaultComboBoxModel;
    14 import javax.swing.DefaultListCellRenderer;
    15 import javax.swing.JLabel;
    16 import javax.swing.JList;
    17 import javax.swing.JPanel;
    18 import javax.swing.ListCellRenderer;
    19 
    204import org.openstreetmap.josm.Main;
     5import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    216import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    227import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    238import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    24 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    25 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    26 import org.openstreetmap.josm.gui.widgets.JosmComboBox;
    279import org.openstreetmap.josm.tools.GBC;
    2810import org.openstreetmap.josm.tools.I18n;
    2911
     12import javax.swing.BorderFactory;
     13import javax.swing.DefaultListCellRenderer;
     14import javax.swing.JList;
     15import javax.swing.JPanel;
     16import javax.swing.ListCellRenderer;
     17import java.awt.Component;
     18import java.awt.GridBagLayout;
     19import java.util.List;
     20import java.util.Locale;
     21
     22import static org.openstreetmap.josm.tools.I18n.tr;
     23
    3024/**
    3125 * Language preferences.
    3226 */
    33 public class LanguagePreference implements SubPreferenceSetting {
     27public class LanguagePreference extends DefaultTabPreferenceSetting {
    3428
    3529    /**
    3630     * Factory used to create a new {@code LanguagePreference}.
    public class LanguagePreference implements SubPreferenceSetting {  
    4337    }
    4438
    4539    /** the combo box with the available locales */
    46     private JosmComboBox<Locale> langCombo;
     40    private JList<Locale> langCombo;
     41
     42    public LanguagePreference() {
     43        super(null, tr("Language"), tr("Change the language of JOSM."));
     44    }
    4745
    4846    @Override
    4947    public void addGui(final PreferenceTabbedPane gui) {
    50         LanguageComboBoxModel model = new LanguageComboBoxModel();
    51         // Selecting the language BEFORE the JComboBox listens to model changes speed up initialization by ~35ms (see #7386)
    52         // See https://stackoverflow.com/questions/3194958/fast-replacement-for-jcombobox-basiccomboboxui
    53         model.selectLanguage(Main.pref.get("language"));
    54         langCombo = new JosmComboBox<>(model);
    55         langCombo.setRenderer(new LanguageCellRenderer());
     48        List<Locale> tr = I18n.getAvailableTranslationsAsList();
     49        tr.add(0, null);
     50        langCombo = new JList<>(tr.toArray(new Locale[tr.size()]));
     51        langCombo.setCellRenderer(new LanguageCellRenderer());
     52        langCombo.setVisibleRowCount(langCombo.getModel().getSize());
     53        selectLanguage(Main.pref.get("language"));
    5654
    57         LafPreference lafPreference = gui.getSetting(LafPreference.class);
    58         final JPanel panel = lafPreference.panel;
    59         panel.add(new JLabel(tr("Language")), GBC.std().insets(20, 0, 0, 0));
    60         panel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL));
    61         panel.add(langCombo, GBC.eol().fill(GBC.HORIZONTAL));
    62         panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
     55        final JPanel panel = new JPanel(new GridBagLayout());
     56        panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
     57        panel.add(langCombo, GBC.eol().fill(GBC.BOTH));
     58        createPreferenceTabWithScrollPane(gui, panel);
     59    }
    6360
    64         TabPreferenceSetting tabPref = lafPreference.getTabPreferenceSetting(gui);
    65         tabPref.registerSubTab(this, tabPref.getSubTab(lafPreference));
     61    protected void selectLanguage(final String languageCode) {
     62        if (languageCode == null || languageCode.isEmpty()) {
     63            langCombo.setSelectedIndex(0);
     64        } else {
     65            langCombo.setSelectedValue(Locale.forLanguageTag(languageCode), true);
     66        }
    6667    }
    6768
    6869    @Override
    6970    public boolean ok() {
    70         if(langCombo.getSelectedItem() == null)
     71        if (langCombo.getSelectedValue() == null) {
    7172            return Main.pref.put("language", null);
    72         else
    73             return Main.pref.put("language",
    74                     ((Locale)langCombo.getSelectedItem()).toString());
    75     }
    76 
    77     private static class LanguageComboBoxModel extends DefaultComboBoxModel<Locale> {
    78         private final List<Locale> data = new ArrayList<>();
    79 
    80         public LanguageComboBoxModel(){
    81             data.add(0,null);
    82             data.addAll(Arrays.asList(I18n.getAvailableTranslations()));
    83         }
    84 
    85         public void selectLanguage(String language) {
    86             setSelectedItem(null);
    87             if (language != null) {
    88                 for (Locale locale: data) {
    89                     if (locale == null) {
    90                         continue;
    91                     }
    92                     if (locale.toString().equals(language)) {
    93                         setSelectedItem(locale);
    94                         return;
    95                     }
    96                 }
    97             }
    98         }
    99 
    100         @Override
    101         public Locale getElementAt(int index) {
    102             return data.get(index);
    103         }
    104 
    105         @Override
    106         public int getSize() {
    107             return data.size();
     73        } else {
     74            return Main.pref.put("language", langCombo.getSelectedValue().toString());
    10875        }
    10976    }
    11077
    11178    private static class LanguageCellRenderer implements ListCellRenderer<Locale> {
    11279        private final DefaultListCellRenderer dispatch;
     80
    11381        public LanguageCellRenderer() {
    11482            this.dispatch = new DefaultListCellRenderer();
    11583        }
     84
    11685        @Override
    117         public Component getListCellRendererComponent(JList<? extends Locale> list, Locale l, 
     86        public Component getListCellRendererComponent(JList<? extends Locale> list, Locale l,
    11887                int index, boolean isSelected, boolean cellHasFocus) {
    11988            return dispatch.getListCellRendererComponent(list,
    12089                    l == null ? tr("Default (Auto determined)") : l.getDisplayName(l),
    public class LanguagePreference implements SubPreferenceSetting {  
    12695    public boolean isExpert() {
    12796        return false;
    12897    }
    129 
    130     @Override
    131     public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
    132         return gui.getSetting(LafPreference.class).getTabPreferenceSetting(gui);
    133     }
    13498}
  • src/org/openstreetmap/josm/gui/preferences/map/BackupPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/map/BackupPreference.java b/src/org/openstreetmap/josm/gui/preferences/map/BackupPreference.java
    index d9dd1d0..b9cfb3c 100644
    a b import javax.swing.JSeparator;  
    1717
    1818import org.openstreetmap.josm.data.AutosaveTask;
    1919import org.openstreetmap.josm.data.preferences.BooleanProperty;
     20import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    2021import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    2122import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    2223import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    import org.openstreetmap.josm.tools.GBC;  
    3031/**
    3132 * Preference settings for data layer autosave.
    3233 */
    33 public class BackupPreference implements SubPreferenceSetting {
     34public class BackupPreference extends DefaultTabPreferenceSetting {
    3435
    3536    /**
    3637     * Factory used to create a new {@code BackupPreference}.
    public class BackupPreference implements SubPreferenceSetting {  
    112113        autosaveEnabled.actionPerformed(null);
    113114
    114115        panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
    115         JScrollPane sp = GuiHelper.embedInVerticalScrollPane(panel);
    116116
    117         gui.getMapPreference().addSubTab(this, tr("File backup"), sp, tr("Configure whether to create backup files"));
     117        createPreferenceTabWithScrollPane(gui, panel);
     118    }
     119
     120    @Override
     121    public String getIconName() {
     122        return null;
     123    }
     124
     125    @Override
     126    public String getTitle() {
     127        return tr("File backup");
     128    }
     129
     130    @Override
     131    public String getTooltip() {
     132        return tr("Configure whether to create backup files");
    118133    }
    119134
    120135    @Override
    public class BackupPreference implements SubPreferenceSetting {  
    130145    }
    131146
    132147    @Override
     148    public String getDescription() {
     149        return getTooltip();
     150    }
     151
     152    @Override
    133153    public boolean isExpert() {
    134154        return false;
    135155    }
    136 
    137     @Override
    138     public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
    139         return gui.getMapPreference();
    140     }
    141156}
  • src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java b/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java
    index 07ff540..f7f2fb0 100644
    a b import java.util.List;  
    1313import java.util.Map;
    1414import java.util.Objects;
    1515import java.util.TreeSet;
    16 
    1716import javax.swing.BorderFactory;
    1817import javax.swing.JCheckBox;
    1918import javax.swing.JPanel;
    20 
    2119import org.openstreetmap.josm.Main;
    2220import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     21import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    2322import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    2423import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    2524import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    import org.openstreetmap.josm.tools.Utils;  
    3736/**
    3837 * Preference settings for map paint styles.
    3938 */
    40 public class MapPaintPreference implements SubPreferenceSetting {
     39public class MapPaintPreference extends DefaultTabPreferenceSetting {
    4140    private SourceEditor sources;
    4241    private JCheckBox enableIconDefault;
    4342
    public class MapPaintPreference implements SubPreferenceSetting {  
    6463        }
    6564    }
    6665
     66    public MapPaintPreference() {
     67        super(null, tr("Map Paint Styles"), tr("Styles for rendering the OSM data."));
     68    }
     69
    6770    @Override
    68     public void addGui(PreferenceTabbedPane gui) {
     71    public void addGui(final PreferenceTabbedPane gui) {
    6972        enableIconDefault = new JCheckBox(tr("Enable built-in icon defaults"),
    7073                Main.pref.getBoolean("mappaint.icon.enable-defaults", true));
    7174
    public class MapPaintPreference implements SubPreferenceSetting {  
    7780        panel.add(sources, GBC.eol().fill(GBC.BOTH));
    7881        panel.add(enableIconDefault, GBC.eol().insets(11,2,5,0));
    7982
    80         final MapPreference mapPref = gui.getMapPreference();
    81         mapPref.addSubTab(this, tr("Map Paint Styles"), panel);
    82         sources.deferLoading(mapPref, panel);
     83        //createPreferenceTabWithScrollPane(gui, panel);
     84        gui.createPreferenceTab(this).add(panel, GBC.eol().fill(GBC.BOTH));
     85
     86        sources.initiallyLoadAvailableSources();
    8387    }
    8488
    8589    static class MapPaintSourceEditor extends SourceEditor {
    public class MapPaintPreference implements SubPreferenceSetting {  
    313317    public boolean isExpert() {
    314318        return false;
    315319    }
    316 
    317     @Override
    318     public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
    319         return gui.getMapPreference();
    320     }
    321320}
  • deleted file src/org/openstreetmap/josm/gui/preferences/map/MapPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/map/MapPreference.java b/src/org/openstreetmap/josm/gui/preferences/map/MapPreference.java
    deleted file mode 100644
    index 45b6b19..0000000
    + -  
    1 //License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.preferences.map;
    3 
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    5 
    6 import javax.swing.JTabbedPane;
    7 
    8 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    9 import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    10 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    11 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    12 import org.openstreetmap.josm.tools.GBC;
    13 
    14 /**
    15  * Map preferences, including map paint styles, tagging presets and autosave sub-preferences.
    16  */
    17 public final class MapPreference extends DefaultTabPreferenceSetting {
    18 
    19     /**
    20      * Factory used to create a new {@code MapPreference}.
    21      */
    22     public static class Factory implements PreferenceSettingFactory {
    23         @Override
    24         public PreferenceSetting createPreferenceSetting() {
    25             return new MapPreference();
    26         }
    27     }
    28    
    29     private MapPreference() {
    30         super("map", tr("Map Settings"), tr("Settings for the map projection and data interpretation."), false, new JTabbedPane());
    31     }
    32    
    33     @Override
    34     public boolean ok() {
    35         return false;
    36     }
    37 
    38     @Override
    39     public void addGui(PreferenceTabbedPane gui) {
    40         gui.createPreferenceTab(this).add(getTabPane(), GBC.eol().fill(GBC.BOTH));
    41     }
    42 }
  • src/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreference.java b/src/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreference.java
    index 034bd25..2d08175 100644
    a b import java.util.Collections;  
    1212import java.util.HashMap;
    1313import java.util.List;
    1414import java.util.Map;
    15 
    1615import javax.swing.BorderFactory;
    1716import javax.swing.JCheckBox;
    1817import javax.swing.JLabel;
    1918import javax.swing.JOptionPane;
    2019import javax.swing.JPanel;
    21 
     20import javax.swing.JSeparator;
    2221import org.openstreetmap.josm.Main;
    2322import org.openstreetmap.josm.gui.ExtendedDialog;
     23import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    2424import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    2525import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    2626import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    import org.openstreetmap.josm.gui.preferences.SourceEditor;  
    2929import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry;
    3030import org.openstreetmap.josm.gui.preferences.SourceEntry;
    3131import org.openstreetmap.josm.gui.preferences.SourceProvider;
     32import org.openstreetmap.josm.gui.tagging.TaggingPreset;
     33import org.openstreetmap.josm.gui.tagging.TaggingPresetMenu;
     34import org.openstreetmap.josm.gui.tagging.TaggingPresetSeparator;
     35import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager;
    3236import org.openstreetmap.josm.gui.preferences.SourceType;
    3337import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    3438import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    import org.xml.sax.SAXParseException;  
    4044/**
    4145 * Preference settings for tagging presets.
    4246 */
    43 public final class TaggingPresetPreference implements SubPreferenceSetting {
     47public class TaggingPresetPreference extends DefaultTabPreferenceSetting {
    4448
    4549    /**
    4650     * Factory used to create a new {@code TaggingPresetPreference}.
    public final class TaggingPresetPreference implements SubPreferenceSetting {  
    5357    }
    5458
    5559    private TaggingPresetPreference() {
    56         super();
     60        super(null, tr("Tagging Presets"), tr("Presets give meaning to OSM tag combinations."));
    5761    }
    5862
    5963    private static final List<SourceProvider> presetSourceProviders = new ArrayList<>();
    public final class TaggingPresetPreference implements SubPreferenceSetting {  
    160164    };
    161165
    162166    @Override
    163     public void addGui(PreferenceTabbedPane gui) {
     167    public void addGui(final PreferenceTabbedPane gui) {
    164168        sortMenu = new JCheckBox(tr("Sort presets menu"),
    165169                Main.pref.getBoolean("taggingpreset.sortmenu", false));
    166170
    public final class TaggingPresetPreference implements SubPreferenceSetting {  
    169173        panel.add(sortMenu, GBC.eol().insets(5,5,5,0));
    170174        sources = new TaggingPresetSourceEditor();
    171175        panel.add(sources, GBC.eol().fill(GBC.BOTH));
    172         final MapPreference mapPref = gui.getMapPreference();
    173         mapPref.addSubTab(this, tr("Tagging Presets"), panel);
    174         sources.deferLoading(mapPref, panel);
    175         gui.addValidationListener(validationListener);
     176
     177        //createPreferenceTabWithScrollPane(gui, panel);
     178        gui.createPreferenceTab(this).add(panel, GBC.eol().fill(GBC.BOTH));
     179
     180        sources.initiallyLoadAvailableSources();
    176181    }
    177182
    178183    static class TaggingPresetSourceEditor extends SourceEditor {
    public final class TaggingPresetPreference implements SubPreferenceSetting {  
    304309    public boolean isExpert() {
    305310        return false;
    306311    }
    307 
    308     @Override
    309     public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
    310         return gui.getMapPreference();
    311     }
    312312}
  • src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java b/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
    index 7cc984d..ce8fa95 100644
    a b import javax.swing.JList;  
    3030import javax.swing.JOptionPane;
    3131import javax.swing.JPanel;
    3232import javax.swing.JScrollPane;
    33 import javax.swing.JTabbedPane;
    3433import javax.swing.SwingUtilities;
    3534import javax.swing.UIManager;
    3635import javax.swing.event.DocumentEvent;
    import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;  
    4544import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    4645import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    4746import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    48 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.PreferencePanel;
    4947import org.openstreetmap.josm.gui.util.GuiHelper;
    5048import org.openstreetmap.josm.gui.widgets.JosmTextField;
    5149import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
    public final class PluginPreference extends DefaultTabPreferenceSetting {  
    7371    }
    7472
    7573    private PluginPreference() {
    76         super("plugin", tr("Plugins"), tr("Configure available plugins."), false, new JTabbedPane());
     74        super("plugin", tr("Plugins"), tr("Configure available plugins."));
    7775    }
    7876
    7977    /**
    public final class PluginPreference extends DefaultTabPreferenceSetting {  
    148146    private PluginListPanel pnlPluginPreferences;
    149147    private PluginPreferencesModel model;
    150148    private JScrollPane spPluginPreferences;
    151     private PluginUpdatePolicyPanel pnlPluginUpdatePolicy;
    152149
    153150    /**
    154151     * is set to true if this preference pane has been selected
    public final class PluginPreference extends DefaultTabPreferenceSetting {  
    210207        return pnl;
    211208    }
    212209
    213     protected JTabbedPane buildContentPane() {
    214         JTabbedPane pane = getTabPane();
    215         pnlPluginUpdatePolicy = new PluginUpdatePolicyPanel();
    216         pane.addTab(tr("Plugins"), buildPluginListPanel());
    217         pane.addTab(tr("Plugin update policy"), pnlPluginUpdatePolicy);
    218         return pane;
    219     }
    220 
    221210    @Override
    222211    public void addGui(final PreferenceTabbedPane gui) {
    223212        GridBagConstraints gc = new GridBagConstraints();
    public final class PluginPreference extends DefaultTabPreferenceSetting {  
    225214        gc.weighty = 1.0;
    226215        gc.anchor = GridBagConstraints.NORTHWEST;
    227216        gc.fill = GridBagConstraints.BOTH;
    228         PreferencePanel plugins = gui.createPreferenceTab(this);
    229         plugins.add(buildContentPane(), gc);
     217        gui.createPreferenceTab(this).add(buildPluginListPanel(), gc);
    230218        readLocalPluginInformation();
    231219        pluginPreferencesActivated = true;
    232220    }
    public final class PluginPreference extends DefaultTabPreferenceSetting {  
    277265    public boolean ok() {
    278266        if (! pluginPreferencesActivated)
    279267            return false;
    280         pnlPluginUpdatePolicy.rememberInPreferences();
    281268        if (model.isActivePluginsChanged()) {
    282269            LinkedList<String> l = new LinkedList<>(model.getSelectedPluginNames());
    283270            Collections.sort(l);
  • src/org/openstreetmap/josm/gui/preferences/plugin/PluginUpdatePolicyPanel.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/plugin/PluginUpdatePolicyPanel.java b/src/org/openstreetmap/josm/gui/preferences/plugin/PluginUpdatePolicyPanel.java
    index 68053cc..f0c9a39 100644
    a b import javax.swing.event.ChangeEvent;  
    1818import javax.swing.event.ChangeListener;
    1919
    2020import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
     22import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     23import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     24import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    2125import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    2226import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
    2327import org.openstreetmap.josm.plugins.PluginHandler;
    2428import org.openstreetmap.josm.gui.widgets.JosmTextField;
     29import org.openstreetmap.josm.tools.GBC;
    2530
    2631/**
    2732 * A panel for configuring whether JOSM shall update plugins at startup.
    import org.openstreetmap.josm.gui.widgets.JosmTextField;  
    2934 */
    3035public class PluginUpdatePolicyPanel extends JPanel {
    3136
     37    /**
     38     * Factory used to create a new {@code PluginUpdatePolicy}.
     39     */
     40    public static class Factory implements PreferenceSettingFactory {
     41
     42        protected final PluginUpdatePolicyPanel panel = new PluginUpdatePolicyPanel();
     43
     44        @Override
     45        public PreferenceSetting createPreferenceSetting() {
     46            return new DefaultTabPreferenceSetting(null, tr("Plugin update policy"), tr("Change the policy for updating plugins.")) {
     47                @Override
     48                public void addGui(PreferenceTabbedPane gui) {
     49                    gui.createPreferenceTab(this).add(panel, GBC.std().fill(GBC.BOTH));
     50                }
     51
     52                @Override
     53                public boolean ok() {
     54                    panel.rememberInPreferences();
     55                    return false;
     56                }
     57            };
     58        }
     59    }
     60
    3261    private enum Policy {
    3362        ASK ("ask"),
    3463        ALWAYS("always"),
  • src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java b/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java
    index 5307b3f..52ccaa2 100644
    a b import java.util.HashMap;  
    1414import java.util.List;
    1515import java.util.Map;
    1616
    17 import javax.swing.BorderFactory;
    18 import javax.swing.JLabel;
    19 import javax.swing.JOptionPane;
    20 import javax.swing.JPanel;
    21 import javax.swing.JScrollPane;
    22 import javax.swing.JSeparator;
     17import javax.swing.*;
    2318
    2419import org.openstreetmap.josm.Main;
    2520import org.openstreetmap.josm.data.Bounds;
    import org.openstreetmap.josm.data.preferences.StringProperty;  
    3025import org.openstreetmap.josm.data.projection.CustomProjection;
    3126import org.openstreetmap.josm.data.projection.Projection;
    3227import org.openstreetmap.josm.gui.NavigatableComponent;
     28import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    3329import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    3430import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    3531import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    36 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    37 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    3832import org.openstreetmap.josm.gui.widgets.JosmComboBox;
    3933import org.openstreetmap.josm.tools.GBC;
    4034
    import org.openstreetmap.josm.tools.GBC;  
    5448 *    a manual implementation of the projection. Use {@link CustomProjection}
    5549 *    if possible.
    5650 */
    57 public class ProjectionPreference implements SubPreferenceSetting {
     51public class ProjectionPreference extends DefaultTabPreferenceSetting {
    5852
    5953    /**
    6054     * Factory used to create a new {@code ProjectionPreference}.
    public class ProjectionPreference implements SubPreferenceSetting {  
    6660        }
    6761    }
    6862
     63    private ProjectionPreference() {
     64        super("map", tr("Map Projection"), tr("Settings for the map projection and data interpretation."));
     65    }
     66
    6967    private static List<ProjectionChoice> projectionChoices = new ArrayList<>();
    7068    private static Map<String, ProjectionChoice> projectionChoicesById = new HashMap<>();
    7169
    public class ProjectionPreference implements SubPreferenceSetting {  
    337335        projPanel.add(unitsCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5));
    338336        projPanel.add(GBC.glue(1,1), GBC.std().fill(GBC.HORIZONTAL).weight(1.0, 1.0));
    339337
    340         JScrollPane scrollpane = new JScrollPane(projPanel);
    341         gui.getMapPreference().addSubTab(this, tr("Map Projection"), scrollpane);
     338        createPreferenceTabWithScrollPane(gui, projPanel);
    342339
    343340        selectedProjectionChanged(pc);
    344341    }
    public class ProjectionPreference implements SubPreferenceSetting {  
    350347        projectionName.setText(proj.toString());
    351348        Bounds b = proj.getWorldBoundsLatLon();
    352349        CoordinateFormat cf = CoordinateFormat.getDefaultFormat();
    353         bounds.setText(b.getMin().lonToString(cf)+", "+b.getMin().latToString(cf)+" : "+b.getMax().lonToString(cf)+", "+b.getMax().latToString(cf));
     350        bounds.setText(b.getMin().lonToString(cf) + ", " + b.getMin().latToString(cf) + " : " + b.getMax().lonToString(cf) + ", " + b.getMax().latToString(cf));
    354351        boolean showCode = true;
    355352        boolean showName = false;
    356353        if (pc instanceof SubPrefsOptions) {
    public class ProjectionPreference implements SubPreferenceSetting {  
    404401        id = pc.getId();
    405402        PROP_PROJECTION.put(id);
    406403        PROP_SUB_PROJECTION.put(pref);
    407         Main.pref.putCollection("projection.sub."+id, pref);
     404        Main.pref.putCollection("projection.sub." + id, pref);
    408405        pc.setPreferences(pref);
    409406        Projection proj = pc.getProjection();
    410407        Main.setProjection(proj);
    public class ProjectionPreference implements SubPreferenceSetting {  
    476473        return false;
    477474    }
    478475
    479     @Override
    480     public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {
    481         return gui.getMapPreference();
    482     }
    483 
    484476    /**
    485477     * Selects the given projection.
    486478     * @param projection The projection to select.
  • src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java b/src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java
    index 989a9ed..d748885 100644
    a b public final class RemoteControlPreference extends DefaultTabPreferenceSetting {  
    113113        };
    114114        enableRemoteControl.addActionListener(remoteControlEnabled);
    115115        remoteControlEnabled.actionPerformed(null);
    116         createPreferenceTabWithScrollPane(gui, remote);
     116        //createPreferenceTabWithScrollPane(gui, remote);
     117        gui.createPreferenceTab(this).add(remote, GBC.eol().fill(GBC.BOTH));
    117118    }
    118119
    119120    @Override
  • deleted file src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreference.java b/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreference.java
    deleted file mode 100644
    index 88f8176..0000000
    + -  
    1 // License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.gui.preferences.server;
    3 
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    5 
    6 import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    7 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    8 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    9 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    10 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    11 
    12 /**
    13  * Authentication sub-preferences in server preferences.
    14  * @since 6523
    15  */
    16 public final class AuthenticationPreference implements SubPreferenceSetting {
    17 
    18     /**
    19      * Factory used to create a new {@code AuthenticationPreference}.
    20      */
    21     public static class Factory implements PreferenceSettingFactory {
    22         @Override
    23         public PreferenceSetting createPreferenceSetting() {
    24             return new AuthenticationPreference();
    25         }
    26     }
    27 
    28     AuthenticationPreferencesPanel pnlAuthPreferences;
    29 
    30     private AuthenticationPreference() {
    31         super();
    32     }
    33 
    34     @Override
    35     public void addGui(PreferenceTabbedPane gui) {
    36         pnlAuthPreferences = new AuthenticationPreferencesPanel();
    37         gui.getServerPreference().addApiUrlChangeListener(pnlAuthPreferences);
    38         gui.getServerPreference().addSubTab(this, tr("Authentication"),
    39                 pnlAuthPreferences.getVerticalScrollPane(),
    40                 tr("Configure your identity and how to authenticate at the OSM server"));
    41     }
    42 
    43     @Override
    44     public boolean ok() {
    45         pnlAuthPreferences.saveToPreferences();
    46         return false;
    47     }
    48 
    49     @Override
    50     public boolean isExpert() {
    51         return false;
    52     }
    53 
    54     @Override
    55     public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {
    56         return gui.getServerPreference();
    57     }
    58 }
  • src/org/openstreetmap/josm/gui/preferences/server/ProxyPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreference.java b/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreference.java
    index ddbaa4b..2fea5cf 100644
    a b import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;  
    1616 * Proxy sub-preferences in server preferences.
    1717 * @since 6523
    1818 */
    19 public final class ProxyPreference implements SubPreferenceSetting {
    20 
    21     /**
    22      * Factory used to create a new {@code ProxyPreference}.
    23      */
    24     public static class Factory implements PreferenceSettingFactory {
    25         @Override
    26         public PreferenceSetting createPreferenceSetting() {
    27             return new ProxyPreference();
    28         }
    29     }
     19public final class ProxyPreference {
    3020
    3121    private static Set<ProxyPreferenceListener> listeners = new HashSet<>();
    3222   
    public final class ProxyPreference implements SubPreferenceSetting {  
    3626        super();
    3727    }
    3828
    39     @Override
    40     public void addGui(PreferenceTabbedPane gui) {
    41         pnlProxyPreferences = new ProxyPreferencesPanel();
    42         gui.getServerPreference().addSubTab(this, tr("Proxy settings"),
    43                 pnlProxyPreferences.getVerticalScrollPane(),
    44                 tr("Configure whether to use a proxy server"));
    45     }
    46 
    47     @Override
    48     public boolean ok() {
    49         pnlProxyPreferences.saveToPreferences();
    50         for (ProxyPreferenceListener listener : listeners) {
    51             listener.proxyPreferenceChanged();
    52         }
    53         return false;
    54     }
    55 
    56     @Override
    57     public boolean isExpert() {
    58         return false;
    59     }
    60 
    61     @Override
    62     public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {
    63         return gui.getServerPreference();
    64     }
    65    
    6629    /**
    6730     * Adds a new ProxyPreferenceListener.
    6831     * @param listener the listener to add
  • src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java b/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java
    index 5e179a8..731d5b9 100644
    a b import java.net.ProxySelector;  
    1717import java.util.HashMap;
    1818import java.util.Map;
    1919
    20 import javax.swing.BorderFactory;
     20import javax.swing.Box;
    2121import javax.swing.ButtonGroup;
    2222import javax.swing.JLabel;
    2323import javax.swing.JPanel;
    import javax.swing.JRadioButton;  
    2525
    2626import org.openstreetmap.josm.Main;
    2727import org.openstreetmap.josm.gui.help.HelpUtil;
     28import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
     29import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     30import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
     31import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    2832import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    2933import org.openstreetmap.josm.gui.widgets.JosmPasswordField;
    3034import org.openstreetmap.josm.gui.widgets.JosmTextField;
    import org.openstreetmap.josm.tools.GBC;  
    4044 */
    4145public class ProxyPreferencesPanel extends VerticallyScrollablePanel {
    4246
     47    public static class Factory implements PreferenceSettingFactory {
     48
     49        @Override
     50        public PreferenceSetting createPreferenceSetting() {
     51            return new DefaultTabPreferenceSetting(null, tr("Proxy settings"), tr("Configure whether to use a proxy server")) {
     52
     53                private ProxyPreferencesPanel pnlProxyPreferences;
     54
     55                @Override
     56                public void addGui(PreferenceTabbedPane gui) {
     57                    //createPreferenceTabWithScrollPane(gui, pnlProxyPreferences = new ProxyPreferencesPanel());
     58                    pnlProxyPreferences = new ProxyPreferencesPanel();
     59                    gui.createPreferenceTab(this).add(pnlProxyPreferences, GBC.eol().fill(GBC.BOTH));
     60                    pnlProxyPreferences.initFromPreferences();
     61                }
     62
     63                @Override
     64                public boolean ok() {
     65                    pnlProxyPreferences.saveToPreferences();
     66                    return false;
     67                }
     68            };
     69        }
     70    }
     71
    4372    /**
    4473     * The proxy policy is how JOSM will use proxy information.
    4574     */
    public class ProxyPreferencesPanel extends VerticallyScrollablePanel {  
    392421     */
    393422    public ProxyPreferencesPanel() {
    394423        setLayout(new GridBagLayout());
    395         setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    396         add(buildProxySettingsPanel(), GBC.eop().anchor(GridBagConstraints.NORTHWEST).fill(GridBagConstraints.BOTH));
     424        add(buildProxySettingsPanel(), GBC.eop().fill(GBC.HORIZONTAL));
     425        add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
    397426
    398427        initFromPreferences();
    399428        updateEnabledState();
  • src/org/openstreetmap/josm/gui/preferences/server/ServerAccessPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/server/ServerAccessPreference.java b/src/org/openstreetmap/josm/gui/preferences/server/ServerAccessPreference.java
    index e1f3fce..5445834 100644
    a b package org.openstreetmap.josm.gui.preferences.server;  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.BorderLayout;
    7 import java.awt.GridBagConstraints;
    8 import java.awt.GridBagLayout;
    9 import java.awt.Insets;
    10 import java.beans.PropertyChangeListener;
    11 
    12 import javax.swing.JPanel;
    13 import javax.swing.JTabbedPane;
    14 
    156import org.openstreetmap.josm.gui.help.HelpUtil;
    167import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    178import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    189import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    1910import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     11import org.openstreetmap.josm.tools.GBC;
     12import java.awt.GridBagLayout;
     13import javax.swing.Box;
     14import javax.swing.JPanel;
    2015
    21 /**
    22  * Connection preferences, including authentication and proxy sub-preferences.
    23  */
    24 public final class ServerAccessPreference extends DefaultTabPreferenceSetting {
     16public class ServerAccessPreference extends DefaultTabPreferenceSetting {
    2517
    26     /**
    27      * Factory used to create a new {@code ServerAccessPreference}.
    28      */
    2918    public static class Factory implements PreferenceSettingFactory {
    30         @Override
    3119        public PreferenceSetting createPreferenceSetting() {
    3220            return new ServerAccessPreference();
    3321        }
    3422    }
    3523
    3624    private ServerAccessPreference() {
    37         super("connection", tr("Connection Settings"), tr("Connection Settings for the OSM server."), false, new JTabbedPane());
     25        super("connection", tr("Connection Settings"),
     26                tr("Connection Settings for the OSM server as well as your identity and how to authenticate at the OSM server."));
    3827    }
    3928
    40     /** indicates whether to use the default OSM URL or not */
    4129    private OsmApiUrlInputPanel pnlApiUrlPreferences;
    4230
    43     /**
    44      * Builds the tabbed pane with the server preferences
    45      *
    46      * @return panel with server preferences tabs
    47      */
    48     protected JPanel buildTabbedServerPreferences() {
    49         JPanel pnl = new JPanel(new BorderLayout());
    50         pnl.add(getTabPane(), BorderLayout.CENTER);
    51         return pnl;
    52     }
     31    /** indicates whether to use the default OSM URL or not */
     32    /** panel for configuring authentication preferences */
     33    private AuthenticationPreferencesPanel pnlAuthPreferences;
    5334
    5435    /**
    5536     * Builds the panel for entering the server access preferences
    5637     *
    57      * @return preferences panel for server settings
     38     * @return
    5839     */
    5940    protected JPanel buildContentPanel() {
    6041        JPanel pnl = new JPanel(new GridBagLayout());
    61         GridBagConstraints gc = new GridBagConstraints();
    6242
    63         // the checkbox for the default UL
    64         gc.fill = GridBagConstraints.HORIZONTAL;
    65         gc.anchor = GridBagConstraints.NORTHWEST;
    66         gc.weightx = 1.0;
    67         gc.insets = new Insets(0,0,0,0);
    68         pnlApiUrlPreferences = new OsmApiUrlInputPanel();
    69         pnl.add(pnlApiUrlPreferences, gc);
     43        pnl.add(pnlApiUrlPreferences = new OsmApiUrlInputPanel(), GBC.eop().fill(GBC.HORIZONTAL));
     44        pnl.add(pnlAuthPreferences = new AuthenticationPreferencesPanel(), GBC.eop().fill(GBC.HORIZONTAL));
     45        pnl.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
    7046
    71         // the remaining access properties
    72         gc.gridy = 1;
    73         gc.fill = GridBagConstraints.BOTH;
    74         gc.weightx = 1.0;
    75         gc.weighty = 1.0;
    76         gc.insets = new Insets(10,0,3,3);
    77         pnl.add(buildTabbedServerPreferences(), gc);
     47        // let the AuthPreferencesPanel know when the API URL changes
     48        pnlApiUrlPreferences.addPropertyChangeListener(pnlAuthPreferences);
    7849
    7950        HelpUtil.setHelpContext(pnl, HelpUtil.ht("/Preferences/Connection"));
    8051        return pnl;
    8152    }
    8253
    83     /**
    84      * Adds a listener that will be notified of API URL change.
    85      * @param listener the listener
    86      * @since 6523
    87      */
    88     public final void addApiUrlChangeListener(PropertyChangeListener listener) {
    89         pnlApiUrlPreferences.addPropertyChangeListener(listener);
    90     }
    91 
    92     @Override
    9354    public void addGui(PreferenceTabbedPane gui) {
    94         GridBagConstraints gc = new GridBagConstraints();
    95         gc.fill = GridBagConstraints.BOTH;
    96         gc.weightx = 1.0;
    97         gc.weighty = 1.0;
    98         gc.anchor = GridBagConstraints.NORTHWEST;
    99         gui.createPreferenceTab(this).add(buildContentPanel(), gc);
     55        //createPreferenceTabWithScrollPane(gui, buildContentPanel());
     56        gui.createPreferenceTab(this).add(buildContentPanel(), GBC.eol().fill(GBC.BOTH));
     57        initFromPreferences();
     58    }
    10059
     60    /**
     61     * Initializes the configuration panel with values from the preferences
     62     */
     63    public void initFromPreferences() {
    10164        pnlApiUrlPreferences.initFromPreferences();
     65        pnlAuthPreferences.initFromPreferences();
    10266    }
    10367
    10468    /**
    10569     * Saves the values to the preferences
    10670     */
    107     @Override
    10871    public boolean ok() {
    10972        pnlApiUrlPreferences.saveToPreferences();
     73        pnlAuthPreferences.saveToPreferences();
    11074        return false;
    11175    }
    11276}
  • src/org/openstreetmap/josm/gui/preferences/validator/ValidatorPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorPreference.java b/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorPreference.java
    index 6b15d40..22d3489 100644
    a b package org.openstreetmap.josm.gui.preferences.validator;  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import javax.swing.BorderFactory;
     7import javax.swing.JCheckBox;
     8import javax.swing.JLabel;
     9import javax.swing.JPanel;
    610import javax.swing.JTabbedPane;
    711
     12import org.openstreetmap.josm.Main;
    813import org.openstreetmap.josm.data.preferences.BooleanProperty;
     14import org.openstreetmap.josm.data.validation.OsmValidator;
     15import org.openstreetmap.josm.data.validation.Test;
     16import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
    917import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    1018import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    1119import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    1220import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    1321import org.openstreetmap.josm.tools.GBC;
    1422
     23import java.awt.GridBagLayout;
     24import java.awt.event.ActionEvent;
     25import java.awt.event.ActionListener;
     26import java.util.ArrayList;
     27import java.util.Collection;
     28import java.util.LinkedList;
     29import java.util.List;
     30
    1531/**
    1632 * Preference settings for the validator.
    1733 *
    public final class ValidatorPreference extends DefaultTabPreferenceSetting {  
    6278     */
    6379    public static final String PREF_FILTER_BY_SELECTION = PREFIX + ".selectionFilter";
    6480
     81    private JCheckBox prefUseIgnore;
     82    private JCheckBox prefUseLayer;
     83    private JCheckBox prefOtherUpload;
     84    private JCheckBox prefOther;
     85
     86    /** The list of all tests */
     87    private Collection<Test> allTests;
     88
    6589    @Override
    6690    public void addGui(PreferenceTabbedPane gui) {
    67         gui.createPreferenceTab(this).add(getTabPane(), GBC.eol().fill(GBC.BOTH));
     91        JPanel testPanel = new JPanel(new GridBagLayout());
     92        testPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
     93
     94        prefUseIgnore = new JCheckBox(tr("Use ignore list."), Main.pref.getBoolean(ValidatorPreference.PREF_USE_IGNORE, true));
     95        prefUseIgnore.setToolTipText(tr("Use the ignore list to suppress warnings."));
     96        testPanel.add(prefUseIgnore, GBC.eol());
     97
     98        prefUseLayer = new JCheckBox(tr("Use error layer."), Main.pref.getBoolean(ValidatorPreference.PREF_LAYER, true));
     99        prefUseLayer.setToolTipText(tr("Use the error layer to display problematic elements."));
     100        testPanel.add(prefUseLayer, GBC.eol());
     101
     102        prefOther = new JCheckBox(tr("Show informational level."), ValidatorPreference.PREF_OTHER.get());
     103        prefOther.setToolTipText(tr("Show the informational tests."));
     104        testPanel.add(prefOther, GBC.eol());
     105
     106        prefOtherUpload = new JCheckBox(tr("Show informational level on upload."), Main.pref.getBoolean(ValidatorPreference.PREF_OTHER_UPLOAD, false));
     107        prefOtherUpload.setToolTipText(tr("Show the informational tests in the upload check windows."));
     108        testPanel.add(prefOtherUpload, GBC.eol());
     109
     110        ActionListener otherUploadEnabled = new ActionListener() {
     111            @Override
     112            public void actionPerformed(ActionEvent e) {
     113                prefOtherUpload.setEnabled(prefOther.isSelected());
     114            }
     115        };
     116        prefOther.addActionListener(otherUploadEnabled);
     117        otherUploadEnabled.actionPerformed(null);
     118
     119        GBC a = GBC.eol().insets(-5,0,0,0);
     120        a.anchor = GBC.EAST;
     121        testPanel.add( new JLabel(tr("On demand")), GBC.std() );
     122        testPanel.add( new JLabel(tr("On upload")), a );
     123
     124        allTests = OsmValidator.getTests();
     125        for (Test test: allTests) {
     126            test.addGui(testPanel);
     127        }
     128
     129        createPreferenceTabWithScrollPane(gui, testPanel);
    68130    }
    69131
    70132    @Override
    71133    public boolean ok() {
     134        Collection<String> tests = new LinkedList<>();
     135        Collection<String> testsBeforeUpload = new LinkedList<>();
     136
     137        for (Test test : allTests) {
     138            test.ok();
     139            String name = test.getClass().getSimpleName();
     140            if(!test.enabled)
     141                tests.add(name);
     142            if(!test.testBeforeUpload)
     143                testsBeforeUpload.add(name);
     144        }
     145
     146        // Initializes all tests but MapCSSTagChecker because it is initialized
     147        // later in ValidatorTagCheckerRulesPreference.ok(),
     148        // after its list of rules has been saved to preferences
     149        List<Test> testsToInitialize = new ArrayList<>(allTests);
     150        testsToInitialize.remove(OsmValidator.getTest(MapCSSTagChecker.class));
     151        OsmValidator.initializeTests(testsToInitialize);
     152
     153        Main.pref.putCollection(ValidatorPreference.PREF_SKIP_TESTS, tests);
     154        Main.pref.putCollection(ValidatorPreference.PREF_SKIP_TESTS_BEFORE_UPLOAD, testsBeforeUpload);
     155        Main.pref.put(ValidatorPreference.PREF_USE_IGNORE, prefUseIgnore.isSelected());
     156        ValidatorPreference.PREF_OTHER.put(prefOther.isSelected());
     157        Main.pref.put(ValidatorPreference.PREF_OTHER_UPLOAD, prefOtherUpload.isSelected());
     158        Main.pref.put(ValidatorPreference.PREF_LAYER, prefUseLayer.isSelected());
    72159        return false;
    73160    }
     161
     162    @Override
     163    public boolean isExpert() {
     164        return false;
     165    }
     166
    74167}
  • src/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreference.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreference.java b/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreference.java
    index 295503c..2430a29 100644
    a b import java.util.Map;  
    1414import org.openstreetmap.josm.Main;
    1515import org.openstreetmap.josm.data.validation.OsmValidator;
    1616import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
     17import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    1718import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    1819import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    1920import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry;  
    2223import org.openstreetmap.josm.gui.preferences.SourceEntry;
    2324import org.openstreetmap.josm.gui.preferences.SourceProvider;
    2425import org.openstreetmap.josm.gui.preferences.SourceType;
    25 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    26 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
     26import org.openstreetmap.josm.tools.GBC;
    2727
    2828/**
    2929 * The general validator preferences, allowing to enable/disable tests.
    3030 * @since 6669
    3131 */
    32 public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting {
     32public class ValidatorTagCheckerRulesPreference extends DefaultTabPreferenceSetting {
    3333
    3434    /**
    3535     * Factory used to create a new {@code ValidatorTagCheckerRulesPreference}.
    public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting  
    4141        }
    4242    }
    4343
     44    private ValidatorTagCheckerRulesPreference() {
     45        super("validator", tr("Tag checker rules"), tr("Choose Tag checker rules to enable"));
     46    }
     47
    4448    private static final List<SourceProvider> ruleSourceProviders = new ArrayList<>();
    4549
    4650    /**
    public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting  
    4852     * @param provider The rule source provider
    4953     * @return {@code true}, if the provider has been added, {@code false} otherwise
    5054     */
    51     public static final boolean registerSourceProvider(SourceProvider provider) {
     55    public static boolean registerSourceProvider(SourceProvider provider) {
    5256        if (provider != null)
    5357            return ruleSourceProviders.add(provider);
    5458        return false;
    public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting  
    178182
    179183    @Override
    180184    public void addGui(PreferenceTabbedPane gui) {
    181         final ValidatorPreference valPref = gui.getValidatorPreference();
    182185        sources = new TagCheckerRulesSourceEditor();
    183        
    184         valPref.addSubTab(this, tr("Tag checker rules"),
    185                 sources, tr("Choose Tag checker rules to enable"));
    186         sources.deferLoading(valPref, sources);
     186        gui.createPreferenceTab(this).add(sources, GBC.eol().fill(GBC.BOTH));
    187187    }
    188188
    189189    @Override
    public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting  
    203203    public boolean isExpert() {
    204204        return false;
    205205    }
    206 
    207     @Override
    208     public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {
    209         return gui.getValidatorPreference();
    210     }
    211206}
  • src/org/openstreetmap/josm/tools/I18n.java

    diff --git a/src/org/openstreetmap/josm/tools/I18n.java b/src/org/openstreetmap/josm/tools/I18n.java
    index a995204..6dc0c23 100644
    a b import java.net.URL;  
    1010import java.nio.charset.StandardCharsets;
    1111import java.text.MessageFormat;
    1212import java.util.ArrayList;
    13 import java.util.Arrays;
    14 import java.util.Collection;
     13import java.util.Collections;
    1514import java.util.Comparator;
    1615import java.util.HashMap;
     16import java.util.List;
    1717import java.util.Locale;
    1818import java.util.Map;
    1919import java.util.jar.JarInputStream;
    public final class I18n {  
    321321
    322322    /**
    323323     * Get a list of all available JOSM Translations.
    324      * @return an array of locale objects.
     324     * @return a sorted list of locale objects.
    325325     */
    326     public static final Locale[] getAvailableTranslations() {
    327         Collection<Locale> v = new ArrayList<>(languages.size());
    328         if(getTranslationFile("en") != null)
    329         {
     326    public static final List<Locale> getAvailableTranslationsAsList() {
     327        List<Locale> v = new ArrayList<>(languages.size());
     328        if (getTranslationFile("en") != null) {
    330329            for (String loc : languages.keySet()) {
    331                 if(getTranslationFile(loc) != null) {
     330                if (getTranslationFile(loc) != null) {
    332331                    v.add(LanguageInfo.getLocale(loc));
    333332                }
    334333            }
    335334        }
    336335        v.add(Locale.ENGLISH);
    337         Locale[] l = new Locale[v.size()];
    338         l = v.toArray(l);
    339         Arrays.sort(l, new Comparator<Locale>() {
     336        Collections.sort(v, new Comparator<Locale>() {
    340337            @Override
    341338            public int compare(Locale o1, Locale o2) {
    342339                return o1.toString().compareTo(o2.toString());
    343340            }
    344341        });
    345         return l;
     342        return v;
     343    }
     344
     345    /**
     346     * Get an array of all available JOSM Translations.
     347     * @return an array of locale objects.
     348     */
     349    public static final Locale[] getAvailableTranslations() {
     350        List<Locale> locales = getAvailableTranslationsAsList();
     351        return locales.toArray(new Locale[locales.size()]);
    346352    }
    347353
    348354    public static boolean hasCode(String code)