Java Code Examples for java.awt.dnd.DropTargetDragEvent#rejectDrag()
The following examples show how to use
java.awt.dnd.DropTargetDragEvent#rejectDrag() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainWindow.java From apkReSign with Apache License 2.0 | 6 votes |
@Override public void dragOver(DropTargetDragEvent dtde) { try { java.util.List files = (java.util.List) dtde.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor); if (files.size() != 1) { dtde.rejectDrag(); return; } if (((File) files.get(0)).getName().endsWith(".apk")) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } else { dtde.rejectDrag(); } } catch (Exception e) { } }
Example 2
Source File: AbstractTreeTransferHandler.java From binnavi with Apache License 2.0 | 6 votes |
@Override public final void dropActionChanged(final DropTargetDragEvent dtde) { final Point pt = dtde.getLocation(); final int action = dtde.getDropAction(); if (drawImage) { paintImage(pt); } if (draggedNode == null) { if (canPerformAction(tree, dtde.getCurrentDataFlavorsAsList().get(0), dtde.getTransferable(), action, pt)) { dtde.acceptDrag(action); } else { dtde.rejectDrag(); } } else { if (canPerformAction(tree, draggedNode, action, pt)) { dtde.acceptDrag(action); } else { dtde.rejectDrag(); } } }
Example 3
Source File: PortraitPanel.java From gcs with Mozilla Public License 2.0 | 5 votes |
private static void acceptOrRejectDrag(DropTargetDragEvent dtde) { if (dtde.isDataFlavorSupported(DataFlavor.imageFlavor) || dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrag(DnDConstants.ACTION_COPY); } else { dtde.rejectDrag(); } }
Example 4
Source File: DataObjectTransferHandler.java From nextreports-designer with Apache License 2.0 | 5 votes |
public void dragOver(DropTargetDragEvent event) { int dropAction = event.getDropAction(); if (canImport && actionSupported(dropAction)) { JTable table = (JTable) event.getDropTargetContext().getComponent(); int row = table.rowAtPoint(event.getLocation()); table.getSelectionModel().setSelectionInterval(row, row); event.acceptDrag(dropAction); } else { event.rejectDrag(); } }
Example 5
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override public void dragEnter(DropTargetDragEvent e) { if (isDragAcceptable(e)) { e.acceptDrag(e.getDropAction()); } else { e.rejectDrag(); } }
Example 6
Source File: OutlineHeader.java From gcs with Mozilla Public License 2.0 | 5 votes |
@Override public void dropActionChanged(DropTargetDragEvent dtde) { if (mOwner.getSourceDragColumn() != null) { mOwner.dropActionChanged(dtde); } else { dtde.rejectDrag(); } }
Example 7
Source File: GenericDNDHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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> */ 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(); } } } }
Example 8
Source File: QueryBuilderPanel.java From nextreports-designer with Apache License 2.0 | 5 votes |
public void dragOver(DropTargetDragEvent dtde) { if (isDragOk(dtde)) { dtde.acceptDrag(DnDConstants.ACTION_MOVE); } else { dtde.rejectDrag(); } }
Example 9
Source File: DragDropHandler.java From TinkerTime with GNU General Public License v3.0 | 5 votes |
@Override public void dragEnter(DropTargetDragEvent dtde) { try { File file = getFile(dtde.getTransferable()); if (isZip(file) || isUrl(file)){ dtde.acceptDrag(DnDConstants.ACTION_LINK); } else { dtde.rejectDrag(); } } catch (UnsupportedFlavorException | IOException e) { e.printStackTrace(); dtde.rejectDrag(); } listenTo.repaint(); }
Example 10
Source File: DBTableInternalFrame.java From nextreports-designer with Apache License 2.0 | 5 votes |
public void dragEnter(DropTargetDragEvent dtde) { if (isDragOk(dtde)) { selectRowAtPoint(dtde.getLocation()); dtde.acceptDrag(DnDConstants.ACTION_MOVE); } else { dtde.rejectDrag(); } }
Example 11
Source File: MetaDataPanel.java From Pixelitor with GNU General Public License v3.0 | 5 votes |
private static void handleOngoingDrag(DropTargetDragEvent dtde) { if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrag(DnDConstants.ACTION_COPY); } else { dtde.rejectDrag(); } }
Example 12
Source File: AbstractTreeTransferHandler.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
public final void dragEnter(DropTargetDragEvent dtde) { Point pt = dtde.getLocation(); int action = dtde.getDropAction(); if (drawImage) { paintImage(pt); } if (canPerformAction(tree, draggedNode, action, pt)) { dtde.acceptDrag(action); } else { dtde.rejectDrag(); } }
Example 13
Source File: JTreeUtil.java From Logisim with GNU General Public License v3.0 | 5 votes |
@Override public final void dragOver(DropTargetDragEvent dtde) { Point pt = dtde.getLocation(); int action = dtde.getDropAction(); autoscroll(tree, pt); if (drawImage) { paintImage(pt); } if (controller.canPerformAction(tree, draggedNode, action, pt)) { dtde.acceptDrag(action); } else { dtde.rejectDrag(); } }
Example 14
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override public void dragOver(DropTargetDragEvent e) { if (e.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { e.acceptDrag(DnDConstants.ACTION_COPY); return; } e.rejectDrag(); }
Example 15
Source File: Dock.java From gcs with Mozilla Public License 2.0 | 5 votes |
@Override public void dropActionChanged(DropTargetDragEvent dtde) { mDragDockable = getDockableInDrag(dtde); if (mDragDockable != null) { updateForDragOver(dtde.getLocation()); dtde.acceptDrag(DnDConstants.ACTION_MOVE); } else { clearDragState(); dtde.rejectDrag(); } }
Example 16
Source File: TemplateSheet.java From gcs with Mozilla Public License 2.0 | 5 votes |
@Override public void dragOver(DropTargetDragEvent dtde) { if (mDragWasAcceptable) { dtde.acceptDrag(DnDConstants.ACTION_MOVE); } else { dtde.rejectDrag(); } }
Example 17
Source File: DnDSupport.java From netbeans with Apache License 2.0 | 5 votes |
public void dragOver(DropTargetDragEvent e) { if( e.isDataFlavorSupported( buttonDataFlavor ) || e.isDataFlavorSupported( actionDataFlavor ) ) { updateDropGesture( e ); if( !validateDropPosition() ) { e.rejectDrag(); } else { e.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE ); } } else if( e.isDataFlavorSupported( toolbarDataFlavor ) ) { e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } else { e.rejectDrag(); } }
Example 18
Source File: TraceTabbedPane.java From pega-tracerviewer with Apache License 2.0 | 5 votes |
@Override public void dropActionChanged(DropTargetDragEvent dtde) { if (isDragOk(dtde)) { dtde.acceptDrag(DnDConstants.ACTION_NONE); } else { dtde.rejectDrag(); } }
Example 19
Source File: MMDEditor.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
@Override public void dragOver(@Nonnull final DropTargetDragEvent dtde) { if (acceptOrRejectDragging(dtde)) { dtde.acceptDrag(DnDConstants.ACTION_MOVE); } else { dtde.rejectDrag(); } this.scrollPane.repaint(); }
Example 20
Source File: mxGraphHandler.java From blog-codes with Apache License 2.0 | 4 votes |
/** * * @param e */ public void dragOver(DropTargetDragEvent e) { if (canImport) { mouseDragged(createEvent(e)); mxGraphTransferHandler handler = getGraphTransferHandler(e); if (handler != null) { mxGraph graph = graphComponent.getGraph(); double scale = graph.getView().getScale(); Point pt = SwingUtilities.convertPoint(graphComponent, e.getLocation(), graphComponent.getGraphControl()); pt = graphComponent.snapScaledPoint(new mxPoint(pt)).getPoint(); handler.setLocation(new Point(pt)); int dx = 0; int dy = 0; // Centers the preview image if (centerPreview && transferBounds != null) { dx -= Math.round(transferBounds.getWidth() * scale / 2); dy -= Math.round(transferBounds.getHeight() * scale / 2); } // Sets the drop offset so that the location in the transfer // handler reflects the actual mouse position handler.setOffset(new Point((int) graph.snap(dx / scale), (int) graph.snap(dy / scale))); pt.translate(dx, dy); // Shifts the preview so that overlapping parts do not // affect the centering if (transferBounds != null && dragImage != null) { dx = (int) Math .round((dragImage.getIconWidth() - 2 - transferBounds .getWidth() * scale) / 2); dy = (int) Math .round((dragImage.getIconHeight() - 2 - transferBounds .getHeight() * scale) / 2); pt.translate(-dx, -dy); } if (!handler.isLocalDrag() && previewBounds != null) { setPreviewBounds(new Rectangle(pt, previewBounds.getSize())); } } } else { e.rejectDrag(); } }