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

46
LINES

< > BotCompany Repo | #1024186 // Quick Annotator with guessing prelude 1

JavaX source code (Dynamic Module) - run with: Stefan's OS

!7

srecord Entry(S text, S annotations, S guess) {
  LS annotations() { ret tok_splitAtComma_emptyOnEmpty(annotations); }
}

/*c*/module QuickAnnotator > DynObjectTable<Entry> {
  start { addCountToName(); }
  
  afterVisualize {
    tablePopupMenuItemAndDoubleClick(table, "Edit annotations...", voidfunc(int row) {
      Entry e = getRow(row);
      if (e == null) ret;
      JTextField tf = jTextField(e.annotations);
      showFormTitled("Edit annotations",
        "Line", e.text,
        "Annotations (comma-separated)", tf, r {
          e.annotations = gtt(tf);
          fireDataChanged();
        });
    });
  }
  
  IntRange visibleRows() { ret jTable_visibleRows(table); }
  
  // API
  
  void fillData(Collection<PairS> l) {
    setList(map(l, p -> nu Entry(text := p.a, annotations := p.b)));
  }
  
  void fillData(SS map) {
    fillData(mapToPairs(map));
  }
  
  void setItems(Collection<S> l) {
    fillData(map(l, s -> pair(s, "")));
  }
  
  Set<S> allAnnotations() {
    Set<S> set = ciSet();
    for (Entry e : data())
      _addAll(set, e.annotations());
    ret set;
  }
}

Author comment

Began life as a copy of #1024172

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1024186
Snippet name: Quick Annotator with guessing prelude 1
Eternal ID of this version: #1024186/1
Text MD5: b95f16d57c5dac69dc14a9f7d26d9d7a
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-24 19:07:47
Source code size: 1144 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 131 / 162
Referenced in: [show references]