- Timestamp:
- 2013-11-29T23:01:35+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/PreferencesAction.java
r6380 r6426 10 10 import org.openstreetmap.josm.Main; 11 11 import org.openstreetmap.josm.gui.preferences.PreferenceDialog; 12 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; 13 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 14 import org.openstreetmap.josm.tools.CheckParameterUtil; 12 15 import org.openstreetmap.josm.tools.Shortcut; 16 import org.openstreetmap.josm.tools.Utils; 13 17 14 18 /** … … 19 23 public class PreferencesAction extends JosmAction implements Runnable { 20 24 25 private final Class<? extends TabPreferenceSetting> tab; 26 private final Class<? extends SubPreferenceSetting> subTab; 27 28 private PreferencesAction(String name, String tooltip, 29 Class<? extends TabPreferenceSetting> tab, Class<? extends SubPreferenceSetting> subTab) { 30 super(name, "preference", tooltip, null, false, "preference_" + Utils.<Class>firstNonNull(tab, subTab).getName(), false); 31 this.tab = tab; 32 this.subTab = subTab; 33 } 34 35 public static PreferencesAction forPreferenceTab(String name, String tooltip, Class<? extends TabPreferenceSetting> tab) { 36 CheckParameterUtil.ensureParameterNotNull(tab); 37 return new PreferencesAction(name, tooltip, tab, null); 38 } 39 40 public static PreferencesAction forPreferenceSubTab(String name, String tooltip, Class<? extends SubPreferenceSetting> subTab) { 41 CheckParameterUtil.ensureParameterNotNull(subTab); 42 return new PreferencesAction(name, tooltip, null, subTab); 43 } 44 21 45 /** 22 46 * Create the preference action with "&Preferences" as label. … … 26 50 Shortcut.registerShortcut("system:preferences", tr("Preferences"), KeyEvent.VK_F12, Shortcut.DIRECT), true); 27 51 putValue("help", ht("/Action/Preferences")); 52 this.tab = null; 53 this.subTab = null; 28 54 } 29 55 … … 38 64 @Override 39 65 public void run() { 66 final PreferenceDialog p = new PreferenceDialog(Main.parent); 67 if (tab != null) { 68 p.selectPreferencesTabByClass(tab); 69 } else if( subTab != null) { 70 p.selectSubPreferencesTabByClass(subTab); 71 } 72 p.setVisible(true); 40 73 new PreferenceDialog(Main.parent).setVisible(true); 41 74 } -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r6412 r6426 110 110 import org.openstreetmap.josm.gui.layer.Layer; 111 111 import org.openstreetmap.josm.gui.mappaint.MapPaintMenu; 112 import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference; 113 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference; 112 114 import org.openstreetmap.josm.gui.tagging.TaggingPresetSearchAction; 113 115 import org.openstreetmap.josm.tools.ImageProvider; … … 693 695 694 696 add(presetsMenu, presetSearchAction); 697 add(presetsMenu, PreferencesAction.forPreferenceSubTab(tr("Preset preferences"), 698 tr("Click to open the tagging presets tab in the preferences"), TaggingPresetPreference.class)); 695 699 presetsMenu.addSeparator(); 700 701 add(imageryMenu, PreferencesAction.forPreferenceTab(tr("Imagery preferences"), 702 tr("Click to open the imagery tab in the preferences"), ImageryPreference.class)); 696 703 697 704 add(selectionMenu, selectAll); -
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r6289 r6426 58 58 import org.openstreetmap.josm.Main; 59 59 import org.openstreetmap.josm.actions.ExtensionFileFilter; 60 import org.openstreetmap.josm.actions.JosmAction; 61 import org.openstreetmap.josm.actions.PreferencesAction; 60 62 import org.openstreetmap.josm.gui.ExtendedDialog; 61 63 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 66 68 import org.openstreetmap.josm.gui.mappaint.StyleSource; 67 69 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 68 import org.openstreetmap.josm.gui.preferences.PreferenceDialog;69 70 import org.openstreetmap.josm.gui.preferences.SourceEntry; 71 import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference; 70 72 import org.openstreetmap.josm.gui.util.FileFilterAllFiles; 71 73 import org.openstreetmap.josm.gui.widgets.HtmlPanel; … … 90 92 protected MoveUpDownAction downAction; 91 93 protected JCheckBox cbWireframe; 94 95 public static final JosmAction PREFERENCE_ACTION = PreferencesAction.forPreferenceSubTab( 96 tr("Map paint preferences"), null, MapPaintPreference.class); 92 97 93 98 /** … … 158 163 InputMapUtils.addSpacebarAction(tblStyles, onoffAction); 159 164 160 createLayout(p, true, Arrays.asList( new SideButton[] {165 createLayout(p, true, Arrays.asList( 161 166 new SideButton(onoffAction, false), 162 167 new SideButton(upAction, false), 163 168 new SideButton(downAction, false), 164 new SideButton( new LaunchMapPaintPreferencesAction(), false)165 }));169 new SideButton(PREFERENCE_ACTION, false) 170 )); 166 171 } 167 172 … … 405 410 public void valueChanged(ListSelectionEvent e) { 406 411 updateEnabledState(); 407 }408 }409 410 /**411 * Opens preferences window and selects the mappaint tab.412 */413 public static class LaunchMapPaintPreferencesAction extends AbstractAction {414 /**415 * Constructs a new {@code LaunchMapPaintPreferencesAction}.416 */417 public LaunchMapPaintPreferencesAction() {418 putValue(NAME, tr("Preferences"));419 putValue(SMALL_ICON, ImageProvider.get("dialogs", "mappaintpreference"));420 }421 422 @Override423 public void actionPerformed(ActionEvent e) {424 final PreferenceDialog p =new PreferenceDialog(Main.parent);425 p.selectMapPaintPreferenceTab();426 p.setVisible(true);427 412 } 428 413 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java
r6336 r6426 14 14 import org.openstreetmap.josm.actions.JosmAction; 15 15 import org.openstreetmap.josm.gui.dialogs.MapPaintDialog; 16 import org.openstreetmap.josm.gui.dialogs.MapPaintDialog.LaunchMapPaintPreferencesAction;17 16 import org.openstreetmap.josm.gui.layer.GpxLayer; 18 17 import org.openstreetmap.josm.gui.layer.Layer; … … 78 77 } 79 78 private final Map<String, MapPaintAction> actions = new HashMap<String, MapPaintAction>(); 80 private final LaunchMapPaintPreferencesAction mapPaintPreferencesAction = new MapPaintDialog.LaunchMapPaintPreferencesAction() {81 82 {83 putValue("toolbar", "mappaintpreference");84 }85 };86 79 87 80 /** … … 110 103 } 111 104 addSeparator(); 112 add( mapPaintPreferencesAction);105 add(MapPaintDialog.PREFERENCE_ACTION); 113 106 } 114 107 -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r6084 r6426 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.MapPaintPreference;35 34 import org.openstreetmap.josm.tools.GBC; 36 35 import org.openstreetmap.josm.tools.ImageProvider; … … 186 185 } 187 186 } 188 189 public void selectMapPaintPreferenceTab() {190 tpPreferences.selectSubTabByPref(MapPaintPreference.class);191 }192 187 }
Note:
See TracChangeset
for help on using the changeset viewer.