Search in sources :

Example 76 with NodeModel

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

the class RemoveFirstAttributeAction method setEnabled.

@Override
public void setEnabled() {
    boolean enable = false;
    final AttributeUtilities atrUtil = new AttributeUtilities();
    final Collection<NodeModel> nodes = Controller.getCurrentModeController().getMapController().getSelectedNodes();
    for (final NodeModel node : nodes) {
        if (node != null && atrUtil.hasAttributes(node)) {
            enable = true;
            break;
        }
    }
    setEnabled(enable);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel)

Example 77 with NodeModel

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

the class CloneAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final MClipboardController clipboardController = (MClipboardController) ClipboardController.getController();
    final NodeModel parent = Controller.getCurrentController().getSelection().getSelected();
    clipboardController.addClone(clipboardController.getClipboardContents(), parent);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel)

Example 78 with NodeModel

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

the class MindMapHTMLWriter method writeHTML.

private int writeHTML(final NodeModel model, final String parentID, int lastChildNumber, final boolean isRoot, final boolean treatAsParagraph, final int depth) throws IOException {
    boolean createFolding = false;
    if (writeFoldingCode) {
        createFolding = mapController.isFolded(model);
        if (getProperty("html_export_folding").equals("html_export_fold_all")) {
            createFolding = mapController.hasChildren(model);
        }
        if (getProperty("html_export_folding").equals("html_export_no_folding") || basedOnHeadings || isRoot) {
            createFolding = false;
        }
    }
    final TextController textController = TextController.getController();
    final Object userObject = model.getUserObject();
    final String text = textController.getTransformedTextNoThrow(userObject, model, userObject);
    final boolean hasHtml = text.startsWith("<html>");
    final boolean heading = basedOnHeadings && !hasHtml && mapController.hasChildren(model) && depth <= 6;
    if (!treatAsParagraph && !basedOnHeadings) {
        fileout.write("<li>");
    } else {
        if (heading) {
            fileout.write("<h" + depth + ">");
        } else if (!hasHtml) {
            fileout.write("<p>");
        }
    }
    String localParentID = parentID;
    if (createFolding) {
        lastChildNumber++;
        localParentID = parentID + "_" + lastChildNumber;
        writeFoldingButtons(localParentID);
    }
    String link = NodeLinks.getLinkAsString(model);
    if (link != null) {
        if (link.endsWith(UrlManager.FREEPLANE_FILE_EXTENSION)) {
            link += ".html";
        }
        fileout.write("<a href=\"" + link + "\" target=\"_blank\"><span class=l>~</span>&nbsp;");
    }
    final String fontStyle = fontStyle(nodeStyleController.getColor(model), nodeStyleController.getFont(model));
    if (!fontStyle.equals("")) {
        fileout.write("<span style=\"" + fontStyle + "\">");
    }
    if (ResourceController.getResourceController().getBooleanProperty("export_icons_in_html")) {
        writeIcons(model);
    }
    writeModelContent(text);
    final String detailText = DetailTextModel.getDetailTextText(model);
    if (detailText != null) {
        writeModelContent(detailText);
    }
    if (fontStyle != "") {
        fileout.write("</span>");
    }
    final String noteContent = NoteModel.getNoteText(model);
    if (noteContent != null) {
        writeModelContent(noteContent);
    }
    fileout.write(MindMapHTMLWriter.el);
    if (link != null) {
        fileout.write("</a>" + MindMapHTMLWriter.el);
    }
    if (heading) {
        fileout.write("</h" + depth + ">" + MindMapHTMLWriter.el);
    }
    boolean treatChildrenAsParagraph = false;
    for (final NodeModel child : mapController.childrenUnfolded(model)) {
        if (child.toString().length() > 100) {
            treatChildrenAsParagraph = true;
            break;
        }
    }
    if (getProperty("html_export_folding").equals("html_export_based_on_headings")) {
        for (final NodeModel child : mapController.childrenUnfolded(model)) {
            lastChildNumber = writeHTML(child, parentID, lastChildNumber, /*isRoot=*/
            false, treatChildrenAsParagraph, depth + 1);
        }
        return lastChildNumber;
    }
    if (mapController.hasChildren(model)) {
        if (getProperty("html_export_folding").equals("html_export_based_on_headings")) {
            for (final NodeModel child : mapController.childrenUnfolded(model)) {
                lastChildNumber = writeHTML(child, parentID, lastChildNumber, /*isRoot=*/
                false, treatChildrenAsParagraph, depth + 1);
            }
        } else if (createFolding) {
            fileout.write("<ul id=\"fold" + localParentID + "\" style=\"POSITION: relative; VISIBILITY: visible;\">");
            if (treatChildrenAsParagraph) {
                fileout.write("<li>");
            }
            int localLastChildNumber = 0;
            for (final NodeModel child : mapController.childrenUnfolded(model)) {
                localLastChildNumber = writeHTML(child, localParentID, localLastChildNumber, /* isRoot=*/
                false, treatChildrenAsParagraph, depth + 1);
            }
        } else {
            fileout.write("<ul>");
            if (treatChildrenAsParagraph) {
                fileout.write("<li>");
            }
            for (final NodeModel child : mapController.childrenUnfolded(model)) {
                lastChildNumber = writeHTML(child, parentID, lastChildNumber, /* isRoot= */
                false, treatChildrenAsParagraph, depth + 1);
            }
        }
        if (treatChildrenAsParagraph) {
            fileout.write("</li>");
        }
        fileout.write(MindMapHTMLWriter.el);
        fileout.write("</ul>");
    }
    if (!treatAsParagraph) {
        fileout.write(MindMapHTMLWriter.el + "</li>" + MindMapHTMLWriter.el);
    }
    return lastChildNumber;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) TextController(org.freeplane.features.text.TextController)

