Libraryless. Click here for Pure Java version (15439L/111K).
1  | !7  | 
2  | |
3  | DynTable > RecentlyDeletedModules {
 | 
4  | S moduleID;  | 
5  | |
6  |   JComponent visualize() {
 | 
7  | JComponent c = super.visualize();  | 
8  | tablePopupMenuItemsThreaded(table,  | 
9  |       "Restore module", voidfunc(int row) { restore(row) },
 | 
10  |       "Show structure", voidfunc(int row) { showStructure(row) });
 | 
11  |     JTextField tfModuleID = jLiveValueTextField_bothWays(dm_fieldLiveValue('moduleID));
 | 
12  | onEnter(tfModuleID, r actualUpdate);  | 
13  | ret northAndCenter(  | 
14  |       centerAndEastWithMargin(withLabel("Module ID:", tfModuleID), jbutton("Search", r actualUpdate)), c);
 | 
15  | }  | 
16  | |
17  |   L<Map> calc() { ret data; }
 | 
18  | |
19  |   void actualUpdate { temp enter(); setField(data := actualCalc(); }
 | 
20  | |
21  |   L<Map> actualCalc() {
 | 
22  | if (empty(moduleID)) null;  | 
23  |     print("Searching for deleted modules of type " + moduleID);
 | 
24  | ret reversed(map(scanLog_iterator(deletedModulesLogFile(moduleID)),  | 
25  |       func(S structure) -> Map {
 | 
26  | O mod = safeUnstructure(structure);  | 
27  | // old layout:  | 
28  | // "c DynamicModule(_className=\"main$TextArea\", created=1529499892012L, frameRect=Rect(h=66, w=130, x=618, y=339), id=384L, moduleID=\"#1016122\", on=t, visible=t)"  | 
29  | // new layout:  | 
30  |         // "hm{deleted=123L, module := c DynamicModule(...)}"
 | 
31  | long deleted = 0;  | 
32  |         if (mod instanceof Map) {
 | 
33  |           deleted = toLong(mod/Map.get("deleted"));
 | 
34  |           mod = mod/Map.get("module");
 | 
35  | }  | 
36  | |
37  | S className = dynShortName(mod);  | 
38  | if (eq(className, "DynamicModule"))  | 
39  | className = shortenClassName(getString(mod, '_className));  | 
40  | ret litorderedmap(  | 
41  |           "Module ID" := joinNempties("/", getString(mod, 'moduleID), className),
 | 
42  | //"Created" := formatLocalDateWithMinutes(getOptLong(mod, 'created)),  | 
43  | "Deleted" := formatLocalDateWithMinutes(deleted),  | 
44  | "Data Size" := toK(l(structure)) + " K",  | 
45  | "[hidden] md5" := md5(structure));  | 
46  | }));  | 
47  | }  | 
48  | |
49  |   S findStructure(int row) {
 | 
50  | Map map = get(data, row);  | 
51  | if (map == null) null;  | 
52  |     S md5 = (S) map.get("[hidden] md5");
 | 
53  | |
54  |     for (S structure : scanLog_iterator(deletedModulesLogFile(moduleID))) {
 | 
55  | if (!eq(md5(structure), md5)) continue;  | 
56  |       print("Found row");
 | 
57  | ret structure;  | 
58  | }  | 
59  | null;  | 
60  | }  | 
61  | |
62  |   void restore(int row) {
 | 
63  | S structure = findStructure(row);  | 
64  | if (structure == null) ret;  | 
65  |     callCreator('restoreModule, structure);
 | 
66  | }  | 
67  | |
68  |   void showStructure(int row) {
 | 
69  | S structure = findStructure(row);  | 
70  | if (structure == null) ret;  | 
71  | //dm_showNewTextArea();  | 
72  |     showWrappedText("Deleted Module Structure", structure);
 | 
73  | }  | 
74  | }  | 
Began life as a copy of #1016508
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1016849 | 
| Snippet name: | Recently Deleted Modules Of Type [OK, but doesn't update automatically] | 
| Eternal ID of this version: | #1016849/16 | 
| Text MD5: | ae07529649b2aa022b57191aea9546e5 | 
| Transpilation MD5: | 7630b43fc6a5a68a51fbe3c157dc8593 | 
| Author: | stefan | 
| Category: | javax / stefan's os | 
| Type: | JavaX source code (Dynamic Module) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2018-11-24 04:17:56 | 
| Source code size: | 2629 bytes / 74 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 799 / 10113 | 
| Version history: | 15 change(s) | 
| Referenced in: | [show references] |