src/net/java/sip/communicator/impl/gui/main/chat/ChatContactRightButtonMenu.java
/**
     * Handles the <tt>ActionEvent</tt>. Determines which menu item was
     * selected and makes the appropriate operations.
     *
     * @param e the <tt>ActionEvent</tt> that notified us
     */


@param e the ActionEvent that notified us
@param e the ActionEvent that notified us
public void actionPerformed(ActionEvent e)
    {
        String menuItemName = ((JMenuItem) e.getSource()).getName();
        if (menuItemName.equals("kickItem"))
        {
            ChatOperationReasonDialog reasonDialog
                = new ChatOperationReasonDialog();
            int result = reasonDialog.showDialog();
            if (result == MessageDialog.OK_RETURN_CODE)
                new KickParticipantThread(  room,
                                            reasonDialog.getReason()).start();
        }
        else if (menuItemName.equals("banItem"))
        {
            ChatOperationReasonDialog reasonDialog
                = new ChatOperationReasonDialog();
            int result = reasonDialog.showDialog();
            if (result == MessageDialog.OK_RETURN_CODE)
                new BanParticipantThread(   room,
                                            reasonDialog.getReason()).start();
        }
        else if (menuItemName.equals("changeRoomSubjectItem"))
        {
            ChatOperationReasonDialog reasonDialog
                = new ChatOperationReasonDialog(
                    chatPanel.getChatContainer().getFrame(),
                    GuiActivator.getResources().getI18NString(
                    "service.gui.CHANGE_ROOM_SUBJECT"),
                    GuiActivator.getResources().getI18NString(
                    "service.gui.CHANGE_ROOM_SUBJECT_LABEL"),
                    "Ok",
                    false);
            reasonDialog.setReasonFieldText(room.getSubject());
            int result = reasonDialog.showDialog();
            if (result == MessageDialog.OK_RETURN_CODE)
            {
                try
                {
                    room.setSubject(reasonDialog.getReason().trim());
                }
                catch (OperationFailedException ex)
                {
                    ex.printStackTrace();
                }
            }
        }
        else if (menuItemName.equals("changeNicknameItem"))
        {
            ChatOperationReasonDialog reasonDialog
                = new ChatOperationReasonDialog(
                    chatPanel.getChatContainer().getFrame(),
                    GuiActivator.getResources().getI18NString(
                    "service.gui.CHANGE_NICKNAME"),
                    GuiActivator.getResources().getI18NString(
                    "service.gui.CHANGE_NICKNAME_LABEL"),
                    "Ok",
                    false, true);
            reasonDialog.setIconImage(ImageLoader.getImage(
              ImageLoader.CHANGE_NICKNAME_ICON));
            reasonDialog.setReasonFieldText(chatContact.getName());
            int result = reasonDialog.showDialog();
            if (result == MessageDialog.OK_RETURN_CODE)
            {
                String nickname = reasonDialog.getReason().trim();
                try
                {
                    room.setUserNickname(nickname);
                    ConfigurationUtils.updateChatRoomProperty(
                        room.getParentProvider(),
                        room.getIdentifier(),
                        "userNickName", nickname);
                }
                catch (OperationFailedException ex)
                {
                    String errorMessage = null;
                    if(ex.getErrorCode()
                        == OperationFailedException.IDENTIFICATION_CONFLICT)
                    {
                        errorMessage = GuiActivator.getResources()
                            .getI18NString(
                                "service.gui.CHANGE_NICKNAME_CONFLICT_ERROR");
                    }
                    else
                    {
                        errorMessage = ex.getLocalizedMessage();
                    }
                    chatPanel.addErrorMessage(
                        nickname,
                        GuiActivator.getResources().getI18NString(
                            "service.gui.CHANGE_NICKNAME_ERROR"),
                        errorMessage);
               }
           }
        }
        else if (menuItemName.equals("grantVoiceItem"))
        {
            room.grantVoice(chatContact.getName());
            ((ChatRoomMember)chatContact.getDescriptor()).setRole(
                ChatRoomMemberRole.MEMBER);
        }
        else if (menuItemName.equals("grantMembershipItem"))
        {
            room.grantMembership(((ChatRoomMember)
                chatContact.getDescriptor()).getContactAddress());
            ((ChatRoomMember)chatContact.getDescriptor()).setRole(
                ChatRoomMemberRole.MEMBER);
        }
        else if(menuItemName.equals("grantModeratorItem"))
        {
            room.grantModerator(chatContact.getName());
            ((ChatRoomMember)chatContact.getDescriptor()).setRole(
                ChatRoomMemberRole.MODERATOR);
        }
        else if(menuItemName.equals("grantAdminItem"))
        {
            room.grantAdmin(((ChatRoomMember) chatContact
                    .getDescriptor()).getContactAddress());
            ((ChatRoomMember)chatContact.getDescriptor()).setRole(
                               ChatRoomMemberRole.ADMINISTRATOR);
        }
        else if(menuItemName.equals("grantOwnershipItem"))
        {
            room.grantOwnership(((ChatRoomMember)
                chatContact.getDescriptor()).getContactAddress());
            ((ChatRoomMember)chatContact.getDescriptor()).setRole(
                ChatRoomMemberRole.OWNER);
        }
        else if(menuItemName.equals("revokeOwnershipItem"))
        {
            room.revokeOwnership(((ChatRoomMember)
                chatContact.getDescriptor()).getContactAddress());
            ((ChatRoomMember)chatContact.getDescriptor()).setRole(
                ChatRoomMemberRole.ADMINISTRATOR);
        }
        else if(menuItemName.equals("revokeAdminItem"))
        {
            room.revokeAdmin(((ChatRoomMember)
                chatContact.getDescriptor()).getContactAddress());
            ((ChatRoomMember)chatContact.getDescriptor()).setRole(
                ChatRoomMemberRole.MEMBER);
        }
        else if(menuItemName.equals("revokeModeratorItem"))
        {
            room.revokeModerator(chatContact.getName());
            ((ChatRoomMember)chatContact.getDescriptor()).setRole(
                ChatRoomMemberRole.MEMBER);
        }
        else if(menuItemName.equals("revokeMembershipItem"))
        {
            room.revokeMembership(((ChatRoomMember)
                chatContact.getDescriptor()).getContactAddress());
            ((ChatRoomMember)chatContact.getDescriptor()).setRole(
                ChatRoomMemberRole.GUEST);
        }
        else if(menuItemName.equals("revokeVoiceItem"))
        {
            room.revokeVoice(chatContact.getName());
            ((ChatRoomMember)chatContact.getDescriptor()).setRole(
                ChatRoomMemberRole.SILENT_MEMBER);
        }
        else if(menuItemName.equals("sendPrivateMessageItem"))
        {
            ChatWindowManager chatWindowManager
                = GuiActivator.getUIService()
                    .getChatWindowManager();
            chatWindowManager.openPrivateChatForChatRoomMember(room, 
                chatContact.getName());
        }
    }
