Libraryless. Click here for Pure Java version (21032L/159K).
1 | !7 |
2 | |
3 | set flag DynModule. |
4 | |
5 | concept Entry { |
6 | S name; |
7 | S description; |
8 | S codeToProduce; |
9 | transient O data; |
10 | long entries, sizeInRAM, loadTime = -1; |
11 | S javaType; |
12 | bool autoLoad; |
13 | Map moreInfo; |
14 | } |
15 | |
16 | module InformationDatabases > DynCRUD<Entry> { |
17 | *() { super(Entry); } |
18 | |
19 | start { |
20 | doLater(5000, r { |
21 | for (Entry e : conceptsWhere(Entry, autoLoad := true)) |
22 | loadEntryOpt(e); |
23 | }); |
24 | } |
25 | |
26 | afterVisualize { |
27 | addComponents(crud.buttons, |
28 | tableDependentButton(table(), "Load", rThread { loadEntry(selected()) }), |
29 | tableDependentButton(table(), "Show", rThread { showEntry(selected()) }) |
30 | ); |
31 | } |
32 | |
33 | SimpleCRUD<Entry> makeCRUD() { |
34 | ret setAllAndReturn(super.makeCRUD(), |
35 | excludeFieldsFromEditing := litset('moreInfo, 'sizeInRAM, 'data), |
36 | renderer := func(Entry e) -> Map { mapPlus(renderConceptForCRUDWithoutFields(e, 'data), |
37 | entries := n2(e.entries), |
38 | loadTime := e.loadTime < 0 ? "" : e.loadTime + " ms", |
39 | sizeInRAM := e.sizeInRAM == 0 ? "" : str_toK(e.sizeInRAM)) }); |
40 | } |
41 | |
42 | void loadEntry(Entry e) pcall { |
43 | cset(e, codeToProduce := trim(e.codeToProduce)); |
44 | O data = null; |
45 | if (anyJavaTokens(e.codeToProduce)) loading "Loading data" { |
46 | long time = sysNow(); |
47 | if (isIdentifier(e.codeToProduce)) { |
48 | makeAndCall_initChild.set(voidfunc(Class c) { shareMyCreatorWith(c) }); |
49 | data = callAndMake(e.codeToProduce); |
50 | } else |
51 | data = dm_javaEval(e.codeToProduce); |
52 | cset(e, loadTime := sysNow()-time); |
53 | } |
54 | cset(e, +data); |
55 | pcall { |
56 | cset(e, sizeInRAM := retainedObjectSize(data)); |
57 | cset(e, entries := l_opt(data)); |
58 | cset(e, javaType := shortJavaTypeDesc(data)); |
59 | } |
60 | } |
61 | |
62 | void loadEntryOpt(Entry e) { |
63 | if (e.data == null) loadEntry(e); |
64 | } |
65 | |
66 | void showEntry(Entry e) { |
67 | loadEntryOpt(e); |
68 | if (e.data instanceof Collection) |
69 | dm_showStringList(e.name, allToString((Collection) e.data)); |
70 | } |
71 | } |
download show line numbers debug dex old transpilations
Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019470 |
Snippet name: | Information Databases [Dyn Module] |
Eternal ID of this version: | #1019470/26 |
Text MD5: | f60824a05892f3d5055ed8a74e0cffa4 |
Transpilation MD5: | 3450dec3be96f8062942e186ceecf321 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-09 19:32:45 |
Source code size: | 2013 bytes / 71 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 396 / 1259 |
Version history: | 25 change(s) |
Referenced in: | [show references] |