Changeset 1814 in josm for trunk/src/org/openstreetmap/josm/actions/CopyAction.java
- Timestamp:
- 2009-07-19T19:04:49+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CopyAction.java
r1750 r1814 45 45 46 46 public void actionPerformed(ActionEvent e) { 47 if( noSelection()) return;47 if(isEmptySelection()) return; 48 48 49 49 Main.pasteBuffer = copyData(); 50 Main.pasteSource = Main.main.createOrGetEditLayer();50 Main.pasteSource = getEditLayer(); 51 51 Main.main.menu.paste.setEnabled(true); /* now we have a paste buffer we can make paste available */ 52 52 … … 56 56 } 57 57 58 public staticDataSet copyData() {58 public DataSet copyData() { 59 59 /* New pasteBuffer - will be assigned to the global one at the end */ 60 60 final DataSet pasteBuffer = new DataSet(); … … 62 62 /* temporarily maps old nodes to new so we can do a true deep copy */ 63 63 64 if( noSelection()) return pasteBuffer;64 if(isEmptySelection()) return pasteBuffer; 65 65 66 66 /* scan the selected objects, mapping them to copies; when copying a way or relation, … … 71 71 * or a way and a node in that way is selected, we'll see it twice, once via the 72 72 * way and once directly; and so on. */ 73 if (map.containsKey(n)) { return; } 73 if (map.containsKey(n)) 74 return; 74 75 Node nnew = new Node(n); 75 76 map.put(n, nnew); … … 78 79 public void visit(Way w) { 79 80 /* check if already in pasteBuffer - could have come from a relation, and directly etc. */ 80 if (map.containsKey(w)) { return; } 81 if (map.containsKey(w)) 82 return; 81 83 Way wnew = new Way(); 82 84 wnew.cloneFrom(w); … … 93 95 } 94 96 public void visit(Relation e) { 95 if (map.containsKey(e)) { return; } 97 if (map.containsKey(e)) 98 return; 96 99 Relation enew = new Relation(e); 97 100 List<RelationMember> members = new ArrayList<RelationMember>(); … … 108 111 } 109 112 public void visitAll() { 110 for (OsmPrimitive osm : Main.ds.getSelected())113 for (OsmPrimitive osm : getCurrentDataSet().getSelected()) { 111 114 osm.visit(this); 115 } 112 116 113 117 // Used internally only (in PasteTagsAction), therefore no need to translate these 114 if( Main.ds.getSelectedNodes().size() > 0)118 if(getCurrentDataSet().getSelectedNodes().size() > 0) { 115 119 pasteBuffer.dataSources.add(new DataSource(null, "Copied Nodes")); 116 if(Main.ds.getSelectedWays().size() > 0) 120 } 121 if(getCurrentDataSet().getSelectedWays().size() > 0) { 117 122 pasteBuffer.dataSources.add(new DataSource(null, "Copied Ways")); 118 if(Main.ds.getSelectedRelations().size() > 0) 123 } 124 if(getCurrentDataSet().getSelectedRelations().size() > 0) { 119 125 pasteBuffer.dataSources.add(new DataSource(null, "Copied Relations")); 126 } 120 127 } 121 128 }.visitAll(); … … 128 135 } 129 136 130 private static boolean noSelection() {131 Collection<OsmPrimitive> sel = Main.ds.getSelected();137 private boolean isEmptySelection() { 138 Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); 132 139 if (sel.isEmpty()) { 133 JOptionPane.showMessageDialog(Main.parent, 134 tr("Please select something to copy.")); 140 JOptionPane.showMessageDialog( 141 Main.parent, 142 tr("Please select something to copy.") 143 ); 135 144 return true; 136 145 }
Note:
See TracChangeset
for help on using the changeset viewer.