Java Code Examples for java.awt.dnd.DragGestureEvent#getDragAction()
The following examples show how to use
java.awt.dnd.DragGestureEvent#getDragAction() .
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: RepositoryGlobalSearchGUIProvider.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
@Override public void dragGestureRecognized(DragGestureEvent event) { // only allow dragging with left mouse button if (event.getTriggerEvent().getModifiers() != InputEvent.BUTTON1_MASK) { return; } // change cursor to drag move Cursor cursor = null; if (event.getDragAction() == DnDConstants.ACTION_COPY) { cursor = DragSource.DefaultCopyDrop; } // set the repository entry as the Transferable TransferableRepositoryEntry transferable = new TransferableRepositoryEntry(location); if (usageLogger != null) { transferable.setUsageStatsLogger(usageLogger); } else if (usageObject != null) { transferable.setUsageObject(usageObject); } event.startDrag(cursor, transferable); }
Example 2
Source File: OperatorGlobalSearchGUIProvider.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
@Override public void dragGestureRecognized(DragGestureEvent event) { // only allow dragging with left mouse button if (event.getTriggerEvent().getModifiers() != InputEvent.BUTTON1_MASK) { return; } // change cursor to drag move Cursor cursor = null; if (event.getDragAction() == DnDConstants.ACTION_COPY) { cursor = DragSource.DefaultCopyDrop; } // set the recommended operator as the Transferable TransferableOperator transferable = new TransferableOperator(new Operator[]{operator}); if (usageLogger != null) { transferable.setUsageStatsLogger(usageLogger); } else if (usageObject != null) { transferable.setUsageObject(usageObject); } event.startDrag(cursor, transferable); }
Example 3
Source File: IndexedCustomizer.java From netbeans with Apache License 2.0 | 5 votes |
/** Initiating the drag */ public void dragGestureRecognized(DragGestureEvent dge) { // check allowed actions if ((dge.getDragAction() & DnDConstants.ACTION_MOVE) == 0) { return; } // prepare transferable and start the drag int index = comp.locationToIndex(dge.getDragOrigin()); // no index, then no dragging... if (index < 0) { return; } // System.out.println("Starting drag..."); // NOI18N // create our flavor for transferring the index myFlavor = new DataFlavor( String.class, NbBundle.getBundle(IndexedCustomizer.class).getString("IndexedFlavor") ); try { dge.startDrag(DragSource.DefaultMoveDrop, new IndexTransferable(myFlavor, index), this); // remember the gesture this.dge = dge; } catch (InvalidDnDOperationException exc) { Logger.getLogger(IndexedCustomizer.class.getName()).log(Level.WARNING, null, exc); // PENDING notify user - cannot start the drag } }
Example 4
Source File: TreePanel.java From gcs with Mozilla Public License 2.0 | 5 votes |
@Override public void dragGestureRecognized(DragGestureEvent event) { mDropReceived = false; int dragAction = event.getDragAction(); Point where = new Point(event.getDragOrigin()); switch (checkAndConvertToArea(where)) { case CONTENT: if (!mIgnoreNextDragGesture && mDragColumnDivider == -1 && !mSelectedRows.isEmpty() && (dragAction & mAllowedRowDragTypes) != 0) { TreeRowSelection selection = new TreeRowSelection(getSelectedRows(), mOpenRows); if (DragSource.isDragImageSupported()) { Img dragImage = createDragImage(where); Point imageOffset; Rectangle dragClip = getDragClip(); imageOffset = dragClip != null ? new Point(dragClip.x - where.x, dragClip.y - where.y) : new Point(); event.startDrag(null, dragImage, imageOffset, selection, this); } else { event.startDrag(null, selection, this); } } break; case HEADER: if (mAllowColumnDrag && dragAction == DnDConstants.ACTION_MOVE && mSortColumn != null) { setSourceDragColumn(mSortColumn); if (DragSource.isDragImageSupported()) { event.startDrag(null, createColumnDragImage(mSortColumn), new Point(-(where.x - getColumnStart(mSortColumn)), -where.y), mSortColumn, this); } else { event.startDrag(null, mSortColumn, this); } } mSortColumn = null; break; default: break; } }
Example 5
Source File: EntityPallet.java From jaamsim with Apache License 2.0 | 5 votes |
@Override public void dragGestureRecognized(DragGestureEvent event) { TreePath path = tree.getSelectionPath(); if (path != null) { // Dragged node is a DefaultMutableTreeNode if(path.getLastPathComponent() instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) path.getLastPathComponent(); // This is an ObjectType node if(treeNode.getUserObject() instanceof ObjectType) { ObjectType type = (ObjectType) treeNode.getUserObject(); Cursor cursor = null; if (event.getDragAction() == DnDConstants.ACTION_COPY) { cursor = DragSource.DefaultCopyDrop; } if (RenderManager.isGood()) { // The new renderer is initialized RenderManager.inst().startDragAndDrop(type); event.startDrag(cursor,new TransferableObjectType(type), RenderManager.inst()); } else { event.startDrag(cursor,new TransferableObjectType(type)); } } } } }