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

61
LINES

< > BotCompany Repo | #1027612 // Generic Multi-CRUD [stable version]

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

Uses 911K of libraries. Click here for Pure Java version (13499L/72K).

!7

concept ObjectType > Named {
  S conceptClassName;
  
  toString { ret "object type " + quote(name); }
}

concept DynamicThing > Named {
  ObjectType type;
  
  toString { ret (type == null ? "?" : type.name) + " " + quote(name); }
}

cmodule DynamicClassesMultiCRUD > DynVoiceMultiCRUD {
  transient S defaultCmdsSnippetID = #1027616;
  
  L<Table> makeTables() {
    ret itemPlusList(new Table("Object Types", "object type", ObjectType), 
      map(list(ObjectType), type ->
        new Table(plural(type.name), type.name, DynamicThing, litparams(+type))));
  }
    
  transient NameBasedVoiceCRUD<ObjectType> typesCRUD;

  start {
    typesCRUD = voiceCRUDs.get(idx(ObjectType));
    
    // Update voice CRUDs when there is a new object type
    onConceptsChange(rWatcher_noRunFirstTime(
      () -> objectTypes(), names -> objectTypesChanged(names)));
  }
  
  void objectTypesChanged(LS names) enter {
    print("Updating voice CRUDs");
    remakeVoiceCRUDs();
    vmBus_send objectTypesChanged(module(), names);
  }
  
  void startSwingCRUDs {
    swingCRUDs = ll(
      pair("Object Types", CRUD(ObjectType)),
      pair("Objects", CRUD(DynamicThing)));
  }
  
  void startFrontEnd enter {
    S frontEnd = dm_showModuleWithParams("#1027602/ChatBotFrontend", backendModuleID := dm_moduleID());
    if (eq(dm_call(frontEnd, 'conceptCount), 0))
      dm_call(frontEnd, 'importCmdsFromSnippet, defaultCmdsSnippetID);
  }
  
  afterVisualize {
    addComponent(firstSwingCRUDButtons(), jbutton("Start front-end", rThread startFrontEnd));
  }
  
  // API
  
  LS objectTypes() {
    ret itemPlus("object type", collect name(list(ObjectType)));
  }
}

Author comment

Began life as a copy of #1027591

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027612
Snippet name: Generic Multi-CRUD [stable version]
Eternal ID of this version: #1027612/9
Text MD5: f5216726aed046d2bc2f477f096e7a28
Transpilation MD5: f37237cc8e5014a833d270fb51248971
Author: stefan
Category: javax / voice crud
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-26 16:32:23
Source code size: 1716 bytes / 61 lines
Pitched / IR pitched: No / No
Views / Downloads: 153 / 269
Version history: 8 change(s)
Referenced in: [show references]