Libraryless. Click here for Pure Java version (14390L/101K).
!7 sclass DirectoryInfo extends DynModule { S dir; bool allowedToLook; Bool exists, isFile; L<S> filesContained; // this should be an immutable list b/c of listeners transient JComboBox comboBox; File dirObject() { ret newFile(dir); } void start { ownTimer(doEvery(2.0, r fullUpdate)); // TODO: watch service } JComponent visualize() { if (dir == null) ret jcenteredbutton("Select directory...", r { selectDir("Select directory to show", voidfunc(File dir) { setDir(dir); }); }); if (comboBox == null) comboBox = yesNoComboBox(allowedToLook, voidfunc(bool b) { setField(allowedToLook := b) }); ret makeForm( "Directory" := dir, allowedToLook := comboBox, +exists, +isFile, "Elements contained", filesContained == null ? "Unknown" : l(filesContained)); } void fullUpdate { updateMe(); } void update { temp enter(); if (dir != null && allowedToLook) { File dirObject = dirObject(); setField(exists := dirObject.isDirectory()); setField(isFile := dirObject.isFile()); if (setField(filesContained := listFileNames(dirObject))) revisualize(); } else if (setFields(exists := null, isFile := null, filesContained := null)) revisualize(); } // API for other modules S getDir() { ret dir; } void setDir(File dir) { setField(dir := f2s(dir)); revisualize(); } L<S> getFiles() { ret filesContained; } void setAllowedToLook(bool b) { setField(allowedToLook := b); } }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, vpdwwinrgdga
No comments. add comment
Snippet ID: | #1015916 |
Snippet name: | Directory Info [Dyn Module] |
Eternal ID of this version: | #1015916/33 |
Text MD5: | bed015bcd35b2f97935b4fe7fc6243cf |
Transpilation MD5: | 3d3c2fda3b1a7a4a7d9105cddd0c255f |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-06-19 00:23:55 |
Source code size: | 1632 bytes / 56 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 484 / 70617 |
Version history: | 32 change(s) |
Referenced in: | #1015922 - Images In Directory [Dyn Module] #1015970 - User's Primary E-Mail Address [Dyn Module, OK] #1016034 - Image Info [Dyn Module] #1016457 - Files In Directory [Dyn Module] |