本文整理汇总了Java中java.awt.dnd.DnDConstants.ACTION_COPY属性的典型用法代码示例。如果您正苦于以下问题:Java DnDConstants.ACTION_COPY属性的具体用法?Java DnDConstants.ACTION_COPY怎么用?Java DnDConstants.ACTION_COPY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.dnd.DnDConstants
的用法示例。
在下文中一共展示了DnDConstants.ACTION_COPY属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapOperation
/**
* 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;
}
示例2: checkNodeForAction
/** Utility method.
* @return true if given node supports given action,
* false otherwise.
*/
static boolean checkNodeForAction(Node node, int dragAction) {
if (
node.canCut() &&
((dragAction == DnDConstants.ACTION_MOVE) || (dragAction == DnDConstants.ACTION_COPY_OR_MOVE))
) {
return true;
}
if (
node.canCopy() &&
((dragAction == DnDConstants.ACTION_COPY) || (dragAction == DnDConstants.ACTION_COPY_OR_MOVE) ||
(dragAction == DnDConstants.ACTION_LINK) || (dragAction == DnDConstants.ACTION_REFERENCE))
) {
return true;
}
// hmmm, conditions not satisfied..
return false;
}
示例3: executeDrop
@Override
public boolean executeDrop(JTree targetTree, Object draggedNode, Object targetNode, int action) {
if (action == DnDConstants.ACTION_COPY) {
return false;
} else if (action == DnDConstants.ACTION_MOVE) {
if (canMove(draggedNode, targetNode)) {
if (draggedNode == targetNode)
return true;
listener.moveRequested(new Event(null), (AddTool) draggedNode, (AddTool) targetNode);
return true;
} else {
return false;
}
} else {
return false;
}
}
示例4: importData
@Override
public boolean importData(TransferHandler.TransferSupport info) {
if (!info.isDrop()) {
return false;
}
if (!canImportHere(info)) {
if (
(JDragDropList.this.dropListener != null) &&
JDragDropList.this.dropListener.acceptDrop(JDragDropList.this, info)
) {
return JDragDropList.this.dropListener.handleDrop(JDragDropList.this, info);
} else {
return false;
}
}
JDDLTransferData<T> data = getData(info);
int destIndex = JDragDropList.this.getDropLocation().getIndex();
/*
System.err.print("[ ");
for (int index : data.getIndices()) {
System.err.print(index + " ");
}
System.err.print("] -> ");
System.err.println(destIndex);
*/
if ((info.getDropAction() & DnDConstants.ACTION_COPY) != 0) {
copyItems(data.getSourceList(), JDragDropList.this, data.getValuesList(), destIndex);
} else if ((info.getDropAction() & DnDConstants.ACTION_MOVE) != 0) {
moveItems(data.getSourceList(), JDragDropList.this, data.getIndices(), destIndex);
} else {
return false;
}
return true;
}
示例5: dragEnter
@Override
public final void dragEnter(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);
}
}
}
示例6: getAllowedDropActions
public int getAllowedDropActions(Transferable t) {
if (t != null && t.isDataFlavorSupported(new DataFlavor(Watch.class, null))) {
return DnDConstants.ACTION_COPY_OR_MOVE;
} else {
return DnDConstants.ACTION_COPY;
}
}
示例7: getXDnDActionForJavaAction
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;
}
}
示例8: dragGestureRecognized
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
Cursor cursor = null;
if(dge.getComponent() instanceof RepositoryViewer){
RepositoryViewer rv = (RepositoryViewer) dge.getComponent();
KernelRepositoryEntry kre = (KernelRepositoryEntry) rv.getSelectedValue();
if(dge.getDragAction()==DnDConstants.ACTION_COPY){
cursor = DragSource.DefaultCopyDrop;
}
dge.startDrag(cursor, new TransferableKernelRepositoryEntry(kre));
}
}
示例9: dropActionChanged
@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);
}
}
}
示例10: convertModifiersToDropAction
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;
}
示例11: getJavaActionForXDnDAction
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;
}
}
示例12: getJavaActionsForMotifActions
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;
}
示例13: dragOver
@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);
}
}
}
示例14: getMotifActionsForJavaActions
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;
}
示例15: getSourceActions
@Override
public int getSourceActions(JComponent component) {
return DnDConstants.ACTION_COPY;
}