Changeset 1023 in josm for trunk/src/org/openstreetmap/josm/actions/CopyAction.java
- Timestamp:
- 2008-10-05T17:06:27+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CopyAction.java
r627 r1023 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 29 30 private LinkedList<JosmAction> listeners; 30 31 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); … … 41 42 listeners.add(a); 42 43 } 43 44 44 45 public void actionPerformed(ActionEvent e) { 45 46 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 46 if (sel.isEmpty()) { 47 if (sel.isEmpty()) { 47 48 JOptionPane.showMessageDialog(Main.parent, 48 tr("Please select something to copy.")); 49 tr("Please select something to copy.")); 49 50 return; 50 51 } … … 55 56 /* temporarily maps old nodes to new so we can do a true deep copy */ 56 57 57 /* scan the selected objects, mapping them to copies; when copying a way or relation, 58 /* scan the selected objects, mapping them to copies; when copying a way or relation, 58 59 * the copy references the copies of their child objects */ 59 60 new Visitor(){ 60 61 public void visit(Node n) { 61 /* check if already in pasteBuffer - e.g. two ways are selected which share a node; 62 * or a way and a node in that way is selected, we'll see it twice, once via the 62 /* check if already in pasteBuffer - e.g. two ways are selected which share a node; 63 * or a way and a node in that way is selected, we'll see it twice, once via the 63 64 * way and once directly; and so on. */ 64 65 if (map.containsKey(n)) { return; } … … 107 108 Main.pasteBuffer = pasteBuffer; 108 109 Main.main.menu.paste.setEnabled(true); /* now we have a paste buffer we can make paste available */ 109 110 110 111 for(JosmAction a : listeners) { 111 112 a.pasteBufferChanged(Main.pasteBuffer);
Note:
See TracChangeset
for help on using the changeset viewer.