Uses 911K of libraries. Click here for Pure Java version (15653L/87K).
1 | !7 |
2 | |
3 | cmodule Categories { |
4 | InputChooser inputChooser = new(this); |
5 | S language = 'english; |
6 | transient SingleComponentPanel form; |
7 | |
8 | start { |
9 | dm_useLocalMechListCopies(); |
10 | onChange(r { inputChooser.forceUpdate() }); // if language change |
11 | dm_afterVisualize(r { inputChooser.forceUpdate() }); |
12 | } |
13 | |
14 | visualize { |
15 | ret northAndCenter(wrap(inputChooser), |
16 | withTopMargin(northAndCenter(jcenteredline(withLabel("Language:", dm_fieldComboBox('language, ll("English", "German")))), |
17 | /*jfullcenter*//*jscroll_trackWidth*/(form = singleComponentPanel())))); |
18 | } |
19 | |
20 | void update { |
21 | if (form == null || !inputChooser.update()) ret; |
22 | S input = inputChooser.input(); |
23 | L<S> words = words(input); |
24 | ai_setLanguage(language); |
25 | |
26 | final Map<S, Set<S>> wordCategories = ai_wordCategoriesWithElements(); |
27 | |
28 | form.setComponentAndRevalidateParent(makeForm(pairsToParams(map(words, |
29 | func(fS word) -> Pair<O> { |
30 | new L<S> cats; |
31 | for (S cat : keys(wordCategories)) |
32 | if (contains(wordCategories.get(cat), word)) |
33 | cats.add(cat); |
34 | |
35 | if (empty(cats) && dm_isShowingAndOSInForeground()) |
36 | dm_toFront(); // uncategorized word - go to front |
37 | |
38 | final JComboBox cb = jcombobox(keys(wordCategories)); |
39 | comboBoxSelectIndex(cb, 0); |
40 | |
41 | ret (Pair) pair( |
42 | // quoted word |
43 | setFontSize(18, jRightAlignedLabel(quote(word))), |
44 | |
45 | centerAndEastWithMargin( |
46 | // known categories |
47 | jlabel(or2(joinWithComma(cats), "-")), |
48 | |
49 | jline( |
50 | // combo box for add/remove category |
51 | cb, |
52 | jbutton("Add", rThread { |
53 | assertEquals("Language!", language, ai_language()); |
54 | addToMechList(first(ai_mechListNamesForAngleBracketCategory(selectedItem(cb))), word); |
55 | inputChooser.forceUpdate() |
56 | }), |
57 | // TODO jbutton("Remove", rThread { removeFromMechList(first(ai_mechListNamesForAngleBracketCategory(selectedItem(cb))), word)}) |
58 | ))); |
59 | })))); |
60 | } |
61 | } |
Began life as a copy of #1017001
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017339 |
Snippet name: | Categories For Each Word [Dyn Module, OK] |
Eternal ID of this version: | #1017339/26 |
Text MD5: | 74233ee18db7256f4369d6bee9270333 |
Transpilation MD5: | 63849785eb53a1cdd9ef6e2fbe18892d |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-02-08 13:27:29 |
Source code size: | 2180 bytes / 61 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 472 / 6513 |
Version history: | 25 change(s) |
Referenced in: | [show references] |