Ticket #1622: thepatch.diff
| File thepatch.diff, 93.2 KB (added by , 18 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/PreferencesAction.java
14 14 import org.openstreetmap.josm.Main; 15 15 import org.openstreetmap.josm.gui.preferences.PreferenceDialog; 16 16 import org.openstreetmap.josm.tools.GBC; 17 import org.openstreetmap.josm.tools.ShortCut; 17 18 18 19 /** 19 20 * Open the Preferences dialog. … … 26 27 * Create the preference action with "&Preferences" as label. 27 28 */ 28 29 public PreferencesAction() { 29 super(tr("Preferences ..."), "preference", tr("Open a preferences page for global settings."), KeyEvent.VK_F12, 0, true); 30 super(tr("Preferences ..."), "preference", tr("Open a preferences page for global settings."), 31 ShortCut.registerShortCut("system:preferences", tr("Preferences"), KeyEvent.VK_F12, ShortCut.GROUP_DIRECT), true); 30 32 } 31 33 32 34 /** -
src/org/openstreetmap/josm/actions/OpenAction.java
24 24 import org.openstreetmap.josm.io.NmeaReader; 25 25 import org.openstreetmap.josm.io.OsmReader; 26 26 import org.xml.sax.SAXException; 27 import org.openstreetmap.josm.tools.ShortCut; 27 28 28 29 /** 29 30 * Open a file chooser dialog and select an file to import. Then call the gpx-import … … 37 38 * Create an open action. The name is "Open a file". 38 39 */ 39 40 public OpenAction() { 40 super(tr("Open ..."), "open", tr("Open a file."), KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK); 41 super(tr("Open ..."), "open", tr("Open a file."), 42 ShortCut.registerShortCut("system:open", tr("File: Open..."), KeyEvent.VK_O, ShortCut.GROUP_MENU)); 41 43 } 42 44 43 45 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/AlignInCircleAction.java
19 19 import org.openstreetmap.josm.data.osm.Node; 20 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 21 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.tools.ShortCut; 22 23 23 24 /** 24 25 * Aligns all selected nodes within a circle. (Useful for roundabouts) … … 28 29 public final class AlignInCircleAction extends JosmAction { 29 30 30 31 public AlignInCircleAction() { 31 super(tr("Align Nodes in Circle"), "aligncircle", tr("Move the selected nodes into a circle."), KeyEvent.VK_O, 0, true); 32 super(tr("Align Nodes in Circle"), "aligncircle", tr("Move the selected nodes into a circle."), 33 ShortCut.registerShortCut("tools:aligncircle", tr("Tool: Align in circle"), KeyEvent.VK_O, ShortCut.GROUP_EDIT), true); 32 34 } 33 35 34 36 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/MoveAction.java
16 16 import org.openstreetmap.josm.data.osm.Node; 17 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; 18 18 import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor; 19 import org.openstreetmap.josm.tools.ShortCut; 19 20 20 21 /** 21 22 * Moves the selection … … 27 28 public enum Direction { UP, LEFT, RIGHT, DOWN } 28 29 private Direction myDirection; 29 30 31 // any better idea? 32 private static Object calltosupermustbefirststatementinconstructor(Direction dir, boolean text) { 33 ShortCut sc; 34 String directiontext; 35 if (dir == Direction.UP) { 36 directiontext = tr("up"); 37 sc = ShortCut.registerShortCut("core:moveup", tr("Move objects {0}", directiontext), KeyEvent.VK_UP, ShortCut.GROUPS_ALT1+ShortCut.GROUP_DIRECT); 38 } else if (dir == Direction.DOWN) { 39 directiontext = tr("down"); 40 sc = ShortCut.registerShortCut("core:movedown", tr("Move objects {0}", directiontext), KeyEvent.VK_DOWN, ShortCut.GROUPS_ALT1+ShortCut.GROUP_DIRECT); 41 } else if (dir == Direction.LEFT) { 42 directiontext = tr("left"); 43 sc = ShortCut.registerShortCut("core:moveleft", tr("Move objects {0}", directiontext), KeyEvent.VK_LEFT, ShortCut.GROUPS_ALT1+ShortCut.GROUP_DIRECT); 44 } else { //dir == Direction.RIGHT) { 45 directiontext = tr("right"); 46 sc = ShortCut.registerShortCut("core:moveright", tr("Move objects {0}", directiontext), KeyEvent.VK_RIGHT, ShortCut.GROUPS_ALT1+ShortCut.GROUP_DIRECT); 47 } 48 if (text) { 49 return directiontext; 50 } else { 51 return sc; 52 } 53 } 54 30 55 public MoveAction(Direction dir) { 31 super(tr("Move"), null, tr("Moves Objects"), 32 (dir == Direction.UP) ? KeyEvent.VK_UP : 33 (dir == Direction.DOWN) ? KeyEvent.VK_DOWN : 34 (dir == Direction.LEFT) ? KeyEvent.VK_LEFT : 35 KeyEvent.VK_RIGHT, 0, true); 56 super(tr("Move {0}", calltosupermustbefirststatementinconstructor(dir, true)), null, 57 tr("Moves Objects {0}", calltosupermustbefirststatementinconstructor(dir, true)), 58 (ShortCut)calltosupermustbefirststatementinconstructor(dir, false), true); 36 59 myDirection = dir; 37 60 } 38 61 -
src/org/openstreetmap/josm/actions/JosmAction.java
1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.actions; 3 3 4 import java.awt.event.InputEvent; 4 5 5 6 import javax.swing.AbstractAction; 6 7 import javax.swing.JComponent; … … 10 11 import org.openstreetmap.josm.data.osm.DataSet; 11 12 import org.openstreetmap.josm.tools.Destroyable; 12 13 import org.openstreetmap.josm.tools.ImageProvider; 13 import org.openstreetmap.josm.tools.ShortCut Label;14 import org.openstreetmap.josm.tools.ShortCut; 14 15 15 16 /** 16 17 * Base class helper for all Actions in JOSM. Just to make the life easier. … … 23 24 */ 24 25 abstract public class JosmAction extends AbstractAction implements Destroyable { 25 26 27 @Deprecated 26 28 public KeyStroke shortCut; 29 protected ShortCut sc; 27 30 31 public ShortCut getShortCut() { 32 if (sc == null) { 33 sc = ShortCut.registerShortCut("core:none", "No Shortcut", 0, ShortCut.GROUP_NONE); 34 sc.setAutomatic(); // as this shortcut is shared by all action that don't want to have a shortcut, 35 // we shouldn't allow the user to change it... 36 } 37 return sc; 38 } 39 40 @Deprecated 28 41 public JosmAction(String name, String iconName, String tooltip, int shortCut, int modifier, boolean register) { 29 42 super(name, iconName == null ? null : ImageProvider.get(iconName)); 30 43 setHelpId(); 31 String scl = ShortCutLabel.name(shortCut, modifier);32 putValue(SHORT_DESCRIPTION, "<html>"+tooltip+" <font size='-2'>"+scl+"</font>"+(scl.equals("")?"":" ")+"</html>");33 44 if (shortCut != 0) { 34 this.shortCut = KeyStroke.getKeyStroke(shortCut, modifier); 35 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(this.shortCut, name); 45 int group = ShortCut.GROUP_LAYER; //GROUP_NONE; 46 if (((modifier & InputEvent.CTRL_MASK) != 0) || ((modifier & InputEvent.CTRL_DOWN_MASK) != 0)) { 47 group = ShortCut.GROUP_MENU; 48 } else if (modifier == 0) { 49 group = ShortCut.GROUP_EDIT; 50 } 51 sc = ShortCut.registerShortCut("auto:"+name, name, shortCut, group); 52 this.shortCut = sc.getKeyStroke(); 53 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sc.getKeyStroke(), name); 36 54 Main.contentPane.getActionMap().put(name, this); 37 55 } 56 putValue(SHORT_DESCRIPTION, Main.platform.makeTooltip(tooltip, sc)); 38 57 putValue("toolbar", iconName); 39 58 if (register) 40 59 Main.toolbar.register(this); 41 60 } 42 61 62 /** 63 * The new super for all actions. 64 * 65 * Use this super constructor to setup your action. It takes 5 parameters: 66 * 67 * name - the action's text as displayed on the menu (if it is added to a menu) 68 * iconName - the filename of the icon to use 69 * tooltip - a longer description of the action that will be displayed in the tooltip. Please note 70 * that html is not supported for menu action on some platforms 71 * shortCut - a ready-created shortcut object or null if you don't want a shortcut. But you always 72 * do want a shortcut, remember you can alway register it with group=none, so you 73 * won't be assigned a shurtcut unless the user configures one. If you pass null here, 74 * the user CANNOT configure a shortcut for your action. 75 * register - register this action for the toolbar preferences? 76 */ 77 public JosmAction(String name, String iconName, String tooltip, ShortCut shortCut, boolean register) { 78 super(name, iconName == null ? null : ImageProvider.get(iconName)); 79 setHelpId(); 80 sc = shortCut; 81 if (sc != null) { 82 this.shortCut = sc.getKeyStroke(); 83 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sc.getKeyStroke(), name); 84 Main.contentPane.getActionMap().put(name, this); 85 } 86 putValue(SHORT_DESCRIPTION, Main.platform.makeTooltip(tooltip, sc)); 87 putValue("toolbar", iconName); 88 if (register) 89 Main.toolbar.register(this); 90 } 91 43 92 public void destroy() { 44 93 if (shortCut != null) { 45 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).remove(s hortCut);46 Main.contentPane.getActionMap().remove(s hortCut);94 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).remove(sc.getKeyStroke()); 95 Main.contentPane.getActionMap().remove(sc.getKeyStroke()); 47 96 } 48 97 } 49 98 -
src/org/openstreetmap/josm/actions/SelectAllAction.java
7 7 import java.awt.event.KeyEvent; 8 8 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.tools.ShortCut; 10 11 11 12 public class SelectAllAction extends JosmAction { 12 13 13 14 public SelectAllAction() { 14 super(tr("Select All"),"selectall", tr("Select all undeleted objects in the data layer. This selects incomplete objects too."), KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK, true); 15 super(tr("Select All"),"selectall", tr("Select all undeleted objects in the data layer. This selects incomplete objects too."), 16 ShortCut.registerShortCut("system:selectall", tr("Edit: Select all"), KeyEvent.VK_A, ShortCut.GROUP_MENU), true); 15 17 } 16 18 17 19 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/ExitAction.java
7 7 import java.awt.event.KeyEvent; 8 8 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.tools.ShortCut; 10 11 11 12 /** 12 13 * Exit the application. May ask for permission first (if something has changed). … … 18 19 * Construct the action with "Exit" as label 19 20 */ 20 21 public ExitAction() { 21 super(tr("Exit"), "exit", tr("Exit the application."), KeyEvent.VK_Q, KeyEvent.CTRL_DOWN_MASK, true); 22 super(tr("Exit"), "exit", tr("Exit the application."), 23 ShortCut.registerShortCut("system:menuexit", tr("Quit JOSM"), KeyEvent.VK_Q, ShortCut.GROUP_MENU), true); 22 24 } 23 25 24 26 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/CopyAction.java
23 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 24 24 import org.openstreetmap.josm.data.osm.Way; 25 25 import org.openstreetmap.josm.data.osm.visitor.Visitor; 26 import org.openstreetmap.josm.tools.ShortCut; 26 27 27 28 public final class CopyAction extends JosmAction implements SelectionChangedListener { 28 29 … … 31 32 public CopyAction() { 32 33 super(tr("Copy"), "copy", 33 34 tr("Copy selected objects to paste buffer."), 34 KeyEvent.VK_C, KeyEvent.CTRL_MASK, true);35 ShortCut.registerShortCut("system:copy", tr("Edit: Copy"), KeyEvent.VK_C, ShortCut.GROUP_MENU), true); 35 36 setEnabled(false); 36 37 DataSet.selListeners.add(this); 37 38 listeners = new LinkedList<JosmAction>(); -
src/org/openstreetmap/josm/actions/UnselectAllAction.java
9 9 import javax.swing.JComponent; 10 10 11 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm.tools.ShortCut; 12 13 13 14 public class UnselectAllAction extends JosmAction { 14 15 15 16 public UnselectAllAction() { 16 17 super(tr("Unselect All"), "unselectall", tr("Unselect all objects."), 17 KeyEvent.VK_U, 0, true); 18 ShortCut.registerShortCut("edit:unselectall", tr("Edit: Unselect all"), KeyEvent.VK_U, ShortCut.GROUP_EDIT), true); 19 // this is not really GROUP_EDIT, but users really would complain if the yhad to reconfigure because we put 20 // the correct group in 18 21 19 22 // Add extra shortcut C-S-a 20 23 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 21 KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK22 | KeyEvent.SHIFT_DOWN_MASK),tr("Unselect All"));24 ShortCut.registerShortCut("edit:unselectall2", tr("Edit: Unselect all (2)"), KeyEvent.VK_A, ShortCut.GROUP_MENU).getKeyStroke(), 25 tr("Unselect All")); 23 26 24 27 // Add extra shortcut ESCAPE 25 28 /* … … 28 31 * for now this is a reasonable approximation. 29 32 */ 30 33 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 31 KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),34 ShortCut.registerShortCut("edit:unselectall3", tr("Edit: Unselect all (3)"), KeyEvent.VK_ESCAPE, ShortCut.GROUP_DIRECT).getKeyStroke(), 32 35 tr("Unselect All")); 33 36 } 34 37 -
src/org/openstreetmap/josm/actions/ZoomInAction.java
7 7 import java.awt.event.KeyEvent; 8 8 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.tools.ShortCut; 10 11 11 12 public final class ZoomInAction extends JosmAction { 12 13 13 14 public ZoomInAction() { 14 15 super(tr("Zoom in"), "dialogs/zoomin", tr("Zoom in"), 15 KeyEvent.VK_PLUS, 0, true);16 ShortCut.registerShortCut("view:zoomin", tr("View: Zoom in"), KeyEvent.VK_PLUS, ShortCut.GROUP_DIRECT), true); 16 17 setEnabled(true); 17 18 } 18 19 -
src/org/openstreetmap/josm/actions/SplitWayAction.java
32 32 import org.openstreetmap.josm.data.osm.Way; 33 33 import org.openstreetmap.josm.data.osm.visitor.NameVisitor; 34 34 import org.openstreetmap.josm.data.osm.visitor.Visitor; 35 import org.openstreetmap.josm.tools.ShortCut; 35 36 36 37 /** 37 38 * Splits a way into multiple ways (all identical except for their node list). … … 49 50 * Create a new SplitWayAction. 50 51 */ 51 52 public SplitWayAction() { 52 super(tr("Split Way"), "splitway", tr("Split a way at the selected node."), KeyEvent.VK_P, 0, true); 53 super(tr("Split Way"), "splitway", tr("Split a way at the selected node."), 54 ShortCut.registerShortCut("tools:splitway", tr("Tool: Split way"), KeyEvent.VK_P, ShortCut.GROUP_EDIT), true); 53 55 DataSet.selListeners.add(this); 54 56 } 55 57 -
src/org/openstreetmap/josm/actions/ZoomOutAction.java
7 7 import java.awt.event.KeyEvent; 8 8 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.tools.ShortCut; 10 11 11 12 public final class ZoomOutAction extends JosmAction { 12 13 13 14 public ZoomOutAction() { 14 15 super(tr("Zoom out"), "dialogs/zoomout", tr("Zoom out"), 15 KeyEvent.VK_MINUS, 0, true);16 ShortCut.registerShortCut("view:zoomout", tr("View: Zoom out"), KeyEvent.VK_MINUS, ShortCut.GROUP_DIRECT), true); 16 17 setEnabled(true); 17 18 } 18 19 -
src/org/openstreetmap/josm/actions/SaveAsAction.java
8 8 import java.io.File; 9 9 10 10 import org.openstreetmap.josm.gui.layer.Layer; 11 import org.openstreetmap.josm.tools.ShortCut; 11 12 12 13 /** 13 14 * Export the data. … … 21 22 * @param layer Save this layer. 22 23 */ 23 24 public SaveAsAction(Layer layer) { 24 super(tr("Save as ..."), "save_as", tr("Save the current data to a new file."), KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, layer); 25 super(tr("Save as ..."), "save_as", tr("Save the current data to a new file."), 26 ShortCut.registerShortCut("system:saveas", tr("File: Save as..."), KeyEvent.VK_S, ShortCut.GROUP_MENU), layer); 25 27 } 26 28 27 29 @Override protected File getFile(Layer layer) { -
src/org/openstreetmap/josm/actions/audio/AudioBackAction.java
10 10 import org.openstreetmap.josm.actions.JosmAction; 11 11 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 12 12 import org.openstreetmap.josm.tools.AudioPlayer; 13 import org.openstreetmap.josm.tools.ShortCut; 13 14 14 15 public class AudioBackAction extends JosmAction { 15 16 16 17 private double amount; // note, normally negative, i.e. jump backwards in time 17 18 18 19 public AudioBackAction() { 19 super(tr("Back"), "audio-back", tr("Jump back."), KeyEvent.VK_F6, 0, true); 20 super(tr("Back"), "audio-back", tr("Jump back."), 21 ShortCut.registerShortCut("audio:back", tr("Audio: Back"), KeyEvent.VK_F6, ShortCut.GROUP_DIRECT), true); 20 22 try { 21 23 amount = - Double.parseDouble(Main.pref.get("audio.forwardbackamount","10.0")); 22 24 } catch (NumberFormatException e) { -
src/org/openstreetmap/josm/actions/audio/AudioFwdAction.java
10 10 import org.openstreetmap.josm.actions.JosmAction; 11 11 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 12 12 import org.openstreetmap.josm.tools.AudioPlayer; 13 import org.openstreetmap.josm.tools.ShortCut; 13 14 14 15 public class AudioFwdAction extends JosmAction { 15 16 16 17 private double amount; 17 18 18 19 public AudioFwdAction() { 19 super(tr("Forward"), "audio-fwd", tr("Jump forward"), KeyEvent.VK_F7, 0, true); 20 super(tr("Forward"), "audio-fwd", tr("Jump forward"), 21 ShortCut.registerShortCut("audio:forward", tr("Audio: Forward"), KeyEvent.VK_F7, ShortCut.GROUP_DIRECT), true); 20 22 try { 21 23 amount = Double.parseDouble(Main.pref.get("audio.forwardbackamount","10.0")); 22 24 } catch (NumberFormatException e) { -
src/org/openstreetmap/josm/actions/audio/AudioFastSlowAction.java
6 6 import org.openstreetmap.josm.Main; 7 7 import org.openstreetmap.josm.actions.JosmAction; 8 8 import org.openstreetmap.josm.tools.AudioPlayer; 9 import org.openstreetmap.josm.tools.ShortCut; 9 10 10 11 abstract public class AudioFastSlowAction extends JosmAction { 11 12 12 13 private double multiplier; 13 14 15 public AudioFastSlowAction(String name, String iconName, String tooltip, ShortCut shortcut, boolean fast) { 16 super(name, iconName, tooltip, shortcut, true); 17 try { 18 multiplier = Double.parseDouble(Main.pref.get("audio.fastfwdmultiplier","1.3")); 19 } catch (NumberFormatException e) { 20 multiplier = 1.3; 21 } 22 if (! fast) 23 multiplier = 1.0 / multiplier; 24 } 25 26 @Deprecated 14 27 public AudioFastSlowAction(String name, String iconName, String tooltip, int shortcut, int modifier, boolean fast) { 15 28 super(name, iconName, tooltip, shortcut, modifier, true); 16 29 try { -
src/org/openstreetmap/josm/actions/audio/AudioPlayPauseAction.java
10 10 import org.openstreetmap.josm.actions.JosmAction; 11 11 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 12 12 import org.openstreetmap.josm.tools.AudioPlayer; 13 import org.openstreetmap.josm.tools.ShortCut; 13 14 14 15 public class AudioPlayPauseAction extends JosmAction { 15 16 16 17 public AudioPlayPauseAction() { 17 super(tr("Play/pause"), "audio-playpause", tr("Play/pause audio."), KeyEvent.VK_PERIOD, 0, true); 18 super(tr("Play/pause"), "audio-playpause", tr("Play/pause audio."), 19 ShortCut.registerShortCut("audio:pause", tr("Audio: Play/Pause"), KeyEvent.VK_PERIOD, ShortCut.GROUP_DIRECT), true); 18 20 } 19 21 20 22 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/audio/AudioFasterAction.java
2 2 package org.openstreetmap.josm.actions.audio; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import org.openstreetmap.josm.tools.ShortCut; 5 6 6 7 import java.awt.event.KeyEvent; 7 8 8 9 public class AudioFasterAction extends AudioFastSlowAction { 9 10 10 11 public AudioFasterAction() { 11 super(tr("Faster"), "audio-faster", tr("Faster Forward"), KeyEvent.VK_F9, 0, true); 12 super(tr("Faster"), "audio-faster", tr("Faster Forward"), 13 ShortCut.registerShortCut("audio:faster", tr("Audio: Faster"), KeyEvent.VK_F9, ShortCut.GROUP_DIRECT), true); 12 14 } 13 15 } -
src/org/openstreetmap/josm/actions/audio/AudioSlowerAction.java
4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 6 import java.awt.event.KeyEvent; 7 import org.openstreetmap.josm.tools.ShortCut; 7 8 8 9 public class AudioSlowerAction extends AudioFastSlowAction { 9 10 10 11 public AudioSlowerAction() { 11 super(tr("Slower"), "audio-slower", tr("Slower Forward"), KeyEvent.VK_F9, KeyEvent.SHIFT_MASK, false); 12 super(tr("Slower"), "audio-slower", tr("Slower Forward"), 13 ShortCut.registerShortCut("audio:slower", tr("Audio: Slower"), KeyEvent.VK_F9, ShortCut.GROUP_DIRECT), true); 12 14 } 13 15 } -
src/org/openstreetmap/josm/actions/audio/AudioPrevAction.java
8 8 9 9 import org.openstreetmap.josm.actions.JosmAction; 10 10 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 11 import org.openstreetmap.josm.tools.ShortCut; 11 12 12 13 public class AudioPrevAction extends JosmAction { 13 14 14 15 public AudioPrevAction() { 15 super(tr("Previous Marker"), "audio-prev", tr("Play previous marker."), KeyEvent.VK_F5, 0, true); 16 super(tr("Previous Marker"), "audio-prev", tr("Play previous marker."), 17 ShortCut.registerShortCut("audio:prev", tr("Audio: Previous"), KeyEvent.VK_F5, ShortCut.GROUP_DIRECT), true); 16 18 } 17 19 18 20 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/audio/AudioNextAction.java
8 8 9 9 import org.openstreetmap.josm.actions.JosmAction; 10 10 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 11 import org.openstreetmap.josm.tools.ShortCut; 11 12 12 13 public class AudioNextAction extends JosmAction { 13 14 14 15 public AudioNextAction() { 15 super(tr("Next Marker"), "audio-next", tr("Play next marker."), KeyEvent.VK_F8, 0, true); 16 super(tr("Next Marker"), "audio-next", tr("Play next marker."), 17 ShortCut.registerShortCut("audio:next", tr("Audio: Next"), KeyEvent.VK_F8, ShortCut.GROUP_DIRECT), true); 16 18 } 17 19 18 20 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
22 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 23 import org.openstreetmap.josm.data.osm.Way; 24 24 import org.openstreetmap.josm.data.osm.WaySegment; 25 import org.openstreetmap.josm.tools.ShortCut; 25 26 26 27 public class JoinNodeWayAction extends JosmAction { 27 28 public JoinNodeWayAction() { 28 super(tr("Join node to way"), "joinnodeway", 29 tr("Join a node into the nearest way segments"), KeyEvent.VK_J, 0, true);29 super(tr("Join node to way"), "joinnodeway", tr("Join a node into the nearest way segments"), 30 ShortCut.registerShortCut("tools:joinnodeway", tr("Tool: Join node to way"), KeyEvent.VK_J, ShortCut.GROUP_EDIT), true); 30 31 } 31 32 32 33 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/search/SearchAction.java
21 21 import org.openstreetmap.josm.actions.JosmAction; 22 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 23 import org.openstreetmap.josm.tools.GBC; 24 import org.openstreetmap.josm.tools.ShortCut; 24 25 25 26 public class SearchAction extends JosmAction { 26 27 … … 35 36 private static SearchSetting lastSearch = null; 36 37 37 38 public SearchAction() { 38 super(tr("Search ..."), "dialogs/search", tr("Search for objects."), KeyEvent.VK_F, KeyEvent.CTRL_DOWN_MASK,39 true);39 super(tr("Search ..."), "dialogs/search", tr("Search for objects."), 40 ShortCut.registerShortCut("system:find", tr("Search..."), KeyEvent.VK_F, ShortCut.GROUP_HOTKEY), true); 40 41 } 41 42 42 43 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/AlignInLineAction.java
17 17 import org.openstreetmap.josm.data.osm.Node; 18 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 19 import org.openstreetmap.josm.data.osm.Way; 20 import org.openstreetmap.josm.tools.ShortCut; 20 21 21 22 /** 22 23 * Aligns all selected nodes into a straight line (useful for … … 28 29 public final class AlignInLineAction extends JosmAction { 29 30 30 31 public AlignInLineAction() { 31 super(tr("Align Nodes in Line"), "alignline", tr("Move the selected nodes onto a line."), KeyEvent.VK_L, 0, true); 32 super(tr("Align Nodes in Line"), "alignline", tr("Move the selected nodes onto a line."), 33 ShortCut.registerShortCut("tools:alignline", tr("Tool: Align in line"), KeyEvent.VK_L, ShortCut.GROUP_EDIT), true); 32 34 } 33 35 34 36 /** -
src/org/openstreetmap/josm/actions/ReverseWayAction.java
24 24 import org.openstreetmap.josm.data.osm.OsmPrimitive; 25 25 import org.openstreetmap.josm.data.osm.Way; 26 26 import org.openstreetmap.josm.data.osm.visitor.Visitor; 27 import org.openstreetmap.josm.tools.ShortCut; 27 28 28 29 public final class ReverseWayAction extends JosmAction { 29 30 30 31 public ReverseWayAction() { 31 super(tr("Reverse ways"), "wayflip", 32 tr("Reverse the direction of all selected ways."), 33 KeyEvent.VK_R, 0, true); 32 super(tr("Reverse ways"), "wayflip", tr("Reverse the direction of all selected ways."), 33 ShortCut.registerShortCut("tools:reverse", tr("Tool: Reverse way"), KeyEvent.VK_R, ShortCut.GROUP_EDIT), true); 34 34 } 35 35 36 36 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/UnGlueAction.java
25 25 import org.openstreetmap.josm.data.osm.Relation; 26 26 import org.openstreetmap.josm.data.osm.RelationMember; 27 27 import org.openstreetmap.josm.data.osm.Way; 28 import org.openstreetmap.josm.tools.ShortCut; 28 29 29 30 /** 30 31 * Dupe a node that is used my multiple ways, so each way has its own node. … … 43 44 * Create a new SplitWayAction. 44 45 */ 45 46 public UnGlueAction() { 46 super(tr("UnGlue Ways"), "unglueways", tr("Duplicate the selected node so each way using it has its own copy."), KeyEvent.VK_G, 0, true); 47 super(tr("UnGlue Ways"), "unglueways", tr("Duplicate the selected node so each way using it has its own copy."), 48 ShortCut.registerShortCut("tools:unglue", tr("Tool: Unglue"), KeyEvent.VK_G, ShortCut.GROUP_EDIT), true); 47 49 DataSet.selListeners.add(this); 48 50 } 49 51 -
src/org/openstreetmap/josm/actions/GpxExportAction.java
33 33 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 34 34 import org.openstreetmap.josm.io.GpxWriter; 35 35 import org.openstreetmap.josm.tools.GBC; 36 import org.openstreetmap.josm.tools.ShortCut; 36 37 37 38 /** 38 39 * Exports data to gpx. … … 44 45 private final Layer layer; 45 46 46 47 public GpxExportAction(Layer layer) { 47 super(tr("Export to GPX ..."), "exportgpx", tr("Export the data to GPX file."), KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK); 48 super(tr("Export to GPX ..."), "exportgpx", tr("Export the data to GPX file."), 49 ShortCut.registerShortCut("file:exportgpx", tr("Export to GPX"), KeyEvent.VK_E, ShortCut.GROUP_MENU)); 48 50 this.layer = layer; 49 51 } 50 52 -
src/org/openstreetmap/josm/actions/DeleteAction.java
7 7 import java.awt.event.KeyEvent; 8 8 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.tools.ShortCut; 10 11 11 12 public final class DeleteAction extends JosmAction { 12 13 13 14 public DeleteAction() { 14 15 super(tr("Delete"), "dialogs/delete", tr("Delete selected objects."), 15 KeyEvent.VK_DELETE, 0, true);16 ShortCut.registerShortCut("system:delete", tr("Edit: Delete"), KeyEvent.VK_DELETE, ShortCut.GROUP_DIRECT), true); 16 17 setEnabled(true); 17 18 } 18 19 -
src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
15 15 import org.openstreetmap.josm.data.osm.WaySegment; 16 16 import org.openstreetmap.josm.gui.MapFrame; 17 17 import org.openstreetmap.josm.tools.ImageProvider; 18 import org.openstreetmap.josm.tools.ShortCut; 18 19 19 20 /** 20 21 * An action that enables the user to delete nodes and other objects. … … 42 43 super(tr("Delete Mode"), 43 44 "delete", 44 45 tr("Delete nodes or ways."), 45 KeyEvent.VK_D,46 ShortCut.registerShortCut("mapmode:delete", tr("Delete mode"), KeyEvent.VK_D, ShortCut.GROUP_EDIT), 46 47 mapFrame, 47 48 ImageProvider.getCursor("normal", "delete")); 48 49 } -
src/org/openstreetmap/josm/actions/mapmode/MapMode.java
11 11 import org.openstreetmap.josm.actions.JosmAction; 12 12 import org.openstreetmap.josm.gui.MapFrame; 13 13 import org.openstreetmap.josm.tools.ImageProvider; 14 import org.openstreetmap.josm.tools.ShortCut; 14 15 15 16 /** 16 17 * A class implementing MapMode is able to be selected as an mode for map editing. … … 27 28 /** 28 29 * Constructor for mapmodes without an menu 29 30 */ 31 public MapMode(String name, String iconName, String tooltip, ShortCut shortCut, MapFrame mapFrame, Cursor cursor) { 32 super(name, "mapmode/"+iconName, tooltip, shortCut, false); 33 this.cursor = cursor; 34 putValue("active", false); 35 } 36 37 /** 38 * Constructor for mapmodes without an menu 39 */ 40 @Deprecated 30 41 public MapMode(String name, String iconName, String tooltip, int keystroke, MapFrame mapFrame, Cursor cursor) { 31 42 super(name, "mapmode/"+iconName, tooltip, keystroke, 0, false); 32 43 this.cursor = cursor; -
src/org/openstreetmap/josm/actions/mapmode/ZoomAction.java
12 12 import org.openstreetmap.josm.gui.SelectionManager; 13 13 import org.openstreetmap.josm.gui.SelectionManager.SelectionEnded; 14 14 import org.openstreetmap.josm.tools.ImageProvider; 15 import org.openstreetmap.josm.tools.ShortCut; 15 16 16 17 /** 17 18 * Enable the zoom mode within the MapFrame. … … 44 45 * @param mapFrame The MapFrame, whose zoom mode should be enabled. 45 46 */ 46 47 public ZoomAction(MapFrame mapFrame) { 47 super(tr("Zoom"), "zoom", tr("Zoom and move map"), KeyEvent.VK_Z, mapFrame, ImageProvider.getCursor("normal", "zoom")); 48 super(tr("Zoom"), "zoom", tr("Zoom and move map"), 49 ShortCut.registerShortCut("mapmode:zoom", tr("Zoom mode"), KeyEvent.VK_Z, ShortCut.GROUP_EDIT), 50 mapFrame, ImageProvider.getCursor("normal", "zoom")); 48 51 mv = mapFrame.mapView; 49 52 selectionManager = new SelectionManager(this, true, mv); 50 53 } -
src/org/openstreetmap/josm/actions/mapmode/PlayHeadDragMode.java
11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.data.coor.EastNorth; 13 13 import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker; 14 import org.openstreetmap.josm.tools.ShortCut; 14 15 15 16 /** 16 17 * Singleton marker class to track position of audio. … … 26 27 private PlayHeadMarker playHeadMarker = null; 27 28 28 29 public PlayHeadDragMode(PlayHeadMarker m) { 29 super("play head drag", "playheaddrag", "play head trag", 0, Main.map, Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); 30 super("play head drag", "playheaddrag", "play head drag", null, 31 Main.map, Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); 30 32 playHeadMarker = m; 31 33 } 32 34 -
src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
51 51 import org.openstreetmap.josm.gui.layer.MapViewPaintable; 52 52 import org.openstreetmap.josm.tools.ImageProvider; 53 53 import org.openstreetmap.josm.tools.Pair; 54 import org.openstreetmap.josm.tools.ShortCut; 54 55 55 56 /** 56 57 * … … 73 74 74 75 public DrawAction(MapFrame mapFrame) { 75 76 super(tr("Draw"), "node/autonode", tr("Draw nodes"), 76 KeyEvent.VK_A, mapFrame, getCursor()); 77 ShortCut.registerShortCut("mapmode:draw", tr("Draw mode"), KeyEvent.VK_A, ShortCut.GROUP_EDIT), 78 mapFrame, getCursor()); 77 79 78 80 // Add extra shortcut N 79 81 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 80 KeyStroke.getKeyStroke(KeyEvent.VK_N, 0), tr("Draw"));82 ShortCut.registerShortCut("mapmode:draw2", tr("Draw mode (2)"), KeyEvent.VK_N, ShortCut.GROUP_EDIT).getKeyStroke(), tr("Draw")); 81 83 82 84 //putValue("help", "Action/AddNode/Autnode"); 83 85 selectedColor = Main.pref.getColor(marktr("selected"), Color.YELLOW); -
src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
35 35 import org.openstreetmap.josm.gui.SelectionManager; 36 36 import org.openstreetmap.josm.gui.SelectionManager.SelectionEnded; 37 37 import org.openstreetmap.josm.tools.ImageProvider; 38 import org.openstreetmap.josm.tools.ShortCut; 39 38 40 /** 39 41 * Move is an action that can move all kind of OsmPrimitives (except keys for now). 40 42 * … … 83 85 */ 84 86 public SelectAction(MapFrame mapFrame) { 85 87 super(tr("Select"), "move/move", tr("Select, move and rotate objects"), 86 KeyEvent.VK_S, mapFrame, 88 ShortCut.registerShortCut("mapmode:select", tr("Select mode"), KeyEvent.VK_S, ShortCut.GROUP_EDIT), 89 mapFrame, 87 90 getCursor("normal", "selection", Cursor.DEFAULT_CURSOR)); 88 91 putValue("help", "Action/Move/Move"); 89 92 selectionManager = new SelectionManager(this, false, mapFrame.mapView); -
src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
29 29 import org.openstreetmap.josm.gui.MapView; 30 30 import org.openstreetmap.josm.gui.layer.MapViewPaintable; 31 31 import org.openstreetmap.josm.tools.ImageProvider; 32 import org.openstreetmap.josm.tools.ShortCut; 33 32 34 /** 33 35 * Makes a rectangle from a line, or modifies a rectangle. 34 36 * … … 71 73 */ 72 74 public ExtrudeAction(MapFrame mapFrame) { 73 75 super(tr("Extrude"), "extrude/extrude", tr("Create areas"), 74 KeyEvent.VK_X, mapFrame, 76 ShortCut.registerShortCut("mapmode:extrude", tr("Extrude mode"), KeyEvent.VK_X, ShortCut.GROUP_EDIT), 77 mapFrame, 75 78 getCursor("normal", "selection", Cursor.DEFAULT_CURSOR)); 76 79 putValue("help", "Action/Extrude/Extrude"); 77 80 initialMoveDelay = Main.pref.getInteger("edit.initial-move-delay",200); -
src/org/openstreetmap/josm/actions/UndoAction.java
8 8 import java.awt.event.KeyEvent; 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.tools.ShortCut; 11 12 12 13 13 /** 14 14 * Undoes the last command. 15 15 * … … 21 21 * Construct the action with "Undo" as label. 22 22 */ 23 23 public UndoAction() { 24 super(tr("Undo"), "undo", tr("Undo the last action."), KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK, true); 24 super(tr("Undo"), "undo", tr("Undo the last action."), 25 ShortCut.registerShortCut("system:undo", tr("Edit: Undo"), KeyEvent.VK_Z, ShortCut.GROUP_MENU), true); 25 26 setEnabled(false); 26 27 } 27 28 -
src/org/openstreetmap/josm/actions/AlignInRectangleAction.java
19 19 import org.openstreetmap.josm.data.osm.Node; 20 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 21 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.tools.ShortCut; 22 23 23 24 /** 24 25 * Aligns all selected nodes within a rectangle. … … 39 40 public final class AlignInRectangleAction extends JosmAction { 40 41 41 42 public AlignInRectangleAction() { 42 super(tr("Align Nodes in Rectangle"), "alignrect", tr("Move the selected nodes into a rectangle."), KeyEvent.VK_Q, 0, true); 43 super(tr("Align Nodes in Rectangle"), "alignrect", tr("Move the selected nodes into a rectangle."), 44 ShortCut.registerShortCut("tools:alignrect", tr("Tool: Align in rectangle"), KeyEvent.VK_Q, ShortCut.GROUP_EDIT), true); 43 45 } 44 46 45 47 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/DownloadAction.java
16 16 import org.openstreetmap.josm.gui.download.DownloadDialog; 17 17 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask; 18 18 import org.openstreetmap.josm.tools.GBC; 19 import org.openstreetmap.josm.tools.ShortCut; 19 20 20 21 /** 21 22 * Action that opens a connection to the osm server and downloads map data. … … 30 31 public DownloadDialog dialog; 31 32 32 33 public DownloadAction() { 33 super(tr("Download from OSM ..."), "download", tr("Download map data from the OSM server."), KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, true); 34 super(tr("Download from OSM ..."), "download", tr("Download map data from the OSM server."), 35 ShortCut.registerShortCut("file:download", tr("File: Download"), KeyEvent.VK_D, ShortCut.GROUPS_ALT1+ShortCut.GROUP_HOTKEY), true); 34 36 } 35 37 36 38 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/DuplicateAction.java
12 12 import org.openstreetmap.josm.data.SelectionChangedListener; 13 13 import org.openstreetmap.josm.data.osm.DataSet; 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 import org.openstreetmap.josm.tools.ShortCut; 15 16 16 17 public final class DuplicateAction extends JosmAction implements SelectionChangedListener { 17 18 18 19 public DuplicateAction() { 19 20 super(tr("Duplicate"), "duplicate", 20 21 tr("Duplicate selection by copy and immediate paste."), 21 KeyEvent.VK_D, KeyEvent.CTRL_MASK, true);22 ShortCut.registerShortCut("system:duplicate", tr("Edit: Duplicate selection"), KeyEvent.VK_D, ShortCut.GROUP_MENU), true); 22 23 setEnabled(false); 23 24 DataSet.selListeners.add(this); 24 25 } -
src/org/openstreetmap/josm/actions/AboutAction.java
33 33 import org.openstreetmap.josm.tools.GBC; 34 34 import org.openstreetmap.josm.tools.ImageProvider; 35 35 import org.openstreetmap.josm.tools.UrlLabel; 36 import org.openstreetmap.josm.tools.ShortCut; 36 37 37 38 /** 38 39 * Nice about screen. I guess every application need one these days.. *sigh* … … 66 67 } 67 68 68 69 public AboutAction() { 69 super(tr("About"), "about", tr("Display the about screen."), KeyEvent.VK_F1, KeyEvent.SHIFT_DOWN_MASK, true);70 super(tr("About"), "about", tr("Display the about screen."), ShortCut.registerShortCut("system:about", tr("About..."), KeyEvent.VK_F1, ShortCut.GROUP_DIRECT), true); 70 71 } 71 72 72 73 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/PasteAction.java
23 23 import org.openstreetmap.josm.data.osm.RelationMember; 24 24 import org.openstreetmap.josm.data.osm.Way; 25 25 import org.openstreetmap.josm.data.coor.EastNorth; 26 import org.openstreetmap.josm.tools.ShortCut; 26 27 27 28 public final class PasteAction extends JosmAction { 28 29 29 30 public PasteAction() { 30 super(tr("Paste"), "paste", 31 tr("Paste contents of paste buffer."), 32 KeyEvent.VK_V, KeyEvent.CTRL_MASK, true); 31 super(tr("Paste"), "paste", tr("Paste contents of paste buffer."), 32 ShortCut.registerShortCut("system:paste", tr("Edit: Paste"), KeyEvent.VK_V, ShortCut.GROUP_MENU), true); 33 33 setEnabled(false); 34 34 } 35 35 -
src/org/openstreetmap/josm/actions/DiskAccessAction.java
9 9 import javax.swing.JOptionPane; 10 10 11 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm.tools.ShortCut; 12 13 13 14 /** 14 15 * Helper class for all actions that access the disk 15 16 */ 16 17 abstract public class DiskAccessAction extends JosmAction { 17 18 19 public DiskAccessAction(String name, String iconName, String tooltip, ShortCut shortCut) { 20 super(name, iconName, tooltip, shortCut, true); 21 } 22 23 @Deprecated 18 24 public DiskAccessAction(String name, String iconName, String tooltip, int shortCut, int modifiers) { 19 25 super(name, iconName, tooltip, shortCut, modifiers, true); 20 26 } -
src/org/openstreetmap/josm/actions/HistoryInfoAction.java
13 13 import org.openstreetmap.josm.data.osm.Way; 14 14 import org.openstreetmap.josm.data.osm.visitor.Visitor; 15 15 import org.openstreetmap.josm.tools.OpenBrowser; 16 import org.openstreetmap.josm.tools.ShortCut; 16 17 17 18 public class HistoryInfoAction extends JosmAction { 18 19 19 20 public HistoryInfoAction() { 20 super(tr("OSM History Information"), "about",tr("Display history information about OSM ways or nodes."), KeyEvent.VK_H, KeyEvent.SHIFT_DOWN_MASK, true); 21 super(tr("OSM History Information"), "about",tr("Display history information about OSM ways or nodes."), 22 ShortCut.registerShortCut("core:history", tr("Display history"), KeyEvent.VK_H, ShortCut.GROUP_HOTKEY), true); 21 23 } 22 24 23 25 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/AutoScaleAction.java
14 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 15 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 16 16 import org.openstreetmap.josm.gui.layer.Layer; 17 import org.openstreetmap.josm.tools.ShortCut; 17 18 18 19 /** 19 20 * Toggles the autoScale feature of the mapView … … 45 46 46 47 public AutoScaleAction(String mode) { 47 48 super(tr("Zoom to {0}", tr(mode)), "dialogs/autoscale/" + mode, tr("Zoom the view to {0}.", tr(mode)), 48 AutoScaleAction.getModeShortcut(mode), 0, true);49 ShortCut.registerShortCut("view:zoom"+mode, tr("View: Zoom to {0}", tr(mode)), getModeShortcut(mode), ShortCut.GROUP_EDIT), true); 49 50 String modeHelp = Character.toUpperCase(mode.charAt(0)) + mode.substring(1); 50 51 putValue("help", "Action/AutoScale/" + modeHelp); 51 52 this.mode = mode; -
src/org/openstreetmap/josm/actions/UploadAction.java
23 23 import org.openstreetmap.josm.io.OsmServerWriter; 24 24 import org.openstreetmap.josm.tools.GBC; 25 25 import org.xml.sax.SAXException; 26 import org.openstreetmap.josm.tools.ShortCut; 26 27 27 28 /** 28 29 * Action that opens a connection to the osm server and uploads all changes. … … 59 60 public final LinkedList<UploadHook> uploadHooks = new LinkedList<UploadHook>(); 60 61 61 62 public UploadAction() { 62 super(tr("Upload to OSM ..."), "upload", tr("Upload all changes to the OSM server."), KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, true); 63 super(tr("Upload to OSM ..."), "upload", tr("Upload all changes to the OSM server."), 64 ShortCut.registerShortCut("file:upload", tr("File: Upload"), KeyEvent.VK_U, ShortCut.GROUPS_ALT1+ShortCut.GROUP_HOTKEY), true); 63 65 64 66 /** 65 67 * Displays a screen where the actions that would be taken are displayed and -
src/org/openstreetmap/josm/actions/CreateCircleAction.java
19 19 import org.openstreetmap.josm.data.osm.Node; 20 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 21 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.tools.ShortCut; 22 23 23 24 /** 24 25 * Create a new circle from three selected nodes--or a way with 3 nodes. (Useful for roundabouts) 26 * 25 27 * Note: If a way is selected, it is changed. If nodes are selected a new way is created. 26 28 * So if you've got a way with 3 nodes it makes a difference between running this on the way or the nodes! 29 * 27 30 * BTW: Someone might want to implement projection corrections for this... 28 31 * 29 32 * @author Henry Loenwind, based on much copy&Paste from other Actions. … … 31 34 public final class CreateCircleAction extends JosmAction { 32 35 33 36 public CreateCircleAction() { 34 super(tr("Create Circle"), "createcircle", tr("Create a circle from three selected nodes."), KeyEvent.VK_O, KeyEvent.CTRL_MASK, true); 37 super(tr("Create Circle"), "createcircle", tr("Create a circle from three selected nodes."), 38 ShortCut.registerShortCut("tools:createcircle", tr("Tool: Create circle"), KeyEvent.VK_O, ShortCut.GROUP_EDIT), true); 35 39 } 36 40 37 41 private double calcang(double xc, double yc, double x, double y) { -
src/org/openstreetmap/josm/actions/MergeNodesAction.java
39 39 import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor; 40 40 import org.openstreetmap.josm.tools.GBC; 41 41 import org.openstreetmap.josm.tools.Pair; 42 import org.openstreetmap.josm.tools.ShortCut; 42 43 43 44 44 45 /** … … 51 52 public class MergeNodesAction extends JosmAction implements SelectionChangedListener { 52 53 53 54 public MergeNodesAction() { 54 super(tr("Merge Nodes"), "mergenodes", tr("Merge nodes into one."), KeyEvent.VK_M, 0, true); 55 super(tr("Merge Nodes"), "mergenodes", tr("Merge nodes into the oldest one."), 56 ShortCut.registerShortCut("tools:mergenodes", tr("Tool: Merge nodes"), KeyEvent.VK_M, ShortCut.GROUP_EDIT), true); 55 57 DataSet.selListeners.add(this); 56 58 } 57 59 -
src/org/openstreetmap/josm/actions/SaveActionBase.java
21 21 import org.openstreetmap.josm.gui.layer.GpxLayer; 22 22 import org.openstreetmap.josm.io.OsmWriter; 23 23 import org.openstreetmap.josm.io.GpxWriter; 24 import org.openstreetmap.josm.tools.ShortCut; 24 25 25 26 public abstract class SaveActionBase extends DiskAccessAction { 26 27 27 28 private Layer layer; 28 29 30 public SaveActionBase(String name, String iconName, String tooltip, ShortCut shortCut, Layer layer) { 31 super(name, iconName, tooltip, shortCut); 32 this.layer = layer; 33 } 34 35 @Deprecated 29 36 public SaveActionBase(String name, String iconName, String tooltip, int shortCut, int modifiers, Layer layer) { 30 37 super(name, iconName, tooltip, shortCut, modifiers); 31 38 this.layer = layer; -
src/org/openstreetmap/josm/actions/RedoAction.java
8 8 import java.awt.event.KeyEvent; 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.tools.ShortCut; 11 12 12 13 13 /** 14 14 * Redoes the last command. 15 15 * … … 21 21 * Construct the action with "Redo" as label. 22 22 */ 23 23 public RedoAction() { 24 super(tr("Redo"), "redo", tr("Redo the last undone action."), KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK, true); 24 super(tr("Redo"), "redo", tr("Redo the last undone action."), 25 ShortCut.registerShortCut("system:redo", tr("Edit: Redo"), KeyEvent.VK_Y, ShortCut.GROUP_MENU), true); 25 26 setEnabled(false); 26 27 } 27 28 -
src/org/openstreetmap/josm/actions/NewAction.java
10 10 import org.openstreetmap.josm.Main; 11 11 import org.openstreetmap.josm.data.osm.DataSet; 12 12 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 13 import org.openstreetmap.josm.tools.ShortCut; 13 14 14 15 public class NewAction extends JosmAction { 15 16 16 17 public NewAction() { 17 super(tr("New"), "new", tr("Create a new map."), KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK, true); 18 super(tr("New"), "new", tr("Create a new map."), 19 ShortCut.registerShortCut("system:new", tr("File: New"), KeyEvent.VK_N, ShortCut.GROUP_MENU), true); 18 20 } 19 21 20 22 public void actionPerformed(ActionEvent e) { -
src/org/openstreetmap/josm/actions/PasteTagsAction.java
19 19 import org.openstreetmap.josm.data.SelectionChangedListener; 20 20 import org.openstreetmap.josm.data.osm.DataSet; 21 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 import org.openstreetmap.josm.tools.ShortCut; 22 23 23 24 public final class PasteTagsAction extends JosmAction implements SelectionChangedListener { 24 25 25 26 public PasteTagsAction(JosmAction copyAction) { 26 27 super(tr("Paste Tags"), "pastetags", 27 28 tr("Apply tags of contents of paste buffer to all selected items."), 28 KeyEvent.VK_V, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK, true);29 ShortCut.registerShortCut("system:pastestyle", tr("Edit: Paste tags"), KeyEvent.VK_V, ShortCut.GROUP_MENU), true); 29 30 DataSet.selListeners.add(this); 30 31 copyAction.addListener(this); 31 32 setEnabled(false); -
src/org/openstreetmap/josm/actions/CombineWayAction.java
39 39 import org.openstreetmap.josm.data.osm.Way; 40 40 import org.openstreetmap.josm.tools.GBC; 41 41 import org.openstreetmap.josm.tools.Pair; 42 import org.openstreetmap.josm.tools.ShortCut; 42 43 43 44 /** 44 45 * Combines multiple ways into one. … … 48 49 public class CombineWayAction extends JosmAction implements SelectionChangedListener { 49 50 50 51 public CombineWayAction() { 51 super(tr("Combine Way"), "combineway", tr("Combine several ways into one."), KeyEvent.VK_C, 0, true); 52 super(tr("Combine Way"), "combineway", tr("Combine several ways into one."), 53 ShortCut.registerShortCut("tools:combineway", tr("Tool: Combine ways"), KeyEvent.VK_C, ShortCut.GROUP_EDIT), true); 52 54 DataSet.selListeners.add(this); 53 55 } 54 56 -
src/org/openstreetmap/josm/actions/SaveAction.java
10 10 import org.openstreetmap.josm.gui.layer.Layer; 11 11 import org.openstreetmap.josm.gui.layer.GpxLayer; 12 12 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 13 import org.openstreetmap.josm.tools.ShortCut; 13 14 14 15 /** 15 16 * Export the data as an OSM xml file. … … 23 24 * @param layer Save this layer. 24 25 */ 25 26 public SaveAction(Layer layer) { 26 super(tr("Save"), "save", tr("Save the current data."), KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK, layer); 27 super(tr("Save"), "save", tr("Save the current data."), 28 ShortCut.registerShortCut("system:save", tr("File: Save"), KeyEvent.VK_S, ShortCut.GROUP_MENU), layer); 27 29 } 28 30 29 31 @Override public File getFile(Layer layer) { -
src/org/openstreetmap/josm/tools/OpenBrowser.java
11 11 12 12 /** 13 13 * Helper to open platform web browser on different platforms 14 * 15 * This now delegates the real work to a platform specific class. 16 * 14 17 * @author Imi 15 18 */ 16 19 public class OpenBrowser { … … 29 32 } 30 33 } 31 34 32 String os = System.getProperty("os.name");33 if (os == null)34 return "unknown operating system";35 35 try { 36 if (os != null && os.startsWith("Windows")) 37 windows(url); 38 else if (os.equals("Linux") || os.equals("Solaris") || os.equals("SunOS") || os.equals("AIX") || os.equals("FreeBSD")) 39 linux(url); 40 else if (os.equals("Mac OS") || os.equals("Mac OS X")) 41 mac(url); 42 else 43 return "unknown operating system"; 36 Main.platform.openUrl(url); 44 37 } catch (IOException e) { 45 38 return e.getMessage(); 46 39 } 47 40 return null; 48 41 } 49 42 50 private static void windows(String url) throws IOException {51 Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);52 43 } 53 54 private static void linux(String url) {55 String[] programs = {"gnome-open", "kfmclient openURL", "firefox"};56 for (String program : programs) {57 try {58 Runtime.getRuntime().exec(program+" "+url);59 return;60 } catch (IOException e) {61 }62 }63 }64 65 private static void mac(String url) throws IOException {66 Runtime.getRuntime().exec("open " + url);67 }68 } -
src/org/openstreetmap/josm/tools/ShortCutLabel.java
5 5 6 6 import java.awt.event.KeyEvent; 7 7 8 8 @Deprecated 9 9 public class ShortCutLabel { 10 @Deprecated 10 11 public static String name(int shortCut, int modifiers) { 11 12 if (shortCut == 0 && modifiers == 0) 12 13 return ""; -
src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
42 42 import org.openstreetmap.josm.gui.NavigatableComponent; 43 43 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 44 44 import org.openstreetmap.josm.gui.SideButton; 45 import org.openstreetmap.josm.tools.ShortCut; 45 46 46 47 public final class ConflictDialog extends ToggleDialog { 47 48 … … 50 51 private final JList displaylist = new JList(model); 51 52 52 53 public ConflictDialog() { 53 super(tr("Conflict"), "conflict", tr("Merging conflicts."), KeyEvent.VK_C, 100); 54 super(tr("Conflict"), "conflict", tr("Merging conflicts."), 55 ShortCut.registerShortCut("subwindow:conflict", tr("Toggle conflict window"), KeyEvent.VK_C, ShortCut.GROUP_LAYER), 100); 54 56 displaylist.setCellRenderer(new OsmPrimitivRenderer()); 55 57 displaylist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 56 58 displaylist.addMouseListener(new MouseAdapter(){ -
src/org/openstreetmap/josm/gui/dialogs/HistoryDialog.java
37 37 import org.openstreetmap.josm.gui.SideButton; 38 38 import org.openstreetmap.josm.tools.GBC; 39 39 import org.openstreetmap.josm.tools.ImageProvider; 40 import org.openstreetmap.josm.tools.ShortCut; 40 41 41 42 /** 42 43 * History dialog works like follows: … … 86 87 private JLabel notLoaded = new JLabel("<html><i>"+tr("Click Reload to refresh list")+"</i></html>"); 87 88 88 89 public HistoryDialog() { 89 super(tr("History"), "history", tr("Display the history of all selected items."), KeyEvent.VK_H, 150); 90 super(tr("History"), "history", tr("Display the history of all selected items."), 91 ShortCut.registerShortCut("subwindow:history", tr("Toggle history window"), KeyEvent.VK_H, ShortCut.GROUP_LAYER), 150); 90 92 historyPane.setVisible(false); 91 93 notLoaded.setVisible(true); 92 94 notLoaded.setHorizontalAlignment(JLabel.CENTER); -
src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
40 40 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 41 41 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 42 42 import org.openstreetmap.josm.gui.SideButton; 43 import org.openstreetmap.josm.tools.ShortCut; 43 44 44 45 /** 45 46 * A small tool dialog for displaying the current selection. The selection manager … … 75 76 private Collection<? extends OsmPrimitive> historyIgnoreSelection = null; 76 77 77 78 public SelectionListDialog() { 78 super(tr("Current Selection"), "selectionlist", tr("Open a selection list window."), KeyEvent.VK_T, 150); 79 super(tr("Current Selection"), "selectionlist", tr("Open a selection list window."), 80 ShortCut.registerShortCut("subwindow:selection", tr("Toggle selection window"), KeyEvent.VK_T, ShortCut.GROUP_LAYER), 150); 79 81 80 82 selectionHistory = new LinkedList<Collection<? extends OsmPrimitive>>(); 81 83 popupMenu = new JPopupMenu(); -
src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
26 26 import org.openstreetmap.josm.actions.HelpAction.Helpful; 27 27 import org.openstreetmap.josm.tools.GBC; 28 28 import org.openstreetmap.josm.tools.ImageProvider; 29 import org.openstreetmap.josm.tools.ShortCut; 29 30 30 31 /** 31 32 * This class is a toggle dialog that can be turned on and off. It is attached … … 39 40 public final String prefname; 40 41 public AbstractButton button; 41 42 42 private ToggleDialogAction(String name, String iconName, String tooltip, int shortCut, int modifier, String prefname) {43 super(name, iconName, tooltip, shortCut, modifier,false);43 private ToggleDialogAction(String name, String iconName, String tooltip, ShortCut shortCut, String prefname) { 44 super(name, iconName, tooltip, shortCut, false); 44 45 this.prefname = prefname; 45 46 } 46 47 … … 61 62 public JPanel parent; 62 63 private final JPanel titleBar = new JPanel(new GridBagLayout()); 63 64 65 @Deprecated 64 66 public ToggleDialog(final String name, String iconName, String tooltip, int shortCut, int preferredHeight) { 65 67 super(new BorderLayout()); 66 68 this.prefName = iconName; 69 ToggleDialogInit(name, iconName, tooltip, ShortCut.registerShortCut("auto:"+name, tooltip, shortCut, ShortCut.GROUP_LAYER), preferredHeight); 70 } 71 72 public ToggleDialog(final String name, String iconName, String tooltip, ShortCut shortCut, int preferredHeight) { 73 super(new BorderLayout()); 74 this.prefName = iconName; 75 ToggleDialogInit(name, iconName, tooltip, shortCut, preferredHeight); 76 } 77 78 private void ToggleDialogInit(final String name, String iconName, String tooltip, ShortCut shortCut, int preferredHeight) { 67 79 setPreferredSize(new Dimension(330,preferredHeight)); 68 action = new ToggleDialogAction(name, "dialogs/"+iconName, tooltip, shortCut, KeyEvent.ALT_MASK,iconName);80 action = new ToggleDialogAction(name, "dialogs/"+iconName, tooltip, shortCut, iconName); 69 81 String helpId = "Dialog/"+getClass().getName().substring(getClass().getName().lastIndexOf('.')+1); 70 82 action.putValue("help", helpId.substring(0, helpId.length()-6)); 71 83 setLayout(new BorderLayout()); -
src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
19 19 import org.openstreetmap.josm.command.Command; 20 20 import org.openstreetmap.josm.gui.MapFrame; 21 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; 22 import org.openstreetmap.josm.tools.ShortCut; 22 23 23 24 public class CommandStackDialog extends ToggleDialog implements CommandQueueListener { 24 25 … … 26 27 private JTree tree = new JTree(treeModel); 27 28 28 29 public CommandStackDialog(final MapFrame mapFrame) { 29 super(tr("Command Stack"), "commandstack", tr("Open a list of all commands (undo buffer)."), KeyEvent.VK_O, 100); 30 super(tr("Command Stack"), "commandstack", tr("Open a list of all commands (undo buffer)."), 31 ShortCut.registerShortCut("subwindow:commandstack", tr("Toggle command stack"), KeyEvent.VK_O, ShortCut.GROUP_LAYER), 100); 30 32 Main.main.undoRedo.listenerCommands.add(this); 31 33 32 34 tree.setRootVisible(false); -
src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
39 39 import org.openstreetmap.josm.tools.DontShowAgainInfo; 40 40 import org.openstreetmap.josm.tools.ImageProvider; 41 41 import org.openstreetmap.josm.tools.ImageProvider.OverlayPosition; 42 import org.openstreetmap.josm.tools.ShortCut; 42 43 43 44 /** 44 45 * A component that manages the list of all layers and react to selection changes … … 157 158 * Create an layerlist and attach it to the given mapView. 158 159 */ 159 160 public LayerListDialog(MapFrame mapFrame) { 160 super(tr("Layers"), "layerlist", tr("Open a list of all loaded layers."), KeyEvent.VK_L, 100); 161 super(tr("Layers"), "layerlist", tr("Open a list of all loaded layers."), 162 ShortCut.registerShortCut("subwindow:layers", tr("Toggle layer window"), KeyEvent.VK_L, ShortCut.GROUP_LAYER), 100); 161 163 instance = new JList(model); 162 164 listScrollPane = new JScrollPane(instance); 163 165 add(listScrollPane, BorderLayout.CENTER); -
src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
31 31 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 32 32 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener; 33 33 import org.openstreetmap.josm.tools.GBC; 34 import org.openstreetmap.josm.tools.ShortCut; 34 35 35 36 /** 36 37 * A dialog showing all known relations, with buttons to add, edit, and … … 54 55 private JList displaylist = new JList(list); 55 56 56 57 public RelationListDialog() { 57 super(tr("Relations"), "relationlist", tr("Open a list of all relations."), KeyEvent.VK_R, 150); 58 super(tr("Relations"), "relationlist", tr("Open a list of all relations."), 59 ShortCut.registerShortCut("subwindow:relations", tr("Toggle relations window"), KeyEvent.VK_R, ShortCut.GROUP_LAYER), 150); 58 60 displaylist.setCellRenderer(new OsmPrimitivRenderer()); 59 61 displaylist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 60 62 displaylist.addMouseListener(new MouseAdapter(){ -
src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
20 20 import org.openstreetmap.josm.data.osm.DataSet; 21 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 22 import org.openstreetmap.josm.data.osm.User; 23 import org.openstreetmap.josm.tools.ShortCut; 23 24 24 25 /** 25 26 * Displays a dialog with all users who have last edited something in the … … 46 47 private static User anonymousUser = User.get("(anonymous users)"); 47 48 48 49 public UserListDialog() { 49 super(tr("Authors"), "userlist", tr("Open a list of people working on the selected objects."), KeyEvent.VK_A, 150); 50 super(tr("Authors"), "userlist", tr("Open a list of people working on the selected objects."), 51 ShortCut.registerShortCut("subwindow:authors", tr("Toggle authors window"), KeyEvent.VK_A, ShortCut.GROUP_LAYER), 150); 50 52 51 53 data.setColumnIdentifiers(new String[]{tr("Author"),tr("# Objects"),"%"}); 52 54 userTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
63 63 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 64 64 import org.openstreetmap.josm.tools.AutoCompleteComboBox; 65 65 import org.openstreetmap.josm.tools.GBC; 66 import org.openstreetmap.josm.tools.ShortCut; 66 67 67 68 /** 68 69 * This dialog displays the properties of the current selected primitives. … … 416 417 * Create a new PropertiesDialog 417 418 */ 418 419 public PropertiesDialog(MapFrame mapFrame) { 419 super(tr("Properties/Memberships"), "propertiesdialog", tr("Properties for selected objects."), KeyEvent.VK_P, 150); 420 super(tr("Properties/Memberships"), "propertiesdialog", tr("Properties for selected objects."), 421 ShortCut.registerShortCut("subwindow:properies", tr("Toggle properties window"), KeyEvent.VK_P, ShortCut.GROUP_LAYER), 150); 420 422 421 423 // --------------------------------------- 422 424 // This drop-down is really deprecated but we offer people a chance to -
src/org/openstreetmap/josm/gui/MainApplication.java
30 30 */ 31 31 public class MainApplication extends Main { 32 32 /** 33 * Allow subclassing (see JOSM.java) 34 */ 35 public MainApplication() {} 36 37 /** 33 38 * Construct an main frame, ready sized and operating. Does not 34 39 * display the frame. 35 40 */ … … 65 70 66 71 Thread.setDefaultUncaughtExceptionHandler(new BugReportExceptionHandler()); 67 72 73 // initialize the plaform hook, and 74 Main.determinePlatformHook(); 75 // call the really early hook before we anything else 76 Main.platform.preStartupHook(); 77 68 78 // construct argument table 69 79 List<String> argList = Arrays.asList(argArray); 70 80 final Map<String, Collection<String>> args = new HashMap<String, Collection<String>>(); … … 143 153 Main.loadPlugins(true, language); 144 154 145 155 if (argList.contains("--help") || argList.contains("-?") || argList.contains("-h")) { 156 // TODO: put in a platformHook for system that have no console by default 146 157 System.out.println(tr("Java OpenStreetMap Editor")+"\n\n"+ 147 158 tr("usage")+":\n"+ 148 159 "\tjava -jar josm.jar <option> <option> <option>...\n\n"+ … … 191 202 } 192 203 }); 193 204 } 205 194 206 } -
src/org/openstreetmap/josm/gui/MapView.java
25 25 26 26 import org.openstreetmap.josm.Main; 27 27 import org.openstreetmap.josm.actions.AutoScaleAction; 28 import org.openstreetmap.josm.actions.JosmAction; 28 29 import org.openstreetmap.josm.actions.MoveAction; 29 30 import org.openstreetmap.josm.data.Bounds; 30 31 import org.openstreetmap.josm.data.SelectionChangedListener; … … 106 107 new AutoScaleAction("data").actionPerformed(null); 107 108 108 109 new MapMover(MapView.this, Main.contentPane); 109 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, java.awt.event.InputEvent.SHIFT_MASK), "UP"); 110 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, java.awt.event.InputEvent.SHIFT_MASK), "DOWN"); 111 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, java.awt.event.InputEvent.SHIFT_MASK), "LEFT"); 112 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, java.awt.event.InputEvent.SHIFT_MASK), "RIGHT"); 110 JosmAction mv; 111 mv = new MoveAction(MoveAction.Direction.UP); 112 if (mv.getShortCut() != null) { 113 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(mv.getShortCut().getKeyStroke(), "UP"); 114 Main.contentPane.getActionMap().put("UP", mv); 115 } 116 mv = new MoveAction(MoveAction.Direction.DOWN); 117 if (mv.getShortCut() != null) { 118 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(mv.getShortCut().getKeyStroke(), "DOWN"); 119 Main.contentPane.getActionMap().put("DOWN", mv); 120 } 121 mv = new MoveAction(MoveAction.Direction.LEFT); 122 if (mv.getShortCut() != null) { 123 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(mv.getShortCut().getKeyStroke(), "LEFT"); 124 Main.contentPane.getActionMap().put("LEFT", mv); 125 } 126 mv = new MoveAction(MoveAction.Direction.RIGHT); 127 if (mv.getShortCut() != null) { 128 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(mv.getShortCut().getKeyStroke(), "RIGHT"); 129 Main.contentPane.getActionMap().put("RIGHT", mv); 130 } 113 131 114 Main.contentPane.getActionMap().put("UP", new MoveAction(MoveAction.Direction.UP));115 Main.contentPane.getActionMap().put("DOWN", new MoveAction(MoveAction.Direction.DOWN));116 Main.contentPane.getActionMap().put("LEFT", new MoveAction(MoveAction.Direction.LEFT));117 Main.contentPane.getActionMap().put("RIGHT", new MoveAction(MoveAction.Direction.RIGHT));118 119 120 132 MapSlider zoomSlider = new MapSlider(MapView.this); 121 133 add(zoomSlider); 122 134 zoomSlider.setBounds(3, 0, 114, 30); -
src/org/openstreetmap/josm/gui/MainMenu.java
12 12 import javax.swing.JMenuBar; 13 13 import javax.swing.JMenuItem; 14 14 import javax.swing.KeyStroke; 15 import java.awt.event.KeyEvent; 15 16 16 17 import org.openstreetmap.josm.Main; 17 18 import org.openstreetmap.josm.actions.AboutAction; … … 58 59 import org.openstreetmap.josm.actions.audio.AudioSlowerAction; 59 60 import org.openstreetmap.josm.actions.search.SearchAction; 60 61 import org.openstreetmap.josm.data.DataSetChecker; 62 import org.openstreetmap.josm.tools.ShortCut; 61 63 62 64 /** 63 65 * This is the JOSM main menu bar. It is overwritten to initialize itself and provide … … 129 131 public final JMenu presetsMenu = new JMenu(tr("Presets")); 130 132 public final JMenu helpMenu = new JMenu(tr("Help")); 131 133 134 /** 135 * Add a JosmAction to a menu. 136 * 137 * This method handles all the shortcut handling. 138 * It also makes sure that actions that are handled by the 139 * OS are not duplicated on the menu. 140 */ 141 public static void add(JMenu menu, JosmAction action) { 142 if (!action.getShortCut().getAutomatic()) { 143 JMenuItem menuitem = menu.add(action); 144 KeyStroke ks = action.getShortCut().getKeyStroke(); 145 if (ks != null) { 146 menuitem.setAccelerator(ks); 147 } 148 } 149 } 132 150 151 /** 152 * Add a menu to the main menu. 153 * 154 * This method handles all the shortcut handling. 155 */ 156 public void add(JMenu menu, int mnemonicKey, String shortName) { 157 ShortCut.registerShortCut("menu:"+shortName, shortName+" menu", mnemonicKey, ShortCut.GROUP_MNEMONIC).setMnemonic(menu); 158 add(menu); 159 } 160 133 161 public MainMenu() { 134 162 JMenuItem current; 135 163 136 fileMenu.setMnemonic('F'); 137 current = fileMenu.add(newAction); 138 current.setAccelerator(newAction.shortCut); 139 current = fileMenu.add(open); 140 current.setAccelerator(open.shortCut); 164 add(fileMenu, newAction); 165 add(fileMenu, open); 141 166 fileMenu.addSeparator(); 142 current = fileMenu.add(save); 143 current.setAccelerator(save.shortCut); 144 current = fileMenu.add(saveAs); 145 current.setAccelerator(saveAs.shortCut); 146 current = fileMenu.add(gpxExport); 147 current.setAccelerator(gpxExport.shortCut); 167 add(fileMenu, save); 168 add(fileMenu, saveAs); 169 add(fileMenu, gpxExport); 148 170 fileMenu.addSeparator(); 149 current = fileMenu.add(download); 150 current.setAccelerator(download.shortCut); 151 current = fileMenu.add(upload); 152 current.setAccelerator(upload.shortCut); 153 fileMenu.addSeparator(); 154 current = fileMenu.add(exit); 155 current.setAccelerator(exit.shortCut); 156 add(fileMenu); 171 add(fileMenu, download); 172 add(fileMenu, upload); 173 add(fileMenu, exit); 174 add(fileMenu, KeyEvent.VK_F, "file"); 157 175 158 editMenu.setMnemonic('E'); 159 current = editMenu.add(undo); 160 current.setAccelerator(undo.shortCut); 161 current = editMenu.add(redo); 162 current.setAccelerator(redo.shortCut); 176 add(editMenu, undo); 177 add(editMenu, redo); 163 178 editMenu.addSeparator(); 164 current = editMenu.add(copy); 165 current.setAccelerator(copy.shortCut); 166 current = editMenu.add(delete); 167 current.setAccelerator(delete.shortCut); 168 current = editMenu.add(paste); 169 current.setAccelerator(paste.shortCut); 170 current = editMenu.add(pasteTags); 171 current.setAccelerator(pasteTags.shortCut); 172 current = editMenu.add(duplicate); 173 current.setAccelerator(duplicate.shortCut); 179 add(editMenu, copy); 180 add(editMenu, delete); 181 add(editMenu, paste); 182 add(editMenu, pasteTags); 183 add(editMenu, duplicate); 174 184 editMenu.addSeparator(); 175 current = editMenu.add(selectAll); 176 current.setAccelerator(selectAll.shortCut); 177 current = editMenu.add(unselectAll); 178 current.setAccelerator(unselectAll.shortCut); 185 add(editMenu, selectAll); 186 add(editMenu, unselectAll); 179 187 editMenu.addSeparator(); 180 current = editMenu.add(search); 181 current.setAccelerator(search.shortCut); 188 add(editMenu, search); 182 189 editMenu.addSeparator(); 183 current = editMenu.add(preferences); 184 current.setAccelerator(preferences.shortCut); 185 add(editMenu); 190 add(editMenu, preferences); 191 add(editMenu, KeyEvent.VK_E, "edit"); 186 192 187 viewMenu.setMnemonic('V');188 193 for (String mode : AutoScaleAction.modes) { 189 194 JosmAction autoScaleAction = new AutoScaleAction(mode); 190 current = viewMenu.add(autoScaleAction); 191 current.setAccelerator(autoScaleAction.shortCut); 195 add(viewMenu, autoScaleAction); 192 196 } 193 197 viewMenu.addSeparator(); 194 JosmAction a = new ZoomOutAction(); 195 viewMenu.add(a).setAccelerator(a.shortCut); 196 a = new ZoomInAction(); 197 viewMenu.add(a).setAccelerator(a.shortCut); 198 198 add(viewMenu, new ZoomOutAction()); 199 add(viewMenu, new ZoomInAction()); 199 200 viewMenu.addSeparator(); 200 201 201 // TODO move code to an "action" like the others? 202 202 final JCheckBoxMenuItem wireframe = new JCheckBoxMenuItem(tr("Wireframe view")); 203 203 wireframe.setSelected(Main.pref.getBoolean("draw.wireframe", false)); 204 wireframe.setAccelerator(KeyStroke.getKeyStroke("ctrl W"));204 wireframe.setAccelerator(ShortCut.registerShortCut("menu:view:wireframe", "Toggle Wireframe view", KeyEvent.VK_W, ShortCut.GROUP_MENU).getKeyStroke()); 205 205 wireframe.addActionListener(new ActionListener() { 206 206 public void actionPerformed(ActionEvent ev) { 207 207 Main.pref.put("draw.wireframe", wireframe.isSelected()); … … 211 211 } 212 212 }); 213 213 viewMenu.add(wireframe); 214 add(viewMenu, KeyEvent.VK_V, "view"); 214 215 215 add(viewMenu); 216 217 toolsMenu.setMnemonic('T'); 218 current = toolsMenu.add(splitWay); 219 current.setAccelerator(splitWay.shortCut); 220 current = toolsMenu.add(combineWay); 221 current.setAccelerator(combineWay.shortCut); 216 add(toolsMenu, splitWay); 217 add(toolsMenu, combineWay); 222 218 toolsMenu.addSeparator(); 223 current = toolsMenu.add(reverseWay); 224 current.setAccelerator(reverseWay.shortCut); 219 add(toolsMenu, reverseWay); 225 220 toolsMenu.addSeparator(); 226 current = toolsMenu.add(alignInCircle); 227 current.setAccelerator(alignInCircle.shortCut); 228 current = toolsMenu.add(alignInLine); 229 current.setAccelerator(alignInLine.shortCut); 230 current = toolsMenu.add(alignInRect); 231 current.setAccelerator(alignInRect.shortCut); 221 add(toolsMenu, alignInCircle); 222 add(toolsMenu, alignInLine); 223 add(toolsMenu, alignInRect); 232 224 toolsMenu.addSeparator(); 233 current = toolsMenu.add(createCircle); 234 current.setAccelerator(createCircle.shortCut); 225 add(toolsMenu, createCircle); 235 226 toolsMenu.addSeparator(); 236 current = toolsMenu.add(mergeNodes); 237 current.setAccelerator(mergeNodes.shortCut); 238 current = toolsMenu.add(joinNodeWay); 239 current.setAccelerator(joinNodeWay.shortCut); 240 current = toolsMenu.add(unglueNodes); 241 current.setAccelerator(unglueNodes.shortCut); 242 add(toolsMenu); 227 add(toolsMenu, mergeNodes); 228 add(toolsMenu, joinNodeWay); 229 add(toolsMenu, unglueNodes); 230 add(toolsMenu, KeyEvent.VK_T, "tools"); 243 231 244 232 if (! Main.pref.getBoolean("audio.menuinvisible")) { 245 audioMenu.setMnemonic('A'); 246 current = audioMenu.add(audioPlayPause); 247 current.setAccelerator(audioPlayPause.shortCut); 248 current = audioMenu.add(audioNext); 249 current.setAccelerator(audioNext.shortCut); 250 current = audioMenu.add(audioPrev); 251 current.setAccelerator(audioPrev.shortCut); 252 current = audioMenu.add(audioFwd); 253 current.setAccelerator(audioFwd.shortCut); 254 current = audioMenu.add(audioBack); 255 current.setAccelerator(audioBack.shortCut); 256 current = audioMenu.add(audioSlower); 257 current.setAccelerator(audioSlower.shortCut); 258 current = audioMenu.add(audioFaster); 259 current.setAccelerator(audioFaster.shortCut); 260 add(audioMenu); 233 add(audioMenu, audioPlayPause); 234 add(audioMenu, audioNext); 235 add(audioMenu, audioPrev); 236 add(audioMenu, audioFwd); 237 add(audioMenu, audioBack); 238 add(audioMenu, audioSlower); 239 add(audioMenu, audioFaster); 240 add(audioMenu, KeyEvent.VK_A, "audio"); 261 241 } 262 242 263 add(presetsMenu); 264 presetsMenu.setMnemonic('P'); 243 add(presetsMenu, KeyEvent.VK_P, "presets"); 265 244 266 helpMenu.setMnemonic('H');267 245 JMenuItem check = new JMenuItem("DEBUG: Check Dataset"); 268 246 check.addActionListener(new ActionListener(){ 269 247 public void actionPerformed(ActionEvent e) { 270 248 DataSetChecker.check(); 271 249 } 272 250 }); 273 current = helpMenu.add(check); 274 current = helpMenu.add(help); 275 //current.setAccelerator(help.shortCut); 276 current = helpMenu.add(about); 277 current.setAccelerator(about.shortCut); 278 current = helpMenu.add(historyinfo); 279 current.setAccelerator(historyinfo.shortCut); 280 add(helpMenu); 251 helpMenu.add(check); 252 current = helpMenu.add(help); // why is help not a JosmAction? 253 current.setAccelerator(ShortCut.registerShortCut("system:help", tr("Help"), KeyEvent.VK_F1, ShortCut.GROUP_DIRECT).getKeyStroke()); 254 add(helpMenu, about); 255 add(helpMenu, historyinfo); 256 add(helpMenu, KeyEvent.VK_H, "help"); 281 257 } 282 258 } -
src/org/openstreetmap/josm/gui/preferences/LafPreference.java
4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 6 import java.awt.Component; 7 import java.lang.reflect.*; 7 8 8 9 import javax.swing.DefaultListCellRenderer; 9 10 import javax.swing.JComboBox; … … 26 27 public void addGui(PreferenceDialog gui) { 27 28 lafCombo = new JComboBox(UIManager.getInstalledLookAndFeels()); 28 29 30 // let's try to load additional LookAndFeels and put them into the list 31 try { 32 Class Cquaqua = Class.forName("ch.randelshofer.quaqua.QuaquaLookAndFeel"); 33 Object Oquaqua = Cquaqua.getConstructor((Class[])null).newInstance((Object[])null); 34 // no exception? Then Go! 35 lafCombo.addItem( 36 new UIManager.LookAndFeelInfo(((javax.swing.LookAndFeel)Oquaqua).getName(), "ch.randelshofer.quaqua.QuaquaLookAndFeel") 37 ); 38 } catch (Exception ex) { 39 // just ignore, Quaqua may not even be installed... 40 //System.out.println("Failed to load Quaqua: " + ex); 41 } 42 29 43 String laf = Main.pref.get("laf"); 30 44 for (int i = 0; i < lafCombo.getItemCount(); ++i) { 31 45 if (((LookAndFeelInfo)lafCombo.getItemAt(i)).getClassName().equals(laf)) { -
src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
110 110 settings.add(new PluginPreference()); 111 111 settings.add(Main.toolbar); 112 112 settings.add(new AudioPreference()); 113 settings.add(new ShortcutPreference()); 113 114 114 115 for (PluginProxy plugin : Main.plugins) { 115 116 PreferenceSetting p = plugin.getPreferenceSetting(); -
src/org/openstreetmap/josm/gui/MapMover.java
15 15 import javax.swing.JComponent; 16 16 import javax.swing.JPanel; 17 17 import javax.swing.KeyStroke; 18 import org.openstreetmap.josm.tools.ShortCut; 19 import static org.openstreetmap.josm.tools.I18n.tr; 18 20 19 21 import org.openstreetmap.josm.data.coor.EastNorth; 20 22 … … 78 80 nc.addMouseMotionListener(this); 79 81 nc.addMouseWheelListener(this); 80 82 81 String[] n = {",",".","up","right","down","left"}; 82 int[] k = {KeyEvent.VK_COMMA, KeyEvent.VK_PERIOD, KeyEvent.VK_UP, KeyEvent.VK_RIGHT, KeyEvent.VK_DOWN, KeyEvent.VK_LEFT}; 83 if (contentPane != null) { 84 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 85 ShortCut.registerShortCut("system:movefocusright", tr("Map: Move right"), KeyEvent.VK_RIGHT, ShortCut.GROUP_HOTKEY).getKeyStroke(), 86 "MapMover.Zoomer.right"); 87 contentPane.getActionMap().put("MapMover.Zoomer.right", new ZoomerAction("right")); 83 88 84 if (contentPane != null) { 85 for (int i = 0; i < n.length; ++i) { 86 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(k[i], KeyEvent.CTRL_DOWN_MASK), "MapMover.Zoomer."+n[i]); 87 contentPane.getActionMap().put("MapMover.Zoomer."+n[i], new ZoomerAction(n[i])); 89 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 90 ShortCut.registerShortCut("system:movefocusleft", tr("Map: Move left"), KeyEvent.VK_LEFT, ShortCut.GROUP_HOTKEY).getKeyStroke(), 91 "MapMover.Zoomer.left"); 92 contentPane.getActionMap().put("MapMover.Zoomer.left", new ZoomerAction("left")); 93 94 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 95 ShortCut.registerShortCut("system:movefocusup", tr("Map: Move up"), KeyEvent.VK_UP, ShortCut.GROUP_HOTKEY).getKeyStroke(), 96 "MapMover.Zoomer.up"); 97 contentPane.getActionMap().put("MapMover.Zoomer.up", new ZoomerAction("up")); 98 99 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 100 ShortCut.registerShortCut("system:movefocusdown", tr("Map: Move down"), KeyEvent.VK_DOWN, ShortCut.GROUP_HOTKEY).getKeyStroke(), 101 "MapMover.Zoomer.down"); 102 contentPane.getActionMap().put("MapMover.Zoomer.down", new ZoomerAction("down")); 103 104 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 105 ShortCut.registerShortCut("view:zoominalternate", tr("Map: Zoom in"), KeyEvent.VK_COMMA, ShortCut.GROUP_HOTKEY).getKeyStroke(), 106 "MapMover.Zoomer.in"); 107 contentPane.getActionMap().put("MapMover.Zoomer.in", new ZoomerAction(",")); 108 109 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 110 ShortCut.registerShortCut("view:zoomoutalternate", tr("Map: Zoom out"), KeyEvent.VK_PERIOD, ShortCut.GROUP_HOTKEY).getKeyStroke(), 111 "MapMover.Zoomer.out"); 112 contentPane.getActionMap().put("MapMover.Zoomer.out", new ZoomerAction(".")); 88 113 } 89 114 } 90 }91 115 92 116 /** 93 117 * If the right (and only the right) mouse button is pressed, move the map -
src/org/openstreetmap/josm/gui/MainApplet.java
28 28 import org.openstreetmap.josm.actions.JosmAction; 29 29 import org.openstreetmap.josm.data.ServerSidePreferences; 30 30 import org.openstreetmap.josm.tools.GBC; 31 import org.openstreetmap.josm.tools.ShortCut; 31 32 32 33 public class MainApplet extends JApplet { 33 34 34 35 public static final class UploadPreferencesAction extends JosmAction { 35 36 public UploadPreferencesAction() { 36 super(tr("Upload Preferences"), "upload-preferences", tr("Upload the current preferences to the server"), KeyEvent.VK_U, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK, true); 37 super(tr("Upload Preferences"), "upload-preferences", tr("Upload the current preferences to the server"), 38 ShortCut.registerShortCut("applet:uploadprefs", tr("Upload preferences"), KeyEvent.VK_U, ShortCut.GROUP_HOTKEY), true); 37 39 } 38 40 public void actionPerformed(ActionEvent e) { 39 41 ((ServerSidePreferences)Main.pref).upload(); -
src/org/openstreetmap/josm/Main.java
58 58 import org.openstreetmap.josm.plugins.PluginInformation; 59 59 import org.openstreetmap.josm.plugins.PluginProxy; 60 60 import org.openstreetmap.josm.tools.ImageProvider; 61 import org.openstreetmap.josm.tools.PlatformHook; 62 import org.openstreetmap.josm.tools.PlatformHookUnixoid; 63 import org.openstreetmap.josm.tools.PlatformHookWindows; 64 import org.openstreetmap.josm.tools.PlatformHookOsx; 65 import org.openstreetmap.josm.tools.ShortCut; 61 66 62 67 abstract public class Main { 63 68 /** … … 132 137 } 133 138 134 139 /** 140 * Platform specific code goes in here. 141 * Plugins may replace it, however, some hooks will be called before any plugins have been loeaded. 142 * So if you need to hook into those early ones, split your class and send the one with the early hooks 143 * to the JOSM team for inclusion. 144 */ 145 public static PlatformHook platform; 146 147 /** 135 148 * Set or clear (if passed <code>null</code>) the map. 136 149 */ 137 150 public final void setMapFrame(final MapFrame map) { … … 177 190 setMapFrame(null); 178 191 } 179 192 180 181 193 public Main() { 182 194 main = this; 195 // platform = determinePlatformHook(); 196 platform.startupHook(); 183 197 contentPane.add(panel, BorderLayout.CENTER); 184 198 panel.add(new GettingStarted(), BorderLayout.CENTER); 185 199 menu = new MainMenu(); … … 189 203 // creating toolbar 190 204 contentPane.add(toolbar.control, BorderLayout.NORTH); 191 205 192 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), "Help");206 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ShortCut.registerShortCut("system:help", tr("Help"), KeyEvent.VK_F1, ShortCut.GROUP_DIRECT).getKeyStroke(), "Help"); 193 207 contentPane.getActionMap().put("Help", menu.help); 194 208 195 209 TaggingPresetPreference.initialize(); … … 414 428 } 415 429 416 430 public static boolean breakBecauseUnsavedChanges() { 431 ShortCut.savePrefs(); 417 432 if (map != null) { 418 433 boolean modified = false; 419 434 boolean uploadedModified = false; … … 470 485 471 486 main.menu.open.openFile(new File(s)); 472 487 } 488 489 protected static void determinePlatformHook() { 490 String os = System.getProperty("os.name"); 491 if (os == null) { 492 System.err.println("Your operating system has no name, so I'm guessing its some kind of *nix."); 493 platform = new PlatformHookUnixoid(); 494 } else if (os.toLowerCase().startsWith("windows")) { 495 platform = new PlatformHookWindows(); 496 } else if (os.equals("Linux") || os.equals("Solaris") || os.equals("SunOS") || os.equals("AIX") || os.equals("FreeBSD")) { 497 platform = new PlatformHookUnixoid(); 498 } else if (os.toLowerCase().startsWith("mac os x")) { 499 platform = new PlatformHookOsx(); 500 } else { 501 System.err.println("I don't know your operating system '"+os+"', so I'm guessing its some kind of *nix."); 502 platform = new PlatformHookUnixoid(); 473 503 } 504 } 505 506 } -
build.xml
36 36 <delete file="dist/josm-custom.jar"/> 37 37 <jar destfile="dist/josm-custom.jar" basedir="build"> 38 38 <manifest> 39 <attribute name="Main-class" value=" org.openstreetmap.josm.gui.MainApplication" />39 <attribute name="Main-class" value="JOSM" /> 40 40 </manifest> 41 41 </jar> 42 42 </target>
