/**
   * Handles the <tt>ActionEvent</tt>. Determines which menu item was selected and makes the
   * appropriate operations.
   *
   * @param e the event.
   */
  public void actionPerformed(ActionEvent e) {
    JMenuItem menuItem = (JMenuItem) e.getSource();
    String itemName = menuItem.getName();

    ConferenceChatManager conferenceManager =
        GuiActivator.getUIService().getConferenceChatManager();

    if (itemName.equals("removeChatRoom")) {
      conferenceManager.removeChatRoom(chatRoomWrapper);
    } else if (itemName.equals("leaveChatRoom")) {
      conferenceManager.leaveChatRoom(chatRoomWrapper);
    } else if (itemName.equals("joinChatRoom")) {
      conferenceManager.joinChatRoom(chatRoomWrapper);
    } else if (itemName.equals("openChatRoom")) {
      if (chatRoomWrapper.getChatRoom() != null) {
        if (!chatRoomWrapper.getChatRoom().isJoined()) {
          conferenceManager.joinChatRoom(chatRoomWrapper);
        }
      } else {
        // this is not a server persistent room we must create it
        // and join
        chatRoomWrapper =
            GuiActivator.getUIService()
                .getConferenceChatManager()
                .createChatRoom(
                    chatRoomWrapper.getChatRoomName(),
                    chatRoomWrapper.getParentProvider().getProtocolProvider(),
                    new ArrayList<String>(),
                    "",
                    true,
                    true);
      }

      ChatWindowManager chatWindowManager = GuiActivator.getUIService().getChatWindowManager();
      ChatPanel chatPanel = chatWindowManager.getMultiChat(chatRoomWrapper, true);

      chatWindowManager.openChat(chatPanel, true);
    } else if (itemName.equals("joinAsChatRoom")) {
      ChatRoomAuthenticationWindow authWindow = new ChatRoomAuthenticationWindow(chatRoomWrapper);

      authWindow.setVisible(true);
    }
  }
Ejemplo n.º 2
0
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      ChatRoomWrapper chatRoom = (ChatRoomWrapper) value;

      this.setText(chatRoom.getChatRoomName());

      Image chatRoomImage = ImageLoader.getImage(ImageLoader.CHAT_ROOM_16x16_ICON);

      if (chatRoom.getChatRoom() == null || !chatRoom.getChatRoom().isJoined()) {
        chatRoomImage = LightGrayFilter.createDisabledImage(chatRoomImage);
      }

      this.setIcon(new ImageIcon(chatRoomImage));

      this.setFont(this.getFont().deriveFont(Font.PLAIN));

      if (isSelected) this.setBackground(table.getSelectionBackground());
      else this.setBackground(UIManager.getColor("Table.background"));

      return this;
    }
Ejemplo n.º 3
0
  /** Opens the currently selected chat. */
  void openChatForSelection() {
    Object selectedValue = this.chatRoomsTableModel.getValueAt(this.chatRoomList.getSelectedRow());

    ChatRoomWrapper chatRoomWrapper;
    if (selectedValue instanceof ChatRoomWrapper) chatRoomWrapper = (ChatRoomWrapper) selectedValue;
    else return;

    if (!chatRoomWrapper.getChatRoom().isJoined()) {
      GuiActivator.getUIService().getConferenceChatManager().joinChatRoom(chatRoomWrapper);
    }

    ChatWindowManager chatWindowManager = GuiActivator.getUIService().getChatWindowManager();
    ChatPanel chatPanel = chatWindowManager.getMultiChat(chatRoomWrapper, true);

    chatWindowManager.openChat(chatPanel, true);
  }
  /**
   * Creates an instance of <tt>ChatRoomsListRightButtonMenu</tt>.
   *
   * @param chatRoomWrapper the chat room wrapper, corresponding to the selected chat room
   */
  public ChatRoomRightButtonMenu(ChatRoomWrapper chatRoomWrapper) {
    this.chatRoomWrapper = chatRoomWrapper;

    this.setLocation(getLocation());

    createMenuItem("service.gui.OPEN", ImageLoader.CHAT_ROOM_16x16_ICON, "openChatRoom");
    JMenuItem joinChatRoomItem =
        createMenuItem("service.gui.JOIN", ImageLoader.JOIN_ICON, "joinChatRoom");
    JMenuItem joinAsChatRoomItem =
        createMenuItem("service.gui.JOIN_AS", ImageLoader.JOIN_AS_ICON, "joinAsChatRoom");
    JMenuItem leaveChatRoomItem =
        createMenuItem("service.gui.LEAVE", ImageLoader.LEAVE_ICON, "leaveChatRoom");
    createMenuItem("service.gui.REMOVE", ImageLoader.DELETE_16x16_ICON, "removeChatRoom");

    ChatRoom chatRoom = chatRoomWrapper.getChatRoom();

    if ((chatRoom != null) && chatRoom.isJoined()) {
      joinAsChatRoomItem.setEnabled(false);
      joinChatRoomItem.setEnabled(false);
    } else leaveChatRoomItem.setEnabled(false);
  }
