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 });
}
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()]);
}
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()));
}
}
Aggregations