Example 79 with NodeModel

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

the class MindMapHTMLWriter method writeHTML.

void writeHTML(final Collection<NodeModel> selectedNodes) throws IOException {
    fileout.write("<html>" + MindMapHTMLWriter.el + "<head>" + MindMapHTMLWriter.el);
    if (!selectedNodes.isEmpty()) {
        final MapModel map = selectedNodes.iterator().next().getMap();
        setDefaultsFrom(map);
        writeStyle();
    }
    fileout.write(MindMapHTMLWriter.el + "</head>" + MindMapHTMLWriter.el + "<body>" + MindMapHTMLWriter.el);
    for (NodeModel node : selectedNodes) {
        writeHTML(node, "1", 0, /* isRoot */
        true, true, /* depth */
        1);
    }
    fileout.write("</body>" + MindMapHTMLWriter.el);
    fileout.write("</html>" + MindMapHTMLWriter.el);
    fileout.close();
    resetDefaults();
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapModel(org.freeplane.features.map.MapModel)

Example 80 with NodeModel

use of org.freeplane.features.map.NodeModel 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(collection, true);
    for (final NodeModel node : collection) {
        if (node.getParentNode() != null) {
            ((MMapController) Controller.getCurrentModeController().getMapController()).deleteNode(node);
        }
    }
    setClipboardContents(transferable);
    return transferable;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MindMapNodesSelection(org.freeplane.features.clipboard.MindMapNodesSelection)

Aggregations

NodeModel (org.freeplane.features.map.NodeModel)450 ModeController (org.freeplane.features.mode.ModeController)100 MapModel (org.freeplane.features.map.MapModel)53 Controller (org.freeplane.features.mode.Controller)46 MapStyleModel (org.freeplane.features.styles.MapStyleModel)46 MMapController (org.freeplane.features.map.mindmapmode.MMapController)39 MapController (org.freeplane.features.map.MapController)38 Point (java.awt.Point)37 IStyle (org.freeplane.features.styles.IStyle)36 IActor (org.freeplane.core.undo.IActor)34 IMapSelection (org.freeplane.features.map.IMapSelection)33 ArrayList (java.util.ArrayList)22 NodeView (org.freeplane.view.swing.map.NodeView)20 URI (java.net.URI)19 Color (java.awt.Color)18 Component (java.awt.Component)17 ResourceController (org.freeplane.core.resources.ResourceController)17 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)16 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)15 MTextController (org.freeplane.features.text.mindmapmode.MTextController)15