Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

74
LINES

< > BotCompany Repo | #1016849 // Recently Deleted Modules Of Type [OK, but doesn't update automatically]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (15439L/111K).

!7

DynTable > RecentlyDeletedModules {
  S moduleID;
  
  JComponent visualize() {
    JComponent c = super.visualize();
    tablePopupMenuItemsThreaded(table,
      "Restore module", voidfunc(int row) { restore(row) },
      "Show structure", voidfunc(int row) { showStructure(row) });
    JTextField tfModuleID = jLiveValueTextField_bothWays(dm_fieldLiveValue('moduleID));
    onEnter(tfModuleID, r actualUpdate);
    ret northAndCenter(
      centerAndEastWithMargin(withLabel("Module ID:", tfModuleID), jbutton("Search", r actualUpdate)), c);
  }
  
  L<Map> calc() { ret data; }
  
  void actualUpdate { temp enter(); setField(data := actualCalc(); }
  
  L<Map> actualCalc() {
    if (empty(moduleID)) null;
    print("Searching for deleted modules of type " + moduleID);
    ret reversed(map(scanLog_iterator(deletedModulesLogFile(moduleID)),
      func(S structure) -> Map {
        O mod = safeUnstructure(structure);
        // old layout:
        // "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)"
        // new layout:
        // "hm{deleted=123L, module := c DynamicModule(...)}"
        long deleted = 0;
        if (mod instanceof Map) {
          deleted = toLong(mod/Map.get("deleted"));
          mod = mod/Map.get("module");
        }

        S className = dynShortName(mod);
        if (eq(className, "DynamicModule"))
          className = shortenClassName(getString(mod, '_className));
        ret litorderedmap(
          "Module ID" := joinNempties("/", getString(mod, 'moduleID), className),
          //"Created" := formatLocalDateWithMinutes(getOptLong(mod, 'created)),
          "Deleted" := formatLocalDateWithMinutes(deleted),
          "Data Size" := toK(l(structure)) + " K",
          "[hidden] md5" := md5(structure));
      }));
  }
  
  S findStructure(int row) {
    Map map = get(data, row);
    if (map == null) null;
    S md5 = (S) map.get("[hidden] md5");
    
    for (S structure : scanLog_iterator(deletedModulesLogFile(moduleID))) {
      if (!eq(md5(structure), md5)) continue;
      print("Found row");
      ret structure;
    }
    null;
  }
  
  void restore(int row) {
    S structure = findStructure(row);
    if (structure == null) ret;
    callCreator('restoreModule, structure);
  }
  
  void showStructure(int row) {
    S structure = findStructure(row);
    if (structure == null) ret;
    //dm_showNewTextArea();
    showWrappedText("Deleted Module Structure", structure);
  }
}

Author comment

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: 327 / 9503
Version history: 15 change(s)
Referenced in: [show references]