Example usage for java.awt.dnd DropTargetDragEvent rejectDrag

List of usage examples for java.awt.dnd DropTargetDragEvent rejectDrag

Introduction

In this page you can find the example usage for java.awt.dnd DropTargetDragEvent rejectDrag.

Prototype

public void rejectDrag() 

Source Link

Document

Rejects the drag as a result of examining either the dropAction or the available DataFlavor types.

Usage

From source file:javazoom.jlgui.player.amp.skin.DropTargetAdapter.java

public void dragEnter(DropTargetDragEvent e) {
    if (isDragOk(e) == false) {
        e.rejectDrag();
    }
}

From source file:javazoom.jlgui.player.amp.skin.DropTargetAdapter.java

public void dragOver(DropTargetDragEvent e) {
    if (isDragOk(e) == false) {
        e.rejectDrag();
    }
}

From source file:javazoom.jlgui.player.amp.skin.DropTargetAdapter.java

public void dropActionChanged(DropTargetDragEvent e) {
    if (isDragOk(e) == false) {
        e.rejectDrag();
    }
}

From source file:TreeDragTest.java

public void dragEnter(DropTargetDragEvent dtde) {
    TreeNode node = getNodeForEvent(dtde);
    if (node.isLeaf()) {
        dtde.rejectDrag();
    } else {/*from  w w  w . j  ava2 s .  c  o  m*/
        // start by supporting move operations
        //dtde.acceptDrag(DnDConstants.ACTION_MOVE);
        dtde.acceptDrag(dtde.getDropAction());
    }
}

From source file:TreeDragTest.java

public void dragOver(DropTargetDragEvent dtde) {
    TreeNode node = getNodeForEvent(dtde);
    if (node.isLeaf()) {
        dtde.rejectDrag();
    } else {/*  www .j  a  v a2s.c  o  m*/
        // start by supporting move operations
        //dtde.acceptDrag(DnDConstants.ACTION_MOVE);
        dtde.acceptDrag(dtde.getDropAction());
    }
}

From source file:org.jas.dnd.MultiLayerDropTargetListener.java

@Override
public void dragOver(DropTargetDragEvent dtde) {
    initializeTransferable(dtde.getTransferable(), false);
    getDragAction().setLocation(dtde.getLocation());
    if (getDragAction().validate(dtde.getLocation())) {
        dtde.acceptDrag(DnDConstants.ACTION_COPY);
    } else {/*from   w w  w. ja  v  a  2s .  co  m*/
        dtde.rejectDrag();
    }
}

From source file:PanelDropTarget.java

protected boolean acceptOrRejectDrag(DropTargetDragEvent dtde) {
    int dropAction = dtde.getDropAction();
    int sourceActions = dtde.getSourceActions();
    boolean acceptedDrag = false;

    DnDUtils.debugPrintln("\tSource actions are " + DnDUtils.showActions(sourceActions) + ", drop action is "
            + DnDUtils.showActions(dropAction));

    // Reject if the object being transferred
    // or the operations available are not acceptable.
    if (!acceptableType || (sourceActions & DnDConstants.ACTION_COPY_OR_MOVE) == 0) {
        DnDUtils.debugPrintln("Drop target rejecting drag");
        dtde.rejectDrag();
    } else if ((dropAction & DnDConstants.ACTION_COPY_OR_MOVE) == 0) {
        // Not offering copy or move - suggest a copy
        DnDUtils.debugPrintln("Drop target offering COPY");
        dtde.acceptDrag(DnDConstants.ACTION_COPY);
        acceptedDrag = true;/*from ww  w .  j  a v  a 2s  .c  o  m*/
    } else {
        // Offering an acceptable operation: accept
        DnDUtils.debugPrintln("Drop target accepting drag");
        dtde.acceptDrag(dropAction);
        acceptedDrag = true;
    }

    return acceptedDrag;
}

From source file:com.mirth.connect.client.ui.editors.JavaScriptEditorDialog.java

public void dragEnter(DropTargetDragEvent dtde) {
    try {//from w  w w  .ja v a2s . c  o m
        Transferable tr = dtde.getTransferable();
        if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {

            dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);

            java.util.List fileList = (java.util.List) tr.getTransferData(DataFlavor.javaFileListFlavor);
            Iterator iterator = fileList.iterator();
            while (iterator.hasNext()) {
                iterator.next();
            }
        } else {
            dtde.rejectDrag();
        }
    } catch (Exception e) {
        dtde.rejectDrag();
    }
}

From source file:EditorDropTarget2.java

protected boolean acceptOrRejectDrag(DropTargetDragEvent dtde) {
    int dropAction = dtde.getDropAction();
    int sourceActions = dtde.getSourceActions();
    boolean acceptedDrag = false;

    DnDUtils.debugPrintln("\tSource actions are " + DnDUtils.showActions(sourceActions) + ", drop action is "
            + DnDUtils.showActions(dropAction));

    // Reject if the object being transferred
    // or the operations available are not acceptable
    if (!acceptableType || (sourceActions & DnDConstants.ACTION_COPY_OR_MOVE) == 0) {
        DnDUtils.debugPrintln("Drop target rejecting drag");
        dtde.rejectDrag();
    } else if (!draggingFile && !pane.isEditable()) {
        // Can't drag text to a read-only JEditorPane
        DnDUtils.debugPrintln("Drop target rejecting drag");
        dtde.rejectDrag();// w ww .  jav a 2  s .  c  o m
    } else if ((dropAction & DnDConstants.ACTION_COPY_OR_MOVE) == 0) {
        // Not offering copy or move - suggest a copy
        DnDUtils.debugPrintln("Drop target offering COPY");
        dtde.acceptDrag(DnDConstants.ACTION_COPY);
        acceptedDrag = true;
    } else {
        // Offering an acceptable operation: accept
        DnDUtils.debugPrintln("Drop target accepting drag");
        dtde.acceptDrag(dropAction);
        acceptedDrag = true;
    }

    return acceptedDrag;
}

From source file:com.igormaznitsa.sciareto.ui.editors.MMDEditor.java

@Override
public void dragEnter(@Nonnull final DropTargetDragEvent dtde) {
    this.dragAcceptableType = checkDragType(dtde);
    if (!this.dragAcceptableType) {
        dtde.rejectDrag();
    } else {//from www  .j av a2  s.co  m
        dtde.acceptDrag(DnDConstants.ACTION_MOVE);
    }
    repaint();
}