示例#1
0
  /**
   * Handles the <tt>ActionEvent</tt> when one of the menu items is selected.
   *
   * @param e the <tt>ActionEvent</tt> that notified us
   */
  public void actionPerformed(ActionEvent e) {
    JMenuItem menuItem = (JMenuItem) e.getSource();
    String itemText = menuItem.getName();

    if (itemText.equalsIgnoreCase("myChatRooms")) {
      ChatRoomTableDialog.showChatRoomTableDialog();
    } else if (itemText.equals("history")) {
      HistoryWindow history;

      HistoryWindowManager historyWindowManager =
          GuiActivator.getUIService().getHistoryWindowManager();

      ChatPanel chatPanel = this.parentWindow.getCurrentChatPanel();
      ChatSession chatSession = chatPanel.getChatSession();

      if (historyWindowManager.containsHistoryWindowForContact(chatSession.getDescriptor())) {
        history = historyWindowManager.getHistoryWindowForContact(chatSession.getDescriptor());

        if (history.getState() == JFrame.ICONIFIED) history.setState(JFrame.NORMAL);

        history.toFront();
      } else {
        history = new HistoryWindow(chatPanel.getChatSession().getDescriptor());

        history.setVisible(true);

        historyWindowManager.addHistoryWindowForContact(chatSession.getDescriptor(), history);
      }
    } else if (itemText.equalsIgnoreCase("close")) {
      this.parentWindow.setVisible(false);
      this.parentWindow.dispose();
    }
  }
  /**
   * Overrides setSelectedIndex in SIPCommTabbedPane in order to remove the indicator of number of
   * unread messages previously set.
   *
   * @param tabIndex the index of the tab to be selected
   */
  public void setSelectedIndex(int tabIndex) {
    if (tabIndex < 0) return;

    Component c = this.getComponentAt(tabIndex);

    if (c instanceof ChatPanel) {
      ChatPanel chatPanel = (ChatPanel) c;

      int unreadMessageNumber = chatPanel.unreadMessageNumber;

      if (unreadMessageNumber > 0) {
        String tabTitle = chatPanel.getChatSession().getChatName();
        this.setTitleAt(tabIndex, tabTitle);
      }

      chatPanel.unreadMessageNumber = 0;
    }

    super.setSelectedIndex(tabIndex);
  }