Java Code Examples for java.awt.dnd.DropTargetDragEvent#isDataFlavorSupported()
The following examples show how to use
java.awt.dnd.DropTargetDragEvent#isDataFlavorSupported() .
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: DataDropOnBrowserHandler.java From ghidra with Apache License 2.0 | 6 votes |
/** * @see ghidra.app.util.ProgramDropProvider#isDropOk(java.lang.Object, java.awt.dnd.DropTargetDragEvent) */ public boolean isDropOk(Object contextObj, DropTargetDragEvent evt) { curService = null; if (!evt.isDataFlavorSupported(DataTypeTransferable.localDataTypeFlavor) && !evt.isDataFlavorSupported(DataTypeTransferable.localBuiltinDataTypeFlavor) ) return false; if (contextObj != null && contextObj instanceof ListingActionContext) { ListingActionContext pl = (ListingActionContext)contextObj; DataService[] services = plugin.getTool().getServices(DataService.class); for (int i=0; i<services.length; i++) { if (services[i].isCreateDataAllowed(pl)) { curService = services[i]; return true; } } } return false; }
Example 2
Source File: Outline.java From gcs with Mozilla Public License 2.0 | 6 votes |
/** * @param dtde The drop target drag event. * @return {@code true} if the contents of the drag can be dropped into this outline. */ protected boolean isDragAcceptable(DropTargetDragEvent dtde) { boolean result = false; mAlternateDragDestination = null; try { if (dtde.isDataFlavorSupported(Column.DATA_FLAVOR)) { Column column = (Column) dtde.getTransferable().getTransferData(Column.DATA_FLAVOR); result = isColumnDragAcceptable(dtde, column); if (result) { mModel.setDragColumn(column); } } else if (dtde.isDataFlavorSupported(RowSelection.DATA_FLAVOR)) { Row[] rows = (Row[]) dtde.getTransferable().getTransferData(RowSelection.DATA_FLAVOR); result = isRowDragAcceptable(dtde, rows); if (result) { mModel.setDragRows(rows); } } else if (dtde.isDataFlavorSupported(DockableTransferable.DATA_FLAVOR)) { mAlternateDragDestination = UIUtilities.getAncestorOfType(this, Dock.class); } } catch (Exception exception) { Log.error(exception); } return result; }
Example 3
Source File: TreePanel.java From gcs with Mozilla Public License 2.0 | 6 votes |
/** * @param event The {@link DropTargetDragEvent}. * @return A newly created {@link TreeDragState}, or {@code null} if the drag was not * acceptable. */ protected TreeDragState checkDragAcceptability(DropTargetDragEvent event) { mAlternateDragDestination = null; try { if (event.isDataFlavorSupported(TreeColumn.DATA_FLAVOR)) { TreeColumn column = (TreeColumn) event.getTransferable().getTransferData(TreeColumn.DATA_FLAVOR); if (isColumnDragAcceptable(event, column)) { return new TreeColumnDragState(this, column); } } if (event.isDataFlavorSupported(TreeRowSelection.DATA_FLAVOR)) { TreeRowSelection rowSelection = (TreeRowSelection) event.getTransferable().getTransferData(TreeRowSelection.DATA_FLAVOR); List<TreeRow> rows = rowSelection.getRows(); if (!rows.isEmpty() && isRowDragAcceptable(event, rows)) { return new TreeRowDragState(this, rowSelection); } } if (event.isDataFlavorSupported(DockableTransferable.DATA_FLAVOR)) { mAlternateDragDestination = UIUtilities.getAncestorOfType(this, Dock.class); } } catch (Exception exception) { Log.error(exception); } return null; }
Example 4
Source File: DockHeader.java From gcs with Mozilla Public License 2.0 | 6 votes |
private Dockable getDockableInDrag(DropTargetDragEvent dtde) { if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) { try { if (dtde.isDataFlavorSupported(DockableTransferable.DATA_FLAVOR)) { Dockable dockable = (Dockable) dtde.getTransferable().getTransferData(DockableTransferable.DATA_FLAVOR); DockContainer dc = dockable.getDockContainer(); if (dc != null && dc.getDock() == getDockContainer().getDock()) { return dockable; } } } catch (Exception exception) { Log.error(exception); } } return null; }
Example 5
Source File: Dock.java From gcs with Mozilla Public License 2.0 | 6 votes |
private Dockable getDockableInDrag(DropTargetDragEvent dtde) { if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) { try { if (dtde.isDataFlavorSupported(DockableTransferable.DATA_FLAVOR)) { Dockable dockable = (Dockable) dtde.getTransferable().getTransferData(DockableTransferable.DATA_FLAVOR); DockContainer dc = dockable.getDockContainer(); if (dc != null && dc.getDock() == this) { return dockable; } } } catch (Exception exception) { Log.error(exception); } } return null; }
Example 6
Source File: TemplateSheet.java From gcs with Mozilla Public License 2.0 | 6 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 7
Source File: DnDSupport.java From netbeans with Apache License 2.0 | 5 votes |
public void dragEnter(DropTargetDragEvent e) { if( e.isDataFlavorSupported( buttonDataFlavor ) || e.isDataFlavorSupported( actionDataFlavor ) ) { e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); isButtonDrag = true; //in case use is dragging something from the customizer window } else if( e.isDataFlavorSupported( toolbarDataFlavor ) ) { e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } else { e.rejectDrag(); } }
Example 8
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 9
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 10
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 11
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 12
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override public void dragOver(DropTargetDragEvent dtde) { if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrag(DnDConstants.ACTION_COPY); return; } dtde.rejectDrag(); }
Example 13
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 14
Source File: DropListener.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 15
Source File: MainDropTarget.java From jadx with Apache License 2.0 | 5 votes |
protected void processDrag(DropTargetDragEvent dtde) { if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrag(DnDConstants.ACTION_COPY); } else { dtde.rejectDrag(); } }
Example 16
Source File: AbstractDSWorkbenchFrame.java From dsworkbench with Apache License 2.0 | 4 votes |
@Override public void dragEnter(DropTargetDragEvent dtde) { if (dtde.isDataFlavorSupported(VillageTransferable.villageDataFlavor) || dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } }