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

47
LINES

< > BotCompany Repo | #1001752 // Get selected table line (search all VMs)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Transpiled version (1614L) is out of date.

!747
!pcall

m {
  static S botID = "#1001756";
  static S botName = "Get Selected Table Line Helper Bot";
  static S cmd = "get selected table line as map";
  
  p {
    new TreeMap<int, S> results;
    for (DialogIO vm : talkToAllOtherVMs()) {
      pcall {
        int vmPort = vm.getPort();
        Map<Number, S> bots = (Map) safeUnstructure(vm.ask("list bots"));
        print("VM " + vmPort + " bots: " + structure(bots));
        if (!containsBot(bots, botName)) {
          print("Injecting bot.");
          injectTo(vmPort, botID);
          
          int safetyCount = 0;
          while (!containsBot((Map) safeUnstructure(vm.ask("list bots")), botName)) {
            if (safetyCount >= 100) fail("bot did not start");
            sleep(500);
          }
        }
        S result = vm.ask("please forward to bot *: *", botName, cmd);
        results.put(vmPort, result);
      }
      vm.close();
    }
    
    // include myself
    Component focus = getFocusOwner();
    if (focus instanceof JTable)
      results.put(myVMPort(), structure(getSelectedLineAsMap((JTable) focus)));
      
    Map result = getResult(results);
    print("Result: " + structure(result));
  }
  
  static Map getResult(Map<int, S> results) {
    for (S s: results.values())
      if (structIsMap(s))
        ret (Map) unstructure(s);
    ret null;
  }
}

Author comment

Began life as a copy of #1001738

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001752
Snippet name: Get selected table line (search all VMs)
Eternal ID of this version: #1001752/2
Text MD5: c66e8982397c52874020811335c8c88a
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-11 22:55:30
Source code size: 1396 bytes / 47 lines
Pitched / IR pitched: No / No
Views / Downloads: 520 / 567
Version history: 1 change(s)
Referenced in: [show references]