Uses 1113K of libraries. Click here for Pure Java version (12201L/61K).
1 | !7 |
2 | |
3 | cmodule2 ServerModuleSearch > DynQuickSearch { |
4 | Map<Long, RecommendedModule> recommendedModules; |
5 | |
6 | start { |
7 | moduleDescForSearch = "Loadable"; |
8 | dm_snippetsDB(); |
9 | doEvery(5.0, 3600.0, r { |
10 | setField(recommendedModules := mapKeys psI( |
11 | (Map<S, RecommendedModule>) indexByField moduleID( |
12 | stefansOS_parseRecommendedModulesList(mL("Recommended Modules")))); |
13 | }); |
14 | |
15 | quickSearchParams = new O[] { |
16 | defaultAction := voidfunc(fS s) enter { |
17 | dm_addDynamicModuleDialog2(beforeSpace(s), true); |
18 | dm_hideQuickSearchModules(); |
19 | }, popupItems := new O[] { |
20 | "Edit", voidfunc(S s) enter { |
21 | dm_openSnippetInEditor(beforeSpace(s)); |
22 | }, "Make New", voidfunc(S s) enter { |
23 | dm_addDynamicModuleDialog2(beforeSpace(s), false); |
24 | dm_hideQuickSearchModules(); |
25 | }, "---", |
26 | "Send to machine...", voidfunc(S s) enter { |
27 | dm_sendModuleToOtherMachineDialog(beforeSpace(s)) |
28 | } |
29 | } |
30 | }; |
31 | } |
32 | |
33 | afterVisualize { |
34 | listPopupMenuThreaded(list, |
35 | (O[]) optPar(quickSearchParams, 'popupItems)); |
36 | |
37 | onDoubleClickOrEnterThreaded(list, (VF1<S>) optPar(quickSearchParams, 'defaultAction)); |
38 | } |
39 | |
40 | L<S> calc_impl() { |
41 | ret searchImpl(query); |
42 | } |
43 | |
44 | L sortSnippets(L snippets) { |
45 | ret sortByCalculatedFieldDesc(snippets, func(O snippet) -> Int { |
46 | long id = getLong(snippet, 'snippetID); |
47 | RecommendedModule rm = mapGet(recommendedModules, id); |
48 | if (rm != null) ret rm.prio+1; |
49 | S title = getString(snippet, 'title); |
50 | ret contains(title, "dev.") ? -1 : 0; |
51 | }); |
52 | } |
53 | |
54 | // API |
55 | |
56 | LS searchImpl(S query) { |
57 | L snippets = dm_dynModulesOnServer(); // L<CSnippet> |
58 | snippets = sortSnippets(snippets); // TODO: don't do this every time |
59 | |
60 | ret scoredSearch_eachTerm(query, |
61 | map(snippets, func(fO snippet) -> S { |
62 | long id = getLong(snippet, 'snippetID); |
63 | ret fsI(id) + " - " + (containsKey(recommendedModules, id) ? unicode_whiteStar() + " " : "") + _get(snippet, 'title); |
64 | })); |
65 | } |
66 | } |
Began life as a copy of #1016702
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1016932 |
Snippet name: | Server Module Search [Dyn Module] |
Eternal ID of this version: | #1016932/57 |
Text MD5: | d98f3ae1e46d510c287e7a3c74293d70 |
Transpilation MD5: | d0bc2052963cc2655d081fed4c34ce10 |
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-01-05 13:45:35 |
Source code size: | 2129 bytes / 66 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 640 / 611841 |
Version history: | 56 change(s) |
Referenced in: | [show references] |