Ticket #7548: 7548_2014_v3.patch
File 7548_2014_v3.patch, 85.5 KB (added by , 10 years ago) |
---|
-
src/org/openstreetmap/josm/actions/PreferencesAction.java
diff --git a/src/org/openstreetmap/josm/actions/PreferencesAction.java b/src/org/openstreetmap/josm/actions/PreferencesAction.java index ba20cbe..9c88cb5 100644
a b public class PreferencesAction extends JosmAction implements Runnable { 58 58 } 59 59 60 60 /** 61 * Returns a new {@code PreferenceAction} opening preferences dialog directly to the given subtab, with default icon.62 * @param name The action name63 * @param tooltip The action tooltip64 * @param subTab The preferences subtab to select65 * @return The created action66 */67 public static PreferencesAction forPreferenceSubTab(String name, String tooltip, Class<? extends SubPreferenceSetting> subTab) {68 return forPreferenceSubTab(name, tooltip, subTab, "preference");69 }70 71 /**72 * Returns a new {@code PreferenceAction} opening preferences dialog directly to the given subtab, with custom icon.73 * @param name The action name74 * @param tooltip The action tooltip75 * @param subTab The preferences subtab to select76 * @param icon The action icon77 * @return The created action78 * @since 696979 */80 public static PreferencesAction forPreferenceSubTab(String name, String tooltip, Class<? extends SubPreferenceSetting> subTab, String icon) {81 CheckParameterUtil.ensureParameterNotNull(subTab);82 return new PreferencesAction(name, icon, tooltip, null, subTab);83 }84 85 /**86 61 * Create the preference action with "Preferences" as label. 87 62 */ 88 63 public PreferencesAction() { -
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..39978d1 100644
a b import org.openstreetmap.josm.data.Version; 45 45 import org.openstreetmap.josm.gui.download.DownloadDialog; 46 46 import org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder; 47 47 import org.openstreetmap.josm.gui.preferences.server.ProxyPreference; 48 import org.openstreetmap.josm.gui.preferences.server.ServerAccessPreference; 48 49 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 49 50 import org.openstreetmap.josm.gui.util.GuiHelper; 50 51 import org.openstreetmap.josm.io.DefaultProxySelector; … … public class MainApplication extends Main { 515 516 ed.setContent(message); 516 517 517 518 if (ed.showDialog().getValue() == 1) { 518 PreferencesAction.forPreference SubTab(null, null, ProxyPreference.class).run();519 PreferencesAction.forPreferenceTab(null, null, ProxyPreference.class).run(); 519 520 } 520 521 } 521 522 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 { 708 708 709 709 add(presetsMenu, presetSearchAction); 710 710 add(presetsMenu, presetSearchPrimitiveAction); 711 add(presetsMenu, PreferencesAction.forPreference SubTab(tr("Preset preferences"),711 add(presetsMenu, PreferencesAction.forPreferenceTab(tr("Preset preferences"), 712 712 tr("Click to open the tagging presets tab in the preferences"), TaggingPresetPreference.class)); 713 713 presetsMenu.addSeparator(); 714 714 -
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; 69 69 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.MapPaintSylesUpdateListener; 70 70 import org.openstreetmap.josm.gui.mappaint.StyleSource; 71 71 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 72 import org.openstreetmap.josm.gui.preferences.PreferenceDialog; 72 73 import org.openstreetmap.josm.gui.preferences.SourceEntry; 73 74 import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference; 74 75 import org.openstreetmap.josm.gui.util.FileFilterAllFiles; … … public class MapPaintDialog extends ToggleDialog implements Main.WindowSwitchLis 94 95 protected MoveUpDownAction downAction; 95 96 protected JCheckBox cbWireframe; 96 97 97 public static final JosmAction PREFERENCE_ACTION = PreferencesAction.forPreference SubTab(98 public static final JosmAction PREFERENCE_ACTION = PreferencesAction.forPreferenceTab( 98 99 tr("Map paint preferences"), null, MapPaintPreference.class, "dialogs/mappaintpreference"); 99 100 100 101 /** -
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. 2 package org.openstreetmap.josm.gui.preferences; 3 4 import org.openstreetmap.josm.Main; 5 import org.openstreetmap.josm.tools.GBC; 6 7 import javax.swing.*; 8 import java.awt.*; 9 import java.util.HashMap; 10 import java.util.Map; 11 12 13 public 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..abf1fdc 100644
a b import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 35 35 import org.openstreetmap.josm.gui.preferences.advanced.AdvancedPreference; 36 36 import org.openstreetmap.josm.gui.preferences.audio.AudioPreference; 37 37 import org.openstreetmap.josm.gui.preferences.display.ColorPreference; 38 import org.openstreetmap.josm.gui.preferences.display.DisplayPreference;39 38 import org.openstreetmap.josm.gui.preferences.display.DrawingPreference; 39 import org.openstreetmap.josm.gui.preferences.display.GPXSettingsPanel; 40 40 import org.openstreetmap.josm.gui.preferences.display.LafPreference; 41 41 import org.openstreetmap.josm.gui.preferences.display.LanguagePreference; 42 42 import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference; 43 43 import org.openstreetmap.josm.gui.preferences.map.BackupPreference; 44 44 import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference; 45 import org.openstreetmap.josm.gui.preferences.map.MapPreference;46 45 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference; 47 46 import org.openstreetmap.josm.gui.preferences.plugin.PluginPreference; 47 import org.openstreetmap.josm.gui.preferences.plugin.PluginUpdatePolicyPanel; 48 48 import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference; 49 49 import org.openstreetmap.josm.gui.preferences.remotecontrol.RemoteControlPreference; 50 import org.openstreetmap.josm.gui.preferences.server.AuthenticationPreference;51 50 import org.openstreetmap.josm.gui.preferences.server.ProxyPreference; 52 51 import org.openstreetmap.josm.gui.preferences.server.ServerAccessPreference; 53 52 import org.openstreetmap.josm.gui.preferences.shortcut.ShortcutPreference; 54 53 import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference; 55 54 import org.openstreetmap.josm.gui.preferences.validator.ValidatorTagCheckerRulesPreference; 56 import org.openstreetmap.josm.gui.preferences.validator.ValidatorTestsPreference;57 55 import org.openstreetmap.josm.plugins.PluginDownloadTask; 58 56 import org.openstreetmap.josm.plugins.PluginHandler; 59 57 import org.openstreetmap.josm.plugins.PluginInformation; … … public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee 238 236 } 239 237 240 238 /** 241 * Returns the {@code D isplayPreference} object.242 * @return the {@code D isplayPreference} object.239 * Returns the {@code DrawingPreference} object. 240 * @return the {@code DrawingPreference} object. 243 241 */ 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); 254 244 } 255 245 256 246 /** … … public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee 427 417 int position = index; 428 418 for (PreferenceTab tab : tabs) { 429 419 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 } 431 425 } 432 426 } 433 427 } … … public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee 455 449 addGUITabsForSetting(icon, tps); 456 450 } else { 457 451 // 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 } 459 457 } 460 458 } 461 459 } else if (!(setting instanceof SubPreferenceSetting)) { … … public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee 489 487 return null; 490 488 } 491 489 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 492 523 static { 524 493 525 // 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."))); 495 527 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()); 503 529 settingsFactory.add(new ProjectionPreference.Factory()); 504 530 settingsFactory.add(new MapPaintPreference.Factory()); 505 531 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 ProxyPreference.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()); 506 542 settingsFactory.add(new BackupPreference.Factory()); 507 settingsFactory.add(new PluginPreference.Factory());508 543 settingsFactory.add(Main.toolbar); 509 settingsFactory.add(new AudioPreference.Factory());510 544 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()); 511 548 settingsFactory.add(new ValidatorPreference.Factory()); 512 settingsFactory.add(new ValidatorTestsPreference.Factory());513 549 settingsFactory.add(new ValidatorTagCheckerRulesPreference.Factory()); 514 550 settingsFactory.add(new RemoteControlPreference.Factory()); 515 settingsFactory.add(new ImageryPreference.Factory());516 517 PluginHandler.getPreferenceSetting(settingsFactory);518 519 // always the last: advanced tab520 551 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 521 558 } 522 559 523 560 /** -
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 { 569 569 private String movingComponent; 570 570 571 571 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.")); 573 573 actionsTreeModel = new DefaultTreeModel(rootActionsNode); 574 574 actionsTree = new JTree(actionsTreeModel); 575 575 } -
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; 41 41 import org.openstreetmap.josm.gui.layer.ImageryLayer; 42 42 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 43 43 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 44 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 44 45 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 45 46 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 46 47 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 47 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;48 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;49 48 import org.openstreetmap.josm.tools.ColorHelper; 50 49 import org.openstreetmap.josm.tools.GBC; 51 50 52 51 /** 53 52 * Color preferences. 54 53 */ 55 public class ColorPreference implements SubPreferenceSetting {54 public class ColorPreference extends DefaultTabPreferenceSetting { 56 55 57 56 /** 58 57 * Factory used to create a new {@code ColorPreference}. … … public class ColorPreference implements SubPreferenceSetting { 72 71 private JButton defaultSet; 73 72 private JButton remove; 74 73 74 public ColorPreference() { 75 super(null, tr("Colors"), tr("Change colors used in program dialogs and in map paint styles.")); 76 } 77 75 78 /** 76 79 * Set the colors to be shown in the preference table. This method creates a table model if 77 80 * none exists and overwrites all existing values. … … public class ColorPreference implements SubPreferenceSetting { 250 253 buttonPanel.add(defaultSet, GBC.std().insets(5,5,5,0)); 251 254 buttonPanel.add(defaultAll, GBC.std().insets(0,5,0,0)); 252 255 buttonPanel.add(remove, GBC.std().insets(0,5,0,0)); 253 gui.getDisplayPreference().addSubTab(this, tr("Colors"), panel); 256 257 createPreferenceTabWithScrollPane(gui, panel); 254 258 } 255 259 256 260 Boolean isRemoveColor(int row) { … … public class ColorPreference implements SubPreferenceSetting { 296 300 public boolean isExpert() { 297 301 return false; 298 302 } 299 300 @Override301 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {302 return gui.getDisplayPreference();303 }304 303 } -
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; 12 12 import javax.swing.JCheckBox; 13 13 import javax.swing.JLabel; 14 14 import javax.swing.JPanel; 15 import javax.swing.JScrollPane;16 15 17 16 import org.openstreetmap.josm.Main; 18 17 import org.openstreetmap.josm.actions.ExpertToggleAction; 18 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 19 19 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 20 20 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 21 21 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 22 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;23 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;24 22 import org.openstreetmap.josm.tools.GBC; 25 23 26 24 /** 27 25 * Map drawing preferences. 28 26 */ 29 public class DrawingPreference implements SubPreferenceSetting {27 public class DrawingPreference extends DefaultTabPreferenceSetting { 30 28 31 29 /** 32 30 * Factory used to create a new {@code DrawingPreference}. … … public class DrawingPreference implements SubPreferenceSetting { 38 36 } 39 37 } 40 38 41 private GPXSettingsPanel gpxPanel;42 39 private JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows")); 43 40 private JCheckBox headArrow = new JCheckBox(tr("Only on the head of a way.")); 44 41 private JCheckBox onewayArrow = new JCheckBox(tr("Draw oneway arrows.")); … … public class DrawingPreference implements SubPreferenceSetting { 55 52 private JCheckBox useWireframeAntialiasing = new JCheckBox(tr("Smooth map graphics in wireframe mode (antialiasing)")); 56 53 private JCheckBox outlineOnly = new JCheckBox(tr("Draw only outlines of areas")); 57 54 58 @Override 55 public DrawingPreference() { 56 super(null, tr("OSM Data"), tr("Settings that control the drawing of OSM data.")); 57 } 58 59 59 public void addGui(PreferenceTabbedPane gui) { 60 gpxPanel = new GPXSettingsPanel();61 gui.addValidationListener(gpxPanel);62 JPanel panel = gpxPanel;63 60 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()); 68 62 panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 69 63 70 64 // directionHint … … public class DrawingPreference implements SubPreferenceSetting { 164 158 ExpertToggleAction.addVisibilitySwitcher(discardableKeys); 165 159 166 160 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); 170 162 } 171 163 172 164 @Override 173 165 public boolean ok() { 174 boolean restart = gpxPanel.savePreferences();175 166 Main.pref.put("draw.data.area_outline_only", outlineOnly.isSelected()); 176 167 Main.pref.put("draw.segment.direction", directionHint.isSelected()); 177 168 Main.pref.put("draw.segment.head_only", headArrow.isSelected()); … … public class DrawingPreference implements SubPreferenceSetting { 194 185 vn = 0; 195 186 } 196 187 Main.pref.putInteger("mappaint.node.virtual-size", vn); 197 return restart;188 return false; 198 189 } 199 190 200 191 @Override 201 192 public boolean isExpert() { 202 193 return false; 203 194 } 204 205 @Override206 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {207 return gui.getDisplayPreference();208 }209 195 } -
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; 24 24 import org.openstreetmap.josm.actions.ExpertToggleAction; 25 25 import org.openstreetmap.josm.gui.layer.markerlayer.Marker; 26 26 import org.openstreetmap.josm.gui.layer.markerlayer.Marker.TemplateEntryProperty; 27 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 28 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 29 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 30 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 27 31 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.ValidationListener; 28 32 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 29 33 import org.openstreetmap.josm.gui.widgets.JosmTextField; … … import org.openstreetmap.josm.tools.template_engine.TemplateParser; 36 40 */ 37 41 public class GPXSettingsPanel extends JPanel implements ValidationListener { 38 42 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 39 67 private static final int WAYPOINT_LABEL_CUSTOM = 6; 40 68 private static final String[] LABEL_PATTERN_TEMPLATE = new String[] {Marker.LABEL_PATTERN_AUTO, Marker.LABEL_PATTERN_NAME, 41 69 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; 13 13 import javax.swing.JLabel; 14 14 import javax.swing.JList; 15 15 import javax.swing.JPanel; 16 import javax.swing.JScrollPane;17 16 import javax.swing.ListCellRenderer; 18 17 import javax.swing.LookAndFeel; 19 18 import javax.swing.UIManager; … … import javax.swing.UIManager.LookAndFeelInfo; 21 20 22 21 import org.openstreetmap.josm.Main; 23 22 import org.openstreetmap.josm.actions.ExpertToggleAction; 23 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 24 24 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 25 25 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 26 26 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 27 27 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 28 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;29 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;30 28 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 31 29 import org.openstreetmap.josm.tools.GBC; 32 30 33 31 /** 34 32 * Look-and-feel preferences. 35 33 */ 36 public class LafPreference implements SubPreferenceSetting {34 public class LafPreference extends DefaultTabPreferenceSetting { 37 35 38 36 /** 39 37 * Factory used to create a new {@code LafPreference}. … … public class LafPreference implements SubPreferenceSetting { 56 54 private JCheckBox modeless = new JCheckBox(tr("Modeless working (Potlatch style)")); 57 55 private JCheckBox dynamicButtons = new JCheckBox(tr("Dynamic buttons in side menus")); 58 56 57 public LafPreference() { 58 super(null, tr("Look and Feel"), tr("Change the Look and Feel of the program")); 59 } 60 59 61 @Override 60 62 public void addGui(PreferenceTabbedPane gui) { 61 63 lafCombo = new JosmComboBox<>(UIManager.getInstalledLookAndFeels()); … … public class LafPreference implements SubPreferenceSetting { 127 129 panel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 128 130 panel.add(lafCombo, GBC.eol().fill(GBC.HORIZONTAL)); 129 131 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); 133 135 } 134 136 135 137 @Override … … public class LafPreference implements SubPreferenceSetting { 148 150 public boolean isExpert() { 149 151 return false; 150 152 } 151 152 @Override153 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {154 return gui.getDisplayPreference();155 }156 153 } -
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 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.preferences.display; 3 3 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 20 4 import org.openstreetmap.josm.Main; 5 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 21 6 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 22 7 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 23 8 import 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;27 9 import org.openstreetmap.josm.tools.GBC; 28 10 import org.openstreetmap.josm.tools.I18n; 29 11 12 import javax.swing.BorderFactory; 13 import javax.swing.DefaultListCellRenderer; 14 import javax.swing.JList; 15 import javax.swing.JPanel; 16 import javax.swing.ListCellRenderer; 17 import java.awt.Component; 18 import java.awt.GridBagLayout; 19 import java.util.List; 20 import java.util.Locale; 21 22 import static org.openstreetmap.josm.tools.I18n.tr; 23 30 24 /** 31 25 * Language preferences. 32 26 */ 33 public class LanguagePreference implements SubPreferenceSetting {27 public class LanguagePreference extends DefaultTabPreferenceSetting { 34 28 35 29 /** 36 30 * Factory used to create a new {@code LanguagePreference}. … … public class LanguagePreference implements SubPreferenceSetting { 43 37 } 44 38 45 39 /** 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 } 47 45 48 46 @Override 49 47 public void addGui(final PreferenceTabbedPane gui) { 50 L anguageComboBoxModel 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-basiccomboboxui53 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")); 56 54 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 } 63 60 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 } 66 67 } 67 68 68 69 @Override 69 70 public boolean ok() { 70 if (langCombo.getSelectedItem() == null)71 if (langCombo.getSelectedValue() == null) { 71 72 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()); 108 75 } 109 76 } 110 77 111 78 private static class LanguageCellRenderer implements ListCellRenderer<Locale> { 112 79 private final DefaultListCellRenderer dispatch; 80 113 81 public LanguageCellRenderer() { 114 82 this.dispatch = new DefaultListCellRenderer(); 115 83 } 84 116 85 @Override 117 public Component getListCellRendererComponent(JList<? extends Locale> list, Locale l, 86 public Component getListCellRendererComponent(JList<? extends Locale> list, Locale l, 118 87 int index, boolean isSelected, boolean cellHasFocus) { 119 88 return dispatch.getListCellRendererComponent(list, 120 89 l == null ? tr("Default (Auto determined)") : l.getDisplayName(l), … … public class LanguagePreference implements SubPreferenceSetting { 126 95 public boolean isExpert() { 127 96 return false; 128 97 } 129 130 @Override131 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {132 return gui.getSetting(LafPreference.class).getTabPreferenceSetting(gui);133 }134 98 } -
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; 17 17 18 18 import org.openstreetmap.josm.data.AutosaveTask; 19 19 import org.openstreetmap.josm.data.preferences.BooleanProperty; 20 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 20 21 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 21 22 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 22 23 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; … … import org.openstreetmap.josm.tools.GBC; 30 31 /** 31 32 * Preference settings for data layer autosave. 32 33 */ 33 public class BackupPreference implements SubPreferenceSetting {34 public class BackupPreference extends DefaultTabPreferenceSetting { 34 35 35 36 /** 36 37 * Factory used to create a new {@code BackupPreference}. … … public class BackupPreference implements SubPreferenceSetting { 112 113 autosaveEnabled.actionPerformed(null); 113 114 114 115 panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH)); 115 JScrollPane sp = GuiHelper.embedInVerticalScrollPane(panel);116 116 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"); 118 133 } 119 134 120 135 @Override … … public class BackupPreference implements SubPreferenceSetting { 130 145 } 131 146 132 147 @Override 148 public String getDescription() { 149 return getTooltip(); 150 } 151 152 @Override 133 153 public boolean isExpert() { 134 154 return false; 135 155 } 136 137 @Override138 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {139 return gui.getMapPreference();140 }141 156 } -
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 2cce8e1..1a9600b 100644
a b import java.util.List; 13 13 import java.util.Map; 14 14 import java.util.Objects; 15 15 import java.util.TreeSet; 16 17 16 import javax.swing.BorderFactory; 18 17 import javax.swing.JCheckBox; 19 18 import javax.swing.JPanel; 20 21 19 import org.openstreetmap.josm.Main; 22 20 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 21 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 23 22 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 24 23 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 25 24 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; … … import org.openstreetmap.josm.tools.Utils; 37 36 /** 38 37 * Preference settings for map paint styles. 39 38 */ 40 public class MapPaintPreference implements SubPreferenceSetting {39 public class MapPaintPreference extends DefaultTabPreferenceSetting { 41 40 private SourceEditor sources; 42 41 private JCheckBox enableIconDefault; 43 42 … … public class MapPaintPreference implements SubPreferenceSetting { 64 63 } 65 64 } 66 65 66 public MapPaintPreference() { 67 super(null, tr("Map Paint Styles"), tr("Styles for rendering the OSM data.")); 68 } 69 67 70 @Override 68 public void addGui( PreferenceTabbedPane gui) {71 public void addGui(final PreferenceTabbedPane gui) { 69 72 enableIconDefault = new JCheckBox(tr("Enable built-in icon defaults"), 70 73 Main.pref.getBoolean("mappaint.icon.enable-defaults", true)); 71 74 … … public class MapPaintPreference implements SubPreferenceSetting { 77 80 panel.add(sources, GBC.eol().fill(GBC.BOTH)); 78 81 panel.add(enableIconDefault, GBC.eol().insets(11,2,5,0)); 79 82 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(); 83 87 } 84 88 85 89 static class MapPaintSourceEditor extends SourceEditor { … … public class MapPaintPreference implements SubPreferenceSetting { 339 343 public boolean isExpert() { 340 344 return false; 341 345 } 342 343 @Override344 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {345 return gui.getMapPreference();346 }347 346 } -
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 @Override24 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 @Override34 public boolean ok() {35 return false;36 }37 38 @Override39 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; 12 12 import java.util.HashMap; 13 13 import java.util.List; 14 14 import java.util.Map; 15 16 15 import javax.swing.BorderFactory; 17 16 import javax.swing.JCheckBox; 18 17 import javax.swing.JLabel; 19 18 import javax.swing.JOptionPane; 20 19 import javax.swing.JPanel; 21 20 import javax.swing.JSeparator; 22 21 import org.openstreetmap.josm.Main; 23 22 import org.openstreetmap.josm.gui.ExtendedDialog; 23 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 24 24 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 25 25 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 26 26 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; … … import org.openstreetmap.josm.gui.preferences.SourceEditor; 29 29 import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry; 30 30 import org.openstreetmap.josm.gui.preferences.SourceEntry; 31 31 import org.openstreetmap.josm.gui.preferences.SourceProvider; 32 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 33 import org.openstreetmap.josm.gui.tagging.TaggingPresetMenu; 34 import org.openstreetmap.josm.gui.tagging.TaggingPresetSeparator; 35 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 32 36 import org.openstreetmap.josm.gui.preferences.SourceType; 33 37 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; 34 38 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; … … import org.xml.sax.SAXParseException; 40 44 /** 41 45 * Preference settings for tagging presets. 42 46 */ 43 public final class TaggingPresetPreference implements SubPreferenceSetting {47 public class TaggingPresetPreference extends DefaultTabPreferenceSetting { 44 48 45 49 /** 46 50 * Factory used to create a new {@code TaggingPresetPreference}. … … public final class TaggingPresetPreference implements SubPreferenceSetting { 53 57 } 54 58 55 59 private TaggingPresetPreference() { 56 super( );60 super(null, tr("Tagging Presets"), tr("Presets give meaning to OSM tag combinations.")); 57 61 } 58 62 59 63 private static final List<SourceProvider> presetSourceProviders = new ArrayList<>(); … … public final class TaggingPresetPreference implements SubPreferenceSetting { 160 164 }; 161 165 162 166 @Override 163 public void addGui( PreferenceTabbedPane gui) {167 public void addGui(final PreferenceTabbedPane gui) { 164 168 sortMenu = new JCheckBox(tr("Sort presets menu"), 165 169 Main.pref.getBoolean("taggingpreset.sortmenu", false)); 166 170 … … public final class TaggingPresetPreference implements SubPreferenceSetting { 169 173 panel.add(sortMenu, GBC.eol().insets(5,5,5,0)); 170 174 sources = new TaggingPresetSourceEditor(); 171 175 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(); 176 181 } 177 182 178 183 static class TaggingPresetSourceEditor extends SourceEditor { … … public final class TaggingPresetPreference implements SubPreferenceSetting { 304 309 public boolean isExpert() { 305 310 return false; 306 311 } 307 308 @Override309 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {310 return gui.getMapPreference();311 }312 312 } -
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; 30 30 import javax.swing.JOptionPane; 31 31 import javax.swing.JPanel; 32 32 import javax.swing.JScrollPane; 33 import javax.swing.JTabbedPane;34 33 import javax.swing.SwingUtilities; 35 34 import javax.swing.UIManager; 36 35 import javax.swing.event.DocumentEvent; … … import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 45 44 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 46 45 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 47 46 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 48 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.PreferencePanel;49 47 import org.openstreetmap.josm.gui.util.GuiHelper; 50 48 import org.openstreetmap.josm.gui.widgets.JosmTextField; 51 49 import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator; … … public final class PluginPreference extends DefaultTabPreferenceSetting { 73 71 } 74 72 75 73 private PluginPreference() { 76 super("plugin", tr("Plugins"), tr("Configure available plugins.") , false, new JTabbedPane());74 super("plugin", tr("Plugins"), tr("Configure available plugins.")); 77 75 } 78 76 79 77 /** … … public final class PluginPreference extends DefaultTabPreferenceSetting { 148 146 private PluginListPanel pnlPluginPreferences; 149 147 private PluginPreferencesModel model; 150 148 private JScrollPane spPluginPreferences; 151 private PluginUpdatePolicyPanel pnlPluginUpdatePolicy;152 149 153 150 /** 154 151 * is set to true if this preference pane has been selected … … public final class PluginPreference extends DefaultTabPreferenceSetting { 210 207 return pnl; 211 208 } 212 209 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 221 210 @Override 222 211 public void addGui(final PreferenceTabbedPane gui) { 223 212 GridBagConstraints gc = new GridBagConstraints(); … … public final class PluginPreference extends DefaultTabPreferenceSetting { 225 214 gc.weighty = 1.0; 226 215 gc.anchor = GridBagConstraints.NORTHWEST; 227 216 gc.fill = GridBagConstraints.BOTH; 228 PreferencePanel plugins = gui.createPreferenceTab(this); 229 plugins.add(buildContentPane(), gc); 217 gui.createPreferenceTab(this).add(buildPluginListPanel(), gc); 230 218 readLocalPluginInformation(); 231 219 pluginPreferencesActivated = true; 232 220 } … … public final class PluginPreference extends DefaultTabPreferenceSetting { 277 265 public boolean ok() { 278 266 if (! pluginPreferencesActivated) 279 267 return false; 280 pnlPluginUpdatePolicy.rememberInPreferences();281 268 if (model.isActivePluginsChanged()) { 282 269 LinkedList<String> l = new LinkedList<>(model.getSelectedPluginNames()); 283 270 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; 18 18 import javax.swing.event.ChangeListener; 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 22 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 23 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 24 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 21 25 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 22 26 import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator; 23 27 import org.openstreetmap.josm.plugins.PluginHandler; 24 28 import org.openstreetmap.josm.gui.widgets.JosmTextField; 29 import org.openstreetmap.josm.tools.GBC; 25 30 26 31 /** 27 32 * A panel for configuring whether JOSM shall update plugins at startup. … … import org.openstreetmap.josm.gui.widgets.JosmTextField; 29 34 */ 30 35 public class PluginUpdatePolicyPanel extends JPanel { 31 36 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 32 61 private enum Policy { 33 62 ASK ("ask"), 34 63 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; 14 14 import java.util.List; 15 15 import java.util.Map; 16 16 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; 17 import javax.swing.*; 23 18 24 19 import org.openstreetmap.josm.Main; 25 20 import org.openstreetmap.josm.data.Bounds; … … import org.openstreetmap.josm.data.preferences.StringProperty; 30 25 import org.openstreetmap.josm.data.projection.CustomProjection; 31 26 import org.openstreetmap.josm.data.projection.Projection; 32 27 import org.openstreetmap.josm.gui.NavigatableComponent; 28 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 33 29 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 34 30 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 35 31 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 36 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;37 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;38 32 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 39 33 import org.openstreetmap.josm.tools.GBC; 40 34 … … import org.openstreetmap.josm.tools.GBC; 54 48 * a manual implementation of the projection. Use {@link CustomProjection} 55 49 * if possible. 56 50 */ 57 public class ProjectionPreference implements SubPreferenceSetting {51 public class ProjectionPreference extends DefaultTabPreferenceSetting { 58 52 59 53 /** 60 54 * Factory used to create a new {@code ProjectionPreference}. … … public class ProjectionPreference implements SubPreferenceSetting { 66 60 } 67 61 } 68 62 63 private ProjectionPreference() { 64 super("map", tr("Map Projection"), tr("Settings for the map projection and data interpretation.")); 65 } 66 69 67 private static List<ProjectionChoice> projectionChoices = new ArrayList<>(); 70 68 private static Map<String, ProjectionChoice> projectionChoicesById = new HashMap<>(); 71 69 … … public class ProjectionPreference implements SubPreferenceSetting { 337 335 projPanel.add(unitsCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5)); 338 336 projPanel.add(GBC.glue(1,1), GBC.std().fill(GBC.HORIZONTAL).weight(1.0, 1.0)); 339 337 340 JScrollPane scrollpane = new JScrollPane(projPanel); 341 gui.getMapPreference().addSubTab(this, tr("Map Projection"), scrollpane); 338 createPreferenceTabWithScrollPane(gui, projPanel); 342 339 343 340 selectedProjectionChanged(pc); 344 341 } … … public class ProjectionPreference implements SubPreferenceSetting { 350 347 projectionName.setText(proj.toString()); 351 348 Bounds b = proj.getWorldBoundsLatLon(); 352 349 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)); 354 351 boolean showCode = true; 355 352 boolean showName = false; 356 353 if (pc instanceof SubPrefsOptions) { … … public class ProjectionPreference implements SubPreferenceSetting { 404 401 id = pc.getId(); 405 402 PROP_PROJECTION.put(id); 406 403 PROP_SUB_PROJECTION.put(pref); 407 Main.pref.putCollection("projection.sub." +id, pref);404 Main.pref.putCollection("projection.sub." + id, pref); 408 405 pc.setPreferences(pref); 409 406 Projection proj = pc.getProjection(); 410 407 Main.setProjection(proj); … … public class ProjectionPreference implements SubPreferenceSetting { 476 473 return false; 477 474 } 478 475 479 @Override480 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {481 return gui.getMapPreference();482 }483 484 476 /** 485 477 * Selects the given projection. 486 478 * @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 { 113 113 }; 114 114 enableRemoteControl.addActionListener(remoteControlEnabled); 115 115 remoteControlEnabled.actionPerformed(null); 116 createPreferenceTabWithScrollPane(gui, remote); 116 //createPreferenceTabWithScrollPane(gui, remote); 117 gui.createPreferenceTab(this).add(remote, GBC.eol().fill(GBC.BOTH)); 117 118 } 118 119 119 120 @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 652315 */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 @Override23 public PreferenceSetting createPreferenceSetting() {24 return new AuthenticationPreference();25 }26 }27 28 AuthenticationPreferencesPanel pnlAuthPreferences;29 30 private AuthenticationPreference() {31 super();32 }33 34 @Override35 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 @Override44 public boolean ok() {45 pnlAuthPreferences.saveToPreferences();46 return false;47 }48 49 @Override50 public boolean isExpert() {51 return false;52 }53 54 @Override55 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..886853d 100644
a b import static org.openstreetmap.josm.tools.I18n.tr; 6 6 import java.util.HashSet; 7 7 import java.util.Set; 8 8 9 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 9 10 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 10 11 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 11 12 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 12 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; 13 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 13 import org.openstreetmap.josm.tools.GBC; 14 14 15 15 /** 16 16 * Proxy sub-preferences in server preferences. 17 17 * @since 6523 18 18 */ 19 public final class ProxyPreference implements SubPreferenceSetting {19 public final class ProxyPreference extends DefaultTabPreferenceSetting { 20 20 21 /**22 * Factory used to create a new {@code ProxyPreference}.23 */24 21 public static class Factory implements PreferenceSettingFactory { 25 22 @Override 26 23 public PreferenceSetting createPreferenceSetting() { … … public final class ProxyPreference implements SubPreferenceSetting { 33 30 private ProxyPreferencesPanel pnlProxyPreferences; 34 31 35 32 private ProxyPreference() { 36 super( );33 super(null, tr("Proxy settings"), tr("Configure whether to use a proxy server")); 37 34 } 38 35 39 36 @Override 40 37 public void addGui(PreferenceTabbedPane gui) { 41 38 pnlProxyPreferences = new ProxyPreferencesPanel(); 42 gui.getServerPreference().addSubTab(this, tr("Proxy settings"), 43 pnlProxyPreferences.getVerticalScrollPane(), 44 tr("Configure whether to use a proxy server")); 39 gui.createPreferenceTab(this).add(pnlProxyPreferences, GBC.eol().fill(GBC.BOTH)); 45 40 } 46 41 47 42 @Override … … public final class ProxyPreference implements SubPreferenceSetting { 58 53 return false; 59 54 } 60 55 61 @Override62 public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {63 return gui.getServerPreference();64 }65 66 56 /** 67 57 * Adds a new ProxyPreferenceListener. 68 58 * @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..ee17568 100644
a b import java.net.ProxySelector; 17 17 import java.util.HashMap; 18 18 import java.util.Map; 19 19 20 import javax.swing.Bo rderFactory;20 import javax.swing.Box; 21 21 import javax.swing.ButtonGroup; 22 22 import javax.swing.JLabel; 23 23 import javax.swing.JPanel; … … public class ProxyPreferencesPanel extends VerticallyScrollablePanel { 392 392 */ 393 393 public ProxyPreferencesPanel() { 394 394 setLayout(new GridBagLayout()); 395 setBorder(BorderFactory.createEmptyBorder(5,5,5,5));396 add( buildProxySettingsPanel(), GBC.eop().anchor(GridBagConstraints.NORTHWEST).fill(GridBagConstraints.BOTH));395 add(buildProxySettingsPanel(), GBC.eop().fill(GBC.HORIZONTAL)); 396 add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH)); 397 397 398 398 initFromPreferences(); 399 399 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; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 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 15 6 import org.openstreetmap.josm.gui.help.HelpUtil; 16 7 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 17 8 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 18 9 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 19 10 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 11 import org.openstreetmap.josm.tools.GBC; 12 import java.awt.GridBagLayout; 13 import javax.swing.Box; 14 import javax.swing.JPanel; 20 15 21 /** 22 * Connection preferences, including authentication and proxy sub-preferences. 23 */ 24 public final class ServerAccessPreference extends DefaultTabPreferenceSetting { 16 public class ServerAccessPreference extends DefaultTabPreferenceSetting { 25 17 26 /**27 * Factory used to create a new {@code ServerAccessPreference}.28 */29 18 public static class Factory implements PreferenceSettingFactory { 30 @Override31 19 public PreferenceSetting createPreferenceSetting() { 32 20 return new ServerAccessPreference(); 33 21 } 34 22 } 35 23 36 24 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.")); 38 27 } 39 28 40 /** indicates whether to use the default OSM URL or not */41 29 private OsmApiUrlInputPanel pnlApiUrlPreferences; 42 30 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; 53 34 54 35 /** 55 36 * Builds the panel for entering the server access preferences 56 37 * 57 * @return preferences panel for server settings38 * @return 58 39 */ 59 40 protected JPanel buildContentPanel() { 60 41 JPanel pnl = new JPanel(new GridBagLayout()); 61 GridBagConstraints gc = new GridBagConstraints();62 42 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)); 70 46 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); 78 49 79 50 HelpUtil.setHelpContext(pnl, HelpUtil.ht("/Preferences/Connection")); 80 51 return pnl; 81 52 } 82 53 83 /**84 * Adds a listener that will be notified of API URL change.85 * @param listener the listener86 * @since 652387 */88 public final void addApiUrlChangeListener(PropertyChangeListener listener) {89 pnlApiUrlPreferences.addPropertyChangeListener(listener);90 }91 92 @Override93 54 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 } 100 59 60 /** 61 * Initializes the configuration panel with values from the preferences 62 */ 63 public void initFromPreferences() { 101 64 pnlApiUrlPreferences.initFromPreferences(); 65 pnlAuthPreferences.initFromPreferences(); 102 66 } 103 67 104 68 /** 105 69 * Saves the values to the preferences 106 70 */ 107 @Override108 71 public boolean ok() { 109 72 pnlApiUrlPreferences.saveToPreferences(); 73 pnlAuthPreferences.saveToPreferences(); 110 74 return false; 111 75 } 112 76 } -
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; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import javax.swing.BorderFactory; 7 import javax.swing.JCheckBox; 8 import javax.swing.JLabel; 9 import javax.swing.JPanel; 6 10 import javax.swing.JTabbedPane; 7 11 12 import org.openstreetmap.josm.Main; 8 13 import org.openstreetmap.josm.data.preferences.BooleanProperty; 14 import org.openstreetmap.josm.data.validation.OsmValidator; 15 import org.openstreetmap.josm.data.validation.Test; 16 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; 9 17 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 10 18 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 11 19 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 12 20 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 13 21 import org.openstreetmap.josm.tools.GBC; 14 22 23 import java.awt.GridBagLayout; 24 import java.awt.event.ActionEvent; 25 import java.awt.event.ActionListener; 26 import java.util.ArrayList; 27 import java.util.Collection; 28 import java.util.LinkedList; 29 import java.util.List; 30 15 31 /** 16 32 * Preference settings for the validator. 17 33 * … … public final class ValidatorPreference extends DefaultTabPreferenceSetting { 62 78 */ 63 79 public static final String PREF_FILTER_BY_SELECTION = PREFIX + ".selectionFilter"; 64 80 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 65 89 @Override 66 90 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); 68 130 } 69 131 70 132 @Override 71 133 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()); 72 159 return false; 73 160 } 161 162 @Override 163 public boolean isExpert() { 164 return false; 165 } 166 74 167 } -
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; 14 14 import org.openstreetmap.josm.Main; 15 15 import org.openstreetmap.josm.data.validation.OsmValidator; 16 16 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; 17 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 17 18 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 18 19 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 19 20 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; … … import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry; 22 23 import org.openstreetmap.josm.gui.preferences.SourceEntry; 23 24 import org.openstreetmap.josm.gui.preferences.SourceProvider; 24 25 import org.openstreetmap.josm.gui.preferences.SourceType; 25 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; 26 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 26 import org.openstreetmap.josm.tools.GBC; 27 27 28 28 /** 29 29 * The general validator preferences, allowing to enable/disable tests. 30 30 * @since 6669 31 31 */ 32 public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting {32 public class ValidatorTagCheckerRulesPreference extends DefaultTabPreferenceSetting { 33 33 34 34 /** 35 35 * Factory used to create a new {@code ValidatorTagCheckerRulesPreference}. … … public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting 41 41 } 42 42 } 43 43 44 private ValidatorTagCheckerRulesPreference() { 45 super("validator", tr("Tag checker rules"), tr("Choose Tag checker rules to enable")); 46 } 47 44 48 private static final List<SourceProvider> ruleSourceProviders = new ArrayList<>(); 45 49 46 50 /** … … public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting 48 52 * @param provider The rule source provider 49 53 * @return {@code true}, if the provider has been added, {@code false} otherwise 50 54 */ 51 public static finalboolean registerSourceProvider(SourceProvider provider) {55 public static boolean registerSourceProvider(SourceProvider provider) { 52 56 if (provider != null) 53 57 return ruleSourceProviders.add(provider); 54 58 return false; … … public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting 178 182 179 183 @Override 180 184 public void addGui(PreferenceTabbedPane gui) { 181 final ValidatorPreference valPref = gui.getValidatorPreference();182 185 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)); 187 187 } 188 188 189 189 @Override … … public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting 203 203 public boolean isExpert() { 204 204 return false; 205 205 } 206 207 @Override208 public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {209 return gui.getValidatorPreference();210 }211 206 } -
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; 10 10 import java.nio.charset.StandardCharsets; 11 11 import java.text.MessageFormat; 12 12 import java.util.ArrayList; 13 import java.util.Arrays; 14 import java.util.Collection; 13 import java.util.Collections; 15 14 import java.util.Comparator; 16 15 import java.util.HashMap; 16 import java.util.List; 17 17 import java.util.Locale; 18 18 import java.util.Map; 19 19 import java.util.jar.JarInputStream; … … public final class I18n { 321 321 322 322 /** 323 323 * Get a list of all available JOSM Translations. 324 * @return a n arrayof locale objects.324 * @return a sorted list of locale objects. 325 325 */ 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) { 330 329 for (String loc : languages.keySet()) { 331 if (getTranslationFile(loc) != null) {330 if (getTranslationFile(loc) != null) { 332 331 v.add(LanguageInfo.getLocale(loc)); 333 332 } 334 333 } 335 334 } 336 335 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>() { 340 337 @Override 341 338 public int compare(Locale o1, Locale o2) { 342 339 return o1.toString().compareTo(o2.toString()); 343 340 } 344 341 }); 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()]); 346 352 } 347 353 348 354 public static boolean hasCode(String code)