!7 concept Definition { S word, definition; sS _fieldOrder = "word definition"; } cmodule Definitions > DynCRUD { start { dbIndexingCI(Definition, 'word, Definition, 'definition); } afterVisualize { replaceComponent(crud.tableSearcher.tfInput, func(JComponent c) -> JComponent { centerAndEastWithMargin(c, jbutton("Define...", rThread { define(searchTerm()) })) }); onEnter(crud.tableSearcher.tfInput, rThread { define(searchTerm()) }); } void define(fS term) enter { final JTextField tfWord = jtextfield(or2(term, dm_topInput())), tfDefinition = jtextfield(); showFormTitled("Add Definition", "Word/Phrase:", tfWord, "Definition:", tfDefinition, rThread { S word = gtt(tfWord), definition = gtt(tfDefinition); uniq_sync(Definition, +word, +definition); }); focus(nempty(term) ? tfDefinition : tfWord); } enhanceFrame { internalFrameTitleMenuItem(f, "Import Text...", r { inputMultiLineText("Definitions (Format: a - b)", "Ice cream - something to eat", voidfunc(S s) { importText(s) }); }); } // API LS getDefinitions(S word) { ret collect('definition, conceptsWhereIC(Definition, +word)); } LS getReverseDefinitions(S definition) { ret collect('word, conceptsWhereIC(Definition, +definition)); } Map getDefinitionsMap() { ret main. ciMultiMapFromKeyAndValueField(list(Definition), 'word, 'definition).data; } void importText(S text) { for (S s : tlft(text)) { LS l = tok_splitAtFirstSpacedDash(s); if (l(l) == 5) uniq_sync(Definition, word := l.get(1), definition := l.get(3)); } } S exportAsText() { ret lines(map(list(Definition), func(Definition d) -> S { d.word + " - " + d.definition })); } void addDefinition(S word, S definition) { uniq_sync(Definition, +word, +definition); } }