List of usage examples for java.awt.dnd DropTargetDragEvent rejectDrag
public void rejectDrag()
From source file:javazoom.jlgui.player.amp.Player.java
/** * DnD : dragEnter implementation.//from w ww . j a v a 2 s .c o m */ public void dragEnter(DropTargetDragEvent e) { if (isDragOk(e) == false) { e.rejectDrag(); return; } }
From source file:javazoom.jlgui.player.amp.Player.java
/** * DnD : dragOver implementation.//from ww w . j a va 2s .c o m */ public void dragOver(DropTargetDragEvent e) { if (isDragOk(e) == false) { e.rejectDrag(); return; } }
From source file:javazoom.jlgui.player.amp.Player.java
/** * DnD : dropActionChanged implementation. *//*from ww w . j av a 2 s .com*/ public void dropActionChanged(DropTargetDragEvent e) { if (isDragOk(e) == false) { e.rejectDrag(); return; } }
From source file:org.jets3t.apps.cockpit.Cockpit.java
/** * Initialise the application's File drop targets for drag and drop copying of local files * to S3./*from w ww. ja va 2s . co m*/ * * @param dropTargetComponents * the components files can be dropped on to transfer them to S3 */ private void initDropTarget(JComponent[] dropTargetComponents) { DropTargetListener dropTargetListener = new DropTargetListener() { private boolean checkValidDrag(DropTargetDragEvent dtde) { if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor) && (DnDConstants.ACTION_COPY == dtde.getDropAction() || DnDConstants.ACTION_MOVE == dtde.getDropAction())) { dtde.acceptDrag(dtde.getDropAction()); return true; } else { dtde.rejectDrag(); return false; } } public void dragEnter(DropTargetDragEvent dtde) { if (checkValidDrag(dtde)) { SwingUtilities.invokeLater(new Runnable() { public void run() { objectsTable.requestFocusInWindow(); }; }); } } public void dragOver(DropTargetDragEvent dtde) { checkValidDrag(dtde); } public void dropActionChanged(DropTargetDragEvent dtde) { if (checkValidDrag(dtde)) { SwingUtilities.invokeLater(new Runnable() { public void run() { objectsTable.requestFocusInWindow(); }; }); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { ownerFrame.requestFocusInWindow(); }; }); } } public void dragExit(DropTargetEvent dte) { SwingUtilities.invokeLater(new Runnable() { public void run() { ownerFrame.requestFocusInWindow(); }; }); } public void drop(DropTargetDropEvent dtde) { if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor) && (DnDConstants.ACTION_COPY == dtde.getDropAction() || DnDConstants.ACTION_MOVE == dtde.getDropAction())) { dtde.acceptDrop(dtde.getDropAction()); try { final List fileList = (List) dtde.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor); if (fileList != null && fileList.size() > 0) { uploadFiles((File[]) fileList.toArray(new File[fileList.size()])); } } catch (Exception e) { String message = "Unable to start accept dropped items"; log.error(message, e); ErrorDialog.showDialog(ownerFrame, null, message, e); } } else { dtde.rejectDrop(); } } }; // Attach drop target listener to each target component. for (int i = 0; i < dropTargetComponents.length; i++) { new DropTarget(dropTargetComponents[i], DnDConstants.ACTION_COPY, dropTargetListener, true); } }
From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java
@Override public void dragEnter(DropTargetDragEvent dtde) { if (dtde.isDataFlavorSupported(VillageTransferable.villageDataFlavor) || dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) { if (dtde.getDropTargetContext().getComponent() == jSourcesTable || dtde.getDropTargetContext().getComponent() == jVictimTable) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } else {/* ww w . j a v a 2s.c om*/ dtde.rejectDrag(); } } else { dtde.rejectDrag(); } }
From source file:org.jets3t.apps.cockpitlite.CockpitLite.java
/** * Initialise the application's File drop targets for drag and drop copying of local files * to S3./*from www .ja va 2s.c o m*/ * * @param dropTargetComponents * the components files can be dropped on to transfer them to S3 */ private void initDropTarget(JComponent[] dropTargetComponents) { DropTargetListener dropTargetListener = new DropTargetListener() { private boolean checkValidDrag(DropTargetDragEvent dtde) { if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor) && (DnDConstants.ACTION_COPY == dtde.getDropAction() || DnDConstants.ACTION_MOVE == dtde.getDropAction())) { dtde.acceptDrag(dtde.getDropAction()); return true; } else { dtde.rejectDrag(); return false; } } public void dragEnter(DropTargetDragEvent dtde) { if (checkValidDrag(dtde)) { SwingUtilities.invokeLater(new Runnable() { public void run() { objectsTable.requestFocusInWindow(); }; }); } } public void dragOver(DropTargetDragEvent dtde) { checkValidDrag(dtde); } public void dropActionChanged(DropTargetDragEvent dtde) { if (checkValidDrag(dtde)) { SwingUtilities.invokeLater(new Runnable() { public void run() { objectsTable.requestFocusInWindow(); }; }); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { ownerFrame.requestFocusInWindow(); }; }); } } public void dragExit(DropTargetEvent dte) { SwingUtilities.invokeLater(new Runnable() { public void run() { ownerFrame.requestFocusInWindow(); }; }); } public void drop(DropTargetDropEvent dtde) { if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor) && (DnDConstants.ACTION_COPY == dtde.getDropAction() || DnDConstants.ACTION_MOVE == dtde.getDropAction())) { dtde.acceptDrop(dtde.getDropAction()); try { final List fileList = (List) dtde.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor); if (fileList != null && fileList.size() > 0) { new Thread() { @Override public void run() { prepareForFilesUpload((File[]) fileList.toArray(new File[fileList.size()])); } }.start(); } } catch (Exception e) { String message = "Unable to start accept dropped item(s)"; log.error(message, e); ErrorDialog.showDialog(ownerFrame, null, cockpitLiteProperties.getProperties(), message, e); } } else { dtde.rejectDrop(); } } }; // Attach drop target listener to each target component. for (int i = 0; i < dropTargetComponents.length; i++) { new DropTarget(dropTargetComponents[i], DnDConstants.ACTION_COPY, dropTargetListener, true); } }
From source file:org.kuali.test.ui.dnd.RepositoryDropTargetAdapter.java
@Override public void dragOver(DropTargetDragEvent dtde) { if (canDrop(dtde)) { dtde.acceptDrag(dtde.getDropAction()); } else {//from w ww . j a va2 s . co m dtde.acceptDrag(DnDConstants.ACTION_NONE); dtde.rejectDrag(); } }
From source file:org.pentaho.reporting.designer.core.util.dnd.GenericDNDHandler.java
/** * Called when a drag operation is ongoing, while the mouse pointer is still over the operable part of the drop site * for the <code>DropTarget</code> registered with this listener. * * @param dtde the <code>DropTargetDragEvent</code> *//*from w w w. ja v a2 s. c o m*/ public void dragOver(final DropTargetDragEvent dtde) { final Transferable transferable = dtde.getTransferable(); for (int i = 0; i < acceptedFlavors.length; i++) { final DataFlavor acceptedFlavor = acceptedFlavors[i]; if (transferable.isDataFlavorSupported(acceptedFlavor)) { // a transfer from the palette. try { transferData = transferable.getTransferData(acceptedFlavor); position = dtde.getLocation(); flavor = acceptedFlavor; final int result = updateDragOver(dtde); if (result > 0) { dtde.acceptDrag(DnDConstants.ACTION_COPY); } else { transferData = null; position = null; flavor = null; dtde.rejectDrag(); } break; } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("ReportPanel.dragOver ", e); // NON-NLS } transferData = null; position = null; flavor = null; dtde.rejectDrag(); } } } }
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 ww w .ja v a 2s . c o m dtde.rejectDrag(); } }