private void applyChanges() { boolean changedFieldSet = false; // Watch if we need to rebuild entry editors // First remove the mappings for fields that have been deleted. // If these were re-added, they will be added below, so it doesn't // cause any harm to remove them here. for (String fieldName : removedFields) { metaData.remove(Globals.SELECTOR_META_PREFIX + fieldName); changedFieldSet = true; } // Cycle through all fields that we have created listmodels for: for (String fieldName : wordListModels.keySet()) { // For each field name, store the values: if ((fieldName == null) || FIELD_FIRST_LINE.equals(fieldName)) { continue; } DefaultListModel<String> lm = wordListModels.get(fieldName); int start = 0; // Avoid storing the <new word> marker if it is there: if (!lm.isEmpty()) { while ((start < lm.size()) && lm.get(start).equals(WORD_FIRSTLINE_TEXT)) { start++; } } Vector<String> data = metaData.getData(Globals.SELECTOR_META_PREFIX + fieldName); boolean bNewField = false; if (data == null) { bNewField = true; data = new Vector<>(); changedFieldSet = true; } else { data.clear(); } for (int wrd = start; wrd < lm.size(); wrd++) { String word = lm.get(wrd); data.add(word); } if (bNewField) { metaData.putData(Globals.SELECTOR_META_PREFIX + fieldName, data); } } // System.out.println("TODO: remove metadata for removed selector field."); panel.markNonUndoableBaseChanged(); // Update all selectors in the current BasePanel. if (changedFieldSet) { panel.rebuildAllEntryEditors(); } else { panel.updateAllContentSelectors(); } panel.getAutoCompleters().addContentSelectorValuesToAutoCompleters(panel.metaData); }