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

81
LINES

< > BotCompany Repo | #1034641 // G22ScriptsFromAllDBsPanel

JavaX fragment (include) [tags: use-pretranspiled]

Uses 2164K of libraries. Compilation Failed (63095L/335K).

sclass G22ScriptsFromAllDBsPanel {
  G22Utils g22utils;
  
  // Each script is registered to a non-persistent Concepts object
  // loaded temporarily but connected to the appropriate db dir
  JObjectTable<G22LeftArrowScript> table;
  
  ReliableSingleThread rstUpdate = new(r _updateTable);
  transient SingleComponentPanel scpDetail = singleComponentPanel();
  
  *(G22Utils *g22utils) {}
  
  visualize {
    table = new JObjectTable;
    swap method table.itemToMap(script) to {
      ret joinMaps(litorderedmap(
        "Project" := fileName(scriptToDBDir(script)),
        "ID" := str(script.id)),
        g22utils.scriptToMap(script));
    }

    var tbl = table.visualize();
    rstUpdate!;
    
    tablePopupMenuItem_top(table.table, "Open database", rThread {
      g22utils.masterStuff.openDatabase(table.selected()._concepts.conceptsDir());
    });
    
    table.onSelect(script -> {
      if (script == null) scpDetail.clear();
      else {
        var tabs = jtabs();
        S editedText = script.editedText();
        if (editedText != null)
          addTab(tabs, "Editing", makeDisabledTextArea(editedText));
        if (script.text != null)
          addTab(tabs, "Saved", makeDisabledTextArea(script.text));
        S codeForAutoRun = script.codeForAutoRun();
        if (codeForAutoRun != null)
          addTab(tabs, "Clear for auto-run", makeDisabledTextArea(codeForAutoRun));
        scpDetail.set(tabs);
      }
    });
    
    ret withTopAndBottomMargin(jCenteredRaisedSection("Scripts from all databases",
      jvsplit(
        withRightAlignedButtons(tbl,
          "Show all scripts as one long text", rThread showHugeText,
        ), scpDetail)));
  }
  
  File scriptToDBDir(G22LeftArrowScript script) {
    ret script == null ?: script._concepts.conceptsDir();
  }
  
  JComponent makeDisabledTextArea(S text) {
    var ta = g22utils.newSyntaxTextArea();
    ta.setText(text);
    uneditableBlack(ta.textArea());
    ret ta.visualize();
  }
  
  void _updateTable {
    table.setData_force(concatLists(
      mapCloseables_pcall(g22utils.peekAllProjectsConcepts(),
        cc -> list(cc, G22LeftArrowScript))));
  }
  
  S makeHugeText() {
    ret g22utils.evalRegisteredCode("Make text from all scripts", -> {
      rstUpdate.waitUntilDone();
      
      ret new G22ScriptUtil(g22utils).makeHugeText(table.getList());
    });
  }
  
  void showHugeText {
    S text = makeHugeText();
    showFrame("Scripts from all DBs", g22utils.newSyntaxTextArea(text));
  }
}

Author comment

Began life as a copy of #1034288

download  show line numbers  debug dex  old transpilations   

Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034641
Snippet name: G22ScriptsFromAllDBsPanel
Eternal ID of this version: #1034641/25
Text MD5: e80613d60ff9b2702d4451394aeae5c2
Transpilation MD5: 3a6082b8bb7d582b11ed55d9ba196679
Author: stefan
Category: javax / gazelle v
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-10-07 17:51:37
Source code size: 2579 bytes / 81 lines
Pitched / IR pitched: No / No
Views / Downloads: 246 / 442
Version history: 24 change(s)
Referenced in: #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167)
#1035496 - G22NetworksFromAllDBsPanel