!7 sclass Categories > DynModule { InputChooser inputChooser = new(this); S language; transient SingleComponentPanel form; start { dm_useLocalMechListCopies(); onChange(r { inputChooser.forceUpdate() }); // if language change } visualize { ret northAndCenter(wrap(inputChooser), withTopMargin(northAndCenter(jcenteredline(withLabel("Language:", dm_fieldComboBox('language, ll("English", "German")))), jfullcenter(form = singleComponentPanel())))); } void update { if (form == null || !inputChooser.update()) ret; S input = inputChooser.input(); L words = words(input); ai_setLanguage(language); final Map> wordCategories = ai_wordCategoriesWithElements(); for (S cat : keys(wordCategories)) print(cat + ": " + l(wordCategories.get(cat))); form.setComponentAndRevalidateParent(makeForm(pairsToParams(map(words, func(fS word) -> Pair { new L cats; for (S cat : keys(wordCategories)) if (contains(wordCategories.get(cat), word)) cats.add(cat); final JComboBox cb = jcombobox_withEmpty(keys(wordCategories)); ret pair( // quoted word setFontSize(18, jRightAlignedLabel(quote(word))), centerAndEastWithMargin( // known categories jlabel(or2(joinWithComma(cats), "-")), jline( // combo box for add/remove category cb, jbutton("Add", rThread { addToMechList(first(ai_mechListNamesForAngleBracketCategory(selectedItem(cb))), word); inputChooser.forceUpdate() }), // TODO jbutton("Remove", rThread { removeFromMechList(first(ai_mechListNamesForAngleBracketCategory(selectedItem(cb))), word)}) ))); })))); } }