Changeset 3384 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2010-07-25T15:56:14+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CopyAction.java
r2892 r3384 3 3 package org.openstreetmap.josm.actions; 4 4 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 6 import static org.openstreetmap.josm.tools.I18n.tr; 6 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;7 7 8 8 import java.awt.Toolkit; … … 14 14 import java.awt.event.KeyEvent; 15 15 import java.util.Collection; 16 import java.util.LinkedList;17 16 18 17 import javax.swing.JOptionPane; … … 20 19 import org.openstreetmap.josm.Main; 21 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 22 22 import org.openstreetmap.josm.tools.Shortcut; 23 23 24 24 public final class CopyAction extends JosmAction { 25 26 private LinkedList<JosmAction> listeners;27 25 28 26 public CopyAction() { … … 31 29 Shortcut.registerShortcut("system:copy", tr("Edit: {0}", tr("Copy")), KeyEvent.VK_C, Shortcut.GROUP_MENU), true); 32 30 putValue("help", ht("/Action/Copy")); 33 listeners = new LinkedList<JosmAction>();34 }35 36 @Override public void addListener(JosmAction a) {37 listeners.add(a);38 31 } 39 32 … … 42 35 Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 43 36 37 copy(getEditLayer(), selection); 38 } 39 40 public static void copy(OsmDataLayer source, Collection<OsmPrimitive> primitives) { 44 41 /* copy ids to the clipboard */ 45 42 StringBuilder idsBuilder = new StringBuilder(); 46 for (OsmPrimitive p : selection) {43 for (OsmPrimitive p : primitives) { 47 44 idsBuilder.append(p.getId()+","); 48 45 } … … 56 53 } 57 54 catch (RuntimeException x) {} 58 59 Main.pasteBuffer.makeCopy(selection);60 Main.pasteSource = getEditLayer();61 Main.main.menu.paste.setEnabled(true); /* now we have a paste buffer we can make paste available */62 55 63 for(JosmAction a : listeners) { 64 a.pasteBufferChanged(Main.pasteBuffer); 65 } 56 Main.pasteBuffer.makeCopy(primitives); 57 Main.pasteSource = source; 66 58 } 67 59 -
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r3327 r3384 12 12 import org.openstreetmap.josm.data.osm.DataSet; 13 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy;15 14 import org.openstreetmap.josm.gui.MapView; 16 15 import org.openstreetmap.josm.gui.layer.Layer; … … 103 102 * needs to be overridden to be useful 104 103 */ 105 public void pasteBufferChanged(PrimitiveDeepCopy newPasteBuffer) {106 return;107 }108 109 /**110 * needs to be overridden to be useful111 */112 104 public void addListener(JosmAction a) { 113 105 return; -
trunk/src/org/openstreetmap/josm/actions/PasteAction.java
r2932 r3384 23 23 import org.openstreetmap.josm.data.osm.RelationMemberData; 24 24 import org.openstreetmap.josm.data.osm.WayData; 25 import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy.PasteBufferChangedListener; 25 26 import org.openstreetmap.josm.gui.ExtendedDialog; 26 27 import org.openstreetmap.josm.gui.layer.Layer; 27 28 import org.openstreetmap.josm.tools.Shortcut; 28 29 29 public final class PasteAction extends JosmAction {30 public final class PasteAction extends JosmAction implements PasteBufferChangedListener { 30 31 31 32 public PasteAction() { … … 33 34 Shortcut.registerShortcut("system:paste", tr("Edit: {0}", tr("Paste")), KeyEvent.VK_V, Shortcut.GROUP_MENU), true); 34 35 putValue("help", ht("/Action/Paste")); 36 Main.pasteBuffer.addPasteBufferChangedListener(this); 35 37 } 36 38 … … 167 169 setEnabled(!Main.pasteBuffer.isEmpty()); 168 170 } 171 172 @Override 173 public void pasteBufferChanged(PrimitiveDeepCopy pasteBuffer) { 174 updateEnabledState(); 175 } 169 176 } -
trunk/src/org/openstreetmap/josm/actions/PasteTagsAction.java
r2512 r3384 3 3 package org.openstreetmap.josm.actions; 4 4 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 6 import static org.openstreetmap.josm.tools.I18n.tr; 6 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;7 7 import static org.openstreetmap.josm.tools.I18n.trn; 8 8 … … 24 24 import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy; 25 25 import org.openstreetmap.josm.data.osm.TagCollection; 26 import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy.PasteBufferChangedListener; 26 27 import org.openstreetmap.josm.gui.conflict.tags.PasteTagsConflictResolverDialog; 27 28 import org.openstreetmap.josm.tools.Shortcut; 28 29 29 public final class PasteTagsAction extends JosmAction {30 public final class PasteTagsAction extends JosmAction implements PasteBufferChangedListener { 30 31 31 32 public PasteTagsAction(JosmAction copyAction) { … … 33 34 tr("Apply tags of contents of paste buffer to all selected items."), 34 35 Shortcut.registerShortcut("system:pastestyle", tr("Edit: {0}", tr("Paste Tags")), KeyEvent.VK_V, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT), true); 35 copyAction.addListener(this);36 Main.pasteBuffer.addPasteBufferChangedListener(this); 36 37 putValue("help", ht("/Action/PasteTags")); 37 38 }
Note:
See TracChangeset
for help on using the changeset viewer.