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).

sclass G22DBFileBrowser {
  G22Utils g22utils;
  
  File dir;
  JObjectTable<File> table;
  ReliableSingleThread rstUpdate = rstWithPreDelay(0.5, r _updateTable);
  
  *(G22Utils *g22utils) {
    dir = g22utils.concepts.conceptsDir();
  }
  
  cachedVisualize {
    table = swing(-> new JObjectTable);
    table.itemToMap = file -> litorderedmap(
      "File / Directory" := nameRelativeToPhysicalSubdirectory(file, dir),
      "Size" := file.isDirectory() ? "Directory" : str_toK(fileSize(file))
    );

    var tbl = table.visualize();
    IVF1<File> fileListener = file -> rstUpdate!;
    bindToComponent(tbl, -> {
      g22utils.onProjectFileChanged(fileListener);
      rstUpdate!;
    }, -> g22utils.removeProjectFileChangedListener(fileListener));

    ret withTopAndBottomMargin(jCenteredRaisedSection("Files in Project",
      northAndCenterWithMargins(
        withLabel("Project directory:", swing(-> new JFilePathLabel(dir).visualize())),
        tbl
      )
    ));
  }
  
  void _updateTable { table.setData_force(findAllFiles(dir)); }
}

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: 92 / 194
Version history: 9 change(s)
Referenced in: [show references]