private Element toElement(final SimpleDictionary dictionary) { final Element elem = getDocument().createElement("value-list-dictionary"); elem.setAttribute("name", dictionary.getName()); if (!Strings.isNullOrEmpty(dictionary.getDescription())) { elem.setAttribute("description", dictionary.getDescription()); } final Set<String> values = dictionary.getValueSet(); for (final String value : values) { appendElement(elem, "value", value); } appendElement(elem, "case-sensitive", dictionary.isCaseSensitive()); return elem; }
@Inject protected SimpleDictionaryDialog(@Nullable final SimpleDictionary dictionary, final MutableReferenceDataCatalog catalog, final WindowContext windowContext) { super(windowContext, ImageManager.get().getImage(IconUtils.DICTIONARY_SIMPLE_IMAGEPATH)); _originalDictionary = dictionary; _catalog = catalog; _nameTextField = WidgetFactory.createTextField("Dictionary name"); _valuesTextArea = WidgetFactory.createTextArea("Values"); _valuesTextArea.setRows(14); _caseSensitiveCheckBox = new DCCheckBox<>("Case-sensitive?", false); _caseSensitiveCheckBox.setForeground(WidgetUtils.BG_COLOR_BRIGHTEST); _caseSensitiveCheckBox.setOpaque(false); _caseSensitiveCheckBox.setToolTipText("Only match on dictionary terms when text-case is the same."); if (dictionary != null) { _nameTextField.setText(dictionary.getName()); final Collection<String> values = dictionary.getValueSet(); final StringBuilder sb = new StringBuilder(); boolean first = true; for (final String value : values) { if (first) { first = false; } else { sb.append('\n'); } sb.append(value); } _valuesTextArea.setText(sb.toString()); _caseSensitiveCheckBox.setSelected(dictionary.isCaseSensitive()); } }