Java 8 DropTargetDropEvent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DropTargetDropEvent class.

This code example shows how to use the following methods:acceptDrop, dropComplete, getTransferable, isDataFlavorSupported, rejectDrop
7
CodeRank
This code example shows how to use the following methods:acceptDrop, dropComplete, getDropAction, getTransferable, rejectDrop
 
    public void dragExit( DropTargetEvent evt ) {
    } 
 
    public void drop( DropTargetDropEvent evt ) {
        int dropAction = evt.getDropAction();
        TransferHandler importer = getTransferHandler();
        if ( canImport && actionSupported( dropAction ) ) {
            evt.acceptDrop( dropAction );
            try { 
                Transferable trans = evt.getTransferable();
                evt.dropComplete( importer.importData( comp, trans ) );
            } 
            catch ( RuntimeException e ) {
                e.printStackTrace();
                evt.dropComplete( false );
            } 
        } 
        else { 
            evt.rejectDrop();

6
CodeRank
This code example shows how to use the following methods:acceptDrop, dropComplete, getCurrentDataFlavors, getTransferable, rejectDrop
 
    public void dragExit(DropTargetEvent e) {
    } 
 
    public void drop(DropTargetDropEvent e) {
        DataFlavor[] flavors = e.getCurrentDataFlavors();
        DropTargetContext ctx = e.getDropTargetContext();
        JComponent c = (JComponent)ctx.getComponent();
        LimeTransferHandler handler = (LimeTransferHandler)c.getTransferHandler();
        DropDropInfo ddi = new DropDropInfo(e);
         
        if(handler != null && handler.canImport(c, flavors, ddi) && actionSupported(ddi.action)) {
            e.acceptDrop(ddi.action);
 
            try { 
                Transferable t = e.getTransferable();
                e.dropComplete(handler.importData(c, t, ddi));
            } catch (RuntimeException re) {
                e.dropComplete(false);
            } 

6
CodeRank
This code example shows how to use the following methods:acceptDrop, dropComplete, getDropAction, rejectDrop
    } 
 
    public void drop(DropTargetDropEvent dtde) {
        if (targetPath != null) {
            try { 
                dtde.acceptDrop(dtde.getDropAction());
                DefaultMutableTreeNode target = (DefaultMutableTreeNode) targetPath.getLastPathComponent();
                DefaultMutableTreeNode parent = (DefaultMutableTreeNode) parentPath.getLastPathComponent();
 
                if (target.getUserObject() instanceof DataNodeDescriptor && parent.getUserObject() instanceof DataMap) {
                    DataNodeDescriptor currentDataNode = (DataNodeDescriptor) target.getUserObject();
                    DataMap currentDataMap = (DataMap) parent.getUserObject();
 
                    LinkDataMapAction action = eventController.getApplication().getActionManager().getAction(LinkDataMapAction.class);
                    action.linkDataMap(currentDataMap, currentDataNode);
 
                    targetTree.makeVisible(targetPath.pathByAddingChild(target));
                    dtde.dropComplete(true);
                } 
            } catch (Exception e) {

6
CodeRank
This code example shows how to use the following methods:acceptDrop, getDropTargetContext
        //Transferable stuff = dtde.getTransferable(); 
         
        /* 
         * @todo check DataFlavor of stuff 
         */ 
        dtde.acceptDrop(DnDConstants.ACTION_MOVE);
 
        if (movingItems) {
            /* 
             * This is a local drag and drop to reorder items 
             */ 
            DnDListModel<T> model = getModel();
            model.moveItems(overIndex, dragIndices);
 
        } else { 
 
            // @todo stuff dragged from other list 
 
        } 
 

5
CodeRank
This code example shows how to use the following methods:acceptDrop, dropComplete, getDropAction
		event.startDrag(cursor, new NodeTransferable(transferNode), this);
	} 
	// DropTargetListener methods 
	public void drop(DropTargetDropEvent event)
	{ 
		event.acceptDrop(event.getDropAction());
		 
		boolean success = false;
		try 
		{ 
			success = handleDrop(event);
		} 
		//these exceptions should not happen: 
		//	the flavor is checked and the returned 
		//	data requires no IO 
		catch(final IOException ioe)
		{ 
			success = false;
		} 
		catch(final UnsupportedFlavorException ufe)

4
CodeRank
This code example shows how to use the following methods:isDataFlavorSupported
This code example shows how to use the following methods:rejectDrop
	public boolean acceptDrop(DataFlavor[] flavors) {
		return false; 
	} 
 
	public boolean processDrop(DropTargetDropEvent event) {
		event.rejectDrop();
		return true; 
	} 
	 
	public boolean setIcons(DefaultTreeCellRenderer renderer) {
		File file = URIUtils.getAbsoluteFile(getLinkURI());
		if((file == null || !file.exists()) && !isSystem()) {
			renderer.setLeafIcon(NOT_EXISTING);
			renderer.setOpenIcon(NOT_EXISTING);
			renderer.setClosedIcon(NOT_EXISTING);
			return true; 
		} 
		if(fileIcon == null) {
			if(linkPath != null) {			
				fileIcon = WorkspaceController.getCurrentModeExtension().getView().getNodeTypeIconManager().getIconForNode(this);
4
CodeRank
This code example shows how to use the following methods:rejectDrop
    if (band == null)
    { 
      final Element defaultEntry = dragContext.getDefaultElement();
      if (defaultEntry instanceof Band == false) 
      { 
        event.rejectDrop();
        dragContext.getRepresentationContainer().removeAll();
        return null; 
      } 
      band = (Band) defaultEntry;
    } 
    return band;
  } 
 
  protected double getParentX(final Section band)
  { 
    final CachedLayoutData data = ModelUtility.getCachedLayoutData(band);
    if (data.getLayoutAge() == -1)
    { 
      return getParentX(band.getParentSection());
4
CodeRank
This code example shows how to use the following methods:rejectDrop
   * @param dtde the <code>DropTargetDropEvent</code> 
   */ 
 
  public void drop(final DropTargetDropEvent dtde)
  { 
    dtde.rejectDrop();
    transferData = null; 
    position = null;
    flavor = null;
  } 
 
  public void cleanup() 
  { 
    transferData = null; 
    position = null;
    flavor = null;
  } 
} 
4
CodeRank
See Code Examples for Java 8 DropTargetDropEvent Methods: