Search in sources :

Example 1 with EditNodeDialog

use of org.freeplane.features.text.mindmapmode.EditNodeDialog in project freeplane by freeplane.

the class FormulaTextTransformer method createEditor.

public EditNodeBase createEditor(final NodeModel node, final EditNodeBase.IEditControl editControl, String text, final boolean editLong) {
    MTextController textController = MTextController.getController();
    if (textController.isTextFormattingDisabled(node))
        return null;
    final KeyEvent firstKeyEvent = textController.getEventQueue().getFirstEvent();
    if (firstKeyEvent != null) {
        if (firstKeyEvent.getKeyChar() == '=') {
            text = "=";
        } else {
            return null;
        }
    }
    if (text.startsWith("=")) {
        JEditorPane textEditor = new JEditorPane();
        textEditor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
        final JRestrictedSizeScrollPane scrollPane = new JRestrictedSizeScrollPane(textEditor);
        scrollPane.setMinimumSize(new Dimension(0, 60));
        final EditNodeDialog editNodeDialog = new FormulaEditor(node, text, firstKeyEvent, editControl, false, textEditor);
        editNodeDialog.setTitle(TextUtils.getText("formula_editor"));
        textEditor.setContentType("text/groovy");
        final String fontName = ResourceController.getResourceController().getProperty(FormulaEditor.GROOVY_EDITOR_FONT);
        final int fontSize = ResourceController.getResourceController().getIntProperty(FormulaEditor.GROOVY_EDITOR_FONT_SIZE);
        textEditor.setFont(new Font(fontName, Font.PLAIN, fontSize));
        return editNodeDialog;
    }
    return null;
}
Also used : KeyEvent(java.awt.event.KeyEvent) JRestrictedSizeScrollPane(org.freeplane.core.ui.components.JRestrictedSizeScrollPane) JEditorPane(javax.swing.JEditorPane) MTextController(org.freeplane.features.text.mindmapmode.MTextController) Dimension(java.awt.Dimension) EditNodeDialog(org.freeplane.features.text.mindmapmode.EditNodeDialog) Font(java.awt.Font)

Example 2 with EditNodeDialog

use of org.freeplane.features.text.mindmapmode.EditNodeDialog in project freeplane by freeplane.

the class LatexRenderer method createEditor.

public EditNodeBase createEditor(NodeModel node, IEditControl editControl, String text, boolean editLong) {
    MTextController textController = MTextController.getController();
    if (// Format=Text!
    textController.isTextFormattingDisabled(node))
        return null;
    final KeyEvent firstKeyEvent = textController.getEventQueue().getFirstEvent();
    String nodeFormat = textController.getNodeFormat(node);
    final String latexText = getLatexNode(text, nodeFormat, TargetMode.FOR_EDITOR);
    // this option has been added to work around bugs in JSyntaxPane with Chinese characters
    if (ResourceController.getResourceController().getBooleanProperty(LATEX_EDITOR_DISABLE))
        return null;
    if (latexText != null) {
        JEditorPane textEditor = new JEditorPane();
        textEditor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
        final JRestrictedSizeScrollPane scrollPane = new JRestrictedSizeScrollPane(textEditor);
        scrollPane.setMinimumSize(new Dimension(0, 60));
        final EditNodeDialog editNodeDialog = new LatexEditor(node, latexText, firstKeyEvent, editControl, false, textEditor);
        editNodeDialog.setTitle(TextUtils.getText("latex_editor"));
        textEditor.setContentType("text/latex");
        final String fontName = ResourceController.getResourceController().getProperty(LATEX_EDITOR_FONT);
        final int fontSize = ResourceController.getResourceController().getIntProperty(LATEX_EDITOR_FONT_SIZE);
        textEditor.setFont(new Font(fontName, Font.PLAIN, fontSize));
        return editNodeDialog;
    }
    return null;
}
Also used : KeyEvent(java.awt.event.KeyEvent) JRestrictedSizeScrollPane(org.freeplane.core.ui.components.JRestrictedSizeScrollPane) JEditorPane(javax.swing.JEditorPane) MTextController(org.freeplane.features.text.mindmapmode.MTextController) Dimension(java.awt.Dimension) EditNodeDialog(org.freeplane.features.text.mindmapmode.EditNodeDialog) Font(java.awt.Font)

Aggregations

Dimension (java.awt.Dimension)2 Font (java.awt.Font)2 KeyEvent (java.awt.event.KeyEvent)2 JEditorPane (javax.swing.JEditorPane)2 JRestrictedSizeScrollPane (org.freeplane.core.ui.components.JRestrictedSizeScrollPane)2 EditNodeDialog (org.freeplane.features.text.mindmapmode.EditNodeDialog)2 MTextController (org.freeplane.features.text.mindmapmode.MTextController)2