Uses 1059K of libraries. Click here for Pure Java version (12377L/63K).
1 | !7 |
2 | |
3 | concept Entry { |
4 | S computerID, shortName, comment; |
5 | S controllableByMe; |
6 | |
7 | sS _fieldOrder = "shortName computerID comment"; |
8 | } |
9 | |
10 | cmodule2 ComputerNames > DynCRUD<Entry> { |
11 | bool automaticallyAddOnlineComputers = true; |
12 | |
13 | start { |
14 | indexConceptField(Entry, 'computerID); |
15 | |
16 | // Add myself |
17 | cset(uniq_returnIfNew(Entry, computerID := computerID()), comment := "This computer"); |
18 | |
19 | dm_vmBus_onMessage('onlineComputerIDs, voidfunc(Collection<S> ids) { |
20 | if (automaticallyAddOnlineComputers) slurpIDs(ids) |
21 | }); |
22 | |
23 | dm_requireAndCall("#1016578/AllOnlineComputers", 'updateList); |
24 | |
25 | // Add currently online computers |
26 | pcall { |
27 | slurpIDs((LS) dm_callModuleOpt(dm_findModule("#1016578/AllOnlineComputers"), 'onlineComputerIDs)); |
28 | } |
29 | |
30 | onConceptsChange(r { dm_findAndCallModule("#1016578/AllOnlineComputers", 'updateList) }); |
31 | |
32 | dm_registerAs('controllableComputerList); |
33 | } |
34 | |
35 | // API |
36 | |
37 | svoid slurpIDs(Collection<S> ids) { |
38 | for (S id : unnull(ids)) uniq(Entry, computerID := id); |
39 | } |
40 | |
41 | S nameForID(S computerID) { |
42 | ret cget(conceptWhere(Entry, +computerID), 'shortName); |
43 | } |
44 | |
45 | void setControllableByMe(S computerID, bool b) { |
46 | cset(uniq(Entry, +computerID), controllableByMe := yesNo_short(b)); |
47 | } |
48 | |
49 | LS controllableComputers() { |
50 | ret withoutMyComputerID(collect('computerID, conceptsWhere(Entry, controllableByMe := 'yes))); |
51 | } |
52 | |
53 | void openDialogForComputerID(S computerID) { |
54 | if (isComputerID(computerID)) |
55 | crud.editConcept(uniq Entry(+computerID)); |
56 | } |
57 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1019281 |
Snippet name: | Computer Names [give names to computers, Dyn Module] |
Eternal ID of this version: | #1019281/34 |
Text MD5: | 169e03226db405f01479a1aa8a46ba76 |
Transpilation MD5: | 2e11d8fa72e8a9b252f7919361b45c7b |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-12-18 02:16:35 |
Source code size: | 1594 bytes / 57 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 479 / 22726 |
Version history: | 33 change(s) |
Referenced in: | [show references] |