Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

56
LINES

< > BotCompany Repo | #1016431 // General Definitions [Dyn Module, shortened, old]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (16088L/116K).

1  
!7
2  
3  
sclass GeneralDefinitions extends DynModule {
4  
  transient S term;
5  
  transient JPanel stack;
6  
  transient OptionalInputPanel inputPanel;
7  
  transient S listName = "General definitions (long list)";
8  
9  
  JComponent visualize() {
10  
    inputPanel = new OptionalInputPanel(this);
11  
    stack = dynamicVStack2();
12  
    ret northCenterAndSouth(
13  
      inputPanel.panel,
14  
      stack, 
15  
      withMargin(jcenteredbutton("Add definition...", r {
16  
        fS t = term;
17  
        final JTextField tfWord = jtextfield(t), tfDefinition = jtextfield();
18  
        showFormTitled("Add Definition",
19  
          "Word/Phrase:", tfWord,
20  
          "Definition:", tfDefinition,
21  
          r {
22  
            S word = gtt(tfWord), def = gtt(tfDefinition);
23  
            if (nempty(word) && nempty(def)) {
24  
              addToMechMap(listName, litmap(word, def));
25  
              infoBox("Definition added: " + word + " = " + def);
26  
              updateMe();
27  
            }
28  
          });
29  
        requestFocus(tfDefinition);
30  
      })));
31  
  }
32  
  
33  
  void update {
34  
    if (stack == null) ret;
35  
    S s = inputPanel.input();
36  
    term = s;
37  
    S text = makeText(s);
38  
    replaceAllComponents(stack, ll(fontSize(17, jCenteredMultiLineLabel(text))));
39  
  }
40  
  
41  
  S makeText(fS s) {
42  
    S text = "";
43  
    if (empty(s)) ret text;
44  
    MultiMap<S> map = mechMultiMapCI(listName);
45  
    L<S> answers = map.get(s);
46  
    MultiMap<S> map2 = mechMultiMapCI("Unauthorized Appends | " + listName);
47  
    L<S> answers2 = map2.get(s);
48  
    if (empty(answers) && empty(answers2))
49  
      ret "No definitions found for " + quote(s);
50  
      
51  
    ret lines(concatLists(
52  
      map(answers, func(S a) -> S { s + " = " + a }),
53  
      map(answers2, func(S a) -> S { s + " " + unicode_questionedEquals() + " " + a })
54  
    ));
55  
  }
56  
}

Author comment

Began life as a copy of #1016357

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1016431
Snippet name: General Definitions [Dyn Module, shortened, old]
Eternal ID of this version: #1016431/9
Text MD5: d77fedb84193d98a49b5519815e0fd1d
Transpilation MD5: a37a2cf6cd73219171ae8a280f5c2cdb
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-19 15:12:54
Source code size: 1788 bytes / 56 lines
Pitched / IR pitched: No / No
Views / Downloads: 406 / 4901
Version history: 8 change(s)
Referenced in: [show references]