Search in sources :

Example 1 with TextController

use of org.freeplane.features.text.TextController 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 {
    if (!model.hasVisibleContent()) {
        for (final NodeModel child : mapController.childrenUnfolded(model)) {
            lastChildNumber = writeHTML(child, parentID, lastChildNumber, false, false, depth);
        }
        return lastChildNumber;
    }
    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(lf + "<h" + depth + ">");
        } else if (!hasHtml) {
            fileout.write("<p>");
        }
    }
    String localParentID = parentID;
    if (createFolding) {
        lastChildNumber++;
        localParentID = parentID + "_" + lastChildNumber;
        writeFoldingButtons(localParentID);
    }
    final String fontStyle = fontStyle(nodeStyleController.getColor(model), nodeStyleController.getFont(model));
    boolean shouldOutputFontStyle = !fontStyle.equals("");
    if (shouldOutputFontStyle) {
        fileout.write("<span style=\"" + fontStyle + "\">");
    }
    String link = NodeLinks.getLinkAsString(model);
    if (link != null) {
        if (link.endsWith(UrlManager.FREEPLANE_FILE_EXTENSION)) {
            link += ".html";
        }
        fileout.write("<a href=\"" + link + "\" target=\"_blank\">");
    }
    if (ResourceController.getResourceController().getBooleanProperty("export_icons_in_html")) {
        writeIcons(model);
    }
    writeModelContent(text);
    if (link != null) {
        fileout.write("</a>" + lf);
    }
    if (shouldOutputFontStyle) {
        fileout.write("</span>");
    }
    final String detailText = DetailTextModel.getDetailTextText(model);
    if (detailText != null) {
        writeModelContent(detailText);
    }
    final String noteContent = NoteModel.getNoteText(model);
    if (noteContent != null) {
        writeModelContent(noteContent);
    }
    if (heading) {
        fileout.write("</h" + depth + ">" + lf);
    }
    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, false, 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, false, depth + 1);
            }
        } else if (createFolding) {
            fileout.write(lf + "<ul id=\"fold" + localParentID + "\" style=\"POSITION: relative; VISIBILITY: visible;\">" + lf);
            int localLastChildNumber = 0;
            for (final NodeModel child : mapController.childrenUnfolded(model)) {
                localLastChildNumber = writeHTML(child, localParentID, localLastChildNumber, /* isRoot=*/
                false, false, depth + 1);
            }
        } else {
            fileout.write(lf + "<ul>" + lf);
            for (final NodeModel child : mapController.childrenUnfolded(model)) {
                lastChildNumber = writeHTML(child, parentID, lastChildNumber, /* isRoot= */
                false, false, depth + 1);
            }
        }
        fileout.write("</ul>" + lf);
    }
    if (!treatAsParagraph) {
        fileout.write("</li>" + lf);
    }
    return lastChildNumber;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) TextController(org.freeplane.features.text.TextController)

Example 2 with TextController

use of org.freeplane.features.text.TextController in project freeplane by freeplane.

the class AttributeConditionController method getValuesForProperty.

public ComboBoxModel getValuesForProperty(final Object selectedItem, TranslatedObject simpleCond) {
    final MapModel map = Controller.getCurrentController().getMap();
    final AttributeRegistry registry = AttributeRegistry.getRegistry(map);
    try {
        final AttributeRegistryElement element = registry.getElement(selectedItem.toString());
        final SortedComboBoxModel list = element.getValues();
        SortedComboBoxModel linkedList = new SortedComboBoxModel();
        for (int i = 0; i < list.getSize(); i++) {
            final Object value = list.getElementAt(i);
            final TextController textController = TextController.getController();
            if (!textController.isFormula(value, null, null)) {
                try {
                    final Object transformedValue = textController.getTransformedObject(value, map.getRootNode(), null);
                    linkedList.add(transformedValue);
                } catch (TransformationException e) {
                    LogUtils.severe(e);
                }
            }
        }
        values.setExtensionList(linkedList);
    } catch (NoSuchElementException e) {
        values.setExtensionList(null);
    }
    return values;
}
Also used : TransformationException(org.freeplane.features.text.TransformationException) TextController(org.freeplane.features.text.TextController) TranslatedObject(org.freeplane.core.resources.TranslatedObject) MapModel(org.freeplane.features.map.MapModel) SortedComboBoxModel(org.freeplane.core.util.collection.SortedComboBoxModel) NoSuchElementException(java.util.NoSuchElementException)

Example 3 with TextController

use of org.freeplane.features.text.TextController in project freeplane by freeplane.

the class AttributeContainsCondition method checkNode.

/*
	 * (non-Javadoc)
	 * @see
	 * freeplane.controller.filter.condition.Condition#checkNode(freeplane.modes
	 * .MindMapNode)
	 */
