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

37
LINES

< > BotCompany Repo | #1034680 // G22DBFileBrowser [backup]

JavaX fragment (include)

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

    var tbl = table.visualize();
    bindToComponent(tbl, -> {
      dirWatcher = new FileWatchService;
      dirWatcher.addRecursiveListener(dir, f -> rstUpdate!);
      rstUpdate!;
    }, -> { dispose dirWatcher; });

    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 #1034679

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034680
Snippet name: G22DBFileBrowser [backup]
Eternal ID of this version: #1034680/1
Text MD5: 508ea731ec3818400ae1c2cd9ff2bac5
Author: stefan
Category: javax / gazelle v
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-01 21:17:52
Source code size: 1118 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 61 / 72
Referenced in: [show references]