Uses 1113K of libraries. Click here for Pure Java version (10804L/55K).
1 | !7 |
2 | |
3 | abstract !include #1016674 // Module List |
4 | |
5 | cmodule LoadedModuleSearch > ModuleList { |
6 | transient S query; |
7 | transient new RestartableCountdown autoHide; |
8 | transient S moduleDescForSearch; |
9 | transient O[] quickSearchParams; |
10 | |
11 | transient int yesPopupOffsetY = -13; |
12 | |
13 | start { |
14 | moduleDescForSearch = "Loaded"; |
15 | calculateWhenHidden = true; |
16 | dm_onTopInput_q(voidfunc(S s) { doSearch(s, false) }); |
17 | dm_onTopInputChange_q(voidfunc(S s) { if (neq(s, query)) doSearch(s, false) }); |
18 | dm_vmBus_onMessage_q hideQuickSearchModules(r dm_hideModule); |
19 | |
20 | quickSearchParams = new O[] { |
21 | defaultAction := voidfunc(S s) { |
22 | dm_showModule(getModule(s)) |
23 | }, popupItems := toObjectArray(concatMap(dm_moduleMenuItems(), func(final Pair<S, VF1<O>> p) -> L { ll(p.a, voidfunc(S s) enter { |
24 | callF(p.b, getModule(s)) |
25 | }) })) |
26 | }; |
27 | } |
28 | |
29 | afterVisualize { |
30 | onDoubleClickOrEnter(list, rEnter dm_hideQuickSearchModules); |
31 | } |
32 | |
33 | void doSearch(S s, bool withYesPopup) enter { |
34 | if "yes" { |
35 | if (dm_hasYesPopupForComponent(list)) { |
36 | print("HAVE POPUP"); |
37 | print("Clicked? " + jlist_doubleClickOnItem(list, 0)); |
38 | ret; |
39 | } |
40 | } |
41 | |
42 | if (dm_dontQuickSearch_combined(s)) ret; |
43 | query = s; |
44 | O qsm = dm_quickSearchManager(); |
45 | if (qsm != null) { |
46 | results = calc(); |
47 | dm_call(qsm, 'setResultsForModule, dm_moduleID(), moduleDescForSearch, query, map(results, func(S s) -> Pair<S> { |
48 | S moduleID = firstIntAsString(s); |
49 | ret pair(dm_programID(moduleID) + " - " + dm_moduleName(moduleID), moduleID); |
50 | }), quickSearchParams); |
51 | } else { |
52 | super.update(); |
53 | if (nempty(query) && nempty(results)) { |
54 | dm_placeModuleUnderAIBar_v2(this, query); |
55 | if (withYesPopup && !dm_hasYesToAcceptPopup()) { |
56 | dm_showYesToAcceptPopupWithParams(list, |
57 | imageID := #1101462, |
58 | height := 247/2, |
59 | mover := voidfunc(Component c, Component popup) enter { |
60 | JList list = cast c; |
61 | Rect r = boundsInParent(c, dm_desktopPane()); |
62 | if (r == null) ret; |
63 | Rect item = jlist_itemBounds(list, 0); |
64 | setLocation(popup, r.x+item.x-popup.getWidth(), r.y+item.y+yesPopupOffsetY); |
65 | }); |
66 | } |
67 | dm_autoHide(autoHide); |
68 | } else |
69 | dm_hideModule(); |
70 | } |
71 | } |
72 | |
73 | L<O> modulesToList() { |
74 | if (empty(query)) ret emptyList(); |
75 | L modules = super.modulesToList(); |
76 | L<S> results = scoredSearch_eachTerm(dm_getInterestingString(), |
77 | map(modules, func(fO m) -> S { |
78 | "[" + dm_moduleID(m) + "] " |
79 | + pcallF(func -> S { dm_moduleName(m) }) |
80 | + " / " + shortClassName(m) |
81 | + " / " + getProgramID(m) })); |
82 | ret map(results, func(S s) -> O { dm_getModule(leadingSquareBracketStuff(s)) }); |
83 | } |
84 | |
85 | void selectFirstEntry() { selectRow(list, 0); } |
86 | |
87 | void enhanceFrame(Container f) { |
88 | super.enhanceFrame(f); |
89 | setClosable(f, false); |
90 | } |
91 | } |
Began life as a copy of #1016674
download show line numbers debug dex old transpilations
Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, unoaxrwscvea, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1016702 |
Snippet name: | Loaded Module Search [Dyn Module] |
Eternal ID of this version: | #1016702/65 |
Text MD5: | 27e82e02b229f0daf84dd371e1462ca1 |
Transpilation MD5: | b7b9512d491c945f1e9b4e4faef7976a |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-22 16:06:32 |
Source code size: | 3068 bytes / 91 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 572 / 584595 |
Version history: | 64 change(s) |
Referenced in: | [show references] |