static void browseDir(File dir) { class Browser { L<Map> origData, data; File dir; JTable table; *(File dir) { browse(dir); } void browse(File path) { dir = path; origData = listDirAwarenessStyle(dir); data = sortedByField("Name", map(func(Map map) { putKeysFirst(renameKeys(map, "dir", "Directory?", "m", "Last modified", "n", "Name", "l", "File Size (Bytes)"), "Name", "Directory?") }, origData)); S title = f2s(dir); bool firstTime = table == null; table = showTable(table, data, title); if (firstTime) { onDoubleClickOrEnter(table, voidfunc(int row) { Map map = getTableLineAsMap(table, row); if (map == null) ret; Map map2 = findByField(origData, "n", map.get("Name")); S name = getString(map, "Name"); if (isTrue(_get(map2, "dir"))) browse(new File(dir, name)); else jShowFile(new File(dir, name)); }); registerKey(getFrame(table), KeyEvent.VK_BACK_SPACE, "Back", r { // TODO: list roots File p = dir.getParentFile(); if (p != null) browse(p); }); } } } new Browser(dir); }
Began life as a copy of #1004132
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004520 |
Snippet name: | browseDir [Swing] |
Eternal ID of this version: | #1004520/1 |
Text MD5: | 2d1012c220df33d7c93226b9bc5eef34 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-19 17:25:10 |
Source code size: | 1349 bytes / 49 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 635 / 639 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |