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).

!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(jcenteredbutton("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);
      })));
  }
  
  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<S> map = mechMultiMapCI(listName);
    L<S> answers = map.get(s);
    MultiMap<S> map2 = mechMultiMapCI("Unauthorized Appends | " + listName);
    L<S> answers2 = map2.get(s);
    if (empty(answers) && empty(answers2))
      ret "No definitions found for " + quote(s);
      
    ret lines(concatLists(
      map(answers, func(S a) -> S { s + " = " + a }),
      map(answers2, func(S a) -> S { s + " " + unicode_questionedEquals() + " " + a })
    ));
  }
}

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: 466 / 4982
Version history: 8 change(s)
Referenced in: #1016466 - General Definitions v3 [OK]