Changeset 5631 in josm
- Timestamp:
- 2012-12-25T23:43:22+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r5463 r5631 57 57 import org.openstreetmap.josm.gui.help.HelpUtil; 58 58 import org.openstreetmap.josm.gui.help.Helpful; 59 import org.openstreetmap.josm.gui.preferences.PreferenceDialog; 60 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 61 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; 62 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 59 63 import org.openstreetmap.josm.tools.Destroyable; 60 64 import org.openstreetmap.josm.tools.GBC; … … 139 143 */ 140 144 protected JCheckBoxMenuItem windowMenuItem; 145 146 /** 147 * The linked preferences class (optional). If set, accessible from the title bar with a dedicated button 148 */ 149 protected Class<? extends PreferenceSetting> preferenceClass; 141 150 142 151 /** … … 146 155 public ToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight) { 147 156 this(name, iconName, tooltip, shortcut, preferredHeight, false); 157 } 158 /** 159 * Constructor 160 * (see below) 161 */ 162 public ToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight, boolean defShow) { 163 this(name, iconName, tooltip, shortcut, preferredHeight, defShow, null); 148 164 } 149 165 /** … … 156 172 * @param preferredHeight the preferred height for the dialog 157 173 * @param defShow if the dialog should be shown by default, if there is no preference 158 */ 159 public ToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight, boolean defShow) { 174 * @param prefClass the preferences settings class, or null if not applicable 175 */ 176 public ToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight, boolean defShow, Class<? extends PreferenceSetting> prefClass) { 160 177 super(new BorderLayout()); 161 178 this.preferencePrefix = iconName; 162 179 this.name = name; 180 this.preferenceClass = prefClass; 163 181 164 182 /** Use the full width of the parent element */ … … 522 540 add(buttonsHide); 523 541 } 542 543 // show the pref button if applicable 544 if (preferenceClass != null) { 545 inIcon = ImageProvider.get("preference"); 546 smallIcon = new ImageIcon(inIcon.getImage().getScaledInstance(16 , 16, Image.SCALE_SMOOTH)); 547 JButton pref = new JButton(smallIcon); 548 pref.setToolTipText(tr("Open preferences for this panel")); 549 pref.setBorder(BorderFactory.createEmptyBorder()); 550 pref.addActionListener( 551 new ActionListener(){ 552 @SuppressWarnings("unchecked") 553 public void actionPerformed(ActionEvent e) { 554 final PreferenceDialog p = new PreferenceDialog(Main.parent); 555 if (TabPreferenceSetting.class.isAssignableFrom(preferenceClass)) { 556 p.selectPreferencesTabByClass((Class<? extends TabPreferenceSetting>) preferenceClass); 557 } else if (SubPreferenceSetting.class.isAssignableFrom(preferenceClass)) { 558 p.selectSubPreferencesTabByClass((Class<? extends SubPreferenceSetting>) preferenceClass); 559 } 560 p.setVisible(true); 561 } 562 } 563 ); 564 add(pref); 565 } 524 566 525 567 // show the sticky button -
trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
r5532 r5631 2 2 package org.openstreetmap.josm.gui.dialogs; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr;5 4 import static org.openstreetmap.josm.tools.I18n.tr; 6 5 … … 93 92 super(tr("Validation Results"), "validator", tr("Open the validation window."), 94 93 Shortcut.registerShortcut("subwindow:validator", tr("Toggle: {0}", tr("Validation results")), 95 KeyEvent.VK_V, Shortcut.ALT_SHIFT), 150 );94 KeyEvent.VK_V, Shortcut.ALT_SHIFT), 150, false, ValidatorPreference.class); 96 95 97 96 popupMenu = new JPopupMenu(); -
trunk/src/org/openstreetmap/josm/gui/preferences/DefaultTabPreferenceSetting.java
r4976 r5631 2 2 package org.openstreetmap.josm.gui.preferences; 3 3 4 import java.awt.Component; 5 import java.util.HashMap; 6 import java.util.Map; 7 4 8 import javax.swing.JPanel; 5 9 import javax.swing.JScrollPane; 10 import javax.swing.JTabbedPane; 6 11 7 12 import org.openstreetmap.josm.tools.GBC; … … 12 17 private final String description; 13 18 private final String title; 19 private final JTabbedPane tabpane; 20 private final Map<SubPreferenceSetting, Component> subSettingMap; 14 21 15 22 public DefaultTabPreferenceSetting() { … … 22 29 23 30 public DefaultTabPreferenceSetting(String iconName, String title, String description, boolean isExpert) { 31 this(iconName, title, description, isExpert, null); 32 } 33 34 public DefaultTabPreferenceSetting(String iconName, String title, String description, boolean isExpert, JTabbedPane tabpane) { 24 35 super(isExpert); 25 36 this.iconName = iconName; 26 37 this.description = description; 27 38 this.title = title; 39 this.tabpane = tabpane; 40 this.subSettingMap = tabpane != null ? new HashMap<SubPreferenceSetting, Component>() : null; 28 41 } 29 42 … … 51 64 return title; 52 65 } 66 67 /** 68 * Get the inner tab pane, if any. 69 * @return The JTabbedPane contained in this tab preference settings, or null if none is set. 70 * @since 5631 71 */ 72 public final JTabbedPane getTabPane() { 73 return tabpane; 74 } 53 75 54 76 protected final void createPreferenceTabWithScrollPane(PreferenceTabbedPane gui, JPanel panel) { … … 63 85 tab.add(GBC.glue(0,10), a); 64 86 } 87 88 @Override 89 public boolean selectSubTab(SubPreferenceSetting subPref) { 90 if (tabpane != null && subPref != null) { 91 Component tab = getSubTab(subPref); 92 if (tab != null) { 93 try { 94 tabpane.setSelectedComponent(tab); 95 return true; 96 } catch (IllegalArgumentException e) { 97 // Ignore exception and return false below 98 e.printStackTrace(); 99 System.out.println(tabpane.getTabCount()); 100 for (int i = 0; i < tabpane.getTabCount() ; i++) { 101 System.out.println(tabpane.getComponentAt(i)); 102 } 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 } 65 133 } -
trunk/src/org/openstreetmap/josm/gui/preferences/PluginPreference.java
r5601 r5631 61 61 62 62 private PluginPreference() { 63 super("plugin", tr("Plugins"), tr("Configure available plugins.") );63 super("plugin", tr("Plugins"), tr("Configure available plugins."), false, new JTabbedPane()); 64 64 } 65 65 … … 163 163 } 164 164 165 protected JPanel buildContentPanel() { 166 JPanel pnl = new JPanel(new BorderLayout()); 167 JTabbedPane tpPluginPreferences = new JTabbedPane(); 168 tpPluginPreferences.add(buildPluginListPanel()); 169 tpPluginPreferences.add(pnlPluginUpdatePolicy =new PluginUpdatePolicyPanel()); 170 tpPluginPreferences.setTitleAt(0, tr("Plugins")); 171 tpPluginPreferences.setTitleAt(1, tr("Plugin update policy")); 172 173 pnl.add(tpPluginPreferences, BorderLayout.CENTER); 174 return pnl; 165 protected JTabbedPane buildContentPane() { 166 JTabbedPane pane = getTabPane(); 167 pane.addTab(tr("Plugins"), buildPluginListPanel()); 168 pane.addTab(tr("Plugin update policy"), pnlPluginUpdatePolicy = new PluginUpdatePolicyPanel()); 169 return pane; 175 170 } 176 171 … … 182 177 gc.fill = GridBagConstraints.BOTH; 183 178 PreferencePanel plugins = gui.createPreferenceTab(this); 184 plugins.add(buildContentPane l(), gc);179 plugins.add(buildContentPane(), gc); 185 180 readLocalPluginInformation(); 186 181 pluginPreferencesActivated = true; -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r5604 r5631 32 32 import org.openstreetmap.josm.gui.help.HelpUtil; 33 33 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane.ValidationListener; 34 import org.openstreetmap.josm.gui.preferences.map.MapP reference;34 import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference; 35 35 import org.openstreetmap.josm.tools.GBC; 36 36 import org.openstreetmap.josm.tools.ImageProvider; … … 135 135 } 136 136 137 public void selectSubPreferencesTabByClass(Class<? extends SubPreferenceSetting> clazz) { 138 tpPreferences.selectSubTabByPref(clazz); 139 } 140 137 141 class CancelAction extends AbstractAction { 138 142 public CancelAction() { … … 181 185 182 186 public void selectMapPaintPreferenceTab() { 183 tpPreferences.selectTabByPref(MapPreference.class); 184 tpPreferences.getMapPreference().mapcontent.setSelectedIndex(1); 187 tpPreferences.selectSubTabByPref(MapPaintPreference.class); 185 188 } 186 189 } -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r5454 r5631 208 208 return tps.getClass().isAssignableFrom((Class<?>) clazz); 209 209 }}, clazz); 210 } 211 212 public boolean selectSubTabByPref(Class<? extends SubPreferenceSetting> clazz) { 213 for (PreferenceSetting setting : settings) { 214 if (clazz.isInstance(setting)) { 215 final SubPreferenceSetting sub = (SubPreferenceSetting) setting; 216 final TabPreferenceSetting tab = sub.getTabPreferenceSetting(PreferenceTabbedPane.this); 217 selectTabBy(new TabIdentifier(){ 218 @Override 219 public boolean identify(TabPreferenceSetting tps, Object unused) { 220 return tps.equals(tab); 221 }}, null); 222 return tab.selectSubTab(sub); 223 } 224 } 225 return false; 210 226 } 211 227 -
trunk/src/org/openstreetmap/josm/gui/preferences/ServerAccessPreference.java
r5266 r5631 27 27 28 28 private ServerAccessPreference() { 29 super("connection", tr("Connection Settings"), tr("Connection Settings for the OSM server.") );29 super("connection", tr("Connection Settings"), tr("Connection Settings for the OSM server."), false, new JTabbedPane()); 30 30 } 31 31 32 32 private OsmApiUrlInputPanel pnlApiUrlPreferences; 33 33 34 private JTabbedPane tpServerPreferences;35 34 /** indicates whether to use the default OSM URL or not */ 36 35 /** panel for configuring authentication preferences */ … … 60 59 JPanel pnl = new JPanel(new BorderLayout()); 61 60 62 tpServerPreferences = new JTabbedPane();61 JTabbedPane tpServerPreferences = getTabPane(); 63 62 pnlAuthPreferences = new AuthenticationPreferencesPanel(); 64 63 tpServerPreferences.add(wrapVerticallyScrollablePanel(pnlAuthPreferences)); -
trunk/src/org/openstreetmap/josm/gui/preferences/TabPreferenceSetting.java
r4989 r5631 1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.gui.preferences; 3 4 import java.awt.Component; 3 5 4 6 /** … … 29 31 /** 30 32 * Called during preferences tab initialization to display a description in one sentence for this tab. 31 * Will be displayed in italic under the title.33 * Will be displayed in italic under the title. 32 34 * @return The description of this preferences tab. 33 35 */ 34 36 public String getDescription(); 37 38 /** 39 * Adds a new sub preference settings tab with the given title and component. 40 * @param sub The new sub preference settings. 41 * @param title The tab title. 42 * @param component The tab component. 43 * @since 5631 44 */ 45 public void addSubTab(SubPreferenceSetting sub, String title, Component component); 46 47 /** 48 * Adds a new sub preference settings tab with the given title, component and tooltip. 49 * @param sub The new sub preference settings. 50 * @param title The tab title. 51 * @param component The tab component. 52 * @param tip The tab tooltip. 53 * @since 5631 54 */ 55 public void addSubTab(SubPreferenceSetting sub, String title, Component component, String tip); 56 57 /** 58 * Registers a sub preference settings to an existing tab component. 59 * @param sub The new sub preference settings. 60 * @param component The component for which a tab already exists. 61 * @since 5631 62 */ 63 public void registerSubTab(SubPreferenceSetting sub, Component component); 64 65 /** 66 * Returns the tab component related to the specified sub preference settings 67 * @param sub The requested sub preference settings. 68 * @return The component related to the specified sub preference settings, or null. 69 * @since 5631 70 */ 71 public Component getSubTab(SubPreferenceSetting sub); 72 73 /** 74 * Selects the specified sub preference settings, if applicable. Not all Tab preference settings need to implement this. 75 * @param subPref The sub preference settings to be selected. 76 * @return true if the specified preference settings have been selected, false otherwise. 77 * @since 5631 78 */ 79 public boolean selectSubTab(SubPreferenceSetting subPref); 35 80 } -
trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java
r4968 r5631 239 239 buttonPanel.add(defaultAll, GBC.std().insets(0,5,0,0)); 240 240 buttonPanel.add(remove, GBC.std().insets(0,5,0,0)); 241 gui.getDisplayPreference(). displaycontent.addTab(tr("Colors"), panel);241 gui.getDisplayPreference().addSubTab(this, tr("Colors"), panel); 242 242 } 243 243 -
trunk/src/org/openstreetmap/josm/gui/preferences/display/DisplayPreference.java
r4969 r5631 20 20 21 21 private DisplayPreference() { 22 super("display", tr("Display Settings"), tr("Various settings that influence the visual representation of the whole program.")); 22 super("display", tr("Display Settings"), tr("Various settings that influence the visual representation of the whole program."), false, new JTabbedPane()); 23 displaycontent = getTabPane(); 23 24 } 24 25 25 public final JTabbedPane displaycontent = new JTabbedPane(); 26 /** 27 * @deprecated Use {@link #getTabPane()} instead. This field will be removed mid-2013. 28 */ 29 public final JTabbedPane displaycontent; 26 30 27 31 @Override … … 32 36 @Override 33 37 public void addGui(PreferenceTabbedPane gui) { 34 gui.createPreferenceTab(this).add( displaycontent, GBC.eol().fill(GBC.BOTH));38 gui.createPreferenceTab(this).add(getTabPane(), GBC.eol().fill(GBC.BOTH)); 35 39 } 36 40 } -
trunk/src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java
r5568 r5631 56 56 JScrollPane scrollpane = new JScrollPane(panel); 57 57 scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 )); 58 gui.getDisplayPreference(). displaycontent.addTab(tr("GPS Points"), scrollpane);58 gui.getDisplayPreference().addSubTab(this, tr("GPS Points"), scrollpane); 59 59 panel = new JPanel(new GridBagLayout()); 60 60 panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); … … 142 142 scrollpane = new JScrollPane(panel); 143 143 scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 )); 144 gui.getDisplayPreference(). displaycontent.addTab(tr("OSM Data"), scrollpane);144 gui.getDisplayPreference().addSubTab(this, tr("OSM Data"), scrollpane); 145 145 } 146 146 -
trunk/src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java
r5429 r5631 116 116 JScrollPane scrollpane = new JScrollPane(panel); 117 117 scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 )); 118 gui.getDisplayPreference(). displaycontent.addTab(tr("Look and Feel"), scrollpane);118 gui.getDisplayPreference().addSubTab(this, tr("Look and Feel"), scrollpane); 119 119 } 120 120 -
trunk/src/org/openstreetmap/josm/gui/preferences/display/LanguagePreference.java
r5429 r5631 54 54 panel.add(langCombo, GBC.eol().fill(GBC.HORIZONTAL)); 55 55 panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH)); 56 57 TabPreferenceSetting tabPref = lafPreference.getTabPreferenceSetting(gui); 58 tabPref.registerSubTab(this, tabPref.getSubTab(lafPreference)); 56 59 } 57 60 … … 120 123 @Override 121 124 public TabPreferenceSetting getTabPreferenceSetting(final PreferenceTabbedPane gui) { 122 return gui.get DisplayPreference();125 return gui.getSetting(LafPreference.class).getTabPreferenceSetting(gui); 123 126 } 124 127 } -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r5617 r5631 76 76 77 77 private ImageryPreference() { 78 super("imagery", tr("Imagery Preferences"), tr("Modify list of imagery layers displayed in the Imagery menu") );78 super("imagery", tr("Imagery Preferences"), tr("Modify list of imagery layers displayed in the Imagery menu"), false, new JTabbedPane()); 79 79 } 80 80 … … 115 115 public void addGui(final PreferenceTabbedPane gui) { 116 116 JPanel p = gui.createPreferenceTab(this); 117 JTabbedPane pane = new JTabbedPane();117 JTabbedPane pane = getTabPane(); 118 118 layerInfo = new ImageryLayerInfo(ImageryLayerInfo.instance); 119 119 imageryProviders = new ImageryProvidersPanel(gui, layerInfo); 120 pane.add (imageryProviders);121 pane.add (buildSettingsPanel(gui));122 pane.add (new OffsetBookmarksPanel(gui));120 pane.addTab(tr("Imagery providers"), imageryProviders); 121 pane.addTab(tr("Settings"), buildSettingsPanel(gui)); 122 pane.addTab(tr("Offset bookmarks"), new OffsetBookmarksPanel(gui)); 123 123 loadSettings(); 124 pane.setTitleAt(0, tr("Imagery providers"));125 pane.setTitleAt(1, tr("Settings"));126 pane.setTitleAt(2, tr("Offset bookmarks"));127 124 p.add(pane,GBC.std().fill(GBC.BOTH)); 128 125 } -
trunk/src/org/openstreetmap/josm/gui/preferences/map/BackupPreference.java
r4968 r5631 101 101 sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 102 102 103 gui.getMapPreference(). mapcontent.addTab(tr("File backup"), null, sp, tr("Configure whether to create backup files"));103 gui.getMapPreference().addSubTab(this, tr("File backup"), sp, tr("Configure whether to create backup files")); 104 104 } 105 105 -
trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java
r5220 r5631 65 65 panel.add(enableIconDefault, GBC.eol().insets(11,2,5,0)); 66 66 67 gui.getMapPreference(). mapcontent.addTab(tr("Map Paint Styles"), panel);67 gui.getMapPreference().addSubTab(this, tr("Map Paint Styles"), panel); 68 68 69 69 // this defers loading of style sources to the first time the tab 70 70 // with the map paint preferences is selected by the user 71 71 // 72 gui.getMapPreference(). mapcontent.addChangeListener(72 gui.getMapPreference().getTabPane().addChangeListener( 73 73 new ChangeListener() { 74 74 public void stateChanged(ChangeEvent e) { 75 if (gui.getMapPreference(). mapcontent.getSelectedComponent() == panel) {75 if (gui.getMapPreference().getTabPane().getSelectedComponent() == panel) { 76 76 sources.initiallyLoadAvailableSources(); 77 77 } -
trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPreference.java
r4969 r5631 20 20 21 21 private MapPreference() { 22 super("map", tr("Map Settings"), tr("Settings for the map projection and data interpretation.")); 22 super("map", tr("Map Settings"), tr("Settings for the map projection and data interpretation."), false, new JTabbedPane()); 23 mapcontent = getTabPane(); 23 24 } 24 25 25 public final JTabbedPane mapcontent = new JTabbedPane(); 26 /** 27 * @deprecated Use {@link #getTabPane()} instead. This field will be removed mid-2013. 28 */ 29 public final JTabbedPane mapcontent; // FIXME remove it mid 2013 26 30 27 31 @Override … … 32 36 @Override 33 37 public void addGui(PreferenceTabbedPane gui) { 34 gui.createPreferenceTab(this).add( mapcontent, GBC.eol().fill(GBC.BOTH));38 gui.createPreferenceTab(this).add(getTabPane(), GBC.eol().fill(GBC.BOTH)); 35 39 } 36 40 } -
trunk/src/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreference.java
r5220 r5631 163 163 sources = new TaggingPresetSourceEditor(); 164 164 panel.add(sources, GBC.eol().fill(GBC.BOTH)); 165 gui.getMapPreference(). mapcontent.addTab(tr("Tagging Presets"), panel);165 gui.getMapPreference().addSubTab(this, tr("Tagging Presets"), panel); 166 166 167 167 // this defers loading of tagging preset sources to the first time the tab 168 168 // with the tagging presets is selected by the user 169 169 // 170 gui.getMapPreference(). mapcontent.addChangeListener(170 gui.getMapPreference().getTabPane().addChangeListener( 171 171 new ChangeListener() { 172 172 public void stateChanged(ChangeEvent e) { 173 if (gui.getMapPreference(). mapcontent.getSelectedComponent() == panel) {173 if (gui.getMapPreference().getTabPane().getSelectedComponent() == panel) { 174 174 sources.initiallyLoadAvailableSources(); 175 175 } -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java
r5604 r5631 319 319 320 320 JScrollPane scrollpane = new JScrollPane(projPanel); 321 gui.getMapPreference(). mapcontent.addTab(tr("Map Projection"), scrollpane);321 gui.getMapPreference().addSubTab(this, tr("Map Projection"), scrollpane); 322 322 323 323 selectedProjectionChanged(pc);
Note:
See TracChangeset
for help on using the changeset viewer.