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

23
LINES

< > BotCompany Repo | #1015977 // DynCalculatedList

JavaX fragment (include)

1  
abstract sclass DynCalculatedList extends DynModule {
2  
  transient JList list;
3  
  transient L<S> results;
4  
  transient bool calculateWhenHidden;
5  
6  
  visualize { ret list = jlist(calc()); }
7  
  void unvisualize() { list = null; }  
8  
  void update() {
9  
    temp enter();
10  
    if (list != null || calculateWhenHidden)
11  
      fillListWithStrings(list, results = calc());
12  
  }
13  
14  
  // Note: This is called on every update, so you should cache
15  
  // results IN the calc function if they are expensive to make
16  
  abstract L<S> calc();
17  
  
18  
  void scrollDown {
19  
    scrollAllTheWayDown(list);
20  
  }
21  
  
22  
  S selected() { ret selectedItem(list); }
23  
}

Author comment

Began life as a copy of #1015929

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1015977
Snippet name: DynCalculatedList
Eternal ID of this version: #1015977/16
Text MD5: b555af5aa62cdef533a1df7628de0b1e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-02 17:08:17
Source code size: 642 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 496 / 3216
Version history: 15 change(s)
Referenced in: [show references]