Search in sources :

Example 16 with MMapController

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

the class SplitNode method splitNode.

private void splitNode(final NodeModel node) {
    if (node.isRoot()) {
        return;
    }
    final String text = node.getText();
    final String[] parts = splitNode(text);
    if (parts == null || parts.length == 1) {
        return;
    }
    final ModeController c = Controller.getCurrentModeController();
    int firstPartNumber = 0;
    while (parts[firstPartNumber] == null) {
        firstPartNumber++;
    }
    ((MTextController) TextController.getController()).setNodeText(node, parts[firstPartNumber]);
    final NodeModel parent = node.getParentNode();
    final int nodePosition = parent.getIndex(node) + 1;
    for (int i = parts.length - 1; i > firstPartNumber; i--) {
        final MMapController mapController = (MMapController) c.getMapController();
        final String part = parts[i];
        if (part == null) {
            continue;
        }
        final NodeModel lowerNode = mapController.addNewNode(parent, nodePosition, node.isLeft());
        ((MTextController) TextController.getController()).setNodeText(lowerNode, part);
        final MNodeStyleController nodeStyleController = (MNodeStyleController) NodeStyleController.getController();
        nodeStyleController.copyStyle(node, lowerNode);
        mapController.setFolded(lowerNode, !lowerNode.isFolded());
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) ModeController(org.freeplane.features.mode.ModeController)

Example 17 with MMapController

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

the class SplitToWordsAction method actionPerformed.

@Override
protected void actionPerformed(ActionEvent e, NodeModel node) {
    final ModeController modeController = Controller.getCurrentModeController();
    MTextController textController = (MTextController) modeController.getExtension(TextController.class);
    final MMapController mapController = (MMapController) modeController.getMapController();
    String details;
    try {
        details = textController.getTransformedObject(node).toString();
    } catch (TransformationException e1) {
        return;
    }
    String plainText = HtmlUtils.htmlToPlain(details).trim();
    int nodeCountInLine;
    boolean newNode;
    if (leaveOriginalNodeEmpty) {
        nodeCountInLine = 0;
        newNode = true;
        textController.setNodeText(node, "");
    } else {
        nodeCountInLine = -1;
        newNode = false;
    }
    NodeModel currentNode = node;
    final Matcher matcher = compiledWordPattern.matcher(plainText);
    while (matcher.find()) {
        String word = matcher.group();
        final String currentText;
        if (newNode) {
            if (nodeCountInLine == nodeNumberInLine) {
                nodeCountInLine = 0;
                currentNode = node;
            }
            currentNode = mapController.addNewNode(currentNode, currentNode.getChildCount(), currentNode.isLeft());
            nodeCountInLine++;
            currentText = "";
        } else if (nodeCountInLine == -1) {
            nodeCountInLine = 0;
            currentNode = node;
            currentText = "";
        } else
            currentText = currentNode.getText() + ' ';
        boolean auxiliaryWord = auxiliaryWords.contains(word.toLowerCase());
        if (!auxiliaryWord) {
            textController.setNodeText(currentNode, currentText + capitalize(word));
            newNode = true;
        } else {
            textController.setNodeText(currentNode, currentText + word);
            newNode = false;
        }
    }
    if (saveOriginalTextAsDetails) {
        textController.setDetails(currentNode, HtmlUtils.isHtmlNode(details) ? details : HtmlUtils.plainToHTML(details));
        textController.setIsMinimized(currentNode, true);
    }
}
Also used : TransformationException(org.freeplane.features.text.TransformationException) NodeModel(org.freeplane.features.map.NodeModel) Matcher(java.util.regex.Matcher) TextController(org.freeplane.features.text.TextController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) ModeController(org.freeplane.features.mode.ModeController)

Example 18 with MMapController

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

the class OnlineDocumentationAction method actionPerformed.

public void actionPerformed(final ActionEvent event) {
    try {
        final URL url = new URL(nodeAndMapReference.getMapReference());
        if (url == null)
            return;
        UITools.executeWhenNodeHasFocus(new Runnable() {

            @Override
            public void run() {
                try {
                    if (nodeAndMapReference.hasFreeplaneFileExtension()) {
                        Controller.getCurrentController().selectMode(MModeController.MODENAME);
                        MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
                        mapController.newDocumentationMap(url);
                        if (nodeAndMapReference.hasNodeReference())
                            mapController.select(nodeAndMapReference.getNodeReference());
                    } else {
                        Controller.getCurrentController().getViewController().openDocument(url);
                    }
                } catch (final Exception e1) {
                    LogUtils.severe(e1);
                }
            }
        });
    } catch (MalformedURLException ex) {
        ex.printStackTrace();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) MMapController(org.freeplane.features.map.mindmapmode.MMapController) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException)

Example 19 with MMapController

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

the class NewLevelStyleAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final MapModel map = Controller.getCurrentController().getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    NodeModel levelStyleParentNode = styleModel.getStyleNodeGroup(map, MapStyleModel.STYLES_AUTOMATIC_LAYOUT);
    final String styleName = "AutomaticLayout.level," + levelStyleParentNode.getChildCount();
    final IStyle styleObject = StyleFactory.create(TranslatedObject.format(styleName));
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    final NodeModel node = new NodeModel(map);
    node.setUserObject(styleObject);
    mapController.insertNode(node, levelStyleParentNode, false, false, true);
    mapController.select(node);
    final IActor actor = new IActor() {

        public void undo() {
            styleModel.removeStyleNode(node);
        }

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

        public void act() {
            styleModel.addStyleNode(node);
        }
    };
    Controller.getCurrentModeController().execute(actor, map);
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel)

Example 20 with MMapController

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

the class NewUserStyleAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final String styleName = JOptionPane.showInputDialog(TextUtils.getText("enter_new_style_name"));
    if (styleName == null) {
        return;
    }
    final Controller controller = Controller.getCurrentController();
    final NodeModel selectedNode = controller.getSelection().getSelected();
    final MapModel map = controller.getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    final IStyle style = StyleFactory.create(styleName);
    if (null != styleModel.getStyleNode(style)) {
        UITools.errorMessage(TextUtils.getText("style_already_exists"));
        return;
    }
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    final NodeModel newNode = new NodeModel(map);
    newNode.setUserObject(style);
    Controller.getCurrentModeController().copyExtensions(LogicalStyleKeys.NODE_STYLE, selectedNode, newNode);
    Controller.getCurrentModeController().copyExtensions(Keys.ICONS, selectedNode, newNode);
    NodeModel userStyleParentNode = styleModel.getStyleNodeGroup(map, MapStyleModel.STYLES_USER_DEFINED);
    if (userStyleParentNode == null) {
        userStyleParentNode = new NodeModel(map);
        userStyleParentNode.setUserObject(new StyleTranslatedObject(MapStyleModel.STYLES_USER_DEFINED));
        mapController.insertNode(userStyleParentNode, map.getRootNode(), false, false, true);
    }
    mapController.insertNode(newNode, userStyleParentNode, false, false, true);
    mapController.select(newNode);
    final IActor actor = new IActor() {

        public void undo() {
            styleModel.removeStyleNode(newNode);
        }

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

        public void act() {
            styleModel.addStyleNode(newNode);
        }
    };
    Controller.getCurrentModeController().execute(actor, map);
}
Also used : IStyle(org.freeplane.features.styles.IStyle) StyleTranslatedObject(org.freeplane.features.styles.StyleTranslatedObject) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel) Controller(org.freeplane.features.mode.Controller) 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