Search in sources :

Example 1 with NoDropHandlerFoundExeption

use of org.freeplane.plugin.workspace.dnd.NoDropHandlerFoundExeption in project freeplane by freeplane.

the class NodePasteAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    AWorkspaceTreeNode targetNode = getNodeFromActionEvent(e);
    if (DnDController.isDropAllowed(targetNode)) {
        Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable transf = clip.getContents(null);
        if (transf == null) {
            return;
        }
        int dndAction = DnDConstants.ACTION_COPY;
        if (transf.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_MOVE_NODE_FLAVOR)) {
            dndAction = DnDConstants.ACTION_MOVE;
        }
        if (WorkspaceController.getCurrentModeExtension().getView() != null) {
            try {
                WorkspaceController.getCurrentModeExtension().getView().getTransferHandler().handleDrop(targetNode, transf, dndAction);
                if (dndAction == DnDConstants.ACTION_MOVE) {
                    clip.setContents(null, null);
                }
            } catch (NoDropHandlerFoundExeption ex) {
                LogUtils.info("Exception in org.freeplane.plugin.workspace.actions.NodePasteAction.actionPerformed(ActionEvent): " + ex.getMessage());
            }
        }
    }
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) NoDropHandlerFoundExeption(org.freeplane.plugin.workspace.dnd.NoDropHandlerFoundExeption) Transferable(java.awt.datatransfer.Transferable) WorkspaceTransferable(org.freeplane.plugin.workspace.dnd.WorkspaceTransferable) Clipboard(java.awt.datatransfer.Clipboard)

Aggregations

Clipboard (java.awt.datatransfer.Clipboard)1 Transferable (java.awt.datatransfer.Transferable)1 NoDropHandlerFoundExeption (org.freeplane.plugin.workspace.dnd.NoDropHandlerFoundExeption)1 WorkspaceTransferable (org.freeplane.plugin.workspace.dnd.WorkspaceTransferable)1 AWorkspaceTreeNode (org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)1