!7 sclass GeneralDefinitions extends DynModule { transient S term; transient JPanel stack; transient OptionalInputPanel inputPanel; transient S listName = "General definitions (long list)"; JComponent visualize() { inputPanel = new OptionalInputPanel(this); stack = dynamicVStack2(); ret northCenterAndSouth( inputPanel.panel, stack, withMargin(jcenteredbuttons("Add definition...", r { fS t = term; final JTextField tfWord = jtextfield(t), tfDefinition = jtextfield(); showFormTitled("Add Definition", "Word/Phrase:", tfWord, "Definition:", tfDefinition, r { S word = gtt(tfWord), def = gtt(tfDefinition); if (nempty(word) && nempty(def)) { addToMechMap(listName, litmap(word, def)); infoBox("Definition added: " + word + " = " + def); updateMe(); } }); requestFocus(tfDefinition); }, "Show all definitions", r { showText("All definitions", ltrim(asciiHeading_twoNewLines("AUTHORIZED")) + mechList_raw_opt(listName) + asciiHeading_twoNewLines("UNAUTHORIZED") + mechList_raw_opt("Unauthorized Appends | " + listName)); }))); } void update { if (stack == null) ret; S s = inputPanel.input(); term = s; S text = makeText(s); replaceAllComponents(stack, ll(fontSize(17, jCenteredMultiLineLabel(text)))); } S makeText(fS s) { S text = ""; if (empty(s)) ret text; MultiMap> map = mechMultiMapPairsCI(listName); L> answers = map.get(s); MultiMap> map2 = mechMultiMapPairsCI("Unauthorized Appends | " + listName); L> answers2 = map2.get(s); if (empty(answers) && empty(answers2)) ret "No definitions found for " + quote(s); ret lines(concatLists( mapPairsToList(answers, func(S a, S b) -> S { a + " = " + b }), mapPairsToList(answers2, func(S a, S b) -> S { a + " " + unicode_questionedEquals() + " " + b }) )); } }