/** * Returns the contents of the specified transferable. * * @param tr transferable * @return contents */ @SuppressWarnings("unchecked") public static ArrayList<Object> contents(final Transferable tr) { final ArrayList<Object> list = new ArrayList<>(); try { if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { for (final File fl : (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor)) list.add(fl); } else if (tr.isDataFlavorSupported(DataFlavor.stringFlavor)) { list.add(tr.getTransferData(DataFlavor.stringFlavor)); } } catch (final Exception ex) { Util.stack(ex); } return list; }
private boolean testFlavor(DataFlavor inFlavor, Transferable t) { if (inFlavor != null) { if (t.isDataFlavorSupported(inFlavor)) { JConfig.log().logVerboseDebug("Accepting(2): " + inFlavor.getMimeType()); return true; } } return false; }
public void drop(DropTargetDropEvent evt) { try { Transferable t = evt.getTransferable(); if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) { evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); String s = (String) t.getTransferData(DataFlavor.stringFlavor); evt.getDropTargetContext().dropComplete(true); process(s); } else { evt.rejectDrop(); } } catch (IOException e) { evt.rejectDrop(); } catch (UnsupportedFlavorException e) { evt.rejectDrop(); } }