source: josm/trunk/src/org/openstreetmap/josm/gui/datatransfer/data/TagTransferData.java@ 10637

Last change on this file since 10637 was 10637, checked in by Don-vip, 8 years ago

fix #13050 - cannot copy from the object history view (patch by michael2402, modified) - gsoc-core

File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.datatransfer.data;
3
4import java.awt.datatransfer.DataFlavor;
5import java.io.Serializable;
6import java.util.Collection;
7import java.util.Collections;
8import java.util.Map;
9
10import org.openstreetmap.josm.data.osm.TagMap;
11import org.openstreetmap.josm.data.osm.Tagged;
12
13/**
14 * This is a special transfer type that only transfers tag data.
15 * <p>
16 * It currently contains all tags contained in the selection that was copied.
17 * @author Michael Zangl
18 * @since 10604
19 */
20public class TagTransferData implements Serializable {
21
22 private static final long serialVersionUID = 1;
23
24 /**
25 * This is a data flavor added
26 */
27 public static final DataFlavor FLAVOR = new DataFlavor(TagTransferData.class, "OSM Tags");
28
29 private final TagMap tags = new TagMap();
30
31 /**
32 * Creates a new {@link TagTransferData} object for the given objects.
33 * @param tagged The tags to transfer.
34 */
35 public TagTransferData(Collection<? extends Tagged> tagged) {
36 for (Tagged t : tagged) {
37 tags.putAll(t.getKeys());
38 }
39 }
40
41 /**
42 * Create a new {@link TagTransferData} object with the given tags.
43 * @param tags The tags.
44 * @since 10637
45 */
46 public TagTransferData(Map<String, String> tags) {
47 this.tags.putAll(tags);
48 }
49
50 /**
51 * Gets all tags contained in this data.
52 * @return The tags.
53 */
54 public Map<String, String> getTags() {
55 return Collections.unmodifiableMap(tags);
56 }
57}
Note: See TracBrowser for help on using the repository browser.