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

48
LINES

< > BotCompany Repo | #1026559 - List With Feedback

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

Uses 793K of libraries. Click here for Pure Java version (10658L/57K).

!7

sclass Entry {
  S item, reasoning, feedback = "";
  
  sS _fieldOrder = "reasoning item feedback";
}

cmodule ListWithFeedback > DynObjectTable<Entry> {
  S description, code, computerNotes, humanNotes, metaData, globalIDSaved;
  
  start {
    defaultAction = voidfunc(Entry e) {
      inputText("Feedback for: " + e.item, e.feedback, feedback -> { e.feedback = feedback; change(); });
    };
  }
  
  visual northCenterAndSouthWithMargins(
    northAndCenterWithMargin(
      centerAndEastWithMargin(
        dm_textFieldWithLabel description(),
        jThreadedButton("Save data", rEnter saveData)),
      jMinHeight(70,
        jhsplit(0.75, dm_textAreaWithTitle code(), dm_textAreaWithTitle computerNotes()))),
    withTitle("The List", super),
    jMinHeight(70, dm_textAreaWithTitle humanNotes()));
  
  // API
  
  void saveData {
    File dir = ai_listsWithFeedbackDir();
    setField(metaData := "Made on computer " + computerID() + " on " + localDateWithSeconds());
    S globalID = aGlobalID();
    S struct = javaTokWordWrap(dm_freshModuleStruct());
    setField(globalIDSaved := globalID);
    infoBox("Saved: " + renderFileInfo(saveTextFile(newFile(dir, globalID + ".struct"), struct)));
  }
  
  // takes a list of strings or pairs (item + reasoning)
  void importItems(L l) {
    setData(map(l, o -> {
      o = quickImport(o);
      if (o cast Pair) ret nu Entry(item := o.a, reasoning := o.b);
      if (o cast WithReasoning) ret nu Entry(item := str(o!), reasoning := o.reasoning);
      ret nu Entry(item := str(o));
    }));
  }
}

download  show line numbers  debug dex   

Travelled to 2 computer(s): mqqgnosmbjvj, tvejysmllsmz

No comments. add comment

Snippet ID: #1026559
Snippet name: List With Feedback
Eternal ID of this version: #1026559/24
Text MD5: b81f63cbd9f6ad30a0b7556a0823e6aa
Transpilation MD5: 1b09c46a90ba8a6d8d1d7eaf015b519a
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-19 15:03:16
Source code size: 1605 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 60 / 382
Version history: 23 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1026559 & http://1026559.tinybrain.de