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

57
LINES

< > BotCompany Repo | #1019281 // Computer Names [give names to computers, Dyn Module]

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

Uses 1059K of libraries. Click here for Pure Java version (12377L/63K).

!7

concept Entry {
  S computerID, shortName, comment;
  S controllableByMe;

  sS _fieldOrder = "shortName computerID comment";
}

cmodule2 ComputerNames > DynCRUD<Entry> {
  bool automaticallyAddOnlineComputers = true;
  
  start {
    indexConceptField(Entry, 'computerID);
    
    // Add myself
    cset(uniq_returnIfNew(Entry, computerID := computerID()), comment := "This computer");
      
    dm_vmBus_onMessage('onlineComputerIDs, voidfunc(Collection<S> ids) {
      if (automaticallyAddOnlineComputers) slurpIDs(ids)
    });
    
    dm_requireAndCall("#1016578/AllOnlineComputers", 'updateList);

    // Add currently online computers
    pcall {
      slurpIDs((LS) dm_callModuleOpt(dm_findModule("#1016578/AllOnlineComputers"), 'onlineComputerIDs));
    }

    onConceptsChange(r { dm_findAndCallModule("#1016578/AllOnlineComputers", 'updateList) });
    
    dm_registerAs('controllableComputerList);
  }
  
  // API
  
  svoid slurpIDs(Collection<S> ids) {
    for (S id : unnull(ids)) uniq(Entry, computerID := id);
  }
  
  S nameForID(S computerID) {
    ret cget(conceptWhere(Entry, +computerID), 'shortName);
  }
  
  void setControllableByMe(S computerID, bool b) {
    cset(uniq(Entry, +computerID), controllableByMe := yesNo_short(b));
  }
  
  LS controllableComputers() {
    ret withoutMyComputerID(collect('computerID, conceptsWhere(Entry, controllableByMe := 'yes)));
  }

  void openDialogForComputerID(S computerID) {
    if (isComputerID(computerID))
      crud.editConcept(uniq Entry(+computerID));
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1019281
Snippet name: Computer Names [give names to computers, Dyn Module]
Eternal ID of this version: #1019281/34
Text MD5: 169e03226db405f01479a1aa8a46ba76
Transpilation MD5: 2e11d8fa72e8a9b252f7919361b45c7b
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-12-18 02:16:35
Source code size: 1594 bytes / 57 lines
Pitched / IR pitched: No / No
Views / Downloads: 476 / 22721
Version history: 33 change(s)
Referenced in: [show references]