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

27
LINES

< > BotCompany Repo | #1004385 // tableWithSearcher - add search bar on top of JTable

JavaX fragment (include)

1  
static JComponent tableWithSearcher(final JTable t, O... _) {
2  
  final new JTextField input;
3  
  onUpdate(input, new Runnable {
4  
    L lastFiltered, lastOriginal;
5  
    
6  
    public void run() {
7  
      S pat = trim(input.getText());
8  
      
9  
      L<Map<S, O>> data = rawTableData(t);
10  
      if (eq(lastFiltered, data))
11  
        data = lastOriginal;
12  
      
13  
      print("Searching " + n(l(data), "entry"));
14  
      new L data2;
15  
      for (Map<S, O> map : data)
16  
        if (anyValueContainsIgnoreCase(map, pat))
17  
          data2.add(map);
18  
          
19  
      print("Found " + n(l(data2), "entry"));
20  
      lastFiltered = data2;
21  
      lastOriginal = data;
22  
      dataToTable(t, data2);
23  
    }
24  
  });
25  
  JComponent top = withLabel("Search:", input);
26  
  ret boolOptPar(_, 'withMargin) ? northAndCenterWithMargin(top, t) : northAndCenter(top, t);
27  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1004385
Snippet name: tableWithSearcher - add search bar on top of JTable
Eternal ID of this version: #1004385/7
Text MD5: 5e1f986a5114857ddb3042847f3c1f0d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-09 15:23:00
Source code size: 844 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 537 / 529
Version history: 6 change(s)
Referenced in: [show references]