List of usage examples for java.awt.datatransfer DataFlavor javaFileListFlavor
DataFlavor javaFileListFlavor
To view the source code for java.awt.datatransfer DataFlavor javaFileListFlavor.
Click Source Link
From source file:net.sf.jabref.external.TransferableFileLinkSelection.java
@Override public boolean isDataFlavorSupported(DataFlavor dataFlavor) { LOGGER.debug("Query: " + dataFlavor.getHumanPresentableName() + " , " + dataFlavor.getDefaultRepresentationClass() + " , " + dataFlavor.getMimeType()); return dataFlavor.equals(DataFlavor.javaFileListFlavor) || dataFlavor.equals(DataFlavor.stringFlavor); }
From source file:com.mirth.connect.client.ui.components.MirthTableTransferHandler.java
@Override public boolean importData(TransferSupport support) { if (canImport(support)) { try {//from ww w.j av a 2s . co m List<File> fileList = (List<File>) support.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor); boolean showAlerts = (fileList.size() == 1); for (File file : fileList) { if (FilenameUtils.isExtension(file.getName(), "xml")) { importFile(file, showAlerts); } } return true; } catch (Exception e) { // Let it return false } } return false; }
From source file:io.neocdtv.simpleplayer.ui.PlaylistTransferHandler.java
@Override public boolean canImport(TransferHandler.TransferSupport info) { return info.isDataFlavorSupported(DataFlavor.javaFileListFlavor); }
From source file:net.sf.keystore_explorer.gui.dnd.KeyStoreEntryTransferable.java
/** * Get transfer data./*from w w w . j a v a2 s. c o m*/ * * @param dataFlavor * Data flavor * @return Transfer data * @throws UnsupportedFlavorException * If the requested data flavor is not supported * @throws IOException * If an I/O problem occurred */ @Override public Object getTransferData(DataFlavor dataFlavor) throws UnsupportedFlavorException, IOException { if (!isDataFlavorSupported(dataFlavor)) { throw new UnsupportedFlavorException(dataFlavor); } if (dataFlavor == DataFlavor.javaFileListFlavor) { String tempDir = System.getProperty("java.io.tmpdir"); File tmpFile = new File(tempDir, dragEntry.getFileName()); tmpFile.deleteOnExit(); FileOutputStream fos = null; try { fos = new FileOutputStream(tmpFile); fos.write(dragEntry.getContent()); } finally { IOUtils.closeQuietly(fos); } List<File> list = new ArrayList<File>(); list.add(tmpFile); return list; } else { return dragEntry.getContentString(); } }
From source file:FileTransferHandler.java
/** * This method returns true if the TransferHandler knows how to work with one * of the specified flavors. This implementation first checks the superclass, * then checks for fileListFlavor support *///from w ww.ja v a 2 s .c o m public boolean canImport(JComponent c, DataFlavor[] flavors) { // If the wrapped handler can import it, we're done if (wrappedHandler.canImport(c, flavors)) return true; // Otherwise, if the wrapped handler can handle string imports, then // see if we are being offered a list of files that we can convert // to a string. if (wrappedHandler.canImport(c, stringFlavorArray)) { for (int i = 0; i < flavors.length; i++) if (flavors[i].equals(DataFlavor.javaFileListFlavor)) return true; } // Otherwise, we can't import any of the flavors. return false; }
From source file:pl.otros.logview.gui.actions.read.DragAndDropFilesHandler.java
private boolean isListOfFiles(TransferSupport support) { boolean dataFlavorSupported = support.isDataFlavorSupported(DataFlavor.javaFileListFlavor); LOGGER.info("Data transfer is list of files: " + dataFlavorSupported); return dataFlavorSupported; }
From source file:com.mirth.connect.client.ui.components.MirthTableTransferHandler.java
@Override public boolean canImport(TransferSupport support) { if (support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { try {//from w ww . j av a 2 s. c o m List<File> fileList = (List<File>) support.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor); for (File file : fileList) { if (!FilenameUtils.isExtension(file.getName(), "xml")) { return false; } } return true; } catch (Exception e) { // Return true anyway until this bug is fixed: // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6759788 return true; } } return false; }
From source file:javazoom.jlgui.player.amp.skin.DropTargetAdapter.java
public void drop(DropTargetDropEvent e) { // Check DataFlavor DataFlavor[] dfs = e.getCurrentDataFlavors(); DataFlavor tdf = null;//from w w w . j av a 2s . c o m for (int i = 0; i < dfs.length; i++) { if (DataFlavor.javaFileListFlavor.equals(dfs[i])) { tdf = dfs[i]; break; } else if (DataFlavor.stringFlavor.equals(dfs[i])) { tdf = dfs[i]; break; } } // Data Flavor available ? if (tdf != null) { // Accept COPY DnD only. if ((e.getSourceActions() & DnDConstants.ACTION_COPY) != 0) { e.acceptDrop(DnDConstants.ACTION_COPY); } else return; try { Transferable t = e.getTransferable(); Object data = t.getTransferData(tdf); processDrop(data); } catch (IOException ioe) { log.info("Drop error", ioe); e.dropComplete(false); return; } catch (UnsupportedFlavorException ufe) { log.info("Drop error", ufe); e.dropComplete(false); return; } catch (Exception ex) { log.info("Drop error", ex); e.dropComplete(false); return; } e.dropComplete(true); } }
From source file:com.mirth.connect.client.ui.editors.JavaScriptEditorDialog.java
public void dragEnter(DropTargetDragEvent dtde) { try {/*from w w w.j a v a2 s.c o m*/ Transferable tr = dtde.getTransferable(); if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); java.util.List fileList = (java.util.List) tr.getTransferData(DataFlavor.javaFileListFlavor); Iterator iterator = fileList.iterator(); while (iterator.hasNext()) { iterator.next(); } } else { dtde.rejectDrag(); } } catch (Exception e) { dtde.rejectDrag(); } }
From source file:Dropper.java
/** * @see javax.swing.TransferHandler#canImport(javax.swing.JComponent, * java.awt.datatransfer.DataFlavor[]) *///from w w w .ja v a 2 s .com public boolean canImport(JComponent arg0, DataFlavor[] arg1) { for (int i = 0; i < arg1.length; i++) { DataFlavor flavor = arg1[i]; if (flavor.equals(DataFlavor.javaFileListFlavor)) { System.out.println("canImport: JavaFileList FLAVOR: " + flavor); return true; } if (flavor.equals(DataFlavor.stringFlavor)) { System.out.println("canImport: String FLAVOR: " + flavor); return true; } System.err.println("canImport: Rejected Flavor: " + flavor); } // Didn't find any that match, so: return false; }