Changeset 9711 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-02-01T23:47:27+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferable.java
r9563 r9711 19 19 20 20 /** 21 * Data flavor for{@link PrimitiveData}.21 * A wrapper for a collection of {@link PrimitiveData}. 22 22 */ 23 public static final DataFlavor PRIMITIVE_DATA = new DataFlavor(PrimitiveData.class, PrimitiveData.class.getName()); 23 public static final class Data { 24 private final Collection<PrimitiveData> primitiveData; 25 26 private Data(Collection<PrimitiveData> primitiveData) { 27 this.primitiveData = primitiveData; 28 } 29 30 /** 31 * Returns the contained {@link PrimitiveData} 32 * @return the contained {@link PrimitiveData} 33 */ 34 public Collection<PrimitiveData> getPrimitiveData() { 35 return primitiveData; 36 } 37 } 38 39 /** 40 * Data flavor for {@link PrimitiveData} which is wrapped in {@link Data}. 41 */ 42 public static final DataFlavor PRIMITIVE_DATA = new DataFlavor(Data.class, Data.class.getName()); 24 43 private final Collection<? extends OsmPrimitive> primitives; 25 44 … … 47 66 return getStringData(); 48 67 } else if (PRIMITIVE_DATA.equals(flavor)) { 49 return get RelationMemberData();68 return getPrimitiveData(); 50 69 } 51 70 throw new UnsupportedFlavorException(flavor); … … 63 82 } 64 83 65 protected Collection<PrimitiveData> getRelationMemberData() {84 protected Data getPrimitiveData() { 66 85 final Collection<PrimitiveData> r = new ArrayList<>(primitives.size()); 67 86 for (OsmPrimitive primitive : primitives) { 68 87 r.add(primitive.save()); 69 88 } 70 return r;89 return new Data(r); 71 90 } 72 91 } -
trunk/src/org/openstreetmap/josm/gui/datatransfer/RelationMemberTransferable.java
r9563 r9711 19 19 20 20 /** 21 * Data flavor for{@link RelationMemberData}.21 * A wrapper for a collection of {@link RelationMemberData}. 22 22 */ 23 public static final DataFlavor RELATION_MEMBER_DATA = new DataFlavor(RelationMemberData.class, RelationMemberData.class.getName()); 23 public static final class Data { 24 private final Collection<RelationMemberData> relationMemberDatas; 25 26 private Data(Collection<RelationMemberData> primitiveData) { 27 this.relationMemberDatas = primitiveData; 28 } 29 30 /** 31 * Returns the contained {@link RelationMemberData} 32 * @return the contained {@link RelationMemberData} 33 */ 34 public Collection<RelationMemberData> getRelationMemberData() { 35 return relationMemberDatas; 36 } 37 } 38 39 /** 40 * Data flavor for {@link RelationMemberData} which is wrapped in {@link Data}. 41 */ 42 public static final DataFlavor RELATION_MEMBER_DATA = new DataFlavor(Data.class, Data.class.getName()); 24 43 private final Collection<RelationMember> members; 25 44 … … 64 83 } 65 84 66 protected Collection<RelationMemberData>getRelationMemberData() {85 protected Data getRelationMemberData() { 67 86 final Collection<RelationMemberData> r = new ArrayList<>(members.size()); 68 87 for (RelationMember member : members) { 69 88 r.add(new RelationMemberData(member.getRole(), member.getType(), member.getUniqueId())); 70 89 } 71 return r;90 return new Data(r); 72 91 } 73 92 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTransferHandler.java
r9379 r9711 64 64 protected void importRelationMemberData(TransferSupport support, final MemberTable destination, int insertRow) 65 65 throws UnsupportedFlavorException, IOException { 66 //noinspection unchecked 67 @SuppressWarnings("unchecked") 68 final Collection<RelationMemberData> memberData = (Collection<RelationMemberData>) 66 final RelationMemberTransferable.Data memberData = (RelationMemberTransferable.Data) 69 67 support.getTransferable().getTransferData(RelationMemberTransferable.RELATION_MEMBER_DATA); 70 importData(destination, insertRow, memberData , new Function<RelationMemberData, RelationMember>() {68 importData(destination, insertRow, memberData.getRelationMemberData(), new Function<RelationMemberData, RelationMember>() { 71 69 @Override 72 70 public RelationMember apply(RelationMemberData member) { … … 84 82 protected void importPrimitiveData(TransferSupport support, final MemberTable destination, int insertRow) 85 83 throws UnsupportedFlavorException, IOException { 86 //noinspection unchecked 87 @SuppressWarnings("unchecked") 88 final Collection<PrimitiveData> data = (Collection<PrimitiveData>) 84 final PrimitiveTransferable.Data data = (PrimitiveTransferable.Data) 89 85 support.getTransferable().getTransferData(PrimitiveTransferable.PRIMITIVE_DATA); 90 importData(destination, insertRow, data , new Function<PrimitiveData, RelationMember>() {86 importData(destination, insertRow, data.getPrimitiveData(), new Function<PrimitiveData, RelationMember>() { 91 87 @Override 92 88 public RelationMember apply(PrimitiveData data) {
Note:
See TracChangeset
for help on using the changeset viewer.