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

63
LINES

< > BotCompany Repo | #1035496 // G22NetworksFromAllDBsPanel

JavaX fragment (include)

1  
sclass G22NetworksFromAllDBsPanel {
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<G22Network> 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  
    table.itemToMap = script -> litorderedmap(
16  
      "Network" := script.description,
17  
      "Project" := fileName(networkToDBDir(script)),
18  
      "ID in original project" := str(script.id),
19  
    );
20  
21  
    var tbl = table.visualize();
22  
    rstUpdate!;
23  
    
24  
    tablePopupMenuItem_top(table.table, "Open project", rThread {
25  
      g22utils.masterStuff.openDatabase(table.selected()._concepts.conceptsDir());
26  
    });
27  
    
28  
    tablePopupMenuItem_top(table.table, "Import network", rThread {
29  
      var network = table.selected();
30  
      var clonedNetwork = (G22Network) g22utils.restructure(network);
31  
      registerConcept(g22utils.concepts(), clonedNetwork);
32  
      g22utils.projectActions().openObjectInProject(clonedNetwork.id);
33  
    });
34  
    
35  
    table.onSelect(network -> {
36  
      if (network == null) scpDetail.clear();
37  
      else {
38  
        scpDetail.set(makeDetailView(network));
39  
      }
40  
    });
41  
    
42  
    ret withTopAndBottomMargin(jCenteredRaisedSection("Networks from all projects",
43  
      jvsplit(tbl, scpDetail)));
44  
  }
45  
  
46  
  JComponent makeDetailView(G22Network network) {
47  
    ret JG22Network(g22utils, network).visualize();
48  
  }
49  
  
50  
  File networkToDBDir(G22Network network) {
51  
    ret network == null ?: network._concepts.conceptsDir();
52  
  }
53  
  
54  
  void _updateTable {
55  
    table.setData_force(concatLists(
56  
      map_pcall(g22utils.gazelleDBs(), db -> {
57  
        var classFinder = g22utils.masterStuff.makeClassFinder();
58  
        var cc = newConceptsWithClassFinder(db.conceptsFile(), classFinder);
59  
        cc.loadFromDisk();
60  
        ret list(cc, G22Network);
61  
      })));
62  
  }
63  
}

Author comment

Began life as a copy of #1034641

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035496
Snippet name: G22NetworksFromAllDBsPanel
Eternal ID of this version: #1035496/9
Text MD5: 9396823f2edbaf08648ecd0b28ae601b
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-16 16:24:49
Source code size: 2055 bytes / 63 lines
Pitched / IR pitched: No / No
Views / Downloads: 135 / 157
Version history: 8 change(s)
Referenced in: [show references]