/** * Loads the (serialized) PriorityTree. * * @author DirkK */ private void loadTree() { tree = new PriorityTree(); boolean successfullyCharsLoaded = tree.loadChars(properties.getProperty("chars")); if (!successfullyCharsLoaded) { properties.setProperty("chars", Config.getConf().getProperty("defaultAllowedChars")); tree.loadChars(Config.getConf().getProperty("defaultAllowedChars")); } new Thread() { public void run() { try { tree.importFromHashMap( ImportExportManager.importFromFile(properties.getProperty("tree"), true)); } catch (IOException err) { logger.warn( "Could not fetch the dictionary for the proifle " + properties.getProperty("name") + ", File: " + properties.getProperty("tree")); } logger.debug("Tree successfully loaded"); dictionaryLoaded = true; Controller.getInstance().showStatusMessage("Dictionary loaded"); } }.start(); }
/** * Saves the PriorityTree as serialized object * * @author DirkK */ private void saveTree() { if (tree != null && dictionaryLoaded) { logger.debug("save tree to " + properties.getProperty("tree")); final PriorityTree tempTree = tree.clone(); new Thread() { public void run() { try { ImportExportManager.exportToFile( tempTree.exportToHashMap(), properties.getProperty("tree")); } catch (IOException err) { logger.error( "Not able to save the tree for proifle " + properties.getProperty("name") + " to " + properties.getProperty("tree")); } } }.start(); logger.debug("save the allowed chars(" + properties.getProperty("chars") + ")"); } else { logger.debug("Tree not saved, because not existend"); } }
public void setAllowedChars(String allowedChars) { tree.loadChars(allowedChars); properties.setProperty("chars", allowedChars); }