sclass G22ScriptsFromAllDBsPanel { G22Utils g22utils; // Each script is registered to a non-persistent Concepts object // loaded temporarily but connected to the appropriate db dir JObjectTable 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( map_pcall(g22utils.gazelleDBs(), db -> { var classFinder = g22utils.masterStuff.makeClassFinder(); var cc = newConceptsWithClassFinder(db.conceptsFile(), classFinder); cc.loadFromDisk(); ret list(cc, G22LeftArrowScript); }))); } S renderScript(S header, S mode, S text) { ret header + "[" + mode +"]\n" + "----\n" + rtrim(text) + "\n" + "----"; } S makeHugeText() { ret g22utils.evalRegisteredCode("Make text from all scripts", -> { rstUpdate.waitUntilDone(); new LS out; for (script : table.getList()) { S header = formatColonProperties( "Script Name" := str(script), "Script ID" := script.id, "DB" := f2s(scriptToDBDir(script))); S editedText = script.editedText(); if (editedText != null) out.add(renderScript(header, "Editing", editedText)); if (script.text != null) out.add(renderScript(header, "Saved", script.text)); S codeForAutoRun = script.codeForAutoRun(); if (codeForAutoRun != null) out.add(renderScript(header, "Clear for auto-run", codeForAutoRun)); } ret paragraphs(out); }); } void showHugeText { S text = makeHugeText(); showFrame("Scripts from all DBs", g22utils.newSyntaxTextArea(text)); } }