Example usage for java.awt.datatransfer DataFlavor isFlavorJavaFileListType

List of usage examples for java.awt.datatransfer DataFlavor isFlavorJavaFileListType

Introduction

In this page you can find the example usage for java.awt.datatransfer DataFlavor isFlavorJavaFileListType.

Prototype

public boolean isFlavorJavaFileListType() 

Source Link

Document

Returns true if the DataFlavor specified represents a list of file objects.

Usage

From source file:Main.java

public static void main(String[] args) {

    DataFlavor df = DataFlavor.stringFlavor;

    System.out.println(df.isFlavorJavaFileListType());
}

From source file:com.igormaznitsa.sciareto.ui.editors.MMDEditor.java

protected static boolean checkDragType(@Nonnull final DropTargetDragEvent dtde) {
    boolean result = false;
    for (final DataFlavor flavor : dtde.getCurrentDataFlavors()) {
        final Class dataClass = flavor.getRepresentationClass();
        if (FileTransferable.class.isAssignableFrom(dataClass) || flavor.isFlavorJavaFileListType()) {
            result = true;//from  www. j a v  a 2s.  c om
            break;
        }
    }
    return result;
}

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);
                }//from  www  . j a  v a 2s. 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.apache.jmeter.gui.MainFrame.java

/**
 * Handler of Top level Dnd/*from   w ww .  j  a va  2  s .c  o m*/
 */
@Override
public void drop(DropTargetDropEvent dtde) {
    try {
        Transferable tr = dtde.getTransferable();
        DataFlavor[] flavors = tr.getTransferDataFlavors();
        for (DataFlavor flavor : flavors) {
            // Check for file lists specifically
            if (flavor.isFlavorJavaFileListType()) {
                dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
                try {
                    openJmxFilesFromDragAndDrop(tr);
                } finally {
                    dtde.dropComplete(true);
                }
                return;
            }
        }
    } catch (UnsupportedFlavorException | IOException e) {
        log.warn("Dnd failed", e);
    }

}