Libraryless. Click here for Pure Java version (15035L/106K).
1 | !7 |
2 | |
3 | sclass UniversalSearch extends DynModule {
|
4 | S query; |
5 | transient L<SS> result; |
6 | |
7 | transient Q q; |
8 | transient int maxInputLength = 120; |
9 | transient WaitForStableValue<S> waitForStableValue = new(1.0); |
10 | transient volatile bool calculating; |
11 | transient JTable table; |
12 | transient SimpleLiveValue<S> lvQuery = stringLiveValue(); |
13 | |
14 | JComponent visualize() {
|
15 | ret jLiveValueSection(lvQuery, dataToTable_uneditable(result, table = sexyTable())); |
16 | } |
17 | |
18 | void unvisualize() { table = null; }
|
19 | |
20 | void start {
|
21 | lvQuery.set(query); |
22 | q = startQ(); |
23 | ownTimer(doEvery(1000, r updateMe)); |
24 | } |
25 | |
26 | void update {
|
27 | S s = dm_getInterestingString(); |
28 | if (nempty(s) && l(s) <= maxInputLength) { // TODO: more quality checks?
|
29 | waitForStableValue.set(s); |
30 | } |
31 | |
32 | fS q = waitForStableValue!; |
33 | if (nempty(q) && neq(q, query)) |
34 | this.q.add(r { calc(q) });
|
35 | } |
36 | |
37 | void calc(S q) {
|
38 | if (eq(query, q)) ret; |
39 | result = null; |
40 | lvQuery.set(query = q); |
41 | temp tempSetField(this, calculating := true); |
42 | L<Pair<O, S>> l = dm_universalSearch(q); |
43 | result = map(l, func(Pair<O, S> p) -> SS {
|
44 | litorderedmap("Result" := str(first(p)), "From Module" := second(p))
|
45 | }); |
46 | dataToTable_uneditable_ifHasTable(result, table); |
47 | } |
48 | } |
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: | #1016241 |
| Snippet name: | Universal Search [Dyn Module, dev.] |
| Eternal ID of this version: | #1016241/4 |
| Text MD5: | c833d3aa768f58ce4b292dfe7ff8df52 |
| Transpilation MD5: | 1fab6eeaa340f5ee7e6e8741b5b1a781 |
| Author: | stefan |
| Category: | javax / stefan's os |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-06-11 20:00:40 |
| Source code size: | 1313 bytes / 48 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 610 / 759 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |