Java Code Examples for java.awt.dnd.DnDConstants#ACTION_COPY

The following examples show how to use java.awt.dnd.DnDConstants#ACTION_COPY . 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: SunDropTargetContextPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * mapOperation
 */

private int mapOperation(int operation) {
    int[] operations = {
            DnDConstants.ACTION_MOVE,
            DnDConstants.ACTION_COPY,
            DnDConstants.ACTION_LINK,
    };
    int   ret = DnDConstants.ACTION_NONE;

    for (int i = 0; i < operations.length; i++) {
        if ((operation & operations[i]) == operations[i]) {
                ret = operations[i];
                break;
        }
    }

    return ret;
}
 
Example 2
Source File: SunDropTargetContextPeer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * mapOperation
 */

private int mapOperation(int operation) {
    int[] operations = {
            DnDConstants.ACTION_MOVE,
            DnDConstants.ACTION_COPY,
            DnDConstants.ACTION_LINK,
    };
    int   ret = DnDConstants.ACTION_NONE;

    for (int i = 0; i < operations.length; i++) {
        if ((operation & operations[i]) == operations[i]) {
                ret = operations[i];
                break;
        }
    }

    return ret;
}
 
Example 3
Source File: SunDropTargetContextPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * mapOperation
 */

private int mapOperation(int operation) {
    int[] operations = {
            DnDConstants.ACTION_MOVE,
            DnDConstants.ACTION_COPY,
            DnDConstants.ACTION_LINK,
    };
    int   ret = DnDConstants.ACTION_NONE;

    for (int i = 0; i < operations.length; i++) {
        if ((operation & operations[i]) == operations[i]) {
                ret = operations[i];
                break;
        }
    }

    return ret;
}
 
Example 4
Source File: SunDropTargetContextPeer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * mapOperation
 */

private int mapOperation(int operation) {
    int[] operations = {
            DnDConstants.ACTION_MOVE,
            DnDConstants.ACTION_COPY,
            DnDConstants.ACTION_LINK,
    };
    int   ret = DnDConstants.ACTION_NONE;

    for (int i = 0; i < operations.length; i++) {
        if ((operation & operations[i]) == operations[i]) {
                ret = operations[i];
                break;
        }
    }

    return ret;
}
 
Example 5
Source File: SunDropTargetContextPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * mapOperation
 */

private int mapOperation(int operation) {
    int[] operations = {
            DnDConstants.ACTION_MOVE,
            DnDConstants.ACTION_COPY,
            DnDConstants.ACTION_LINK,
    };
    int   ret = DnDConstants.ACTION_NONE;

    for (int i = 0; i < operations.length; i++) {
        if ((operation & operations[i]) == operations[i]) {
                ret = operations[i];
                break;
        }
    }

    return ret;
}
 
Example 6
Source File: MotifDnDConstants.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static int getMotifActionsForJavaActions(int javaActions) {
    int motifActions = MOTIF_DND_NOOP;

    if ((javaActions & DnDConstants.ACTION_MOVE) != 0) {
        motifActions |= MOTIF_DND_MOVE;
    }
    if ((javaActions & DnDConstants.ACTION_COPY) != 0) {
        motifActions |= MOTIF_DND_COPY;
    }
    if ((javaActions & DnDConstants.ACTION_LINK) != 0) {
        motifActions |= MOTIF_DND_LINK;
    }

    return motifActions;
}
 
Example 7
Source File: JTreeUtil.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public final void dropActionChanged(DragSourceDragEvent dsde) {
	int action = dsde.getDropAction();
	if (action == DnDConstants.ACTION_COPY) {
		dsde.getDragSourceContext().setCursor(DragSource.DefaultCopyDrop);
	} else {
		if (action == DnDConstants.ACTION_MOVE) {
			dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
		} else {
			dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
		}
	}
}
 
Example 8
Source File: MotifDnDConstants.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static int getMotifActionsForJavaActions(int javaActions) {
    int motifActions = MOTIF_DND_NOOP;

    if ((javaActions & DnDConstants.ACTION_MOVE) != 0) {
        motifActions |= MOTIF_DND_MOVE;
    }
    if ((javaActions & DnDConstants.ACTION_COPY) != 0) {
        motifActions |= MOTIF_DND_COPY;
    }
    if ((javaActions & DnDConstants.ACTION_LINK) != 0) {
        motifActions |= MOTIF_DND_LINK;
    }

    return motifActions;
}
 
