Changeset 10801 in josm


Ignore:
Timestamp:
2016-08-15T13:25:30+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13341 - refactor construction of data flavors, specify classloader to use

Location:
trunk/src/org/openstreetmap/josm/gui/datatransfer
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/ClipboardUtils.java

    r10611 r10801  
    148148        });
    149149    }
     150
     151    /**
     152     * Returns a new {@link DataFlavor} for the given class and human-readable name.
     153     * @param c class
     154     * @param humanPresentableName the human-readable string used to identify this flavor
     155     * @return a new {@link DataFlavor} for the given class and human-readable name
     156     * @since 10801
     157     */
     158    public static DataFlavor newDataFlavor(Class<?> c, String humanPresentableName) {
     159        try {
     160            return new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=" + c.getName(),
     161                    humanPresentableName, c.getClassLoader());
     162        } catch (ClassNotFoundException e) {
     163            throw new IllegalArgumentException(e);
     164        }
     165    }
    150166}
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/LayerTransferable.java

    r10605 r10801  
    6363     * Data flavor for {@link Layer}s which are wrapped in {@link Data}.
    6464     */
    65     public static final DataFlavor LAYER_DATA = new DataFlavor(
    66             DataFlavor.javaJVMLocalObjectMimeType + ";class=" + Data.class.getName(), "Layers");
     65    public static final DataFlavor LAYER_DATA = ClipboardUtils.newDataFlavor(Data.class, "Layers");
    6766
    6867    private final Data data;
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/data/LayerTransferData.java

    r10605 r10801  
    77import java.util.List;
    88
     9import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    910import org.openstreetmap.josm.gui.datatransfer.LayerTransferable;
    1011import org.openstreetmap.josm.gui.layer.Layer;
     
    2021     * This is a data flavor for all layer types
    2122     */
    22     public static final DataFlavor FLAVOR = new DataFlavor(
    23             DataFlavor.javaJVMLocalObjectMimeType + ";class=" + LayerTransferData.class.getName(), "Layer");
     23    public static final DataFlavor FLAVOR = ClipboardUtils.newDataFlavor(LayerTransferData.class, "Layer");
    2424
    2525    /**
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/data/OsmLayerTransferData.java

    r10745 r10801  
    77import java.util.List;
    88
     9import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    910import org.openstreetmap.josm.gui.datatransfer.LayerTransferable;
    1011import org.openstreetmap.josm.gui.layer.LayerManager;
     
    2324     * @see #FLAVORS
    2425     */
    25     public static final DataFlavor OSM_FLAVOR = new DataFlavor(
    26             DataFlavor.javaJVMLocalObjectMimeType + ";class=" + LayerTransferData.class.getName(), "Layer");
     26    public static final DataFlavor OSM_FLAVOR = ClipboardUtils.newDataFlavor(OsmLayerTransferData.class, "Layer");
    2727
    2828    /**
Note: See TracChangeset for help on using the changeset viewer.