Index: trunk/src/org/openstreetmap/josm/actions/CopyAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/CopyAction.java	(revision 1350)
+++ trunk/src/org/openstreetmap/josm/actions/CopyAction.java	(revision 1351)
@@ -44,16 +44,22 @@
 
     public void actionPerformed(ActionEvent e) {
-        Collection<OsmPrimitive> sel = Main.ds.getSelected();
-        if (sel.isEmpty()) {
-            JOptionPane.showMessageDialog(Main.parent,
-                    tr("Please select something to copy."));
-            return;
+        if(noSelection()) return;
+        
+        Main.pasteBuffer = copyData();
+        Main.main.menu.paste.setEnabled(true); /* now we have a paste buffer we can make paste available */
+
+        for(JosmAction a : listeners) {
+            a.pasteBufferChanged(Main.pasteBuffer);
         }
-
+    }
+    
+    public static DataSet copyData() {
         /* New pasteBuffer - will be assigned to the global one at the end */
         final DataSet pasteBuffer = new DataSet();
         final HashMap<OsmPrimitive,OsmPrimitive> map = new HashMap<OsmPrimitive,OsmPrimitive>();
         /* temporarily maps old nodes to new so we can do a true deep copy */
-
+        
+        if(noSelection()) return pasteBuffer;
+        
         /* scan the selected objects, mapping them to copies; when copying a way or relation,
          * the copy references the copies of their child objects */
@@ -105,11 +111,6 @@
             }
         }.visitAll();
-
-        Main.pasteBuffer = pasteBuffer;
-        Main.main.menu.paste.setEnabled(true); /* now we have a paste buffer we can make paste available */
-
-        for(JosmAction a : listeners) {
-            a.pasteBufferChanged(Main.pasteBuffer);
-        }
+        
+        return pasteBuffer;
     }
 
@@ -117,3 +118,13 @@
         setEnabled(! newSelection.isEmpty());
     }
+    
+    private static boolean noSelection() {
+        Collection<OsmPrimitive> sel = Main.ds.getSelected();
+        if (sel.isEmpty()) {
+            JOptionPane.showMessageDialog(Main.parent,
+                    tr("Please select something to copy."));
+            return true;
+        }
+        return false;
+    }
 }
Index: trunk/src/org/openstreetmap/josm/actions/DuplicateAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/DuplicateAction.java	(revision 1350)
+++ trunk/src/org/openstreetmap/josm/actions/DuplicateAction.java	(revision 1351)
@@ -10,4 +10,6 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.CopyAction;
+import org.openstreetmap.josm.actions.PasteAction;
 import org.openstreetmap.josm.data.SelectionChangedListener;
 import org.openstreetmap.josm.data.osm.DataSet;
@@ -22,10 +24,9 @@
             Shortcut.registerShortcut("system:duplicate", tr("Edit: {0}", tr("Duplicate")), KeyEvent.VK_D, Shortcut.GROUP_MENU), true);
         setEnabled(false);
-            DataSet.selListeners.add(this);
+        DataSet.selListeners.add(this);
     }
 
     public void actionPerformed(ActionEvent e) {
-        Main.main.menu.copy.actionPerformed(e);
-        Main.main.menu.paste.actionPerformed(e);
+        PasteAction.pasteData(CopyAction.copyData(), e);
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/PasteAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/PasteAction.java	(revision 1350)
+++ trunk/src/org/openstreetmap/josm/actions/PasteAction.java	(revision 1351)
@@ -31,10 +31,12 @@
         super(tr("Paste"), "paste", tr("Paste contents of paste buffer."),
             Shortcut.registerShortcut("system:paste", tr("Edit: {0}", tr("Paste")), KeyEvent.VK_V, Shortcut.GROUP_MENU), true);
-            setEnabled(false);
+        setEnabled(false);
     }
 
     public void actionPerformed(ActionEvent e) {
-        DataSet pasteBuffer = Main.pasteBuffer;
-
+        pasteData(Main.pasteBuffer, e);
+    }
+    
+    public static void pasteData(DataSet pasteBuffer, ActionEvent e) {
         /* Find the middle of the pasteBuffer area */
         double maxEast = -1E100, minEast = 1E100, maxNorth = -1E100, minNorth = 1E100;