Example 9
Source File: LocalTreeNodeHandler.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void handleFolderDrag(DomainFolder destFolder, int dropAction,
		DomainFolder sourceFolder, TaskMonitor monitor) {
	if (dropAction == DnDConstants.ACTION_COPY || !sourceFolder.isInWritableProject()) {
		CopyTask task = new CopyTask(destFolder, sourceFolder);
		task.run(monitor);
		return;
	}

	try {
		sourceFolder.moveTo(destFolder);
	}
	catch (DuplicateFileException dfe) {
		Msg.showError(this, dataTree, "Error Moving Folder",
			"Destination folder already contains a folder named \"" + sourceFolder.getName() +
				"\"");
	}
	catch (FileInUseException fiue) {
		String message = fiue.getMessage();
		if (message == null || message.length() == 0) {
			message = "Cannot move folder '" + sourceFolder.toString() + "' to '" +
				destFolder.toString() +
				"'\nsince it contains a file that is checked out or in use.";
		}
		Msg.showError(this, dataTree, "Error Moving Folder", message);
	}
	catch (IOException e) {
		Msg.showError(this, dataTree, "Error Moving Folder", "Cannot Move Folder", e);
	}
}
 
Example 10
Source File: XDnDConstants.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static int getJavaActionForXDnDAction(long xdndAction) {
    if (xdndAction == XA_XdndActionCopy.getAtom()) {
        return DnDConstants.ACTION_COPY;
    } else if (xdndAction == XA_XdndActionMove.getAtom()) {
        return DnDConstants.ACTION_MOVE;
    } else if (xdndAction == XA_XdndActionLink.getAtom()) {
        return DnDConstants.ACTION_LINK;
    } else {
        return DnDConstants.ACTION_NONE;
    }
}
 
Example 11
Source File: SunDragSourceContextPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static int convertModifiersToDropAction(final int modifiers,
                                               final int supportedActions) {
    int dropAction = DnDConstants.ACTION_NONE;

    /*
     * Fix for 4285634.
     * Calculate the drop action to match Motif DnD behavior.
     * If the user selects an operation (by pressing a modifier key),
     * return the selected operation or ACTION_NONE if the selected
     * operation is not supported by the drag source.
     * If the user doesn't select an operation search the set of operations
     * supported by the drag source for ACTION_MOVE, then for
     * ACTION_COPY, then for ACTION_LINK and return the first operation
     * found.
     */
    switch (modifiers & (InputEvent.SHIFT_DOWN_MASK |
                         InputEvent.CTRL_DOWN_MASK)) {
    case InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK:
        dropAction = DnDConstants.ACTION_LINK; break;
    case InputEvent.CTRL_DOWN_MASK:
        dropAction = DnDConstants.ACTION_COPY; break;
    case InputEvent.SHIFT_DOWN_MASK:
        dropAction = DnDConstants.ACTION_MOVE; break;
    default:
        if ((supportedActions & DnDConstants.ACTION_MOVE) != 0) {
            dropAction = DnDConstants.ACTION_MOVE;
        } else if ((supportedActions & DnDConstants.ACTION_COPY) != 0) {
            dropAction = DnDConstants.ACTION_COPY;
        } else if ((supportedActions & DnDConstants.ACTION_LINK) != 0) {
            dropAction = DnDConstants.ACTION_LINK;
        }
    }

    return dropAction & supportedActions;
}
 
Example 12
Source File: XDnDConstants.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static int getJavaActionForXDnDAction(long xdndAction) {
    if (xdndAction == XA_XdndActionCopy.getAtom()) {
        return DnDConstants.ACTION_COPY;
    } else if (xdndAction == XA_XdndActionMove.getAtom()) {
        return DnDConstants.ACTION_MOVE;
    } else if (xdndAction == XA_XdndActionLink.getAtom()) {
        return DnDConstants.ACTION_LINK;
    } else {
        return DnDConstants.ACTION_NONE;
    }
}
 
Example 13
Source File: MotifDnDConstants.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static int getJavaActionsForMotifActions(int motifActions) {
    int javaActions = DnDConstants.ACTION_NONE;

    if ((motifActions & MOTIF_DND_MOVE) != 0) {
        javaActions |= DnDConstants.ACTION_MOVE;
    }
    if ((motifActions & MOTIF_DND_COPY) != 0) {
        javaActions |= DnDConstants.ACTION_COPY;
    }
    if ((motifActions & MOTIF_DND_LINK) != 0) {
        javaActions |= DnDConstants.ACTION_LINK;
    }

    return javaActions;
}
 
