Libraryless. Click here for Pure Java version (23135L/141K).
1 | sclass ConceptsComboBox<A extends Concept> extends JComboBox<A> { |
2 | Concepts concepts; |
3 | Class<A> conceptClass; |
4 | AWTOnConceptChanges updater; |
5 | settable bool allowNull; |
6 | settable IPred<A> itemFilter; |
7 | |
8 | *(Concepts *concepts, Class<A> *conceptClass) { |
9 | updateItems(); |
10 | |
11 | updater = new AWTOnConceptChanges(concepts, this, l0 updateItems); |
12 | updater.install(); |
13 | } |
14 | |
15 | void updateItems { |
16 | var l = sortTheList(filterTheList(freshList())); |
17 | if (allowNull) l = nullPlus(l); |
18 | setComboBoxItems_notifyListeners(this, l); |
19 | } |
20 | |
21 | swappable Cl<A> freshList() { |
22 | ret main list(concepts, conceptClass); |
23 | } |
24 | |
25 | L<A> filterTheList(Cl<A> l) { |
26 | ret itemFilter == null ? asList(l) : filter(itemFilter, l); |
27 | } |
28 | |
29 | swappable L<A> sortTheList(L<A> l) { |
30 | ret sortConceptsByID(l); |
31 | } |
32 | |
33 | selfType sorter(IF1<L<A>> sorter) { sortTheList = sorter; this; } |
34 | |
35 | A get() { ret getSelectedItem_typed(this); } |
36 | |
37 | void select(long conceptID) { |
38 | main setSelectedItem(this, getConcept(concepts, conceptClass, conceptID)); |
39 | } |
40 | } |
Began life as a copy of #1006615
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1033913 |
Snippet name: | ConceptsComboBox |
Eternal ID of this version: | #1033913/22 |
Text MD5: | c0e3f2c70708ff6d0a429636c69a6a21 |
Transpilation MD5: | 347cba42374f2705c3ce1e07b930c238 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-10-17 16:48:22 |
Source code size: | 1078 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 229 / 448 |
Version history: | 21 change(s) |
Referenced in: | [show references] |