use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.
the class MMapIO method install.
public static void install(MModeController modeController) {
MFileManager urlManager = (MFileManager) modeController.getExtension(UrlManager.class);
MMapController mapController = (MMapController) modeController.getMapController();
final MMapIO mapIO = new MMapIO(urlManager, mapController);
modeController.addExtension(MapIO.class, mapIO);
}
use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.
the class MNodeDropListener method drop.
public void drop(final DropTargetDropEvent dtde) {
try {
final MainView mainView = (MainView) dtde.getDropTargetContext().getComponent();
final NodeView targetNodeView = mainView.getNodeView();
final MapView mapView = targetNodeView.getMap();
mapView.select();
final NodeModel targetNode = targetNodeView.getModel();
final Controller controller = Controller.getCurrentController();
int dropAction = getDropAction(dtde);
final Transferable t = dtde.getTransferable();
mainView.setDraggedOver(NodeView.DRAGGED_OVER_NO);
mainView.repaint();
if (dtde.isLocalTransfer() && !isDropAcceptable(dtde, dropAction)) {
dtde.rejectDrop();
return;
}
final boolean dropAsSibling = mainView.dropAsSibling(dtde.getLocation().getX());
ModeController modeController = controller.getModeController();
final MMapController mapController = (MMapController) modeController.getMapController();
if ((dropAction == DnDConstants.ACTION_MOVE || dropAction == DnDConstants.ACTION_COPY)) {
final NodeModel parent = dropAsSibling ? targetNode.getParentNode() : targetNode;
if (!mapController.isWriteable(parent)) {
dtde.rejectDrop();
final String message = TextUtils.getText("node_is_write_protected");
UITools.errorMessage(message);
return;
}
}
final boolean isLeft = mainView.dropLeft(dtde.getLocation().getX());
if (!dtde.isLocalTransfer()) {
dtde.acceptDrop(DnDConstants.ACTION_COPY);
((MClipboardController) ClipboardController.getController()).paste(t, targetNode, dropAsSibling, isLeft, dropAction);
dtde.dropComplete(true);
return;
}
dtde.acceptDrop(dropAction);
if (dropAction == DnDConstants.ACTION_LINK) {
int yesorno = JOptionPane.YES_OPTION;
if (controller.getSelection().size() >= 5) {
yesorno = JOptionPane.showConfirmDialog(controller.getViewController().getCurrentRootComponent(), TextUtils.getText("lots_of_links_warning"), Integer.toString(controller.getSelection().size()) + " links to the same node", JOptionPane.YES_NO_OPTION);
}
if (yesorno == JOptionPane.YES_OPTION) {
for (final NodeModel sourceNodeModel : getNodeObjects(t)) {
((MLinkController) LinkController.getController(modeController)).addConnector(sourceNodeModel, targetNode);
}
}
} else {
final Collection<NodeModel> selecteds = mapController.getSelectedNodes();
if (DnDConstants.ACTION_MOVE == dropAction && isFromSameMap(dtde)) {
final NodeModel[] array = selecteds.toArray(new NodeModel[selecteds.size()]);
moveNodes(mapController, targetNode, t, dropAsSibling, isLeft);
if (dropAsSibling || !targetNodeView.isFolded())
controller.getSelection().replaceSelection(array);
else
controller.getSelection().selectAsTheOnlyOneSelected(targetNode);
} else if (DnDConstants.ACTION_COPY == dropAction || DnDConstants.ACTION_MOVE == dropAction) {
((MClipboardController) ClipboardController.getController()).paste(t, targetNode, dropAsSibling, isLeft);
controller.getSelection().selectAsTheOnlyOneSelected(targetNode);
}
}
} catch (final Exception e) {
LogUtils.severe("Drop exception:", e);
dtde.dropComplete(false);
return;
}
dtde.dropComplete(true);
}
use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.
the class MNodeMotionListener method adjustNodeIndexBackupSelection.
private NodeModel[] adjustNodeIndexBackupSelection(final NodeView nodeV, NodeModel[] selectedsBackup) {
final NodeModel node = nodeV.getModel();
boolean isLeft = nodeV.isLeft();
final int newIndex = calculateNewFreeNodeIndex(nodeV);
if (newIndex != -1) {
final ModeController modeController = nodeV.getMap().getModeController();
MMapController mapController = (MMapController) modeController.getMapController();
if (selectedsBackup == null) {
final Collection<NodeModel> selecteds = mapController.getSelectedNodes();
selectedsBackup = selecteds.toArray(new NodeModel[selecteds.size()]);
}
mapController.moveNode(node, newIndex);
}
return selectedsBackup;
}
Aggregations