Search in sources :

Example 46 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class FilterHistory method undo.

void undo() {
    Controller controller = Controller.getCurrentController();
    final MapModel map = controller.getMap();
    final Filter previous = filters.previous();
    undoImpl(map);
    while (previous != filters.next()) {
        ;
    }
    if (filters.nextIndex() > 1) {
        filters.previous();
    }
}
Also used : MapModel(org.freeplane.features.map.MapModel) Controller(org.freeplane.features.mode.Controller)

Example 47 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class FindAction method findNext.

void findNext(Direction direction) {
    final MapModel map = Controller.getCurrentController().getMap();
    final FoundNodes info = FoundNodes.get(map);
    if (info.condition == null) {
        displayNoPreviousFindMessage();
        return;
    }
    final FilterController filterController = FilterController.getCurrentFilterController();
    final NodeModel start = Controller.getCurrentController().getSelection().getSelected();
    final NodeModel root = map.getNodeForID(info.rootID);
    if (root == null) {
        info.condition = null;
        displayNoPreviousFindMessage();
        return;
    }
    final NodeModel next = filterController.findNext(start, null, direction, info.condition);
    if (next == null) {
        displayNotFoundMessage(root, info.condition);
        return;
    }
    info.displayFoundNode(next);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapModel(org.freeplane.features.map.MapModel)

Example 48 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class FoundNodes method displayFoundNode.

/**
 * Display a node in the display (used by find and the goto action by arrow
 * link actions).
 */
void displayFoundNode(final NodeModel node) {
    final MapModel map = node.getMap();
    final LinkedList<String> nodesUnfoldedByDisplay = new LinkedList<String>();
    NodeModel nodeOnPath = null;
    for (nodeOnPath = node; nodeOnPath != null && !this.nodesUnfoldedByDisplay.contains(nodeOnPath.createID()); nodeOnPath = nodeOnPath.getParentNode()) {
        if (Controller.getCurrentModeController().getMapController().isFolded(nodeOnPath)) {
            nodesUnfoldedByDisplay.add(nodeOnPath.createID());
        }
    }
    final ListIterator<String> oldPathIterator = this.nodesUnfoldedByDisplay.listIterator(this.nodesUnfoldedByDisplay.size());
    while (oldPathIterator.hasPrevious()) {
        final String oldPathNodeID = oldPathIterator.previous();
        final NodeModel oldPathNode = map.getNodeForID(oldPathNodeID);
        if (oldPathNode != null && oldPathNode.equals(nodeOnPath)) {
            break;
        }
        oldPathIterator.remove();
        if (oldPathNode != null) {
            Controller.getCurrentModeController().getMapController().fold(oldPathNode);
        }
    }
    this.nodesUnfoldedByDisplay.addAll(nodesUnfoldedByDisplay);
    Controller.getCurrentModeController().getMapController().select(node);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapModel(org.freeplane.features.map.MapModel) LinkedList(java.util.LinkedList)

Example 49 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class MMapController method insertSingleNewNode.

private void insertSingleNewNode(final NodeModel newNode, final NodeModel parent, final int index, final boolean newNodeIsLeft) {
    final MapModel map = parent.getMap();
    newNode.setLeft(newNodeIsLeft);
    final IActor actor = new IActor() {

        public void act() {
            insertNodeIntoWithoutUndo(newNode, parent, index);
        }

        public String getDescription() {
            return "addNewNode";
        }

        public void undo() {
            deleteWithoutUndo(parent, index);
        }
    };
    Controller.getCurrentModeController().execute(actor, map);
}
Also used : IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel)

Example 50 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class MMapController method restoreCurrentMap.

/**
 *@throws XMLException
 * @deprecated -- use MMapIO
 */
@Deprecated
public boolean restoreCurrentMap() throws FileNotFoundException, IOException, URISyntaxException, XMLException {
    final Controller controller = Controller.getCurrentController();
    final MapModel map = controller.getMap();
    final URL url = map.getURL();
    if (url == null) {
        UITools.errorMessage(TextUtils.getText("map_not_saved"));
        return false;
    }
    if (map.containsExtension(DocuMapAttribute.class)) {
        closeWithoutSaving(map);
        return newDocumentationMap(url);
    }
    final URL alternativeURL = MFileManager.getController(getMModeController()).getAlternativeURL(url, AlternativeFileMode.ALL);
    if (alternativeURL == null)
        return false;
    controller.getViewController().setWaitingCursor(true);
    try {
        final MapModel newModel = new MMapModel();
        ((MFileManager) MFileManager.getController()).loadAndLock(alternativeURL, newModel);
        newModel.setURL(url);
        newModel.setSaved(alternativeURL.equals(url));
        fireMapCreated(newModel);
        closeWithoutSaving(map);
        newMapView(newModel);
        return true;
    } finally {
        controller.getViewController().setWaitingCursor(false);
    }
}
Also used : MFileManager(org.freeplane.features.url.mindmapmode.MFileManager) MapModel(org.freeplane.features.map.MapModel) MLogicalStyleController(org.freeplane.features.styles.mindmapmode.MLogicalStyleController) MTextController(org.freeplane.features.text.mindmapmode.MTextController) MapController(org.freeplane.features.map.MapController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) ClipboardController(org.freeplane.features.clipboard.ClipboardController) AddOnsController(org.freeplane.main.addons.AddOnsController) ResourceController(org.freeplane.core.resources.ResourceController) ViewController(org.freeplane.features.ui.ViewController) ModeController(org.freeplane.features.mode.ModeController) MLocationController(org.freeplane.features.nodelocation.mindmapmode.MLocationController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) URL(java.net.URL)

Aggregations

MapModel (org.freeplane.features.map.MapModel)143 NodeModel (org.freeplane.features.map.NodeModel)47 ModeController (org.freeplane.features.mode.ModeController)35 Controller (org.freeplane.features.mode.Controller)31 IActor (org.freeplane.core.undo.IActor)27 MMapModel (org.freeplane.features.map.mindmapmode.MMapModel)16 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)16 IUndoHandler (org.freeplane.core.undo.IUndoHandler)15 AttributeRegistry (org.freeplane.features.attribute.AttributeRegistry)14 IStyle (org.freeplane.features.styles.IStyle)14 File (java.io.File)13 MMapController (org.freeplane.features.map.mindmapmode.MMapController)13 URL (java.net.URL)12 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)11 MapStyleModel (org.freeplane.features.styles.MapStyleModel)10 IMapViewManager (org.freeplane.features.ui.IMapViewManager)10 MapController (org.freeplane.features.map.MapController)9 URI (java.net.URI)8 ResourceController (org.freeplane.core.resources.ResourceController)8 IOException (java.io.IOException)7