Ticket #7548: 7548_2014.patch
File 7548_2014.patch, 81.1 KB (added by , 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; 44 44 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 import org.openstreetmap.josm.gui.preferences.server. ProxyPreference;47 import org.openstreetmap.josm.gui.preferences.server.ServerAccessPreference; 48 48 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 49 49 import org.openstreetmap.josm.gui.util.GuiHelper; 50 50 import org.openstreetmap.josm.io.DefaultProxySelector; … … public class MainApplication extends Main { 515 515 ed.setContent(message); 516 516 517 517 if (ed.showDialog().getValue() == 1) { 518 PreferencesAction.forPreference SubTab(null, null, ProxyPreference.class).run();518 PreferencesAction.forPreferenceTab(null, null, ServerAccessPreference.class).run(); 519 519 } 520 520 } 521 521 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 ef9fe55..f43ffa1 100644
a b public class MainMenu extends JMenuBar { 706 706 707 707 add(presetsMenu, presetSearchAction); 708 708 add(presetsMenu, presetSearchPrimitiveAction); 709 add(presetsMenu, PreferencesAction.forPreference SubTab(tr("Preset preferences"),709 add(presetsMenu, PreferencesAction.forPreferenceTab(tr("Preset preferences"), 710 710 tr("Click to open the tagging presets tab in the preferences"), TaggingPresetPreference.class)); 711 711 presetsMenu.addSeparator(); 712 712 -
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..e27bda4 100644
a b import org.openstreetmap.josm.gui.preferences.audio.AudioPreference; 37 37 import org.openstreetmap.josm.gui.preferences.display.ColorPreference; 38 38 import org.openstreetmap.josm.gui.preferences.display.DisplayPreference; 39 39 import org.openstreetmap.josm.gui.preferences.display.DrawingPreference; 40 import org.openstreetmap.josm.gui.preferences.display.GPXSettingsPanel; 40 41 import org.openstreetmap.josm.gui.preferences.display.LafPreference; 41 42 import org.openstreetmap.josm.gui.preferences.display.LanguagePreference; 42 43 import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference; 43 44 import org.openstreetmap.josm.gui.preferences.map.BackupPreference; 44 45 import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference; 45 import org.openstreetmap.josm.gui.preferences.map.MapPreference;46 46 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference; 47 47 import org.openstreetmap.josm.gui.preferences.plugin.PluginPreference; 48 import org.openstreetmap.josm.gui.preferences.plugin.PluginUpdatePolicyPanel; 48 49 import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference; 50 import org.openstreetmap.josm.gui.preferences.server.ProxyPreferencesPanel; 49 51 import 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;52 52 import org.openstreetmap.josm.gui.preferences.server.ServerAccessPreference; 53 53 import org.openstreetmap.josm.gui.preferences.shortcut.ShortcutPreference; 54 54 import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference; … … public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee 246 246 } 247 247 248 248 /** 249 * Returns the {@code MapPreference} object.250 * @return the {@code MapPreference} object.251 */252 public final MapPreference getMapPreference() {253 return getSetting(MapPreference.class);254 }255 256 /**257 249 * Returns the {@code PluginPreference} object. 258 250 * @return the {@code PluginPreference} object. 259 251 */ … … public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee 427 419 int position = index; 428 420 for (PreferenceTab tab : tabs) { 429 421 if (tab.getTabPreferenceSetting().equals(tps)) { 430 insertTab(null, icon, tab.getComponent(), tps.getTooltip(), position++); 422 if (tps instanceof IconPreferenceSetting) { 423 insertTab(null, icon, tab.getComponent(), tps.getTooltip(), position++); 424 } else { 425 insertTab(tps.getTitle(), null, tab.getComponent(), tps.getTooltip(), position++); 426 } 431 427 } 432 428 } 433 429 } … … public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee 455 451 addGUITabsForSetting(icon, tps); 456 452 } else { 457 453 // If it has not been initialized, create an empty tab with only icon and tooltip 458 addTab(null, icon, new PreferencePanel(tps), tps.getTooltip()); 454 if (tps instanceof IconPreferenceSetting) { 455 addTab(null, icon, new PreferencePanel(tps), tps.getTooltip()); 456 } else { 457 addTab(tps.getTitle(), null, new PreferencePanel(tps), tps.getTooltip()); 458 } 459 459 } 460 460 } 461 461 } else if (!(setting instanceof SubPreferenceSetting)) { … … public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee 489 489 return null; 490 490 } 491 491 492 static class IconPreferenceSetting extends DefaultTabPreferenceSetting { 493 494 public static class Factory implements PreferenceSettingFactory { 495 496 private final String iconName, title, description; 497 498 public Factory(String iconName, String title, String description) { 499 this.iconName = iconName; 500 this.title = title; 501 this.description = description; 502 } 503 504 @Override 505 public PreferenceSetting createPreferenceSetting() { 506 return new IconPreferenceSetting(iconName, title, description); 507 } 508 } 509 510 public IconPreferenceSetting(String iconName, String title, String description) { 511 super(iconName, title, description); 512 } 513 514 @Override 515 public void addGui(PreferenceTabbedPane gui) { 516 createPreferenceTabWithScrollPane(gui, new JPanel()); 517 } 518 519 @Override 520 public boolean ok() { 521 return false; 522 } 523 } 524 492 525 static { 526 493 527 // order is important! 494 settingsFactory.add(new DisplayPreference.Factory());528 settingsFactory.add(new IconPreferenceSetting.Factory("map", tr("Mapping"), tr("Various settings that influence the visual representation of geodata."))); 495 529 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()); 530 settingsFactory.add(new GPXSettingsPanel.Factory()); 503 531 settingsFactory.add(new ProjectionPreference.Factory()); 504 532 settingsFactory.add(new MapPaintPreference.Factory()); 505 533 settingsFactory.add(new TaggingPresetPreference.Factory()); 534 settingsFactory.add(new ImageryPreference.Factory()); 535 536 settingsFactory.add(new IconPreferenceSetting.Factory("connection", tr("Server"), tr("Connection Settings for the OSM server."))); 537 settingsFactory.add(new ServerAccessPreference.Factory()); 538 settingsFactory.add(new ProxyPreferencesPanel.Factory()); 539 540 settingsFactory.add(new IconPreferenceSetting.Factory("display", tr("User Interface"), tr("Various settings that influence the visual representation of the whole program."))); 541 settingsFactory.add(new ColorPreference.Factory()); 542 settingsFactory.add(new LafPreference.Factory()); 543 settingsFactory.add(new LanguagePreference.Factory()); 506 544 settingsFactory.add(new BackupPreference.Factory()); 507 settingsFactory.add(new PluginPreference.Factory());508 545 settingsFactory.add(Main.toolbar); 509 settingsFactory.add(new AudioPreference.Factory());510 546 settingsFactory.add(new ShortcutPreference.Factory()); 511 settingsFactory.add(new ValidatorPreference.Factory()); 547 548 settingsFactory.add(new IconPreferenceSetting.Factory("advanced", tr("Advanced Preferences"), tr("Modify advanced JOSM configuration."))); 549 settingsFactory.add(new AudioPreference.Factory()); 512 550 settingsFactory.add(new ValidatorTestsPreference.Factory()); 513 551 settingsFactory.add(new ValidatorTagCheckerRulesPreference.Factory()); 514 552 settingsFactory.add(new RemoteControlPreference.Factory()); 515 settingsFactory.add(new ImageryPreference.Factory());516 517 PluginHandler.getPreferenceSetting(settingsFactory);518 519 // always the last: advanced tab520 553 settingsFactory.add(new AdvancedPreference.Factory()); 554 555 settingsFactory.add(new IconPreferenceSetting.Factory("plugin", tr("Plugins"), tr("Install new plugins or configure installed plugins."))); 556 settingsFactory.add(new PluginPreference.Factory()); 557 settingsFactory.add(new PluginUpdatePolicyPanel.Factory()); 558 PluginHandler.getPreferenceSetting(settingsFactory); 559 521 560 } 522 561 523 562 /** -
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..2fcfe20 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.DefaultListCellRenderer; 13 import javax.swing.JList; 14 import javax.swing.JPanel; 15 import javax.swing.ListCellRenderer; 16 import java.awt.Component; 17 import java.awt.GridBagLayout; 18 import java.util.List; 19 import java.util.Locale; 20 21 import static org.openstreetmap.josm.tools.I18n.tr; 22 30 23 /** 31 24 * Language preferences. 32 25 */ 33 public class LanguagePreference implements SubPreferenceSetting {26 public class LanguagePreference extends DefaultTabPreferenceSetting { 34 27 35 28 /** 36 29 * Factory used to create a new {@code LanguagePreference}. … … public class LanguagePreference implements SubPreferenceSetting { 43 36 } 44 37 45 38 /** the combo box with the available locales */ 46 private JosmComboBox<Locale> langCombo; 39 private JList<Locale> langCombo; 40 41 public LanguagePreference() { 42 super(null, tr("Language"), tr("Change the language of JOSM.")); 43 } 47 44 48 45 @Override 49 46 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());47 List<Locale> tr = I18n.getAvailableTranslationsAsList(); 48 tr.add(0, null); 49 langCombo = new JList<>(tr.toArray(new Locale[tr.size()])); 50 langCombo.setCellRenderer(new LanguageCellRenderer()); 51 langCombo.setVisibleRowCount(langCombo.getModel().getSize()); 52 selectLanguage(Main.pref.get("language")); 56 53 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)); 54 final JPanel panel = new JPanel(new GridBagLayout()); 55 panel.add(langCombo, GBC.eol().fill(GBC.BOTH)); 56 createPreferenceTabWithScrollPane(gui, panel); 57 } 63 58 64 TabPreferenceSetting tabPref = lafPreference.getTabPreferenceSetting(gui); 65 tabPref.registerSubTab(this, tabPref.getSubTab(lafPreference)); 59 protected void selectLanguage(final String languageCode) { 60 if (languageCode == null || languageCode.isEmpty()) { 61 langCombo.setSelectedIndex(0); 62 } else { 63 langCombo.setSelectedValue(Locale.forLanguageTag(languageCode), true); 64 } 66 65 } 67 66 68 67 @Override 69 68 public boolean ok() { 70 if (langCombo.getSelectedItem() == null)69 if (langCombo.getSelectedValue() == null) { 71 70 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(); 71 } else { 72 return Main.pref.put("language", langCombo.getSelectedValue().toString()); 108 73 } 109 74 } 110 75 111 76 private static class LanguageCellRenderer implements ListCellRenderer<Locale> { 112 77 private final DefaultListCellRenderer dispatch; 78 113 79 public LanguageCellRenderer() { 114 80 this.dispatch = new DefaultListCellRenderer(); 115 81 } 82 116 83 @Override 117 public Component getListCellRendererComponent(JList<? extends Locale> list, Locale l, 84 public Component getListCellRendererComponent(JList<? extends Locale> list, Locale l, 118 85 int index, boolean isSelected, boolean cellHasFocus) { 119 86 return dispatch.getListCellRendererComponent(list, 120 87 l == null ? tr("Default (Auto determined)") : l.getDisplayName(l), … … public class LanguagePreference implements SubPreferenceSetting { 126 93 public boolean isExpert() { 127 94 return false; 128 95 } 129 130 @Override131 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {132 return gui.getSetting(LafPreference.class).getTabPreferenceSetting(gui);133 }134 96 } -
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 07ff540..f7f2fb0 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 { 313 317 public boolean isExpert() { 314 318 return false; 315 319 } 316 317 @Override318 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {319 return gui.getMapPreference();320 }321 320 } -
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..47ad879 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; … … import org.openstreetmap.josm.tools.GBC; 54 50 * a manual implementation of the projection. Use {@link CustomProjection} 55 51 * if possible. 56 52 */ 57 public class ProjectionPreference implements SubPreferenceSetting {53 public class ProjectionPreference extends DefaultTabPreferenceSetting { 58 54 59 55 /** 60 56 * Factory used to create a new {@code ProjectionPreference}. … … public class ProjectionPreference implements SubPreferenceSetting { 66 62 } 67 63 } 68 64 65 private ProjectionPreference() { 66 super("map", tr("Map Projection"), tr("Settings for the map projection and data interpretation.")); 67 } 68 69 69 private static List<ProjectionChoice> projectionChoices = new ArrayList<>(); 70 70 private static Map<String, ProjectionChoice> projectionChoicesById = new HashMap<>(); 71 71 … … public class ProjectionPreference implements SubPreferenceSetting { 337 337 projPanel.add(unitsCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5)); 338 338 projPanel.add(GBC.glue(1,1), GBC.std().fill(GBC.HORIZONTAL).weight(1.0, 1.0)); 339 339 340 JScrollPane scrollpane = new JScrollPane(projPanel); 341 gui.getMapPreference().addSubTab(this, tr("Map Projection"), scrollpane); 340 createPreferenceTabWithScrollPane(gui, projPanel); 342 341 343 342 selectedProjectionChanged(pc); 344 343 } … … public class ProjectionPreference implements SubPreferenceSetting { 350 349 projectionName.setText(proj.toString()); 351 350 Bounds b = proj.getWorldBoundsLatLon(); 352 351 CoordinateFormat cf = CoordinateFormat.getDefaultFormat(); 353 bounds.setText(b.getMin().lonToString(cf) +", "+b.getMin().latToString(cf)+" : "+b.getMax().lonToString(cf)+", "+b.getMax().latToString(cf));352 bounds.setText(b.getMin().lonToString(cf) + ", " + b.getMin().latToString(cf) + " : " + b.getMax().lonToString(cf) + ", " + b.getMax().latToString(cf)); 354 353 boolean showCode = true; 355 354 boolean showName = false; 356 355 if (pc instanceof SubPrefsOptions) { … … public class ProjectionPreference implements SubPreferenceSetting { 404 403 id = pc.getId(); 405 404 PROP_PROJECTION.put(id); 406 405 PROP_SUB_PROJECTION.put(pref); 407 Main.pref.putCollection("projection.sub." +id, pref);406 Main.pref.putCollection("projection.sub." + id, pref); 408 407 pc.setPreferences(pref); 409 408 Projection proj = pc.getProjection(); 410 409 Main.setProjection(proj); … … public class ProjectionPreference implements SubPreferenceSetting { 476 475 return false; 477 476 } 478 477 479 @Override480 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) {481 return gui.getMapPreference();482 }483 484 478 /** 485 479 * Selects the given projection. 486 480 * @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..2fea5cf 100644
a b import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 16 16 * Proxy sub-preferences in server preferences. 17 17 * @since 6523 18 18 */ 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 } 19 public final class ProxyPreference { 30 20 31 21 private static Set<ProxyPreferenceListener> listeners = new HashSet<>(); 32 22 … … public final class ProxyPreference implements SubPreferenceSetting { 36 26 super(); 37 27 } 38 28 39 @Override40 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 @Override48 public boolean ok() {49 pnlProxyPreferences.saveToPreferences();50 for (ProxyPreferenceListener listener : listeners) {51 listener.proxyPreferenceChanged();52 }53 return false;54 }55 56 @Override57 public boolean isExpert() {58 return false;59 }60 61 @Override62 public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {63 return gui.getServerPreference();64 }65 66 29 /** 67 30 * Adds a new ProxyPreferenceListener. 68 31 * @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..1b2c682 100644
a b import javax.swing.JRadioButton; 25 25 26 26 import org.openstreetmap.josm.Main; 27 27 import org.openstreetmap.josm.gui.help.HelpUtil; 28 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 29 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 30 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 31 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 28 32 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 29 33 import org.openstreetmap.josm.gui.widgets.JosmPasswordField; 30 34 import org.openstreetmap.josm.gui.widgets.JosmTextField; … … import org.openstreetmap.josm.io.auth.CredentialsAgent; 34 38 import org.openstreetmap.josm.io.auth.CredentialsAgentException; 35 39 import org.openstreetmap.josm.io.auth.CredentialsManager; 36 40 import org.openstreetmap.josm.tools.GBC; 41 import sun.awt.VerticalBagLayout; 37 42 38 43 /** 39 44 * Component allowing input of proxy settings. 40 45 */ 41 46 public class ProxyPreferencesPanel extends VerticallyScrollablePanel { 42 47 48 public static class Factory implements PreferenceSettingFactory { 49 50 @Override 51 public PreferenceSetting createPreferenceSetting() { 52 return new DefaultTabPreferenceSetting(null, tr("Proxy settings"), tr("Configure whether to use a proxy server")) { 53 54 private ProxyPreferencesPanel pnlProxyPreferences; 55 56 @Override 57 public void addGui(PreferenceTabbedPane gui) { 58 //createPreferenceTabWithScrollPane(gui, pnlProxyPreferences = new ProxyPreferencesPanel()); 59 pnlProxyPreferences = new ProxyPreferencesPanel(); 60 gui.createPreferenceTab(this).add(pnlProxyPreferences, GBC.eol().fill(GBC.BOTH)); 61 pnlProxyPreferences.initFromPreferences(); 62 } 63 64 @Override 65 public boolean ok() { 66 pnlProxyPreferences.saveToPreferences(); 67 return false; 68 } 69 }; 70 } 71 } 72 43 73 /** 44 74 * The proxy policy is how JOSM will use proxy information. 45 75 */ … … public class ProxyPreferencesPanel extends VerticallyScrollablePanel { 391 421 * Constructs a new {@code ProxyPreferencesPanel}. 392 422 */ 393 423 public ProxyPreferencesPanel() { 394 setLayout(new GridBagLayout());395 setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 396 add(buildProxySettingsPanel() , GBC.eop().anchor(GridBagConstraints.NORTHWEST).fill(GridBagConstraints.BOTH));424 setLayout(new VerticalBagLayout(20)); 425 426 add(buildProxySettingsPanel()); 397 427 398 428 initFromPreferences(); 399 429 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..4ea2a08 100644
a b 1 // License: GPL. For details, see LICENSE file.1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 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 import org.openstreetmap.josm.gui.help.HelpUtil;16 6 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 17 7 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 18 8 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 19 9 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 10 import org.openstreetmap.josm.tools.GBC; 11 import sun.awt.VerticalBagLayout; 12 import javax.swing.JPanel; 13 import org.openstreetmap.josm.gui.help.HelpUtil; 14 import org.openstreetmap.josm.gui.preferences.server.AuthenticationPreferencesPanel; 15 import org.openstreetmap.josm.gui.preferences.server.OsmApiUrlInputPanel; 20 16 21 /** 22 * Connection preferences, including authentication and proxy sub-preferences. 23 */ 24 public final class ServerAccessPreference extends DefaultTabPreferenceSetting { 17 public class ServerAccessPreference extends DefaultTabPreferenceSetting { 25 18 26 /**27 * Factory used to create a new {@code ServerAccessPreference}.28 */29 19 public static class Factory implements PreferenceSettingFactory { 30 @Override31 20 public PreferenceSetting createPreferenceSetting() { 32 21 return new ServerAccessPreference(); 33 22 } 34 23 } 35 24 36 25 private ServerAccessPreference() { 37 super("connection", tr("Connection Settings"), tr("Connection Settings for the OSM server."), false, new JTabbedPane()); 26 super("connection", tr("Connection Settings"), 27 tr("Connection Settings for the OSM server as well as your identity and how to authenticate at the OSM server.")); 38 28 } 39 29 40 /** indicates whether to use the default OSM URL or not */41 30 private OsmApiUrlInputPanel pnlApiUrlPreferences; 42 31 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 } 32 /** indicates whether to use the default OSM URL or not */ 33 /** panel for configuring authentication preferences */ 34 private AuthenticationPreferencesPanel pnlAuthPreferences; 53 35 54 36 /** 55 37 * Builds the panel for entering the server access preferences 56 38 * 57 * @return preferences panel for server settings39 * @return 58 40 */ 59 41 protected JPanel buildContentPanel() { 60 JPanel pnl = new JPanel(new GridBagLayout()); 61 GridBagConstraints gc = new GridBagConstraints(); 42 JPanel pnl = new JPanel(new VerticalBagLayout(20)); 62 43 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); 44 pnl.add(pnlApiUrlPreferences = new OsmApiUrlInputPanel()); 45 pnl.add(pnlAuthPreferences = new AuthenticationPreferencesPanel()); 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/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..89eebf0 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.SourceProvider; 24 25 import org.openstreetmap.josm.gui.preferences.SourceType; 25 26 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; 26 27 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 28 import org.openstreetmap.josm.tools.GBC; 29 30 import javax.swing.*; 27 31 28 32 /** 29 33 * The general validator preferences, allowing to enable/disable tests. 30 34 * @since 6669 31 35 */ 32 public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting {36 public class ValidatorTagCheckerRulesPreference extends DefaultTabPreferenceSetting { 33 37 34 38 /** 35 39 * Factory used to create a new {@code ValidatorTagCheckerRulesPreference}. … … public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting 41 45 } 42 46 } 43 47 48 private ValidatorTagCheckerRulesPreference() { 49 super("validator", tr("Tag checker rules"), tr("Choose Tag checker rules to enable")); 50 } 51 44 52 private static final List<SourceProvider> ruleSourceProviders = new ArrayList<>(); 45 53 46 54 /** … … public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting 178 186 179 187 @Override 180 188 public void addGui(PreferenceTabbedPane gui) { 181 final ValidatorPreference valPref = gui.getValidatorPreference();182 189 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); 190 gui.createPreferenceTab(this).add(sources, GBC.eol().fill(GBC.BOTH)); 187 191 } 188 192 189 193 @Override … … public class ValidatorTagCheckerRulesPreference implements SubPreferenceSetting 203 207 public boolean isExpert() { 204 208 return false; 205 209 } 206 207 @Override208 public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {209 return gui.getValidatorPreference();210 }211 210 } -
src/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreference.java
diff --git a/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreference.java b/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreference.java index 3d0c45f..ebd6b93 100644
a b import java.util.Collection; 11 11 import java.util.LinkedList; 12 12 import java.util.List; 13 13 14 import javax.swing.BorderFactory; 15 import javax.swing.JCheckBox; 16 import javax.swing.JLabel; 17 import javax.swing.JPanel; 14 import javax.swing.*; 18 15 19 16 import org.openstreetmap.josm.Main; 20 17 import org.openstreetmap.josm.data.validation.OsmValidator; 21 18 import org.openstreetmap.josm.data.validation.Test; 22 19 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; 20 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 23 21 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 24 22 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 25 23 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; … … import org.openstreetmap.josm.tools.GBC; 32 30 * The general validator preferences, allowing to enable/disable tests. 33 31 * @since 6666 34 32 */ 35 public class ValidatorTestsPreference implements SubPreferenceSetting {33 public class ValidatorTestsPreference extends DefaultTabPreferenceSetting { 36 34 37 35 /** 38 36 * Factory used to create a new {@code ValidatorTestsPreference}. … … public class ValidatorTestsPreference implements SubPreferenceSetting { 52 50 /** The list of all tests */ 53 51 private Collection<Test> allTests; 54 52 53 private ValidatorTestsPreference() { 54 super("validator", tr("Data validator"), 55 tr("An OSM data validator that checks for common errors made by users and editor programs."), 56 false, new JTabbedPane()); 57 } 58 55 59 @Override 56 60 public void addGui(PreferenceTabbedPane gui) { 57 61 JPanel testPanel = new JPanel(new GridBagLayout()); … … public class ValidatorTestsPreference implements SubPreferenceSetting { 91 95 for (Test test: allTests) { 92 96 test.addGui(testPanel); 93 97 } 94 95 gui.getValidatorPreference().addSubTab(this, tr("Tests"), 96 GuiHelper.embedInVerticalScrollPane(testPanel), 97 tr("Choose tests to enable")); 98 99 createPreferenceTabWithScrollPane(gui, testPanel); 98 100 } 99 101 100 102 @Override … … public class ValidatorTestsPreference implements SubPreferenceSetting { 131 133 public boolean isExpert() { 132 134 return false; 133 135 } 134 135 @Override136 public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {137 return gui.getValidatorPreference();138 }139 136 } -
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..4102a99 100644
a b import java.text.MessageFormat; 12 12 import java.util.ArrayList; 13 13 import java.util.Arrays; 14 14 import java.util.Collection; 15 import java.util.Collections; 15 16 import java.util.Comparator; 16 17 import java.util.HashMap; 18 import java.util.List; 17 19 import java.util.Locale; 18 20 import java.util.Map; 19 21 import java.util.jar.JarInputStream; … … public final class I18n { 321 323 322 324 /** 323 325 * Get a list of all available JOSM Translations. 324 * @return a n arrayof locale objects.326 * @return a sorted list of locale objects. 325 327 */ 326 public static final Locale[] getAvailableTranslations() { 327 Collection<Locale> v = new ArrayList<>(languages.size()); 328 if(getTranslationFile("en") != null) 329 { 328 public static final List<Locale> getAvailableTranslationsAsList() { 329 List<Locale> v = new ArrayList<>(languages.size()); 330 if (getTranslationFile("en") != null) { 330 331 for (String loc : languages.keySet()) { 331 if (getTranslationFile(loc) != null) {332 if (getTranslationFile(loc) != null) { 332 333 v.add(LanguageInfo.getLocale(loc)); 333 334 } 334 335 } 335 336 } 336 337 v.add(Locale.ENGLISH); 337 Locale[] l = new Locale[v.size()]; 338 l = v.toArray(l); 339 Arrays.sort(l, new Comparator<Locale>() { 338 Collections.sort(v, new Comparator<Locale>() { 340 339 @Override 341 340 public int compare(Locale o1, Locale o2) { 342 341 return o1.toString().compareTo(o2.toString()); 343 342 } 344 343 }); 345 return l; 344 return v; 345 } 346 347 /** 348 * Get an array of all available JOSM Translations. 349 * @return an array of locale objects. 350 */ 351 public static final Locale[] getAvailableTranslations() { 352 List<Locale> locales = getAvailableTranslationsAsList(); 353 return locales.toArray(new Locale[locales.size()]); 346 354 } 347 355 348 356 public static boolean hasCode(String code)