Search in sources :

Example 1 with SystemFlavorMap

use of java.awt.datatransfer.SystemFlavorMap in project jdk8u_jdk by JetBrains.

the class ImageSelection method leaveFormat.

static void leaveFormat(String format) {
    SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
    sfm.setFlavorsForNative(format, new DataFlavor[] { DataFlavor.imageFlavor });
    sfm.setNativesForFlavor(DataFlavor.imageFlavor, new String[] { format });
}
Also used : SystemFlavorMap(java.awt.datatransfer.SystemFlavorMap)

Example 2 with SystemFlavorMap

use of java.awt.datatransfer.SystemFlavorMap in project jdk8u_jdk by JetBrains.

the class ImageSelection method retrieveFormatsToTest.

static String[] retrieveFormatsToTest() {
    SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
    java.util.List<String> ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor);
    if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) && !ln.contains("METAFILEPICT")) {
        // for test failing on JDK without this fix
        ln.add("METAFILEPICT");
    }
    return ln.toArray(new String[ln.size()]);
}
Also used : SystemFlavorMap(java.awt.datatransfer.SystemFlavorMap)

Example 3 with SystemFlavorMap

use of java.awt.datatransfer.SystemFlavorMap in project jdk8u_jdk by JetBrains.

the class DuplicatedNativesTest method main.

public static void main(String[] args) throws Exception {
    // 1. Check that returned natives do not contain duplicates.
    SystemFlavorMap flavorMap = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
    for (Map.Entry<DataFlavor, String> entry : flavorMap.getNativesForFlavors(null).entrySet()) {
        List<String> natives = flavorMap.getNativesForFlavor(entry.getKey());
        if (new HashSet<>(natives).size() != natives.size()) {
            throw new RuntimeException("FAILED: returned natives contain duplicates: " + Arrays.toString(natives.toArray()));
        }
    }
    // 2. Check that even if we set a duplicate it would be ignored.
    flavorMap.setNativesForFlavor(DataFlavor.stringFlavor, new String[] { "test", "test", "test" });
    List<String> natives = flavorMap.getNativesForFlavor(DataFlavor.stringFlavor);
    if (new HashSet<>(natives).size() != natives.size()) {
        throw new RuntimeException("FAILED: duplicates were not ignored: " + Arrays.toString(natives.toArray()));
    }
}
Also used : SystemFlavorMap(java.awt.datatransfer.SystemFlavorMap) Map(java.util.Map) SystemFlavorMap(java.awt.datatransfer.SystemFlavorMap) DataFlavor(java.awt.datatransfer.DataFlavor) HashSet(java.util.HashSet)

Aggregations

SystemFlavorMap (java.awt.datatransfer.SystemFlavorMap)3 DataFlavor (java.awt.datatransfer.DataFlavor)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1