public boolean checkNode(final NodeModel node) {
    final IAttributeTableModel attributes = NodeAttributeTableModel.getModel(node);
    final TextController textController = TextController.getController();
    for (int i = 0; i < attributes.getRowCount(); i++) {
        if (attribute.equals(AttributeConditionController.ANY_ATTRIBUTE_NAME_OR_VALUE_OBJECT)) {
            if (checkText(attributes.getValueAt(i, 0).toString()))
                return true;
        } else if (!attributes.getValueAt(i, 0).equals(attribute)) {
            continue;
        }
        final Object originalContent = attributes.getValueAt(i, 1);
        String text = textController.getTransformedTextNoThrow(originalContent, node, null);
        if (checkText(text)) {
            return true;
        }
    }
    return false;
}
Also used : TextController(org.freeplane.features.text.TextController)

Example 4 with TextController

use of org.freeplane.features.text.TextController in project freeplane by freeplane.

the class NodeView method isShortened.

public boolean isShortened() {
    final ModeController modeController = getMap().getModeController();
    final TextController textController = TextController.getController(modeController);
    final boolean textShortened = textController.isMinimized(getModel());
    return textShortened;
}
Also used : TextController(org.freeplane.features.text.TextController) ModeController(org.freeplane.features.mode.ModeController)

Example 5 with TextController

use of org.freeplane.features.text.TextController in project freeplane by freeplane.

the class MMapController method addFreeNode.

public NodeModel addFreeNode(final Point pt, final boolean newNodeIsLeft) {
    final ModeController modeController = Controller.getCurrentModeController();
    final TextController textController = TextController.getController();
    if (textController instanceof MTextController) {
        ((MTextController) textController).stopEditing();
        modeController.forceNewTransaction();
    }
    final NodeModel target = getRootNode();
    final NodeModel targetNode = target;
    final boolean parentFolded = isFolded(targetNode);
    if (parentFolded) {
        unfold(targetNode);
    }
    if (!isWriteable(target)) {
        UITools.errorMessage(TextUtils.getText("node_is_write_protected"));
        return null;
    }
    final NodeModel newNode = newNode("", target.getMap());
    LogicalStyleModel.createExtension(newNode).setStyle(MapStyleModel.FLOATING_STYLE);
    newNode.addExtension(modeController.getExtension(FreeNode.class));
    if (!addNewNode(newNode, target, target.getChildCount(), newNodeIsLeft))
        return null;
    final Quantity<LengthUnits> x = LengthUnits.pixelsInPt(pt.x);
    final Quantity<LengthUnits> y = LengthUnits.pixelsInPt(pt.y);
    ((MLocationController) MLocationController.getController(modeController)).moveNodePosition(newNode, x, y);
    final Component component = Controller.getCurrentController().getMapViewManager().getComponent(newNode);
    if (component == null)
        return newNode;
    component.addFocusListener(new FocusListener() {

        public void focusLost(FocusEvent e) {
        }

        public void focusGained(FocusEvent e) {
            e.getComponent().removeFocusListener(this);
            ((MTextController) textController).edit(newNode, targetNode, true, false, false);
        }
    });
    select(newNode);
    return newNode;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) LengthUnits(org.freeplane.core.ui.LengthUnits) MLocationController(org.freeplane.features.nodelocation.mindmapmode.MLocationController) MTextController(org.freeplane.features.text.mindmapmode.MTextController) TextController(org.freeplane.features.text.TextController) FreeNode(org.freeplane.features.map.FreeNode) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MTextController(org.freeplane.features.text.mindmapmode.MTextController) Component(java.awt.Component) FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent)

Aggregations

TextController (org.freeplane.features.text.TextController)17 NodeModel (org.freeplane.features.map.NodeModel)6 ModeController (org.freeplane.features.mode.ModeController)6 Component (java.awt.Component)4 JPopupMenu (javax.swing.JPopupMenu)3 IconController (org.freeplane.features.icon.IconController)3 LinkController (org.freeplane.features.link.LinkController)3 Controller (org.freeplane.features.mode.Controller)3 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)3 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)3 FocusEvent (java.awt.event.FocusEvent)2 FocusListener (java.awt.event.FocusListener)2 Icon (javax.swing.Icon)2 FreeplaneToolBar (org.freeplane.core.ui.components.FreeplaneToolBar)2 ClipboardController (org.freeplane.features.clipboard.ClipboardController)2 CloudController (org.freeplane.features.cloud.CloudController)2 EdgeController (org.freeplane.features.edge.EdgeController)2 FilterController (org.freeplane.features.filter.FilterController)2 MapController (org.freeplane.features.map.MapController)2 MMapController (org.freeplane.features.map.mindmapmode.MMapController)2