/** {@inheritDoc} */ @Override public void execute( final FrameContainer origin, final CommandArguments args, final CommandContext context) { final Server server = ((ServerCommandContext) context).getServer(); final String line = args.getArgumentsAsString(); server.getParser().sendRawMessage(line); sendLine(origin, args.isSilent(), "rawCommand", line); }
/** * Instantiates a new invite label. * * @param mainFrame Parent window */ public InviteLabel(final MainFrame mainFrame) { super(new JLabel()); this.mainFrame = mainFrame; setBorder(BorderFactory.createEtchedBorder()); label.setIcon(IconManager.getIconManager().getIcon("invite")); inviteList = new MapList<Server, Invite>(); menu = new JPopupMenu(); dismiss = new JMenuItem("Dismiss all invites"); dismiss.addActionListener( new java.awt.event.ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(final ActionEvent e) { for (Server server : inviteList.keySet()) { final List<Invite> invites = new ArrayList<Invite>(inviteList.values(server)); for (Invite invite : invites) { invite.getServer().removeInvite(invite); } } } }); accept = new JMenuItem("Accept all invites"); accept.addActionListener( new java.awt.event.ActionListener() { /** {@inheritDoc} */ @Override public void actionPerformed(final ActionEvent e) { for (Server server : inviteList.keySet()) { final List<Invite> invites = new ArrayList<Invite>(inviteList.values(server)); for (Invite invite : invites) { invite.accept(); } } } }); for (Server server : ServerManager.getServerManager().getServers()) { inviteList.add(server, server.getInvites()); server.addInviteListener(this); } ActionManager.addListener(this, CoreActionType.CLIENT_FRAME_CHANGED); ActionManager.addListener(this, CoreActionType.SERVER_CONNECTED); ActionManager.addListener(this, CoreActionType.SERVER_DISCONNECTED); ActionManager.addListener(this, CoreActionType.SERVER_CONNECTERROR); update(); }
/** {@inheritDoc} */ @Override public void execute( final FrameContainer origin, final CommandArguments args, final CommandContext context) { final Server server = ((ServerCommandContext) context).getServer(); if (args.getArguments().length < 2) { showUsage(origin, args.isSilent(), "ctcp", "<target> <type> [arguments]"); } else { server .getParser() .sendCTCP(args.getArguments()[0], args.getArguments()[1], args.getArgumentsAsString(2)); sendLine( origin, args.isSilent(), "selfCTCP", args.getArguments()[0], args.getArgumentsAsString(1)); } }
/** Updates the invite label for the currently active server. */ private void update() { if (activeFrame == null) { activeServer = null; } else { activeServer = activeFrame.getServer(); } if (activeServer != null && !inviteList.containsKey(activeServer)) { inviteList.add(activeServer, activeServer.getInvites()); activeServer.addInviteListener(this); } if (activeServer == null || inviteList.get(activeServer).isEmpty()) { setVisible(false); closeDialog(); } else { refreshDialog(); setVisible(true); } }
/** Popuplates the menu. */ private void popuplateMenu() { menu.removeAll(); final List<Invite> invites = activeServer.getInvites(); for (Invite invite : invites) { menu.add(new JMenuItem(new InviteAction(invite))); } menu.add(new JSeparator()); menu.add(accept); menu.add(dismiss); }
/** {@inheritDoc} */ @Override public void execute( final FrameContainer origin, final CommandArguments args, final CommandContext context) { final Server server = ((ServerCommandContext) context).getServer(); if (args.getArguments().length < 2) { showUsage(origin, args.isSilent(), "msg", "<target> <message>"); } else { final String target = args.getArguments()[0]; final String message = args.getArgumentsAsString(1); sendLine(origin, args.isSilent(), "selfMessage", target, message); // If this is a known server or channel, and this is not a silent // invokation, use sendLine, else send it raw to the parser. if (!args.isSilent() && server.hasChannel(target)) { server.getChannel(target).sendLine(message); } else if (!args.isSilent() && server.hasQuery(target)) { server.getQuery(target).sendLine(message, target); } else { final Parser parser = server.getParser(); if (parser == null) { // This can happen if the server gets disconnected after // the command manager has checked the @CommandOptions // annotation. Yay for concurrency. sendLine( origin, args.isSilent(), FORMAT_ERROR, "You must be connected to use this command"); } else { parser.sendMessage(target, message); } } } }