Search in sources :

Example 6 with SHTMLPanel

use of com.lightdev.app.shtm.SHTMLPanel in project freeplane by freeplane.

the class FreeplaneWindow method getShtmlPanel.

private SHTMLPanel getShtmlPanel() {
    final UIComponent[] components = getUIComponents(SHTMLPanel.class);
    Assert.assertTrue(components.length == 1);
    SHTMLPanel panel = (SHTMLPanel) components[0].getAwtComponent();
    return panel;
}
Also used : SHTMLPanel(com.lightdev.app.shtm.SHTMLPanel) UIComponent(org.uispec4j.UIComponent)

Example 7 with SHTMLPanel

use of com.lightdev.app.shtm.SHTMLPanel in project freeplane by freeplane.

the class NoteManager method saveNote.

void saveNote() {
    if (node == null) {
        return;
    }
    final SHTMLPanel noteViewerComponent = noteController.getNoteViewerComponent();
    if (noteViewerComponent == null) {
        return;
    }
    boolean editorContentEmpty = true;
    String documentText = noteViewerComponent.getDocumentText();
    documentText = HEAD.matcher(documentText).replaceFirst("");
    editorContentEmpty = HtmlUtils.isEmpty(documentText);
    Controller.getCurrentModeController().getMapController().removeNodeSelectionListener(this);
    if (noteViewerComponent.needsSaving()) {
        try {
            ignoreEditorUpdate = true;
            if (editorContentEmpty) {
                noteController.setNoteText(node, null);
            } else {
                noteController.setNoteText(node, documentText);
            }
        } finally {
            ignoreEditorUpdate = false;
        }
        noteController.setLastContentEmpty(editorContentEmpty);
    }
    Controller.getCurrentModeController().getMapController().addNodeSelectionListener(this);
}
Also used : SHTMLPanel(com.lightdev.app.shtm.SHTMLPanel)

Example 8 with SHTMLPanel

use of com.lightdev.app.shtm.SHTMLPanel in project freeplane by freeplane.

the class NoteManager method updateEditor.

void updateEditor() {
    if (ignoreEditorUpdate) {
        return;
    }
    final SHTMLPanel noteViewerComponent = noteController.getNoteViewerComponent();
    if (noteViewerComponent == null) {
        return;
    }
    final HTMLDocument document = noteViewerComponent.getDocument();
    document.removeDocumentListener(mNoteDocumentListener);
    try {
        final URL url = node.getMap().getURL();
        if (url != null) {
            document.setBase(url);
        } else {
            document.setBase(new URL("file: "));
        }
    } catch (final Exception e) {
    }
    noteController.setDefaultFont();
    final String note = node != null ? NoteModel.getNoteText(node) : null;
    if (note != null) {
        noteViewerComponent.setCurrentDocumentContent(note);
        noteController.setLastContentEmpty(false);
    } else if (!noteController.isLastContentEmpty()) {
        noteViewerComponent.setCurrentDocumentContent("");
        noteController.setLastContentEmpty(true);
    }
    document.addDocumentListener(mNoteDocumentListener);
}
Also used : SHTMLPanel(com.lightdev.app.shtm.SHTMLPanel) HTMLDocument(javax.swing.text.html.HTMLDocument) URL(java.net.URL)

Aggregations

SHTMLPanel (com.lightdev.app.shtm.SHTMLPanel)8 JEditorPane (javax.swing.JEditorPane)3 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 URI (java.net.URI)2 URL (java.net.URL)2 HTMLDocument (javax.swing.text.html.HTMLDocument)2 ActionBuilder (com.lightdev.app.shtm.ActionBuilder)1 TextResources (com.lightdev.app.shtm.TextResources)1 Color (java.awt.Color)1 KeyEvent (java.awt.event.KeyEvent)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 BadLocationException (javax.swing.text.BadLocationException)1 JTextComponent (javax.swing.text.JTextComponent)1 StyleSheet (javax.swing.text.html.StyleSheet)1 UIComponent (org.uispec4j.UIComponent)1