private void init() {
if (spellCheckerInitialized == true) {
return;
}
spellCheckerInitialized = true;
final ResourceController resourceController = ResourceController.getResourceController();
final File orthoDir = new File(resourceController.getResourceBaseDir(), "ortho");
registerDictionaries(orthoDir);
final File userOrthoDir = new File(resourceController.getFreeplaneUserDirectory(), "ortho");
registerDictionaries(userOrthoDir);
if (!spellCheckerEnabled) {
return;
}
setSpellCheckOptions(resourceController);
resourceController.addPropertyChangeListener(new IFreeplanePropertyListener() {
public void propertyChanged(final String propertyName, final String newValue, final String oldValue) {
if (propertyName.startsWith("spelling_opt")) {
setSpellCheckOptions(resourceController);
}
}
});
String spellingLanguage = resourceController.getProperty(SPELLING_LANGUAGE, null);
if (spellingLanguage == null) {
spellingLanguage = resourceController.getLanguageCode();
}
if (!spellingLanguage.equals("disabled")) {
SpellChecker.setLanguage(spellingLanguage);
}
languageChangeListener = new LanguageChangeListener() {
public void languageChanged(final LanguageChangeEvent ev) {
EventQueue.invokeLater(new Runnable() {
public void run() {
final Locale currentLocale = ev.getCurrentLocale();
if (currentLocale == null) {
resourceController.setProperty(SPELLING_LANGUAGE, "disabled");
return;
}
resourceController.setProperty(SPELLING_LANGUAGE, currentLocale.getLanguage());
}
});
}
};
SpellChecker.addLanguageChangeLister(languageChangeListener);