public void actionPerformed ( ActionEvent e ) { String menuItemName = ( ( JMenuItem ) e . getSource ( ) ) . getName ( ) ; if ( menuItemName . equals ( "kickItem" ) ) { ChatOperationReasonDialog reasonDialog = new ChatOperationReasonDialog ( ) ; int result = reasonDialog . showDialog ( ) ; if ( result == MessageDialog . OK_RETURN_CODE ) new KickParticipantThread ( room , reasonDialog . getReason ( ) ) . start ( ) ; } else if ( menuItemName . equals ( "banItem" ) ) { ChatOperationReasonDialog reasonDialog = new ChatOperationReasonDialog ( ) ; int result = reasonDialog . showDialog ( ) ; if ( result == MessageDialog . OK_RETURN_CODE ) new BanParticipantThread ( room , reasonDialog . getReason ( ) ) . start ( ) ; } else if ( menuItemName . equals ( "changeRoomSubjectItem" ) ) { ChatOperationReasonDialog reasonDialog = new ChatOperationReasonDialog ( chatPanel . getChatContainer ( ) . getFrame ( ) , GuiActivator . getResources ( ) . getI18NString ( "service.gui.CHANGE_ROOM_SUBJECT" ) , GuiActivator . getResources ( ) . getI18NString ( "service.gui.CHANGE_ROOM_SUBJECT_LABEL" ) , "Ok" , false ) ; reasonDialog . setReasonFieldText ( room . getSubject ( ) ) ; int result = reasonDialog . showDialog ( ) ; if ( result == MessageDialog . OK_RETURN_CODE ) { try { room . setSubject ( reasonDialog . getReason ( ) . trim ( ) ) ; } catch ( OperationFailedException ex ) { ex . printStackTrace ( ) ; } } } else if ( menuItemName . equals ( "changeNicknameItem" ) ) { ChatOperationReasonDialog reasonDialog = new ChatOperationReasonDialog ( chatPanel . getChatContainer ( ) . getFrame ( ) , GuiActivator . getResources ( ) . getI18NString ( "service.gui.CHANGE_NICKNAME" ) , GuiActivator . getResources ( ) . getI18NString ( "service.gui.CHANGE_NICKNAME_LABEL" ) , "Ok" , false , true ) ; reasonDialog . setIconImage ( ImageLoader . getImage ( ImageLoader . CHANGE_NICKNAME_ICON ) ) ; reasonDialog . setReasonFieldText ( chatContact . getName ( ) ) ; int result = reasonDialog . showDialog ( ) ; if ( result == MessageDialog . OK_RETURN_CODE ) { String nickname = reasonDialog . getReason ( ) . trim ( ) ; try { room . setUserNickname ( nickname ) ; ConfigurationUtils . updateChatRoomProperty ( room . getParentProvider ( ) , room . getIdentifier ( ) , "userNickName" , nickname ) ; } catch ( OperationFailedException ex ) { String errorMessage = null ; if ( ex . getErrorCode ( ) == OperationFailedException . IDENTIFICATION_CONFLICT ) { errorMessage = GuiActivator . getResources ( ) . getI18NString ( "service.gui.CHANGE_NICKNAME_CONFLICT_ERROR" ) ; } else { errorMessage = ex . getLocalizedMessage ( ) ; } chatPanel . addErrorMessage ( nickname , GuiActivator . getResources ( ) . getI18NString ( "service.gui.CHANGE_NICKNAME_ERROR" ) , errorMessage ) ; } } } else if ( menuItemName . equals ( "grantVoiceItem" ) ) { room . grantVoice ( chatContact . getName ( ) ) ; ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . setRole ( ChatRoomMemberRole . MEMBER ) ; } else if ( menuItemName . equals ( "grantMembershipItem" ) ) { room . grantMembership ( ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . getContactAddress ( ) ) ; ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . setRole ( ChatRoomMemberRole . MEMBER ) ; } else if ( menuItemName . equals ( "grantModeratorItem" ) ) { room . grantModerator ( chatContact . getName ( ) ) ; ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . setRole ( ChatRoomMemberRole . MODERATOR ) ; } else if ( menuItemName . equals ( "grantAdminItem" ) ) { room . grantAdmin ( ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . getContactAddress ( ) ) ; ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . setRole ( ChatRoomMemberRole . ADMINISTRATOR ) ; } else if ( menuItemName . equals ( "grantOwnershipItem" ) ) { room . grantOwnership ( ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . getContactAddress ( ) ) ; ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . setRole ( ChatRoomMemberRole . OWNER ) ; } else if ( menuItemName . equals ( "revokeOwnershipItem" ) ) { room . revokeOwnership ( ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . getContactAddress ( ) ) ; ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . setRole ( ChatRoomMemberRole . ADMINISTRATOR ) ; } else if ( menuItemName . equals ( "revokeAdminItem" ) ) { room . revokeAdmin ( ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . getContactAddress ( ) ) ; ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . setRole ( ChatRoomMemberRole . MEMBER ) ; } else if ( menuItemName . equals ( "revokeModeratorItem" ) ) { room . revokeModerator ( chatContact . getName ( ) ) ; ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . setRole ( ChatRoomMemberRole . MEMBER ) ; } else if ( menuItemName . equals ( "revokeMembershipItem" ) ) { room . revokeMembership ( ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . getContactAddress ( ) ) ; ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . setRole ( ChatRoomMemberRole . GUEST ) ; } else if ( menuItemName . equals ( "revokeVoiceItem" ) ) { room . revokeVoice ( chatContact . getName ( ) ) ; ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . setRole ( ChatRoomMemberRole . SILENT_MEMBER ) ; } else if ( menuItemName . equals ( "sendPrivateMessageItem" ) ) { ChatWindowManager chatWindowManager = GuiActivator . getUIService ( ) . getChatWindowManager ( ) ; chatWindowManager . openPrivateChatForChatRoomMember ( room , chatContact . getName ( ) ) ; } }
Handles the <tt>ActionEvent</tt>.
Handles the <tt > ActionEvent< / tt > .
//reasonDialog.setIconImage( //ImageLoader.getImage(ImageLoader.CHANGE_ROOM_SUBJECT_ICON_16x16));