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.

srecord noeq JG22ProjectSelector(G22Utils g22utils) is Swingable {
  transient JLabel lblDB;
  
  cachedVisualize {
    lblDB = toolTip("Currently selected project (" + f2s(g22utils.projectDir()) + ")",
      /*boldLabel*/(jSimpleLabel(fileName(g22utils.projectDir()))));
      
    onClick(lblDB, evt -> new PopupMenuMaker(evt, menu -> {
    
      addMenuItem(menu, "New project...",
        rThread { g22utils.projectActions().databasesPanel().newDatabase() });
        
      addMenuItem(menu, "Projects..." /*"Manage or open projects..."*/,
        rThread { g22utils.showUIURL("Projects")});
        
      LS recent = takeFirst(10, g22utils.dbNamesRecentlyOpened());
      
      // List open projects
      /*for (File otherDB : g22utils.masterStuff().openConceptDirs()) {
        S name = fileName(otherDB);
        if (!eq(otherDB, g22utils.projectDir()))
          addMenuItem(menu, name + " [Open]", rThread { g22utils.masterStuff().openDatabase(otherDB) });
        removeAll(recent, name, "*" + name);
      }*/
      for (IG22LoadedDB otherDB : g22utils.masterStuff().openProjects()) {
        S name = otherDB.g22utils().projectName();
        if (g22utils != otherDB.g22utils()) {
          S status = otherDB.hidden() ? "Hidden" : "Open";
          addMenuItem(menu, name + " [" + status + "]", rThread { otherDB.activate() });
        }
        removeAll(recent, name, "*" + name);
      }
      
      // List non-open recent projects
      for (name : recent) {
        S name2 = dropStarPrefix(name);
        File otherDB = newFile(g22utils.databasesMotherDir(), name2);
        if (isDirectory(otherDB))
          addMenuItem(menu, name2, rThread {
            g22utils.masterStuff().openDatabase(otherDB, neq(name, name2))
          });
      }
    }).run());
    
    ret lblDB;
  }
}

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: 197 / 294
Version history: 15 change(s)
Referenced in: [show references]