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

71
LINES

< > BotCompany Repo | #1019470 // Information Databases [Dyn Module]

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

Libraryless. Click here for Pure Java version (21032L/159K).

!7

set flag DynModule.

concept Entry {
  S name;
  S description;
  S codeToProduce;
  transient O data;
  long entries, sizeInRAM, loadTime = -1;
  S javaType;
  bool autoLoad;
  Map moreInfo;
}

module InformationDatabases > DynCRUD<Entry> {
  *() { super(Entry); }
  
  start {
    doLater(5000, r {
      for (Entry e : conceptsWhere(Entry, autoLoad := true))
        loadEntryOpt(e);
    });
  }
  
  afterVisualize {
    addComponents(crud.buttons,
      tableDependentButton(table(), "Load", rThread { loadEntry(selected()) }),
      tableDependentButton(table(), "Show", rThread { showEntry(selected()) })
    );
  }
  
  SimpleCRUD<Entry> makeCRUD() {
    ret setAllAndReturn(super.makeCRUD(),
      excludeFieldsFromEditing := litset('moreInfo, 'sizeInRAM, 'data),
      renderer := func(Entry e) -> Map { mapPlus(renderConceptForCRUDWithoutFields(e, 'data),
        entries := n2(e.entries),
        loadTime := e.loadTime < 0 ? "" : e.loadTime + " ms",
        sizeInRAM := e.sizeInRAM == 0 ? "" : str_toK(e.sizeInRAM)) });
  }
  
  void loadEntry(Entry e) pcall {
    cset(e, codeToProduce := trim(e.codeToProduce));
    O data = null;
    if (anyJavaTokens(e.codeToProduce)) loading "Loading data" {
      long time = sysNow();
      if (isIdentifier(e.codeToProduce)) {
        makeAndCall_initChild.set(voidfunc(Class c) { shareMyCreatorWith(c) });
        data = callAndMake(e.codeToProduce);
      } else
        data = dm_javaEval(e.codeToProduce);
      cset(e, loadTime := sysNow()-time);
    }
    cset(e, +data);
    pcall {
      cset(e, sizeInRAM := retainedObjectSize(data));
      cset(e, entries := l_opt(data));
      cset(e, javaType := shortJavaTypeDesc(data));
    }
  }
  
  void loadEntryOpt(Entry e) {
    if (e.data == null) loadEntry(e);
  }
  
  void showEntry(Entry e) {
    loadEntryOpt(e);
    if (e.data instanceof Collection)
      dm_showStringList(e.name, allToString((Collection) e.data));
  }
}

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: 395 / 1256
Version history: 25 change(s)
Referenced in: