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

46
LINES

< > BotCompany Repo | #1020906 // Mech Lists Selector

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

Libraryless. Click here for Pure Java version (12886L/91K).

1  
!7
2  
3  
sclass Entry {
4  
  S listName;
5  
  bool selected;
6  
  
7  
  *() {}
8  
  *(S *listName) {}
9  
}
10  
11  
module MechListsSelector > DynObjectTable<Entry> {
12  
  transient JTextArea taDetail;
13  
  
14  
  start {
15  
    dm_useLocalMechListCopies();
16  
    set withSearcher;
17  
  }
18  
  
19  
  visualize {
20  
    if (empty(data))
21  
      addLists(mechListNames()); // TODO: update later
22  
    JComponent c = super.visualize();
23  
    onTableSelectionChanged(table(), r {
24  
      if (selected() == null) clearTextAndDisable(taDetail);
25  
      else setTextAndEnable(taDetail, mL_raw(selected().listName));
26  
    });
27  
    onTableCellLeftClick(table(), voidfunc(int col, int row) {
28  
      if (tableColumnNameIs(table(), col, "Selected")) {
29  
        data.get(row).selected = !data.get(row).selected;
30  
        fireDataChanged();
31  
      }
32  
    });
33  
    ret jhsplit(c, taDetail = wordWrapTypeWriterTextArea(), 0.3);
34  
  }
35  
  
36  
  // API
37  
38  
  void addLists(Collection<S> names) {
39  
    L<Entry> l = cloneList(data);
40  
    Map<S, Entry> index = indexByFieldCI name(l);
41  
    for (S name : unnull(names))
42  
      if (!index.containsKey(name))
43  
        l.add(Entry(name));
44  
    setData(sortedByFieldIC name(l));
45  
  }
46  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020906
Snippet name: Mech Lists Selector
Eternal ID of this version: #1020906/10
Text MD5: 071c426be9ab9958fb8dad73dfa9d0b1
Transpilation MD5: e65f287100a361d181dc95e2100f2590
Author: stefan
Category: javax / concepts
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-19 15:38:38
Source code size: 1161 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 312 / 1351
Version history: 9 change(s)
Referenced in: [show references]