public void persistDictionaries() { StringBuilder sb = new StringBuilder(); for (int index = 0; index < this.getSize(); index++) { DataDictionaryFile dictionaryFile = this.getElementAt(index); sb.append( dictionaryFile.getName() + "=" + dictionaryFile.getFile().getAbsolutePath() + "|"); } preferences.put(FILE_LIST, sb.toString()); }
private void handleSelection(final JList<DataDictionaryFile> jlist) { DataDictionaryFile value = jlist.getSelectedValue(); if (value != null) { setSelectedDictionary(value); preferences.put(SELECTED_DICTIONARY, value.getName()); fireDataDictionarySelected(value.getDataDictionary()); jlist.repaint(); } }
public void loadDictionaries() { String fileList = preferences.get(FILE_LIST, null); if (fileList == null || "".equals(fileList)) return; String selectedDictName = preferences.get(SELECTED_DICTIONARY, null); DataDictionaryFile selectedDict = null; String[] tokens = fileList.split("\\|"); for (String string : tokens) { String[] kv = string.split("\\="); String name = kv[0]; String filePath = kv[1]; try { DataDictionaryFile item = DataDictionaryFile.load(name, new File(filePath)); this.addElement(item); if (selectedDictName != null && item.getName().equals(selectedDictName)) selectedDict = item; } catch (FileNotFoundException | ConfigError e) { System.err.println("Could not load dictionary: " + filePath); } } if (selectedDict != null) { setSelectedDictionary(selectedDict); fireDataDictionarySelected(selectedDictionary.getDataDictionary()); } }