javax.swing.TransferHandler#COPY源码实例Demo

下面列出了javax.swing.TransferHandler#COPY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: blog-codes   文件: mxGraphHandler.java
/**
 * 
 */
protected MouseEvent createEvent(DropTargetEvent e)
{
	JComponent component = getDropTarget(e);
	Point location = null;
	int action = 0;

	if (e instanceof DropTargetDropEvent)
	{
		location = ((DropTargetDropEvent) e).getLocation();
		action = ((DropTargetDropEvent) e).getDropAction();
	}
	else if (e instanceof DropTargetDragEvent)
	{
		location = ((DropTargetDragEvent) e).getLocation();
		action = ((DropTargetDragEvent) e).getDropAction();
	}

	if (location != null)
	{
		location = convertPoint(location);
		Rectangle r = graphComponent.getViewport().getViewRect();
		location.translate(r.x, r.y);
	}

	// LATER: Fetch state of modifier keys from event or via global
	// key listener using Toolkit.getDefaultToolkit().addAWTEventListener(
	// new AWTEventListener() {...}, AWTEvent.KEY_EVENT_MASK). Problem
	// is the event does not contain the modifier keys and the global
	// handler is not called during drag and drop.
	int mod = (action == TransferHandler.COPY) ? InputEvent.CTRL_MASK : 0;

	return new MouseEvent(component, 0, System.currentTimeMillis(), mod,
			location.x, location.y, 1, false, MouseEvent.BUTTON1);
}
 
源代码2 项目: sldeditor   文件: DataFlavourManager.java
/**
 * Display messages.
 *
 * @param destinationTreeNode the destination tree node
 * @param transferredData the transferred data
 * @param action the action
 */
public static void displayMessages(
        NodeInterface destinationTreeNode, TransferredData transferredData, int action) {
    if ((destinationTreeNode == null) || (transferredData == null)) {
        return;
    }

    String actionString = "???";
    if (action == TransferHandler.MOVE) {
        actionString = "Moved";
    } else if (action == TransferHandler.COPY) {
        actionString = "Copied";
    }

    String destinationString =
            destinationTreeNode.getHandler().getDestinationText(destinationTreeNode);
    for (int index = 0; index < transferredData.getDataListSize(); index++) {
        NodeInterface nodeToTransfer =
                (NodeInterface) transferredData.getTreePath(index).getLastPathComponent();
        SelectedFiles selectedFiles =
                nodeToTransfer.getHandler().getSLDContents(nodeToTransfer);

        for (SLDDataInterface sldData : selectedFiles.getSldData()) {
            ConsoleManager.getInstance()
                    .information(
                            DataFlavourManager.class,
                            String.format(
                                    "%s %s -> %s",
                                    actionString, sldData.getLayerName(), destinationString));
        }
    }
}
 
源代码3 项目: netbeans   文件: DashboardTransferHandler.java
/**
 * We support copy
 */
@Override
public int getSourceActions(JComponent c) {
    return TransferHandler.COPY;
}
 
@Override
public int getSourceActions(JComponent c) {
    return TransferHandler.COPY;
}
 
@Override
public int getSourceActions(JComponent c) {
    return TransferHandler.COPY;
}
 
源代码6 项目: sldeditor   文件: TreeTransferHandler.java
@Override
public int getSourceActions(JComponent c) {
    return TransferHandler.COPY;
}
 
源代码7 项目: RobotBuilder   文件: IconPaletteTransferHandler.java
@Override
public int getSourceActions(JComponent c) {
    return TransferHandler.COPY;
}
 
源代码8 项目: Spark   文件: GroupChatRoomTransferHandler.java
@Override
public int getSourceActions(JComponent c) {
       return TransferHandler.COPY;
   }