List of usage examples for java.awt.datatransfer DataFlavor getRepresentationClass
public Class<?> getRepresentationClass()
From source file:com.igormaznitsa.sciareto.ui.editors.MMDEditor.java
@Override public void drop(@Nonnull final DropTargetDropEvent dtde) { dtde.acceptDrop(DnDConstants.ACTION_MOVE); File detectedFileObject = null; for (final DataFlavor df : dtde.getCurrentDataFlavors()) { final Class<?> representation = df.getRepresentationClass(); if (FileTransferable.class.isAssignableFrom(representation)) { final FileTransferable t = (FileTransferable) dtde.getTransferable(); final List<File> listOfFiles = t.getFiles(); detectedFileObject = listOfFiles.isEmpty() ? null : listOfFiles.get(0); break; } else if (df.isFlavorJavaFileListType()) { try { final List list = (List) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor); if (list != null && !list.isEmpty()) { detectedFileObject = (File) list.get(0); }/* ww w. ja v a2s . c om*/ break; } catch (Exception ex) { LOGGER.error("Can't extract file from DnD", ex); } } } if (detectedFileObject != null) { addFileToElement(detectedFileObject, this.mindMapPanel.findTopicUnderPoint(dtde.getLocation())); } }
From source file:org.gephi.ui.components.ReportSelection.java
/** * * @param flavor/*from w ww.ja v a2 s .c o m*/ * @return * @throws java.awt.datatransfer.UnsupportedFlavorException */ @Override public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { if (String.class.equals(flavor.getRepresentationClass())) { return html; } throw new UnsupportedFlavorException(flavor); }
From source file:org.wings.STransferHandler.java
private DataFlavor getPropertyDataFlavor(Class<?> argument, DataFlavor[] flavors) { for (DataFlavor flavor : flavors) { if ("application".equals(flavor.getPrimaryType()) && "x-java-jvm-local-objectref".equals(flavor.getSubType())) { if (argument.isAssignableFrom(flavor.getRepresentationClass())) { return flavor; }/* w w w . java 2 s .c o m*/ } } return null; }