!7 cm AllOnlineComputers > DynCalculatedList { transient LS computerIDs, data; transient StefansOS_ConnectToServer connector; transient JLabel trayIcon; LS calc() { ret data; } start { dm_addTrayIcon(trayIcon = jlabel()); updateList(); ownResource(connector = new StefansOS_ConnectToServer); connector.onLine = voidfunc(S line) { new Matches m; if (swic(line, "ComputerIDs = ", m)) { computerIDs = (LS) safeUnstruct($1); updateList(); vmBus_send('onlineComputerIDs, computerIDs); setModuleName(n2(computerIDs, "Online Computer")); } }; connector.startWithSubs("computerIDs"); } afterVisualize { listPopupMenuItemsThreaded(list, "Send clipboard there", rEnter { pcall-infobox { dm_sendClipboardTo_verbose(selectedComputerID()); } }, "Set name...", rEnter { setNameDialog(selectedComputerID()) }); } // API LS onlineComputerIDs() { ret computerIDs; } bool isComputerOnline(S computerID) { ret contains(computerIDs, computerID); } void updateList { O computerNames = dm_computerNames_opt(); if (setField(data := sortedIC(map(computerIDs, func(S id) -> S { S name = dm_callOpt(computerNames, "nameForID", id); ret (eq(id, computerID()) ? "[this one] " : "") + (nempty(name) ? name + " (" + id + ")" : id); })))); dm_q(r update); setTextAndToolTip(trayIcon, n2(data) + "c", nComputers(data) + " online"); } S selectedComputerID() { ret extractLastComputerID(selected()); } void setNameDialog(S computerID) { dm_call(dm_requireComputerNames(), 'openDialogForComputerID, computerID); } }