Changeset 4611 in josm
- Timestamp:
- 2011-11-26T16:58:22+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r4539 r4611 13 13 import java.awt.Toolkit; 14 14 import java.awt.event.AWTEventListener; 15 import java.awt.event.ActionEvent; 15 16 import java.awt.event.InputEvent; 16 17 import java.awt.event.KeyEvent; … … 28 29 import java.util.Set; 29 30 31 import javax.swing.AbstractAction; 30 32 import javax.swing.JOptionPane; 31 33 … … 79 81 80 82 private Shortcut extraShortcut; 81 83 private Shortcut backspaceShortcut; 84 82 85 public DrawAction(MapFrame mapFrame) { 83 86 super(tr("Draw"), "node/autonode", tr("Draw nodes"), … … 176 179 drawTargetHighlight = Main.pref.getBoolean("draw.target-highlight", true); 177 180 wayIsFinished = false; 181 182 backspaceShortcut = Shortcut.registerShortcut("mapmode:backspace", tr("Backspace in Add mode"), KeyEvent.VK_BACK_SPACE, Shortcut.GROUP_EDIT); 183 Main.registerActionShortcut(new BackSpaceAction(), backspaceShortcut); 178 184 179 185 Main.map.mapView.addMouseListener(this); … … 196 202 Main.map.mapView.removeTemporaryLayer(this); 197 203 DataSet.removeSelectionListener(this); 204 Main.unregisterActionShortcut(backspaceShortcut); 205 198 206 removeHighlighting(); 199 207 try { … … 968 976 Main.unregisterActionShortcut(extraShortcut); 969 977 } 978 979 public static class BackSpaceAction extends AbstractAction { 980 981 @Override 982 public void actionPerformed(ActionEvent e) { 983 Main.main.undoRedo.undo(); 984 Node n=null; 985 Command lastCmd=Main.main.undoRedo.commands.peekLast(); 986 if (lastCmd==null) return; 987 for (OsmPrimitive p: lastCmd.getParticipatingPrimitives()) { 988 if (p instanceof Node) { 989 if (n==null) { 990 n=(Node) p; // found one node 991 } else { 992 // if more than 1 node were affected by previous command, 993 // we have no way to continue, so we forget about found node 994 n=null; 995 break; 996 } 997 } 998 } 999 // select last added node - maybe we will continue drawing from it 1000 if (n!=null) getCurrentDataSet().addSelected(n); 1001 } 1002 } 1003 970 1004 }
Note:
See TracChangeset
for help on using the changeset viewer.