package com.ts3client.ui; import com.ts3client.net.ClientEntry; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; /** * The context menu for a client, shared by the server tree and the clickable * names in the chat log. */ final class ClientMenu { private ClientMenu() { } static JPopupMenu build(ClientEntry client, boolean self, ServerTreePanel.Actions actions) { JPopupMenu menu = new JPopupMenu(); if (!self) { JMenuItem pm = new JMenuItem("Open text chat", Icons.of("PLAYER_CHAT")); pm.addActionListener(a -> actions.openPrivateChat(client)); menu.add(pm); JMenuItem poke = new JMenuItem("Poke", Icons.of("POKE")); poke.addActionListener(a -> actions.pokeClient(client)); menu.add(poke); menu.addSeparator(); boolean muted = actions.isClientLocallyMuted(client.id); JMenuItem mute = new JMenuItem(muted ? "Unmute client" : "Mute client", Icons.of(muted ? "PLAYER_ON" : "INPUT_MUTED")); mute.addActionListener(a -> actions.toggleClientMute(client)); menu.add(mute); } else { JMenuItem me = new JMenuItem("This is you", Icons.of("PLAYER_OFF")); me.setEnabled(false); menu.add(me); } menu.addSeparator(); JMenuItem info = new JMenuItem("Connection Info", Icons.of("INFO")); info.addActionListener(a -> actions.showConnectionInfo(client)); menu.add(info); return menu; } }