Search in sources :

Example 36 with MMapController

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);
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MFileManager(org.freeplane.features.url.mindmapmode.MFileManager)

Example 37 with MMapController

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);
}
Also used : MainView(org.freeplane.view.swing.map.MainView) MMapController(org.freeplane.features.map.mindmapmode.MMapController) Transferable(java.awt.datatransfer.Transferable) ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView) ClipboardController(org.freeplane.features.clipboard.ClipboardController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) LinkController(org.freeplane.features.link.LinkController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) MClipboardController(org.freeplane.features.clipboard.mindmapmode.MClipboardController) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException) NodeModel(org.freeplane.features.map.NodeModel) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) MClipboardController(org.freeplane.features.clipboard.mindmapmode.MClipboardController) MapView(org.freeplane.view.swing.map.MapView)

Example 38 with MMapController

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;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) ModeController(org.freeplane.features.mode.ModeController) Point(java.awt.Point)

Aggregations

MMapController (org.freeplane.features.map.mindmapmode.MMapController)38 NodeModel (org.freeplane.features.map.NodeModel)26 ModeController (org.freeplane.features.mode.ModeController)16 Controller (org.freeplane.features.mode.Controller)13 MLinkController (org.freeplane.features.link.mindmapmode.MLinkController)11 LinkController (org.freeplane.features.link.LinkController)9 MapModel (org.freeplane.features.map.MapModel)9 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)9 File (java.io.File)7 MNodeStyleController (org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController)7 TextController (org.freeplane.features.text.TextController)7 ResourceController (org.freeplane.core.resources.ResourceController)6 MapController (org.freeplane.features.map.MapController)6 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)6 MTextController (org.freeplane.features.text.mindmapmode.MTextController)6 IOException (java.io.IOException)5 MalformedURLException (java.net.MalformedURLException)5 URL (java.net.URL)5 IActor (org.freeplane.core.undo.IActor)5 IconController (org.freeplane.features.icon.IconController)4