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

37
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]

Uses 2164K of libraries. Click here for Pure Java version (62790L/334K).

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());
      
      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 (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/15
Text MD5: c568280976c4fb66c6e02695c222793e
Transpilation MD5: bef2a54626395e3b565f33fd4fcaee50
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-09-16 19:49:31
Source code size: 1391 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 44 / 109
Version history: 14 change(s)
Referenced in: [show references]