Ejemplo n.º 5
0
  /**
   * Handles the <tt>ActionEvent</tt>. Determines which menu item was selected and makes the
   * appropriate operations.
   *
   * @param e the event.
   */
  public void actionPerformed(ActionEvent e) {
    JMenuItem menuItem = (JMenuItem) e.getSource();
    String itemName = menuItem.getName();

    ConferenceChatManager conferenceManager =
        GuiActivator.getUIService().getConferenceChatManager();

    if (itemName.equals("removeChatRoom")) {
      conferenceManager.removeChatRoom(chatRoomWrapper);
    } else if (itemName.equals("leaveChatRoom")) {
      conferenceManager.leaveChatRoom(chatRoomWrapper);
    } else if (itemName.equals("joinChatRoom")) {
      String nickName = null;

      nickName =
          ConfigurationManager.getChatRoomProperty(
              chatRoomWrapper.getParentProvider().getProtocolProvider(),
              chatRoomWrapper.getChatRoomID(),
              "userNickName");
      if (nickName == null) nickName = getNickname();

      if (nickName != null) conferenceManager.joinChatRoom(chatRoomWrapper, nickName, null);
      else conferenceManager.joinChatRoom(chatRoomWrapper);
    } else if (itemName.equals("openChatRoom")) {
      if (chatRoomWrapper.getChatRoom() != null) {
        if (!chatRoomWrapper.getChatRoom().isJoined()) {
          String nickName = null;

          nickName =
              ConfigurationManager.getChatRoomProperty(
                  chatRoomWrapper.getParentProvider().getProtocolProvider(),
                  chatRoomWrapper.getChatRoomID(),
                  "userNickName");
          if (nickName == null) nickName = getNickname();

          if (nickName != null) conferenceManager.joinChatRoom(chatRoomWrapper, nickName, null);
          else conferenceManager.joinChatRoom(chatRoomWrapper);
        }
      } else {
        // this is not a server persistent room we must create it
        // and join
        chatRoomWrapper =
            GuiActivator.getUIService()
                .getConferenceChatManager()
                .createChatRoom(
                    chatRoomWrapper.getChatRoomName(),
                    chatRoomWrapper.getParentProvider().getProtocolProvider(),
                    new ArrayList<String>(),
                    "",
                    false,
                    true);

        String nickName = null;

        nickName =
            ConfigurationManager.getChatRoomProperty(
                chatRoomWrapper.getParentProvider().getProtocolProvider(),
                chatRoomWrapper.getChatRoomID(),
                "userNickName");

        if (nickName == null) nickName = getNickname();

        if (nickName != null) conferenceManager.joinChatRoom(chatRoomWrapper, nickName, null);
        else conferenceManager.joinChatRoom(chatRoomWrapper);
      }

      ChatWindowManager chatWindowManager = GuiActivator.getUIService().getChatWindowManager();
      ChatPanel chatPanel = chatWindowManager.getMultiChat(chatRoomWrapper, true);

      chatWindowManager.openChat(chatPanel, true);
    } else if (itemName.equals("joinAsChatRoom")) {
      ChatRoomAuthenticationWindow authWindow = new ChatRoomAuthenticationWindow(chatRoomWrapper);

      authWindow.setVisible(true);
    } else if (itemName.equals("nickNameChatRoom")) {
      String nickName = null;

      nickName =
          ConfigurationManager.getChatRoomProperty(
              chatRoomWrapper.getParentProvider().getProtocolProvider(),
              chatRoomWrapper.getChatRoomID(),
              "userNickName");

      ChatOperationReasonDialog reasonDialog =
          new ChatOperationReasonDialog(
              GuiActivator.getResources().getI18NString("service.gui.CHANGE_NICKNAME"),
              GuiActivator.getResources().getI18NString("service.gui.CHANGE_NICKNAME_LABEL"));

      reasonDialog.setReasonFieldText(
          nickName == null
              ? chatRoomWrapper.getParentProvider().getProtocolProvider().getAccountID().getUserID()
              : nickName);

      int result = reasonDialog.showDialog();

      if (result == MessageDialog.OK_RETURN_CODE) {
        nickName = reasonDialog.getReason().trim();
      }

      ConfigurationManager.updateChatRoomProperty(
          chatRoomWrapper.getParentProvider().getProtocolProvider(),
          chatRoomWrapper.getChatRoomID(),
          "userNickName",
          nickName);
    }
  }