java.awt.dnd.DropTargetDragEvent Java Examples
The following examples show how to use
java.awt.dnd.DropTargetDragEvent.
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: FileDrop.java From PDF4Teachers with Apache License 2.0 | 6 votes |
@SuppressWarnings("rawtypes") public void dragEnter(DropTargetDragEvent e){ Transferable transferable = e.getTransferable(); DataFlavor[] types = transferable.getTransferDataFlavors(); for(DataFlavor type : types){ try{ if(type.equals(DataFlavor.javaFileListFlavor)){ e.acceptDrag(DnDConstants.ACTION_COPY); Iterator iterator = ((List) transferable.getTransferData(type)).iterator(); File file = (File) iterator.next(); if(isFileAcceptable(file)){ e.acceptDrag(1); }else{ e.rejectDrag(); } } }catch (Exception e1){ e1.printStackTrace(); } } }
Example #2
Source File: AbstractTreeTransferHandler.java From binnavi with Apache License 2.0 | 6 votes |
@Override public final void dragEnter(final DropTargetDragEvent dtde) { final Point pt = dtde.getLocation(); final int action = dtde.getDropAction(); if (drawImage) { paintImage(pt); } final Transferable transferable = dtde.getTransferable(); if (!transferable.isDataFlavorSupported(TransferableNode.NODE_FLAVOR)) { 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: 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 #4
Source File: Outline.java From gcs with Mozilla Public License 2.0 | 6 votes |
@Override public void dragEnter(DropTargetDragEvent dtde) { mDragWasAcceptable = isDragAcceptable(dtde); if (mDragWasAcceptable) { if (mModel.getDragColumn() != null) { dtde.acceptDrag(dragEnterColumn(dtde)); return; } Row[] rows = mModel.getDragRows(); if (rows != null && rows.length > 0) { dtde.acceptDrag(dragEnterRow(dtde)); return; } } else if (mAlternateDragDestination != null) { UIUtilities.updateDropTargetDragPointTo(dtde, mAlternateDragDestination); mAlternateDragDestination.dragEnter(dtde); return; } dtde.rejectDrag(); }
Example #5
Source File: Outline.java From gcs with Mozilla Public License 2.0 | 6 votes |
@Override public void dropActionChanged(DropTargetDragEvent dtde) { if (mDragWasAcceptable) { Row[] rows; if (mModel.getDragColumn() != null) { dtde.acceptDrag(dropActionChangedColumn(dtde)); return; } rows = mModel.getDragRows(); if (rows != null && rows.length > 0) { dtde.acceptDrag(dropActionChangedRow(dtde)); return; } } else if (mAlternateDragDestination != null) { UIUtilities.updateDropTargetDragPointTo(dtde, mAlternateDragDestination); mAlternateDragDestination.dropActionChanged(dtde); return; } dtde.rejectDrag(); }
Example #6
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 #7
Source File: MMDGraphEditor.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
@Override public void dragOver(final DropTargetDragEvent dtde) { if (acceptOrRejectDragging(dtde)) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } else { dtde.rejectDrag(); } }
Example #8
Source File: PaletteDropTarget.java From niftyeditor with Apache License 2.0 | 5 votes |
@Override public synchronized void dragOver(DropTargetDragEvent dtde){ super.dragOver(dtde); J2DNiftyView comp = (J2DNiftyView) this.getComponent(); if(dtde.getDropAction() == DnDConstants.ACTION_MOVE && dtde.getTransferable().isDataFlavorSupported(WidgetData.POINTFLAVOR)){ comp.moveRect(dtde.getLocation().x, dtde.getLocation().y); comp.getDDManager().dragAround(dtde.getLocation().x, dtde.getLocation().y); } }
Example #9
Source File: MissingDragExitEventTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void dragEnter(final DropTargetDragEvent dtde) { if (inside) { FAILED = true; Thread.dumpStack(); } inside = true; MOUSE_ENTERED_DT = true; try { Thread.sleep(10000); // we should have time to leave a component } catch (InterruptedException ignored) { } }
Example #10
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 #11
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override public void dropActionChanged(DropTargetDragEvent e) { // if (isDragAcceptable(e)) { // e.acceptDrag(e.getDropAction()); // } else { // e.rejectDrag(); // } }
Example #12
Source File: IndexedCustomizer.java From netbeans with Apache License 2.0 | 5 votes |
/** User is starting to drag over us */ public void dragEnter(DropTargetDragEvent dtde) { if (!checkConditions(dtde)) { dtde.rejectDrag(); } else { lastIndex = comp.locationToIndex(dtde.getLocation()); cellRenderer.draggingEnter(lastIndex, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation()); comp.repaint(comp.getCellBounds(lastIndex, lastIndex)); } }
Example #13
Source File: MissingDragExitEventTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public void dragEnter(final DropTargetDragEvent dtde) { if (inside) { FAILED = true; Thread.dumpStack(); } inside = true; MOUSE_ENTERED_DT = true; try { Thread.sleep(10000); // we should have time to leave a component } catch (InterruptedException ignored) { } }
Example #14
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 #15
Source File: CharacterSheet.java From gcs with Mozilla Public License 2.0 | 5 votes |
@Override public void dragEnter(DropTargetDragEvent dtde) { mDragWasAcceptable = false; try { if (dtde.isDataFlavorSupported(RowSelection.DATA_FLAVOR)) { Row[] rows = (Row[]) dtde.getTransferable().getTransferData(RowSelection.DATA_FLAVOR); if (rows.length > 0) { mDragRows = new ArrayList<>(rows.length); for (Row element : rows) { if (element instanceof ListRow) { mDragRows.add(element); } } if (!mDragRows.isEmpty()) { mDragWasAcceptable = true; dtde.acceptDrag(DnDConstants.ACTION_MOVE); } } } } catch (Exception exception) { Log.error(exception); } if (!mDragWasAcceptable) { dtde.rejectDrag(); } }
Example #16
Source File: MenuEditLayer.java From netbeans with Apache License 2.0 | 5 votes |
private boolean shouldRedispatchDnDToHandle(DropTargetDragEvent dtde) { RADComponent rad = formDesigner.getHandleLayer().getMetaComponentAt(dtde.getLocation(), HandleLayer.COMP_DEEPEST); if(rad != null && isMenuRelatedComponentClass(rad.getBeanClass())) { return false; } if(!USE_JSEPARATOR_FIX) return false; PaletteItem item = PaletteUtils.getSelectedItem(); if(item != null && JSeparator.class.isAssignableFrom(item.getComponentClass())) { return true; } return false; }
Example #17
Source File: MissingDragExitEventTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public void dragEnter(final DropTargetDragEvent dtde) { if (inside) { FAILED = true; Thread.dumpStack(); } inside = true; MOUSE_ENTERED_DT = true; try { Thread.sleep(10000); // we should have time to leave a component } catch (InterruptedException ignored) { } }
Example #18
Source File: MissingDragExitEventTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void dragOver(final DropTargetDragEvent dtde) { if (!inside) { FAILED = true; Thread.dumpStack(); } }
Example #19
Source File: Dock.java From gcs with Mozilla Public License 2.0 | 5 votes |
@Override public void dragOver(DropTargetDragEvent dtde) { if (mDragDockable != null) { updateForDragOver(dtde.getLocation()); dtde.acceptDrag(DnDConstants.ACTION_MOVE); } else { dtde.rejectDrag(); } }
Example #20
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 #21
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 #22
Source File: CompEditorPanel.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void dragUnderFeedback(boolean ok, DropTargetDragEvent e) { synchronized (table) { int dropAction = e.getDropAction(); boolean actionChanged = false; if (dropAction != lastDndAction) { actionChanged = true; lastDndAction = dropAction; } if (table.isEditing()) { table.editingCanceled(null); } boolean inserting = false; if (dropAction == DnDConstants.ACTION_COPY) { inserting = true; } dndTableCellRenderer.selectRange(inserting); dndDtiCellRenderer.selectRange(inserting); Point p = e.getLocation(); int row = table.rowAtPoint(p); boolean setRow = dndTableCellRenderer.setRowForFeedback(row); boolean setDtiRow = dndDtiCellRenderer.setRowForFeedback(row); if (actionChanged || setRow || setDtiRow) { table.repaint(); } } }
Example #23
Source File: ProcessRendererDropTarget.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@Override public void dragEnter(final DropTargetDragEvent e) { super.dragEnter(e); if (dropTragetListenerList != null) { Object[] listeners = dropTragetListenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == DropTargetListener.class) { ((DropTargetListener) listeners[i + 1]).dragEnter(e); } } } }
Example #24
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 #25
Source File: MissingDragExitEventTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public void dragEnter(final DropTargetDragEvent dtde) { if (inside) { FAILED = true; Thread.dumpStack(); } inside = true; MOUSE_ENTERED_DT = true; try { Thread.sleep(10000); // we should have time to leave a component } catch (InterruptedException ignored) { } }
Example #26
Source File: CalculationTree.java From swing_library with MIT License | 5 votes |
private void doDragOver(DropTargetDragEvent dtde) { if (acceptDrag(dtde)) dtde.acceptDrag(dtde.getDropAction()); else dtde.rejectDrag(); }
Example #27
Source File: DndTabbedPaneDropTargetListener.java From bigtable-sql with Apache License 2.0 | 5 votes |
@Override public void dragEnter(DropTargetDragEvent e) { if (isDragAcceptable(e)) { e.acceptDrag(e.getDropAction()); } else { e.rejectDrag(); } }
Example #28
Source File: AdvantageOutline.java From gcs with Mozilla Public License 2.0 | 4 votes |
@Override protected boolean isRowDragAcceptable(DropTargetDragEvent dtde, Row[] rows) { return !getModel().isLocked() && rows.length > 0 && (rows[0] instanceof Advantage || rows[0] instanceof AdvantageModifier); }
Example #29
Source File: MetaDataPanel.java From Pixelitor with GNU General Public License v3.0 | 4 votes |
@Override public void dragEnter(DropTargetDragEvent dtde) { handleOngoingDrag(dtde); }
Example #30
Source File: FileDropTargetListener.java From magarena with GNU General Public License v3.0 | 4 votes |
@Override public void dragEnter(DropTargetDragEvent event) { }