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

46
LINES

< > BotCompany Repo | #1019099 // Directory Tree With Sizes [Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (9959L/51K).

1  
!7
2  
3  
cmodule DirectoryTree > DynSCP {
4  
  File dir;
5  
  
6  
  start {
7  
    dm_onTopInput(voidfunc(fS s) {
8  
      if (isAbsolutePath(s) && dirExists(s)) thread "Load Directory" {
9  
        setDir(s);
10  
      }
11  
    });
12  
  }
13  
  
14  
  JComponent visualize2() {
15  
    if (dir == null)
16  
      ret jcenteredbutton("Select directory...", rThread select);
17  
    else {
18  
      thread "Load Directory" {
19  
        sleepSeconds(1.0); // to avoid race condition
20  
        setDir(dir);
21  
      }
22  
      ret loadingLabel();
23  
    }
24  
  }
25  
  
26  
  JLabel loadingLabel() { ret jcenteredlabel("Loading..."); }
27  
  
28  
  void select {
29  
    temp enter();
30  
    selectDir(voidfunc(final File dir) { thread { setDir(dir); } });
31  
  }
32  
  
33  
  void setDir(S dir) { setDir(newFile(dir)); }
34  
  void setDir(File dir) enter {
35  
    setComponent(loadingLabel());
36  
    Tree<FileWithSize> dataTree = findDirsWithSizes_tree(dir);
37  
    sortTreeOfFilesWithSizeBySize(dataTree);
38  
    final JTree tree = jDynamicTreeFromTree(dataTree, makeChildrenIsFast := true);
39  
    setTreeCellRenderer(tree, customToStringTreeCellRenderer(func(Tree<FileWithSize> t) -> S {
40  
      fileName(t.a.file) +  " [" + str_toM(t.a.size) + "]" }));
41  
42  
    setField(+dir);
43  
    setModuleName(f2s(dir) + " [Directory Tree w/sizes]");
44  
    setComponent(tree);
45  
  }
46  
}

Author comment

Began life as a copy of #1019090

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1019099
Snippet name: Directory Tree With Sizes [Dyn Module]
Eternal ID of this version: #1019099/16
Text MD5: 9712088c0ec2e6a5e351437c57d931ef
Transpilation MD5: d5efb9e6d429a9d775b36e16e4cc44eb
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-20 14:13:31
Source code size: 1282 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 455 / 802
Version history: 15 change(s)
Referenced in: [show references]