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).

1  
!7
2  
3  
concept ObjectType > Named {
4  
  S conceptClassName;
5  
  
6  
  toString { ret "object type " + quote(name); }
7  
}
8  
9  
concept DynamicThing > Named {
10  
  ObjectType type;
11  
  
12  
  toString { ret (type == null ? "?" : type.name) + " " + quote(name); }
13  
}
14  
15  
cmodule DynamicClassesMultiCRUD > DynVoiceMultiCRUD {
16  
  transient S defaultCmdsSnippetID = #1027616;
17  
  
18  
  L<Table> makeTables() {
19  
    ret itemPlusList(new Table("Object Types", "object type", ObjectType), 
20  
      map(list(ObjectType), type ->
21  
        new Table(plural(type.name), type.name, DynamicThing, litparams(+type))));
22  
  }
23  
    
24  
  transient NameBasedVoiceCRUD<ObjectType> typesCRUD;
25  
26  
  start {
27  
    typesCRUD = voiceCRUDs.get(idx(ObjectType));
28  
    
29  
    // Update voice CRUDs when there is a new object type
30  
    onConceptsChange(rWatcher_noRunFirstTime(
31  
      () -> objectTypes(), names -> objectTypesChanged(names)));
32  
  }
33  
  
34  
  void objectTypesChanged(LS names) enter {
35  
    print("Updating voice CRUDs");
36  
    remakeVoiceCRUDs();
37  
    vmBus_send objectTypesChanged(module(), names);
38  
  }
39  
  
40  
  void startSwingCRUDs {
41  
    swingCRUDs = ll(
42  
      pair("Object Types", CRUD(ObjectType)),
43  
      pair("Objects", CRUD(DynamicThing)));
44  
  }
45  
  
46  
  void startFrontEnd enter {
47  
    S frontEnd = dm_showModuleWithParams("#1027602/ChatBotFrontend", backendModuleID := dm_moduleID());
48  
    if (eq(dm_call(frontEnd, 'conceptCount), 0))
49  
      dm_call(frontEnd, 'importCmdsFromSnippet, defaultCmdsSnippetID);
50  
  }
51  
  
52  
  afterVisualize {
53  
    addComponent(firstSwingCRUDButtons(), jbutton("Start front-end", rThread startFrontEnd));
54  
  }
55  
  
56  
  // API
57  
  
58  
  LS objectTypes() {
59  
    ret itemPlus("object type", collect name(list(ObjectType)));
60  
  }
61  
}

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: 229 / 364
Version history: 8 change(s)
Referenced in: [show references]