use of org.freeplane.features.text.mindmapmode.FreeplaneToSHTMLPropertyChangeAdapter in project freeplane by freeplane.
the class MNoteController method getHtmlEditorPanel.
SHTMLPanel getHtmlEditorPanel() {
if (htmlEditorPanel != null) {
return htmlEditorPanel;
}
htmlEditorPanel = MTextController.getController().createSHTMLPanel(NoteModel.EDITING_PURPOSE);
// make sure that SHTML gets notified of relevant config changes!
ResourceController.getResourceController().addPropertyChangeListener(new FreeplaneToSHTMLPropertyChangeAdapter(htmlEditorPanel));
htmlEditorPanel.setMinimumSize(new Dimension(100, 100));
final SHTMLEditorPane editorPane = (SHTMLEditorPane) htmlEditorPanel.getEditorPane();
for (InputMap inputMap = editorPane.getInputMap(); inputMap != null; inputMap = inputMap.getParent()) {
inputMap.remove(KeyStroke.getKeyStroke("ctrl pressed T"));
inputMap.remove(KeyStroke.getKeyStroke("ctrl shift pressed T"));
inputMap.remove(KeyStroke.getKeyStroke("ctrl pressed SPACE"));
}
editorPane.addFocusListener(new FocusListener() {
private SpellCheckerController spellCheckerController = null;
private boolean enabled = false;
public void focusLost(final FocusEvent e) {
if (!e.isTemporary()) {
spellCheckerController.enableAutoSpell(editorPane, false);
enabled = false;
noteManager.saveNote();
}
}
public void focusGained(final FocusEvent e) {
if (!enabled) {
initSpellChecker();
spellCheckerController.enableAutoSpell(editorPane, true);
enabled = true;
}
}
private void initSpellChecker() {
if (spellCheckerController != null) {
return;
}
spellCheckerController = SpellCheckerController.getController();
spellCheckerController.addSpellCheckerMenu(editorPane.getPopup());
spellCheckerController.enableShortKey(editorPane, true);
}
});
htmlEditorPanel.getSourceEditorPane().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
if (!e.isTemporary()) {
noteManager.saveNote();
}
}
@Override
public void focusGained(FocusEvent e) {
}
});
return htmlEditorPanel;
}
Aggregations