private boolean processDrop(AWorkspaceTreeNode targetNode, DropTargetDropEvent event) {
    event.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);

    final Transferable transferable = event.getTransferable();
    final int dropAction = event.getDropAction();
    try {
      if (!targetNode.getAllowsChildren()) {
        targetNode = targetNode.getParent();
      }
      if (!DnDController.isDropAllowed(targetNode)) {
        event.dropComplete(false);
        return false;
      }
      if (handleDrop(targetNode, transferable, dropAction)) {
        event.dropComplete(true);
        return true;
      }
    } catch (NoDropHandlerFoundExeption e) {
      LogUtils.info(
          "org.freeplane.plugin.workspace.dnd.WorkspaceTransferHandler.processDrop(targetNode, event): "
              + e.getMessage());
    }

    event.dropComplete(false);
    return false;
  }
  /**
   * ********************************************************************************* REQUIRED
   * METHODS FOR INTERFACES
   * ********************************************************************************
   */
  public void mouseClicked(MouseEvent e) {
    if (e.isConsumed()) {
      return;
    }
    TreePath path = ((JTree) e.getSource()).getClosestPathForLocation(e.getX(), e.getY());

    ((TreeView) WorkspaceController.getCurrentModeExtension().getView()).addSelectionPath(path);
    if (path != null) {
      AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
      // encode buttons
      int eventType = 0;
      if (e.getButton() == MouseEvent.BUTTON1) {
        eventType += WorkspaceActionEvent.MOUSE_LEFT;
      }
      if (e.getButton() == MouseEvent.BUTTON3) {
        eventType += WorkspaceActionEvent.MOUSE_RIGHT;
      }
      if (e.getClickCount() % 2 == 0) {
        eventType += WorkspaceActionEvent.MOUSE_DBLCLICK;
      } else {
        eventType += WorkspaceActionEvent.MOUSE_CLICK;
      }

      if (e.isPopupTrigger()) {
        eventType += WorkspaceActionEvent.POPUP_TRIGGER;
      }

      WorkspaceActionEvent event =
          new WorkspaceActionEvent(node, eventType, e.getX(), e.getY(), e.getComponent());

      List<IWorkspaceNodeActionListener> nodeEventListeners =
          WorkspaceController.getCurrentModeExtension()
              .getIOController()
              .getNodeActionListeners(node.getClass(), eventType);
      if (nodeEventListeners != null) {
        for (IWorkspaceNodeActionListener listener : nodeEventListeners) {
          if (event.isConsumed()) {
            break;
          }
          listener.handleAction(event);
        }
      }

      if (!event.isConsumed() && node instanceof IWorkspaceNodeActionListener) {
        ((IWorkspaceNodeActionListener) node).handleAction(event);
      }

    } else {
      if (e.getButton() == MouseEvent.BUTTON3) {
        // WorkspaceController.getController().getPopups().showWorkspacePopup(e.getComponent(),
        // e.getX(), e.getY());
        ((AWorkspaceTreeNode) WorkspaceController.getCurrentModel().getRoot())
            .showPopup(e.getComponent(), e.getX(), e.getY());
      }
    }
  }
  public boolean handleDrop(AWorkspaceTreeNode targetNode, Transferable transf, int dndAction)
      throws NoDropHandlerFoundExeption {
    if (targetNode == null) {
      throw new IllegalArgumentException("targetNode is NULL");
    }

    INodeDropHandler h = findHandler(targetNode.getClass());
    if (h == null) {
      throw new NoDropHandlerFoundExeption(targetNode);
    }

    if (h.acceptDrop(transf)) {
      return h.processDrop(targetNode, transf, dndAction);
    }
    return false;
  }
 private void processWorkspaceNodeDrop(List<AWorkspaceTreeNode> nodes, int dropAction) {
   try {
     File targetDir = WorkspaceUtils.resolveURI(getPath());
     for (AWorkspaceTreeNode node : nodes) {
       if (node instanceof DefaultFileNode) {
         if (targetDir != null && targetDir.isDirectory()) {
           if (dropAction == DnDConstants.ACTION_COPY) {
             ((DefaultFileNode) node).copyTo(targetDir);
           } else if (dropAction == DnDConstants.ACTION_MOVE) {
             File oldFile = ((DefaultFileNode) node).getFile();
             ((DefaultFileNode) node).moveTo(targetDir);
             File newFile = new File(targetDir, ((DefaultFileNode) node).getName());
             AWorkspaceTreeNode parent = node.getParent();
             WorkspaceUtils.getModel().cutNodeFromParent(node);
             parent.refresh();
             WorkspaceUtils.getModel().nodeMoved(node, oldFile, newFile);
           }
         }
       } else if (node instanceof LinkTypeFileNode) {
         File srcFile = WorkspaceUtils.resolveURI(((LinkTypeFileNode) node).getLinkPath());
         if (targetDir != null && targetDir.isDirectory()) {
           FileUtils.copyFileToDirectory(srcFile, targetDir);
           if (dropAction == DnDConstants.ACTION_MOVE) {
             AWorkspaceTreeNode parent = node.getParent();
             WorkspaceUtils.getModel().cutNodeFromParent(node);
             parent.refresh();
             WorkspaceUtils.getModel()
                 .nodeMoved(node, srcFile, new File(targetDir, srcFile.getName()));
           }
         }
       }
     }
     WorkspaceController.getController().getExpansionStateHandler().addPathKey(this.getKey());
     refresh();
   } catch (Exception e) {
     LogUtils.warn(e);
   }
 }