List of usage examples for java.awt.dnd DropTargetDragEvent getCurrentDataFlavors
public DataFlavor[] getCurrentDataFlavors()
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 w ww. j a v a 2s. c om break; } } return result; }
From source file:javazoom.jlgui.player.amp.skin.DropTargetAdapter.java
protected boolean isDragOk(DropTargetDragEvent e) { // Check DataFlavor DataFlavor[] dfs = e.getCurrentDataFlavors(); DataFlavor tdf = null;// w w w.j a va 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; } } // Only file list allowed. if (tdf != null) { // Only DnD COPY allowed. if ((e.getSourceActions() & DnDConstants.ACTION_COPY) != 0) { return true; } else return false; } else return false; }
From source file:PanelDropTarget.java
protected void checkTransferType(DropTargetDragEvent dtde) { // Only accept a flavor that returns a Component acceptableType = false;/* w w w . ja v a 2 s .c o m*/ DataFlavor[] fl = dtde.getCurrentDataFlavors(); for (int i = 0; i < fl.length; i++) { Class dataClass = fl[i].getRepresentationClass(); if (Component.class.isAssignableFrom(dataClass)) { // This flavor returns a Component - accept it. targetFlavor = fl[i]; acceptableType = true; break; } } DnDUtils.debugPrintln("File type acceptable - " + acceptableType); }
From source file:EditorDropTarget2.java
protected void checkTransferType(DropTargetDragEvent dtde) { // Accept a list of files, or data content that // amounts to plain text or a Unicode text string acceptableType = false;/*from w w w . jav a 2 s . co m*/ draggingFile = false; if (DnDUtils.isDebugEnabled()) { DataFlavor[] flavors = dtde.getCurrentDataFlavors(); for (int i = 0; i < flavors.length; i++) { DataFlavor flavor = flavors[i]; DnDUtils.debugPrintln("Drop MIME type " + flavor.getMimeType() + " is available"); } } if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { acceptableType = true; draggingFile = true; } else if (dtde.isDataFlavorSupported(DataFlavor.plainTextFlavor) || dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) { acceptableType = true; } DnDUtils.debugPrintln("File type acceptable - " + acceptableType); }
From source file:javazoom.jlgui.player.amp.Player.java
/** * Checks if Drag allowed.// w w w . j a va 2 s. com */ protected boolean isDragOk(DropTargetDragEvent e) { // Check DataFlavor DataFlavor[] dfs = e.getCurrentDataFlavors(); DataFlavor tdf = null; for (int i = 0; i < dfs.length; i++) { if (DataFlavor.javaFileListFlavor.equals(dfs[i])) { tdf = dfs[i]; break; } } // Only file list allowed. if (tdf != null) { // Only DnD COPY allowed. if ((e.getSourceActions() & DnDConstants.ACTION_COPY) != 0) { return true; } else return false; } else return false; }
From source file:tvbrowser.ui.mainframe.MainFrame.java
@Override public void dragEnter(DropTargetDragEvent dtde) { File[] files = getDragDropPlugins(dtde.getCurrentDataFlavors(), dtde.getTransferable()); if (files.length > 0) { dtde.acceptDrag(dtde.getDropAction()); } else {//from w w w . j a v a 2 s . c o m dtde.rejectDrag(); } }