Example 14
Source File: XDnDConstants.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static int getJavaActionForXDnDAction(long xdndAction) {
    if (xdndAction == XA_XdndActionCopy.getAtom()) {
        return DnDConstants.ACTION_COPY;
    } else if (xdndAction == XA_XdndActionMove.getAtom()) {
        return DnDConstants.ACTION_MOVE;
    } else if (xdndAction == XA_XdndActionLink.getAtom()) {
        return DnDConstants.ACTION_LINK;
    } else {
        return DnDConstants.ACTION_NONE;
    }
}
 
Example 15
Source File: XDnDConstants.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static long getXDnDActionForJavaAction(int javaAction) {
    switch (javaAction) {
    case DnDConstants.ACTION_COPY : return XA_XdndActionCopy.getAtom();
    case DnDConstants.ACTION_MOVE : return XA_XdndActionMove.getAtom();
    case DnDConstants.ACTION_LINK : return XA_XdndActionLink.getAtom();
    default                       : return 0;
    }
}
 
Example 16
Source File: SunDragSourceContextPeer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public static int convertModifiersToDropAction(final int modifiers,
                                               final int supportedActions) {
    int dropAction = DnDConstants.ACTION_NONE;

    /*
     * Fix for 4285634.
     * Calculate the drop action to match Motif DnD behavior.
     * If the user selects an operation (by pressing a modifier key),
     * return the selected operation or ACTION_NONE if the selected
     * operation is not supported by the drag source.
     * If the user doesn't select an operation search the set of operations
     * supported by the drag source for ACTION_MOVE, then for
     * ACTION_COPY, then for ACTION_LINK and return the first operation
     * found.
     */
    switch (modifiers & (InputEvent.SHIFT_DOWN_MASK |
                         InputEvent.CTRL_DOWN_MASK)) {
    case InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK:
        dropAction = DnDConstants.ACTION_LINK; break;
    case InputEvent.CTRL_DOWN_MASK:
        dropAction = DnDConstants.ACTION_COPY; break;
    case InputEvent.SHIFT_DOWN_MASK:
        dropAction = DnDConstants.ACTION_MOVE; break;
    default:
        if ((supportedActions & DnDConstants.ACTION_MOVE) != 0) {
            dropAction = DnDConstants.ACTION_MOVE;
        } else if ((supportedActions & DnDConstants.ACTION_COPY) != 0) {
            dropAction = DnDConstants.ACTION_COPY;
        } else if ((supportedActions & DnDConstants.ACTION_LINK) != 0) {
            dropAction = DnDConstants.ACTION_LINK;
        }
    }

    return dropAction & supportedActions;
}
 
Example 17
Source File: XDnDConstants.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static long getXDnDActionForJavaAction(int javaAction) {
    switch (javaAction) {
    case DnDConstants.ACTION_COPY : return XA_XdndActionCopy.getAtom();
    case DnDConstants.ACTION_MOVE : return XA_XdndActionMove.getAtom();
    case DnDConstants.ACTION_LINK : return XA_XdndActionLink.getAtom();
    default                       : return 0;
    }
}
 
Example 18
Source File: JTreeUtil.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public final void dragOver(DragSourceDragEvent dsde) {
	int action = dsde.getDropAction();
	if (action == DnDConstants.ACTION_COPY) {
		dsde.getDragSourceContext().setCursor(DragSource.DefaultCopyDrop);
	} else {
		if (action == DnDConstants.ACTION_MOVE) {
			dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
		} else {
			dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
		}
	}
}
 
Example 19
Source File: XDnDConstants.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static long getXDnDActionForJavaAction(int javaAction) {
    switch (javaAction) {
    case DnDConstants.ACTION_COPY : return XA_XdndActionCopy.getAtom();
    case DnDConstants.ACTION_MOVE : return XA_XdndActionMove.getAtom();
    case DnDConstants.ACTION_LINK : return XA_XdndActionLink.getAtom();
    default                       : return 0;
    }
}
 
Example 20
Source File: ErrLogExpandableDialog.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public int getSupportedDragActions() {
	return DnDConstants.ACTION_COPY;
}