1 | static void browseDir(File dir) { |
2 | class Browser { |
3 | L<Map> origData, data; |
4 | File dir; |
5 | JTable table; |
6 | |
7 | *(File dir) { |
8 | browse(dir); |
9 | } |
10 | |
11 | void browse(File path) { |
12 | dir = path; |
13 | origData = listDirAwarenessStyle(dir); |
14 | |
15 | data = sortedByField("Name", map(func(Map map) { |
16 | putKeysFirst(renameKeys(map, |
17 | "dir", "Directory?", "m", "Last modified", |
18 | "n", "Name", "l", "File Size (Bytes)"), |
19 | "Name", "Directory?") |
20 | }, origData)); |
21 | |
22 | S title = f2s(dir); |
23 | bool firstTime = table == null; |
24 | table = showTable(table, data, title); |
25 | |
26 | if (firstTime) { |
27 | onDoubleClickOrEnter(table, voidfunc(int row) { |
28 | Map map = getTableLineAsMap(table, row); |
29 | if (map == null) ret; |
30 | Map map2 = findByField(origData, "n", map.get("Name")); |
31 | S name = getString(map, "Name"); |
32 | if (isTrue(_get(map2, "dir"))) |
33 | browse(new File(dir, name)); |
34 | else |
35 | jShowFile(new File(dir, name)); |
36 | }); |
37 | |
38 | registerKey(getFrame(table), KeyEvent.VK_BACK_SPACE, "Back", r { |
39 | // TODO: list roots |
40 | File p = dir.getParentFile(); |
41 | if (p != null) |
42 | browse(p); |
43 | }); |
44 | } |
45 | } |
46 | } |
47 | |
48 | new Browser(dir); |
49 | } |
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: | 636 / 641 |
Referenced in: | [show references] |