public void onSaveNode(MindMapNode node) {
            if (this.node != node) {
                return;
            }
            boolean editorContentEmpty = true;
            // // TODO: Save the style with the note.
            // StyleSheet styleSheet = noteViewerComponent.getDocument()
            // .getStyleSheet();
            // styleSheet.removeStyle("body");
            // styleSheet.removeStyle("p");
            JEditorPane editorPane = noteViewerComponent.getEditorPane();
            int caretPosition = editorPane.getCaretPosition();
            int selectionStart = editorPane.getSelectionStart();
            int selectionEnd = editorPane.getSelectionEnd();
            String documentText = getDocumentText();
            editorContentEmpty = documentText
                    .equals(NodeNote.EMPTY_EDITOR_STRING)
                    || documentText
                    .equals(NodeNote.EMPTY_EDITOR_STRING_ALTERNATIVE)
                    || documentText
                    .equals(NodeNote.EMPTY_EDITOR_STRING_ALTERNATIVE2);
            // String noteText = node.getNoteText();
            // logger.info("Old doc =\n'" +
            // ((noteText==null)?noteText:noteText.replaceAll("\n", "\\\\n")) +
            // "', Current document: \n'" + documentText.replaceAll("\n",
            // "\\\\n") + "', empty="+editorContentEmpty);
            controller.deregisterNodeSelectionListener(this);
            if (noteViewerComponent.needsSaving()) {
                if (editorContentEmpty) {
                    changeNoteText(null, node);
                } else {
                    changeNoteText(documentText, node);
                }
                mLastContentEmpty = editorContentEmpty;
            }
            controller.registerNodeSelectionListener(this, false);
            try {
                // on inserting tabs, the caret position changes, as they are deleted:
                if (caretPosition < getDocument().getLength()) {
                    editorPane.setCaretPosition(caretPosition);
                }
                editorPane.setSelectionEnd(selectionEnd);
                editorPane.setSelectionStart(selectionStart);
            } catch (Exception e) {
                Resources.getInstance().logException(e);
            }
        }