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;
}
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);
}
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);
}
Aggregations