@Override public void actionPerformed(ActionEvent e) { execute(); }
@Override public void drop(DropTargetDropEvent dtde) { try { final Transferable transferable = dtde.getTransferable(); if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); final List<File> fileList = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor); if (fileList.size() > 0) { final OpenProductAction open = new OpenProductAction(); open.setFiles(fileList.toArray(new File[fileList.size()])); dtde.dropComplete(Boolean.TRUE.equals(open.execute())); } } else { dtde.rejectDrop(); } } catch (UnsupportedFlavorException | IOException e) { SystemUtils.LOG.log(Level.SEVERE, "Exception during drag-and-drop operation", e); dtde.rejectDrop(); } }
File[] files = fileList.stream().map(Path::toFile).filter(Objects::nonNull).toArray(File[]::new); productAction.setFiles(files); productAction.execute();