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

1  
sclass G22ScriptsFromAllDBsPanel {
2  
  G22Utils g22utils;
3  
  
4  
  // Each script is registered to a non-persistent Concepts object
5  
  // loaded temporarily but connected to the appropriate db dir
6  
  JObjectTable<G22LeftArrowScript> table;
7  
  
8  
  ReliableSingleThread rstUpdate = new(r _updateTable);
9  
  transient SingleComponentPanel scpDetail = singleComponentPanel();
10  
  
11  
  *(G22Utils *g22utils) {}
12  
  
13  
  visualize {
14  
    table = new JObjectTable;
15  
    swap method table.itemToMap(script) to {
16  
      ret joinMaps(litorderedmap(
17  
        "Project" := fileName(scriptToDBDir(script)),
18  
        "ID" := str(script.id)),
19  
        g22utils.scriptToMap(script));
20  
    }
21  
22  
    var tbl = table.visualize();
23  
    rstUpdate!;
24  
    
25  
    tablePopupMenuItem_top(table.table, "Open database", rThread {
26  
      g22utils.masterStuff.openDatabase(table.selected()._concepts.conceptsDir());
27  
    });
28  
    
29  
    table.onSelect(script -> {
30  
      if (script == null) scpDetail.clear();
31  
      else {
32  
        var tabs = jtabs();
33  
        S editedText = script.editedText();
34  
        if (editedText != null)
35  
          addTab(tabs, "Editing", makeDisabledTextArea(editedText));
36  
        if (script.text != null)
37  
          addTab(tabs, "Saved", makeDisabledTextArea(script.text));
38  
        S codeForAutoRun = script.codeForAutoRun();
39  
        if (codeForAutoRun != null)
40  
          addTab(tabs, "Clear for auto-run", makeDisabledTextArea(codeForAutoRun));
41  
        scpDetail.set(tabs);
42  
      }
43  
    });
44  
    
45  
    ret withTopAndBottomMargin(jCenteredRaisedSection("Scripts from all databases",
46  
      jvsplit(
47  
        withRightAlignedButtons(tbl,
48  
          "Show all scripts as one long text", rThread showHugeText,
49  
        ), scpDetail)));
50  
  }
51  
  
52  
  File scriptToDBDir(G22LeftArrowScript script) {
53  
    ret script == null ?: script._concepts.conceptsDir();
54  
  }
55  
  
56  
  JComponent makeDisabledTextArea(S text) {
57  
    var ta = g22utils.newSyntaxTextArea();
58  
    ta.setText(text);
59  
    uneditableBlack(ta.textArea());
60  
    ret ta.visualize();
61  
  }
62  
  
63  
  void _updateTable {
64  
    table.setData_force(concatLists(
65  
      mapCloseables_pcall(g22utils.peekAllProjectsConcepts(),
66  
        cc -> list(cc, G22LeftArrowScript))));
67  
  }
68  
  
69  
  S makeHugeText() {
70  
    ret g22utils.evalRegisteredCode("Make text from all scripts", -> {
71  
      rstUpdate.waitUntilDone();
72  
      
73  
      ret new G22ScriptUtil(g22utils).makeHugeText(table.getList());
74  
    });
75  
  }
76  
  
77  
  void showHugeText {
78  
    S text = makeHugeText();
79  
    showFrame("Scripts from all DBs", g22utils.newSyntaxTextArea(text));
80  
  }
81  
}

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: 247 / 444
Version history: 24 change(s)
Referenced in: [show references]