Changeset 1351 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-01-31T14:43:27+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CopyAction.java
r1169 r1351 44 44 45 45 public void actionPerformed(ActionEvent e) { 46 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 47 if (sel.isEmpty()) { 48 JOptionPane.showMessageDialog(Main.parent, 49 tr("Please select something to copy.")); 50 return; 46 if(noSelection()) return; 47 48 Main.pasteBuffer = copyData(); 49 Main.main.menu.paste.setEnabled(true); /* now we have a paste buffer we can make paste available */ 50 51 for(JosmAction a : listeners) { 52 a.pasteBufferChanged(Main.pasteBuffer); 51 53 } 52 54 } 55 56 public static DataSet copyData() { 53 57 /* New pasteBuffer - will be assigned to the global one at the end */ 54 58 final DataSet pasteBuffer = new DataSet(); 55 59 final HashMap<OsmPrimitive,OsmPrimitive> map = new HashMap<OsmPrimitive,OsmPrimitive>(); 56 60 /* temporarily maps old nodes to new so we can do a true deep copy */ 57 61 62 if(noSelection()) return pasteBuffer; 63 58 64 /* scan the selected objects, mapping them to copies; when copying a way or relation, 59 65 * the copy references the copies of their child objects */ … … 105 111 } 106 112 }.visitAll(); 107 108 Main.pasteBuffer = pasteBuffer; 109 Main.main.menu.paste.setEnabled(true); /* now we have a paste buffer we can make paste available */ 110 111 for(JosmAction a : listeners) { 112 a.pasteBufferChanged(Main.pasteBuffer); 113 } 113 114 return pasteBuffer; 114 115 } 115 116 … … 117 118 setEnabled(! newSelection.isEmpty()); 118 119 } 120 121 private static boolean noSelection() { 122 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 123 if (sel.isEmpty()) { 124 JOptionPane.showMessageDialog(Main.parent, 125 tr("Please select something to copy.")); 126 return true; 127 } 128 return false; 129 } 119 130 } -
trunk/src/org/openstreetmap/josm/actions/DuplicateAction.java
r1169 r1351 10 10 11 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm.actions.CopyAction; 13 import org.openstreetmap.josm.actions.PasteAction; 12 14 import org.openstreetmap.josm.data.SelectionChangedListener; 13 15 import org.openstreetmap.josm.data.osm.DataSet; … … 22 24 Shortcut.registerShortcut("system:duplicate", tr("Edit: {0}", tr("Duplicate")), KeyEvent.VK_D, Shortcut.GROUP_MENU), true); 23 25 setEnabled(false); 24 26 DataSet.selListeners.add(this); 25 27 } 26 28 27 29 public void actionPerformed(ActionEvent e) { 28 Main.main.menu.copy.actionPerformed(e); 29 Main.main.menu.paste.actionPerformed(e); 30 PasteAction.pasteData(CopyAction.copyData(), e); 30 31 } 31 32 -
trunk/src/org/openstreetmap/josm/actions/PasteAction.java
r1205 r1351 31 31 super(tr("Paste"), "paste", tr("Paste contents of paste buffer."), 32 32 Shortcut.registerShortcut("system:paste", tr("Edit: {0}", tr("Paste")), KeyEvent.VK_V, Shortcut.GROUP_MENU), true); 33 33 setEnabled(false); 34 34 } 35 35 36 36 public void actionPerformed(ActionEvent e) { 37 DataSet pasteBuffer = Main.pasteBuffer; 38 37 pasteData(Main.pasteBuffer, e); 38 } 39 40 public static void pasteData(DataSet pasteBuffer, ActionEvent e) { 39 41 /* Find the middle of the pasteBuffer area */ 40 42 double maxEast = -1E100, minEast = 1E100, maxNorth = -1E100, minNorth = 1E100;
Note:
See TracChangeset
for help on using the changeset viewer.