Ejemplo n.º 1
0
 /** {@inheritDoc} */
 @Override
 public void inviteExpired(final Server server, final Invite invite) {
   if (!inviteList.containsKey(server)) {
     inviteList.add(server);
   }
   inviteList.remove(server, invite);
   update();
 }
Ejemplo n.º 2
0
  /** 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);
    }
  }
Ejemplo n.º 3
0
  /**
   * 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();
  }