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

!7

cmodule DirectoryTree > DynSCP {
  File dir;
  
  start {
    dm_onTopInput(voidfunc(fS s) {
      if (isAbsolutePath(s) && dirExists(s)) thread "Load Directory" {
        setDir(s);
      }
    });
  }
  
  JComponent visualize2() {
    if (dir == null)
      ret jcenteredbutton("Select directory...", rThread select);
    else {
      thread "Load Directory" {
        sleepSeconds(1.0); // to avoid race condition
        setDir(dir);
      }
      ret loadingLabel();
    }
  }
  
  JLabel loadingLabel() { ret jcenteredlabel("Loading..."); }
  
  void select {
    temp enter();
    selectDir(voidfunc(final File dir) { thread { setDir(dir); } });
  }
  
  void setDir(S dir) { setDir(newFile(dir)); }
  void setDir(File dir) enter {
    setComponent(loadingLabel());
    Tree<FileWithSize> dataTree = findDirsWithSizes_tree(dir);
    sortTreeOfFilesWithSizeBySize(dataTree);
    final JTree tree = jDynamicTreeFromTree(dataTree, makeChildrenIsFast := true);
    setTreeCellRenderer(tree, customToStringTreeCellRenderer(func(Tree<FileWithSize> t) -> S {
      fileName(t.a.file) +  " [" + str_toM(t.a.size) + "]" }));

    setField(+dir);
    setModuleName(f2s(dir) + " [Directory Tree w/sizes]");
    setComponent(tree);
  }
}

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: 454 / 801
Version history: 15 change(s)
Referenced in: