Search in sources :

Example 1 with MindMapNodesSelection

use of org.freeplane.features.clipboard.MindMapNodesSelection in project freeplane by freeplane.

the class MClipboardController method cut.

Transferable cut(final List<NodeModel> collection) {
    Controller.getCurrentModeController().getMapController().sortNodesByDepth(collection);
    final MindMapNodesSelection transferable = copy(collection, true);
    for (final NodeModel node : collection) {
        if (node.getParentNode() != null) {
            ((MMapController) Controller.getCurrentModeController().getMapController()).deleteNode(node);
        }
    }
    setClipboardContents(transferable);
    return transferable;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MindMapNodesSelection(org.freeplane.features.clipboard.MindMapNodesSelection)

Example 2 with MindMapNodesSelection

use of org.freeplane.features.clipboard.MindMapNodesSelection in project freeplane by freeplane.

the class MNodeDragListener method dragGestureRecognized.

public void dragGestureRecognized(final DragGestureEvent e) {
    final MainView mainView = (MainView) e.getComponent();
    final NodeView nodeView = mainView.getNodeView();
    final MapView mapView = nodeView.getMap();
    mapView.select();
    if (!nodeView.isSelected()) {
        nodeView.getMap().getModeController().getController().getSelection().selectAsTheOnlyOneSelected(nodeView.getModel());
    }
    Rectangle bounds = new Rectangle(0, 0, mainView.getWidth(), mainView.getHeight());
    if (!bounds.contains(e.getDragOrigin()))
        return;
    final int dragActionType = e.getDragAction();
    if (dragActionType == DnDConstants.ACTION_MOVE) {
        final NodeModel node = nodeView.getModel();
        if (node.isRoot()) {
            if (!isLinkDragEvent(e))
                return;
        }
    }
    final String dragActionName;
    Cursor cursor = getCursorByAction(dragActionType);
    if (isLinkDragEvent(e)) {
        cursor = DragSource.DefaultLinkDrop;
        dragActionName = "LINK";
    } else if ((e.getTriggerEvent().getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) {
        cursor = DragSource.DefaultCopyDrop;
        dragActionName = "COPY";
    } else {
        dragActionName = "MOVE";
    }
    final Transferable t = ClipboardController.getController().copy(Controller.getCurrentController().getSelection());
    ((MindMapNodesSelection) t).setDropAction(dragActionName);
    try {
        e.startDrag(cursor, t, new DragSourceListener() {

            public void dragDropEnd(final DragSourceDropEvent dsde) {
            }

            public void dragEnter(final DragSourceDragEvent e) {
            }

            public void dragExit(final DragSourceEvent dse) {
            }

            public void dragOver(final DragSourceDragEvent dsde) {
            }

            public void dropActionChanged(final DragSourceDragEvent dsde) {
                dsde.getDragSourceContext().setCursor(getCursorByAction(dsde.getUserAction()));
            }
        });
    } catch (final InvalidDnDOperationException ex) {
    }
}
Also used : InvalidDnDOperationException(java.awt.dnd.InvalidDnDOperationException) MainView(org.freeplane.view.swing.map.MainView) DragSourceDragEvent(java.awt.dnd.DragSourceDragEvent) Rectangle(java.awt.Rectangle) Transferable(java.awt.datatransfer.Transferable) NodeView(org.freeplane.view.swing.map.NodeView) Cursor(java.awt.Cursor) DragSourceListener(java.awt.dnd.DragSourceListener) DragSourceEvent(java.awt.dnd.DragSourceEvent) NodeModel(org.freeplane.features.map.NodeModel) MapView(org.freeplane.view.swing.map.MapView) DragSourceDropEvent(java.awt.dnd.DragSourceDropEvent) MindMapNodesSelection(org.freeplane.features.clipboard.MindMapNodesSelection)

Example 3 with MindMapNodesSelection

use of org.freeplane.features.clipboard.MindMapNodesSelection in project freeplane by freeplane.

the class MClipboardController method copySingle.

@Override
public Transferable copySingle(Collection<NodeModel> source) {
    final MindMapNodesSelection transferable = (MindMapNodesSelection) super.copySingle(source);
    transferable.setNodeObjects(new ArrayList<NodeModel>(source), true);
    return transferable;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MindMapNodesSelection(org.freeplane.features.clipboard.MindMapNodesSelection)

Example 4 with MindMapNodesSelection

use of org.freeplane.features.clipboard.MindMapNodesSelection in project freeplane by freeplane.

the class MClipboardController method copy.

@Override
public Transferable copy(IMapSelection selection) {
    final List<NodeModel> collection = selection.getSortedSelection(true);
    final MindMapNodesSelection transferable = copy(collection, false);
    transferable.setNodeObjects(collection);
    return transferable;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MindMapNodesSelection(org.freeplane.features.clipboard.MindMapNodesSelection)

Aggregations

MindMapNodesSelection (org.freeplane.features.clipboard.MindMapNodesSelection)4 NodeModel (org.freeplane.features.map.NodeModel)4 Cursor (java.awt.Cursor)1 Rectangle (java.awt.Rectangle)1 Transferable (java.awt.datatransfer.Transferable)1 DragSourceDragEvent (java.awt.dnd.DragSourceDragEvent)1 DragSourceDropEvent (java.awt.dnd.DragSourceDropEvent)1 DragSourceEvent (java.awt.dnd.DragSourceEvent)1 DragSourceListener (java.awt.dnd.DragSourceListener)1 InvalidDnDOperationException (java.awt.dnd.InvalidDnDOperationException)1 MMapController (org.freeplane.features.map.mindmapmode.MMapController)1 MainView (org.freeplane.view.swing.map.MainView)1 MapView (org.freeplane.view.swing.map.MapView)1 NodeView (org.freeplane.view.swing.map.NodeView)1