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

41
LINES

< > BotCompany Repo | #1021740 // Gazelle: Statements [Dyn Module]

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

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

!7

concept Statement {
  S globalID = aGlobalIDUnlessLoading();
  S text;
  S comments;
  long discordUserID;
  S context;
}

cmodule Statements > DynCRUD<Statement> {
  enhanceFrame { internalFrameIcon(f, gazelle_frameIcon()); }
  
  start {
    dbIndexing(Statement, 'globalID);
    
    crud.multiLineFields = litset('text, 'comments);
    crud.dontDuplicateFields = litset('globalID);
    crud.renderer = func(Statement r) -> Map { litorderedmap("Statement ID" := r.globalID, text := joinWithSpace(tlft(r.text)), comments := escapeNewLines(r.comments)) };
    onConceptsChange(r { vmBus_sendMessage('gazelleStatementsChanged, this) });
  }
  
  // API
  
  Pair<S, Bool> addStatement(S text) {
    ret addStatementWithComment(text, null);
  }
  
  Pair<S, Bool> addStatementWithComment(S text, S comment) {
    Pair<Statement, Bool> p = uniq2_sync(Statement,
      text := rtrim(text),
      comments := nullIfEmpty(rtrim(comment)));
    if (p.b) vmBus_sendMessage('gazelleStatementCreated, this, p.a);
    ret pair(p.a.globalID, p.b);
  }
  
  PairS textAndCommentForStatement(S statementID) {
    Statement r = conceptWhere Statement(globalID := statementID);
    ret r == null ? null : pair(r.text, r.comments);
  }
}

Author comment

Began life as a copy of #1021352

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1021740
Snippet name: Gazelle: Statements [Dyn Module]
Eternal ID of this version: #1021740/3
Text MD5: 06e68d05959b1dc4c373a4aa1b46993c
Transpilation MD5: 626d23c247315176eb6714a84d265548
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-25 17:02:11
Source code size: 1265 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 308 / 4300
Version history: 2 change(s)
Referenced in: [show references]