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

57
LINES

< > BotCompany Repo | #1016073 // Mech Lists With Text [Dyn Module]

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

Uses 1113K of libraries. Click here for Pure Java version (19248L/101K).

!7

please include function mL.

cmodule2 MechLists > DynCalculatedList {
  SS listToMD5;
  transient ReliableSingleThread rst = new(r downloadAll);
  transient bool authed;
  switchable double downloadInterval = 10.0;
  
  visualize {
    JComponent c = super.visualize();
    onDoubleClickOrEnter(list, voidfunc(S listName) {
      showText(listName, mechList_raw_localCopy(listName))
    });
    if (!authed) ret c;
    ret withLeftAlignedButtonsOnTop(c, "Create...", r createList);
  }
  
  start {
    set serverMechList_raw_fresh_verbose;
    setModuleName("Mech Lists With Text" + trueFalseNull(authed = mech_authedOnServer(), " [Authed]", " [Not Authed]", ""));
    actualCalc();
    if (!isTrue(vm_generalMap_get('noMechDownload)))
      doEvery(5.0, downloadInterval, rst);
    bot("Mech Lists Mirror.");
    dm_registerMainClassAs mechListsHolder();
  }
  
  void actualCalc { setField(results := sortedIC(keys(listToMD5))); }
  
  L<S> calc() { ret results; }

  void downloadAll {
    // TODO: transmit timestamp and get only changes
    L<LS> l = mechListMD5sAndStatuses_fresh();
    new HashMap listToMD5;
    for (LS x : l) {
      S name = first(x);
      listToMD5.put(name, second(x));
      saveTextFileIfDifferent(remoteMechListMirrorMetaFile(name),
        struct(litmap("Name" := name, "Status" := third(x))));
    }
    deleteLocalMechListCopiesOtherThan(keys(listToMD5));
    setField(+listToMD5);
    actualCalc();
    mechList_completeLocalCopies(listToMD5);
  }
  
  void createList enter {
    inputText("List Name", voidfunc(S name) {
      if (emptyAfterTrim(name)) ret;
      createMechList(trim(name));
      rst.trigger();
    });
  }
}

Author comment

Began life as a copy of #1015978

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1016073
Snippet name: Mech Lists With Text [Dyn Module]
Eternal ID of this version: #1016073/35
Text MD5: 2cf0925b32b88bfa20f55458ddc66c4a
Transpilation MD5: 6c358ad1706bf0034b42c2c740e0cdc5
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-29 21:06:08
Source code size: 1726 bytes / 57 lines
Pitched / IR pitched: No / No
Views / Downloads: 576 / 50754
Version history: 34 change(s)
Referenced in: #1017199 - Match Input With Pattern v2 [Dyn Module, dev.]
#1017206 - dm_useLocallyCopiedMechLists (copies of server lists)
#1017252 - Local Mech Lists [Dyn Module]
#1020212 - Stack Trace showing unnoticed deadlock in old version of setField()