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

45
LINES

< > BotCompany Repo | #1017623 // Follow-up/No follow-up [Tag Telegram Messages, OK]

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

Libraryless. Click here for Pure Java version (15588L/113K).

1  
!7
2  
3  
sclass FollowUp > DynModule {
4  
  start {
5  
    dm_useLocalMechListCopies();
6  
  }
7  
  
8  
  visualize {
9  
    final Set<S> followUps = asHashSet(map dropLeadingHash(extractSingleStarMatches("* is a follow-up message",
10  
      concatLists(mL("Facts about Telegram messages"), lines((S) call(dm_get_newFacts(), 'text))))));
11  
      
12  
    new L<L> data;
13  
    for (TelegramMsg msg : serverTelegramLog())
14  
      if (nempty(msg.globalID))
15  
        data.add(ll(msg.globalID, escapeNewLines(msg.text), followUps.contains(msg.globalID)));
16  
        
17  
    final L<S> cols = ll("Global ID", "Text", "Is Follow-Up");
18  
    
19  
    final JTable table = sexyTable();
20  
    Pair<Object[][], O[]> p = fillTableWithData_makeData(data, cols);
21  
    setTableModel(table, new DefaultTableModel(p.a, p.b) {
22  
      public Class getColumnClass(int column) {
23  
        return or(_getClass(getValueAt(0, column)), S.class);
24  
      }
25  
      
26  
      public bool isCellEditable(int rowIndex, int columnIndex) {
27  
        ret columnIndex == l(cols)-1;
28  
      }
29  
    });
30  
    onTableChanged(table, voidfunc(final TableModelEvent e) {
31  
      thread {
32  
        O facts = dm_require_newFacts();
33  
        int i = e.getFirstRow(), j = e.getLastRow();
34  
        print(i + "/" + j);
35  
        for (; i <= j; i++) {
36  
          bool b = isTrue(print(rawCellData(table, i, l(cols)-1)));
37  
          S id = (S) rawCellData(table, i, 0);
38  
          call(facts, 'add, "#" + id + " is " + (b ? "a" : "not a") + " follow-up message");
39  
          call(facts, 'remove, "#" + id + " is " + (!b ? "a" : "not a") + " follow-up message");
40  
        }
41  
      }
42  
    });
43  
    ret table;
44  
  }
45  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1017623
Snippet name: Follow-up/No follow-up [Tag Telegram Messages, OK]
Eternal ID of this version: #1017623/19
Text MD5: 8fd9e582544353751f682cb819264e44
Transpilation MD5: e8f1b87ed44cfc82d8b5689a65f0519d
Author: stefan
Category: javax / networking
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-02 17:15:45
Source code size: 1627 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 346 / 1366
Version history: 18 change(s)
Referenced in: [show references]