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

47
LINES

< > BotCompany Repo | #1035692 // JG22ProjectSelector - the little project name/project switcher label in the top left corner of all "workspace" windows

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

Transpiled version (62790L) is out of date.

1  
srecord noeq JG22ProjectSelector(G22Utils g22utils) is Swingable {
2  
  transient JLabel lblDB;
3  
  
4  
  cachedVisualize {
5  
    lblDB = toolTip("Currently selected project (" + f2s(g22utils.projectDir()) + ")",
6  
      /*boldLabel*/(jSimpleLabel(fileName(g22utils.projectDir()))));
7  
      
8  
    onClick(lblDB, evt -> new PopupMenuMaker(evt, menu -> {
9  
    
10  
      addMenuItem(menu, "New project...",
11  
        rThread { g22utils.projectActions().databasesPanel().newDatabase() });
12  
        
13  
      addMenuItem(menu, "Projects..." /*"Manage or open projects..."*/,
14  
        rThread { g22utils.showUIURL("Projects")});
15  
        
16  
      LS recent = takeFirst(10, g22utils.dbNamesRecentlyOpened());
17  
      
18  
      // List open projects
19  
      /*for (File otherDB : g22utils.masterStuff().openConceptDirs()) {
20  
        S name = fileName(otherDB);
21  
        if (!eq(otherDB, g22utils.projectDir()))
22  
          addMenuItem(menu, name + " [Open]", rThread { g22utils.masterStuff().openDatabase(otherDB) });
23  
        removeAll(recent, name, "*" + name);
24  
      }*/
25  
      for (IG22LoadedDB otherDB : g22utils.masterStuff().openProjects()) {
26  
        S name = otherDB.g22utils().projectName();
27  
        if (g22utils != otherDB.g22utils()) {
28  
          S status = otherDB.hidden() ? "Hidden" : "Open";
29  
          addMenuItem(menu, name + " [" + status + "]", rThread { otherDB.activate() });
30  
        }
31  
        removeAll(recent, name, "*" + name);
32  
      }
33  
      
34  
      // List non-open recent projects
35  
      for (name : recent) {
36  
        S name2 = dropStarPrefix(name);
37  
        File otherDB = newFile(g22utils.databasesMotherDir(), name2);
38  
        if (isDirectory(otherDB))
39  
          addMenuItem(menu, name2, rThread {
40  
            g22utils.masterStuff().openDatabase(otherDB, neq(name, name2))
41  
          });
42  
      }
43  
    }).run());
44  
    
45  
    ret lblDB;
46  
  }
47  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035692
Snippet name: JG22ProjectSelector - the little project name/project switcher label in the top left corner of all "workspace" windows
Eternal ID of this version: #1035692/16
Text MD5: 472876078e7d1b4b593f4fd01a28f49f
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-10-26 15:52:05
Source code size: 1855 bytes / 47 lines
Pitched / IR pitched: No / No
Views / Downloads: 124 / 218
Version history: 15 change(s)
Referenced in: [show references]