Libraryless. Click here for Pure Java version (16065L/97K).
1 | abstract sclass DynQuickSearch extends DynCalculatedList { |
2 | transient S query; |
3 | transient new RestartableCountdown autoHide; |
4 | transient S moduleDescForSearch; |
5 | transient O[] quickSearchParams; |
6 | transient bool doSearchVerbose; |
7 | transient int yesPopupOffsetY = -13; |
8 | |
9 | start { |
10 | calculateWhenHidden = true; |
11 | ownResource(vmBus_onMessage('topInput, voidfunc(S s) { doSearch(s) })); |
12 | ownResource(vmBus_onMessage('topInputChanged, voidfunc(S s) { if (neq(s, query)) doSearch(s) })); |
13 | dm_vmBus_onMessage_q hideQuickSearchModules(r dm_hideModule); |
14 | } |
15 | |
16 | void doSearch(S s) enter { |
17 | if (dm_dontQuickSearch_combined(s)) ret; |
18 | query = s; |
19 | O qsm = dm_quickSearchManager(); |
20 | if (qsm != null && !dm_isMe(qsm)) { |
21 | results = calc(); |
22 | dm_call(qsm, 'setResultsForModule, dm_moduleID(), moduleDescForSearch, query, results, quickSearchParams); |
23 | } else { |
24 | super.update(); |
25 | if (doSearchVerbose) |
26 | print("doSearch: Got " + n2(results, "result") + " for " + query); |
27 | if (nempty(query) && nempty(results)) { |
28 | dm_placeModuleUnderAIBar_v2(this, query); |
29 | dm_autoHide(autoHide); |
30 | if (dm_yesPopupEnabled() && dm_amFirstQuickSearchModule() |
31 | && !dm_myYesPopup()) |
32 | dm_showYesToAcceptPopupAbove_v2(list, |
33 | imageID := #1101462, |
34 | height := 247/2, |
35 | mover := voidfunc(Component c, Component popup) enter { |
36 | JList list = cast c; |
37 | Rect r = boundsInParent(c, dm_desktopPane()); |
38 | if (r == null) ret; |
39 | Rect item = jlist_itemBounds(list, 0); |
40 | setLocation(popup, r.x+item.x-popup.getWidth(), r.y+item.y+yesPopupOffsetY); |
41 | }); |
42 | } else |
43 | dm_hideModule(); |
44 | } |
45 | } |
46 | |
47 | void yes { |
48 | jlist_doubleClickOnItem(list, 0); |
49 | } |
50 | |
51 | final L<S> calc() { |
52 | if (empty(query)) ret emptyList(); |
53 | ret calc_impl(); |
54 | } |
55 | |
56 | abstract LS calc_impl(); |
57 | |
58 | void enhanceFrame(Container f) { |
59 | super.enhanceFrame(f); |
60 | setClosable(f, false); |
61 | internalFramePopupMenuItem(f, "Delete", rThread { dm_deleteModuleInBackground(module()) }); |
62 | } |
63 | |
64 | // API |
65 | |
66 | void selectFirstEntry() { |
67 | selectRow(list, 0); |
68 | } |
69 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1018420 |
Snippet name: | DynQuickSearch |
Eternal ID of this version: | #1018420/29 |
Text MD5: | 2051ae197a97d8c7457df703ecf68ac3 |
Transpilation MD5: | 16a229f3a5c974f97fe4281dfe4a8fcb |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-22 16:06:28 |
Source code size: | 2252 bytes / 69 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 462 / 1162 |
Version history: | 28 change(s) |
Referenced in: | [show references] |