Uses 1113K of libraries. Click here for Pure Java version (14600L/76K).
1 | !7 |
2 | |
3 | cm AllOnlineComputers > DynCalculatedList { |
4 | transient LS computerIDs, data; |
5 | transient StefansOS_ConnectToServer connector; |
6 | transient JLabel trayIcon; |
7 | |
8 | LS calc() { ret data; } |
9 | |
10 | start { |
11 | dm_addTrayIcon(trayIcon = jlabel()); |
12 | updateList(); |
13 | ownResource(connector = new StefansOS_ConnectToServer); |
14 | connector.onLine = voidfunc(S line) { |
15 | new Matches m; |
16 | if (swic(line, "ComputerIDs = ", m)) { |
17 | computerIDs = (LS) safeUnstruct($1); |
18 | updateList(); |
19 | vmBus_send('onlineComputerIDs, computerIDs); |
20 | setModuleName(n2(computerIDs, "Online Computer")); |
21 | } |
22 | }; |
23 | connector.startWithSubs("computerIDs"); |
24 | } |
25 | |
26 | afterVisualize { |
27 | listPopupMenuItemsThreaded(list, "Send clipboard there", rEnter { |
28 | pcall-infobox { |
29 | dm_sendClipboardTo_verbose(selectedComputerID()); |
30 | } |
31 | }, "Set name...", rEnter { setNameDialog(selectedComputerID()) }); |
32 | } |
33 | |
34 | // API |
35 | |
36 | LS onlineComputerIDs() { ret computerIDs; } |
37 | |
38 | bool isComputerOnline(S computerID) { |
39 | ret contains(computerIDs, computerID); |
40 | } |
41 | |
42 | void updateList { |
43 | O computerNames = dm_computerNames_opt(); |
44 | if (setField(data := sortedIC(map(computerIDs, func(S id) -> S { |
45 | S name = dm_callOpt(computerNames, "nameForID", id); |
46 | ret (eq(id, computerID()) ? "[this one] " : "") |
47 | + (nempty(name) ? name + " (" + id + ")" : id); |
48 | })))); |
49 | dm_q(r update); |
50 | |
51 | setTextAndToolTip(trayIcon, n2(data) + "c", nComputers(data) + " online"); |
52 | } |
53 | |
54 | S selectedComputerID() { |
55 | ret extractLastComputerID(selected()); |
56 | } |
57 | |
58 | void setNameDialog(S computerID) { |
59 | dm_call(dm_requireComputerNames(), 'openDialogForComputerID, computerID); |
60 | } |
61 | } |
Began life as a copy of #1016576
download show line numbers debug dex old transpilations
Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1016578 |
Snippet name: | All Online Computers [Show Connected Computers] |
Eternal ID of this version: | #1016578/43 |
Text MD5: | 9df1357f3bbe9ac0b6582d3660202ea8 |
Transpilation MD5: | 6eafaf66f045ccc24c774294eba0b7f0 |
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: | 2022-01-10 16:21:53 |
Source code size: | 1755 bytes / 61 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 567 / 83385 |
Version history: | 42 change(s) |
Referenced in: | [show references] |