Search in sources :

Example 1 with FileUserDictionary

use of com.inet.jortho.FileUserDictionary in project freeplane by freeplane.

the class SpellCheckerController method registerDictionaries.

private void registerDictionaries(final File orthoDir) {
    if (!orthoDir.isDirectory())
        return;
    final String[] dictionaryList = orthoDir.list(new FilenameFilter() {

        public boolean accept(final File dir, final String name) {
            return name.length() == "dictionary_XX.ortho".length() && name.startsWith("dictionary_") && name.endsWith(".ortho");
        }
    });
    if (dictionaryList.length == 0) {
        return;
    }
    final ResourceController resourceController = ResourceController.getResourceController();
    SpellChecker.setUserDictionaryProvider(new FileUserDictionary(resourceController.getFreeplaneUserDirectory()));
    final StringBuilder availableLocales = new StringBuilder();
    for (int i = 0; i < dictionaryList.length; i++) {
        final String language = dictionaryList[i].substring("dictionary_".length(), "dictionary_".length() + 2);
        availableLocales.append(language);
        availableLocales.append(",");
    }
    try {
        SpellChecker.registerDictionaries(orthoDir.toURI().toURL(), availableLocales.toString(), null, ".ortho");
        spellCheckerEnabled = true;
    } catch (final MalformedURLException e) {
        LogUtils.severe(e);
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) FileUserDictionary(com.inet.jortho.FileUserDictionary) MalformedURLException(java.net.MalformedURLException) ResourceController(org.freeplane.core.resources.ResourceController) File(java.io.File)

Aggregations

FileUserDictionary (com.inet.jortho.FileUserDictionary)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 MalformedURLException (java.net.MalformedURLException)1 ResourceController (org.freeplane.core.resources.ResourceController)1