Search in sources :

Example 1 with MMapController

use of org.freeplane.features.map.mindmapmode.MMapController 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(new SummaryGroupEdgeListAdder(collection).addSummaryEdgeNodes(), true);
    ((MMapController) Controller.getCurrentModeController().getMapController()).deleteNodes(collection);
    setClipboardContents(transferable);
    return transferable;
}
Also used : MMapController(org.freeplane.features.map.mindmapmode.MMapController) SummaryGroupEdgeListAdder(org.freeplane.features.map.mindmapmode.SummaryGroupEdgeListAdder) MindMapNodesSelection(org.freeplane.features.clipboard.MindMapNodesSelection)

Example 2 with MMapController

use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.

the class MClipboardController method pasteStringWithoutRedisplay.

private void pasteStringWithoutRedisplay(final TextFragment[] textFragments, NodeModel parent, final boolean asSibling, final boolean isLeft) {
    final MapModel map = parent.getMap();
    int insertionIndex;
    if (asSibling) {
        NodeModel target = parent;
        parent = parent.getParentNode();
        final NodeModel childNode = target;
        insertionIndex = parent.getIndex(childNode);
    } else {
        insertionIndex = parent.getChildCount();
    }
    final ArrayList<NodeModel> parentNodes = new ArrayList<NodeModel>();
    final ArrayList<Integer> parentNodesDepths = new ArrayList<Integer>();
    parentNodes.add(parent);
    parentNodesDepths.add(new Integer(-1));
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    for (int i = 0; i < textFragments.length; ++i) {
        final TextFragment textFragment = textFragments[i];
        String text = textFragment.text;
        final String link = textFragment.link;
        URI uri = null;
        if (link != null) {
            try {
                URI linkUri = new URI(link);
                uri = linkUri;
                File absoluteFile = UrlManager.getController().getAbsoluteFile(map, uri);
                if (absoluteFile != null) {
                    // if ("file".equals(linkUri.getScheme())) {
                    final File mapFile = map.getFile();
                    uri = LinkController.toLinkTypeDependantURI(mapFile, absoluteFile);
                    if (link.equals(text)) {
                        text = uri.toString();
                    }
                }
            } catch (Exception e) {
            }
        }
        final NodeModel node = mapController.newNode(text, map);
        if (uri != null) {
            NodeLinks.createLinkExtension(node).setHyperLink(uri);
        }
        for (int j = parentNodes.size() - 1; j >= 0; --j) {
            if (textFragment.depth > ((Integer) parentNodesDepths.get(j)).intValue()) {
                for (int k = j + 1; k < parentNodes.size(); ++k) {
                    final NodeModel n = (NodeModel) parentNodes.get(k);
                    if (n.getParentNode() == null) {
                        mapController.insertNode(n, parent, insertionIndex++);
                    }
                    parentNodes.remove(k);
                    parentNodesDepths.remove(k);
                }
                final NodeModel target = (NodeModel) parentNodes.get(j);
                node.setLeft(isLeft);
                if (target != parent) {
                    target.setFolded(true);
                    target.insert(node, target.getChildCount());
                }
                parentNodes.add(node);
                parentNodesDepths.add(new Integer(textFragment.depth));
                break;
            }
        }
    }
    {
        for (int k = 0; k < parentNodes.size(); ++k) {
            final NodeModel n = (NodeModel) parentNodes.get(k);
            if (map.getRootNode() != n && n.getParentNode() == null) {
                mapController.insertNode(n, parent, insertionIndex++);
            }
        }
    }
}
Also used : MMapController(org.freeplane.features.map.mindmapmode.MMapController) ArrayList(java.util.ArrayList) MapModel(org.freeplane.features.map.MapModel) URI(java.net.URI) Hint(org.freeplane.features.map.MapWriter.Hint) XMLException(org.freeplane.n3.nanoxml.XMLException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) BadLocationException(javax.swing.text.BadLocationException) CloneEncryptedNodeException(org.freeplane.features.map.CloneEncryptedNodeException) IOException(java.io.IOException) NodeModel(org.freeplane.features.map.NodeModel) File(java.io.File)

