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

35
LINES

< > BotCompany Repo | #1034679 // G22DBFileBrowser

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

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

1  
sclass G22DBFileBrowser {
2  
  G22Utils g22utils;
3  
  
4  
  File dir;
5  
  JObjectTable<File> table;
6  
  ReliableSingleThread rstUpdate = rstWithPreDelay(0.5, r _updateTable);
7  
  
8  
  *(G22Utils *g22utils) {
9  
    dir = g22utils.concepts.conceptsDir();
10  
  }
11  
  
12  
  cachedVisualize {
13  
    table = swing(-> new JObjectTable);
14  
    table.itemToMap = file -> litorderedmap(
15  
      "File / Directory" := nameRelativeToPhysicalSubdirectory(file, dir),
16  
      "Size" := file.isDirectory() ? "Directory" : str_toK(fileSize(file))
17  
    );
18  
19  
    var tbl = table.visualize();
20  
    IVF1<File> fileListener = file -> rstUpdate!;
21  
    bindToComponent(tbl, -> {
22  
      g22utils.onProjectFileChanged(fileListener);
23  
      rstUpdate!;
24  
    }, -> g22utils.removeProjectFileChangedListener(fileListener));
25  
26  
    ret withTopAndBottomMargin(jCenteredRaisedSection("Files in Project",
27  
      northAndCenterWithMargins(
28  
        withLabel("Project directory:", swing(-> new JFilePathLabel(dir).visualize())),
29  
        tbl
30  
      )
31  
    ));
32  
  }
33  
  
34  
  void _updateTable { table.setData_force(findAllFiles(dir)); }
35  
}

Author comment

Began life as a copy of #1034288

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034679
Snippet name: G22DBFileBrowser
Eternal ID of this version: #1034679/10
Text MD5: f806af0de3fefd2851c451e377a8878d
Transpilation MD5: f380f1e961f141ed7522e1cd7ec15016
Author: stefan
Category: javax / gazelle v
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-05 18:30:55
Source code size: 1085 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 214 / 334
Version history: 9 change(s)
Referenced in: [show references]