Java Code Examples for javax.swing.TransferHandler#COPY

The following examples show how to use javax.swing.TransferHandler#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: mxGraphHandler.java    From blog-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
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);
}
 
Example 2
Source File: DataFlavourManager.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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));
        }
    }
}
 
Example 3
Source File: DashboardTransferHandler.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * We support copy
 */
@Override
public int getSourceActions(JComponent c) {
    return TransferHandler.COPY;
}
 
Example 4
Source File: InjectScript.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 4 votes vote down vote up
@Override
public int getSourceActions(JComponent c) {
    return TransferHandler.COPY;
}
 
Example 5
Source File: FeatureListTransferHandler.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 4 votes vote down vote up
@Override
public int getSourceActions(JComponent c) {
    return TransferHandler.COPY;
}
 
Example 6
Source File: TreeTransferHandler.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int getSourceActions(JComponent c) {
    return TransferHandler.COPY;
}
 
Example 7
Source File: IconPaletteTransferHandler.java    From RobotBuilder with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public int getSourceActions(JComponent c) {
    return TransferHandler.COPY;
}
 
Example 8
Source File: GroupChatRoomTransferHandler.java    From Spark with Apache License 2.0 4 votes vote down vote up
@Override
public int getSourceActions(JComponent c) {
       return TransferHandler.COPY;
   }