Libraryless. Click here for Pure Java version (7792L/54K/180K).
1 | !752 |
2 | |
3 | concepts. |
4 | |
5 | concept FileRef { |
6 | S path; |
7 | long touched; |
8 | } |
9 | |
10 | static JTable table; |
11 | |
12 | p-substance { |
13 | concepts(); |
14 | update(); |
15 | awtOnConceptChanges(table, "update", false); |
16 | hideConsoleIfMainProgram(); |
17 | dbBot(); |
18 | } |
19 | |
20 | svoid update { |
21 | bool first = table == null; |
22 | L data = map(sortedByFieldDesc(list(FileRef), "touched"), func(FileRef f) { |
23 | Map map = litorderedmap("Path" := f.path); |
24 | pcall { |
25 | File file = new File(f.path); |
26 | S type; |
27 | if (file.isFile()) { |
28 | type = "File"; |
29 | map.put("Size", file.length()); |
30 | } else if (file.isDirectory()) |
31 | type = "Directory"; |
32 | else |
33 | type = "Not found"; |
34 | map.put("Type", type); |
35 | } |
36 | ret map; |
37 | }); |
38 | table = showTable(data, table); |
39 | |
40 | if (first) { |
41 | addToWindow(table, jbutton("Add file or directory...", r { |
42 | addFile(); |
43 | })); |
44 | |
45 | tablePopupMenu(table, voidfunc(JPopupMenu menu, int row) { |
46 | Map map = getTableLineAsMap(table, row); |
47 | S path = (S) map.get("Path"); |
48 | final File file = new File(path); |
49 | if (file.isDirectory()) |
50 | addMenuItem(menu, "Browse", r { browseDir(file) }); |
51 | }); |
52 | } |
53 | } |
54 | |
55 | svoid addFile() { |
56 | final new JTextField tf; |
57 | showFormTitled("Add file or directory", |
58 | "File/directory path", tf, |
59 | r { |
60 | S path = tf.getText().trim(); |
61 | if (!isAbsolutePath(path)) { |
62 | messageBox("Please enter an absolute path."); |
63 | addFile(); |
64 | ret; |
65 | } |
66 | cset(uniq(FileRef, +path), touched := now()); |
67 | }); |
68 | } |
Began life as a copy of #1005728
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: | #1005741 |
Snippet name: | File Exchange [a persistent clipboard] |
Eternal ID of this version: | #1005741/1 |
Text MD5: | 96547342ff81908ccb27449c894f7bd1 |
Transpilation MD5: | f19ee4729aec5d0ed3441da777a18b18 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-12-05 22:39:01 |
Source code size: | 1553 bytes / 68 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 665 / 747 |
Referenced in: | [show references] |