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;
}
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) {
}
}
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;
}
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;
}
Aggregations