Example 3 with MMapController

use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.

the class MTextController method edit.

public void edit(final FirstAction action, final boolean editLong) {
    final Controller controller = Controller.getCurrentController();
    final IMapSelection selection = controller.getSelection();
    if (selection == null)
        return;
    final NodeModel selectedNode = selection.getSelected();
    if (selectedNode == null)
        return;
    if (FirstAction.EDIT_CURRENT.equals(action)) {
        edit(selectedNode, selectedNode, false, false, editLong);
    } else if (!Controller.getCurrentModeController().isBlocked()) {
        final int mode = FirstAction.ADD_CHILD.equals(action) ? MMapController.NEW_CHILD : MMapController.NEW_SIBLING_BEHIND;
        ((MMapController) Controller.getCurrentModeController().getMapController()).addNewNode(mode);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapController(org.freeplane.features.map.MapController) MIconController(org.freeplane.features.icon.mindmapmode.MIconController) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) FormatController(org.freeplane.features.format.FormatController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) ResourceController(org.freeplane.core.resources.ResourceController) ViewController(org.freeplane.features.ui.ViewController) LinkController(org.freeplane.features.link.LinkController) ModeController(org.freeplane.features.mode.ModeController) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ScannerController(org.freeplane.features.format.ScannerController)

Example 4 with MMapController

use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.

the class ViewerController method pasteImage.

public boolean pasteImage(URI uri, final NodeModel targetNode, final PasteMode mode, final boolean isLeft) {
    if (uri == null || getViewerFactory(uri) == null) {
        return false;
    }
    File file = new File(uri.getPath());
    boolean isFile = uri.getScheme().equals("file");
    if (isFile) {
        if (!file.exists()) {
            return false;
        }
        final File mapFile = targetNode.getMap().getFile();
        if (mapFile == null && LinkController.getLinkType() == LinkController.LINK_RELATIVE_TO_MINDMAP) {
            JOptionPane.showMessageDialog(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(), TextUtils.getText("not_saved_for_image_error"), "Freeplane", JOptionPane.WARNING_MESSAGE);
            return false;
        }
        if (LinkController.getLinkType() != LinkController.LINK_ABSOLUTE) {
            uri = LinkController.toLinkTypeDependantURI(mapFile, file);
        }
    }
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    final NodeModel node;
    if (mode.equals(PasteMode.INSIDE)) {
        node = targetNode;
    } else {
        node = mapController.newNode(file.getName(), targetNode.getMap());
        mapController.insertNode(node, targetNode, mode.equals(PasteMode.AS_SIBLING), isLeft, isLeft);
    }
    final ExternalResource preview = new ExternalResource(uri);
    undoableDeactivateHook(node);
    undoableActivateHook(node, preview);
    ProgressIcons.updateExtendedProgressIcons(node, file.getName());
    return true;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) File(java.io.File)

Example 5 with MMapController

use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.

the class FreeNode method undoableToggleHook.

@Override
public void undoableToggleHook(NodeModel node, IExtension extension) {
    if (node.isRoot())
        return;
    final NodeModel[] selecteds = getSelectedNodes();
    ((MLocationController) LocationController.getController()).moveNodePosition(node, LocationModel.DEFAULT_HGAP, LocationModel.DEFAULT_SHIFT_Y);
    super.undoableToggleHook(node, extension);
    if (isFreeNode(node)) {
        MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
        mapController.moveNode(node, 0);
    }
    Controller.getCurrentController().getSelection().replaceSelection(selecteds);
}
Also used : MLocationController(org.freeplane.features.nodelocation.mindmapmode.MLocationController) MMapController(org.freeplane.features.map.mindmapmode.MMapController)

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