src/net/java/sip/communicator/impl/gui/main/chat/ChatContactRightButtonMenu.java
/**
     * Initializes the menu, by adding all containing menu items.
     */
Initializes the menu, by adding all containing menu items.
Initializes the menu by adding all containing menu items .
private void init()
    {
        this.kickItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic("service.gui.KICK"));
        this.banItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic("service.gui.BAN"));
        this.grantAdminItem.setMnemonic(
           GuiActivator.getResources().getI18nMnemonic(
           "service.gui.GRANT_ADMIN"));
        this.grantMembershipItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic(
           "service.gui.GRANT_MEMBERSHIP"));
        this.grantModeratorItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic(
            "service.gui.GRANT_MODERATOR"));
        this.grantOwnershipItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic(
            "service.gui.GRANT_OWNERSHIP"));
        this.grantVoiceItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic(
            "service.gui.GRANT_VOICE"));
        this.revokeAdminItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic(
            "service.gui.REVOKE_ADMIN"));
        this.revokeMembershipItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic(
            "service.gui.REVOKE_MEMBERSHIP"));
        this.revokeModeratorItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic(
            "service.gui.REVOKE_MODERATOR"));
        this.revokeOwnershipItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic(
            "service.gui.REVOKE_OWNERSHIP"));
        this.revokeVoiceItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic(
            "service.gui.REVOKE_VOICE"));
        this.changeNicknameItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic(
            "service.gui.CHANGE_NICKNAME"));
        this.changeRoomSubjectItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic(
            "service.gui.CHANGE_ROOM_SUBJECT"));
        this.sendPrivateMessageItem.setMnemonic(
            GuiActivator.getResources().getI18nMnemonic(
            "service.gui.SEND_PRIVATE_MESSAGE"));
        this.kickItem.addActionListener(this);
        this.banItem.addActionListener(this);
        this.changeNicknameItem.addActionListener(this);
        this.changeRoomSubjectItem.addActionListener(this);
        this.grantAdminItem.addActionListener(this);
        this.grantMembershipItem.addActionListener(this);
        this.grantModeratorItem.addActionListener(this);
        this.grantOwnershipItem.addActionListener(this);
        this.grantVoiceItem.addActionListener(this);
        this.revokeAdminItem.addActionListener(this);
        this.revokeMembershipItem.addActionListener(this);
        this.revokeModeratorItem.addActionListener(this);
        this.revokeOwnershipItem.addActionListener(this);
        this.revokeVoiceItem.addActionListener(this);
        this.sendPrivateMessageItem.addActionListener(this);
        this.kickItem.setName("kickItem");
        this.banItem.setName("banItem");
        this.changeNicknameItem.setName("changeNicknameItem");
        this.changeRoomSubjectItem.setName("changeRoomSubjectItem");
        this.grantAdminItem.setName("grantAdminItem");
        this.grantMembershipItem.setName("grantMembershipItem");
        this.grantModeratorItem.setName("grantModeratorItem");
        this.grantOwnershipItem.setName("grantOwnershipItem");
        this.grantVoiceItem.setName("grantVoiceItem");
        this.revokeAdminItem.setName("revokeAdminItem");
        this.revokeMembershipItem.setName("revokeMembershipItem");
        this.revokeModeratorItem.setName("revokeModeratorItem");
        this.revokeOwnershipItem.setName("revokeOwnershipItem");
        this.revokeVoiceItem.setName("revokeVoiceItem");
        this.sendPrivateMessageItem.setName("sendPrivateMessageItem");
        loadSkin();
        ChatRoomMemberRole role
            = chatContact.getName().equals(room.getUserNickname())
                ? room.getUserRole()
                : ((ChatRoomMember) chatContact.getDescriptor()).getRole();
        int roleIndex = role.getRoleIndex();
        String roleName = role.getLocalizedRoleName();
        JLabel jl_username =
            new JLabel(" " + chatContact.getName() + " ("
                + GuiActivator.getResources().getI18NString(roleName) + ") ");
        jl_username.setFont(jl_username.getFont().deriveFont(Font.BOLD));
        this.add(jl_username);
        this.addSeparator();
        if(chatContact.getName().equals(room.getUserNickname()))
        {
            if(roleIndex >= 50)
            {
                this.add(this.changeRoomSubjectItem);
            }
            this.add(this.changeNicknameItem);
        }
        else
        {
            if(!ConfigurationUtils.isPrivateMessagingInChatRoomDisabled())
                this.add(this.sendPrivateMessageItem);
            if(room.getUserRole().getRoleIndex() >= 50)
            {
                if(roleIndex <= 40)
                {
                    this.add(this.kickItem);
                    if(room.getUserRole().getRoleIndex() >= 60 && roleIndex < 50)
                    {
                        this.add(this.banItem);
                    }
                    this.addSeparator();
                }
                if(roleIndex <= 20)
                    this.add(this.grantVoiceItem);
                else if(roleIndex == 40 || roleIndex == 30)
                    this.add(this.revokeVoiceItem);
            }
            if(room.getUserRole().getRoleIndex() >= 60)
            {
                if(roleIndex < 40)
                    this.add(this.grantMembershipItem);
                if(roleIndex < 50)    
                    this.add(this.grantModeratorItem);
                else if(roleIndex == 50)
                    this.add(this.revokeModeratorItem);
            }
                 room owners can edit owners list
                if(roleIndex != 70 && roleIndex >= 40)
                    this.add(this.grantOwnershipItem);
                else if(roleIndex == 70)
                    this.add(this.revokeOwnershipItem);
            }
        }
    }
private void init ( ) { this . kickItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.KICK" ) ) ; this . banItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.BAN" ) ) ; this . grantAdminItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.GRANT_ADMIN" ) ) ; this . grantMembershipItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.GRANT_MEMBERSHIP" ) ) ; this . grantModeratorItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.GRANT_MODERATOR" ) ) ; this . grantOwnershipItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.GRANT_OWNERSHIP" ) ) ; this . grantVoiceItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.GRANT_VOICE" ) ) ; this . revokeAdminItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.REVOKE_ADMIN" ) ) ; this . revokeMembershipItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.REVOKE_MEMBERSHIP" ) ) ; this . revokeModeratorItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.REVOKE_MODERATOR" ) ) ; this . revokeOwnershipItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.REVOKE_OWNERSHIP" ) ) ; this . revokeVoiceItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.REVOKE_VOICE" ) ) ; this . changeNicknameItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.CHANGE_NICKNAME" ) ) ; this . changeRoomSubjectItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.CHANGE_ROOM_SUBJECT" ) ) ; this . sendPrivateMessageItem . setMnemonic ( GuiActivator . getResources ( ) . getI18nMnemonic ( "service.gui.SEND_PRIVATE_MESSAGE" ) ) ; this . kickItem . addActionListener ( this ) ; this . banItem . addActionListener ( this ) ; this . changeNicknameItem . addActionListener ( this ) ; this . changeRoomSubjectItem . addActionListener ( this ) ; this . grantAdminItem . addActionListener ( this ) ; this . grantMembershipItem . addActionListener ( this ) ; this . grantModeratorItem . addActionListener ( this ) ; this . grantOwnershipItem . addActionListener ( this ) ; this . grantVoiceItem . addActionListener ( this ) ; this . revokeAdminItem . addActionListener ( this ) ; this . revokeMembershipItem . addActionListener ( this ) ; this . revokeModeratorItem . addActionListener ( this ) ; this . revokeOwnershipItem . addActionListener ( this ) ; this . revokeVoiceItem . addActionListener ( this ) ; this . sendPrivateMessageItem . addActionListener ( this ) ; this . kickItem . setName ( "kickItem" ) ; this . banItem . setName ( "banItem" ) ; this . changeNicknameItem . setName ( "changeNicknameItem" ) ; this . changeRoomSubjectItem . setName ( "changeRoomSubjectItem" ) ; this . grantAdminItem . setName ( "grantAdminItem" ) ; this . grantMembershipItem . setName ( "grantMembershipItem" ) ; this . grantModeratorItem . setName ( "grantModeratorItem" ) ; this . grantOwnershipItem . setName ( "grantOwnershipItem" ) ; this . grantVoiceItem . setName ( "grantVoiceItem" ) ; this . revokeAdminItem . setName ( "revokeAdminItem" ) ; this . revokeMembershipItem . setName ( "revokeMembershipItem" ) ; this . revokeModeratorItem . setName ( "revokeModeratorItem" ) ; this . revokeOwnershipItem . setName ( "revokeOwnershipItem" ) ; this . revokeVoiceItem . setName ( "revokeVoiceItem" ) ; this . sendPrivateMessageItem . setName ( "sendPrivateMessageItem" ) ; loadSkin ( ) ; ChatRoomMemberRole role = chatContact . getName ( ) . equals ( room . getUserNickname ( ) ) ? room . getUserRole ( ) : ( ( ChatRoomMember ) chatContact . getDescriptor ( ) ) . getRole ( ) ; int roleIndex = role . getRoleIndex ( ) ; String roleName = role . getLocalizedRoleName ( ) ; JLabel jl_username = new JLabel ( " " + chatContact . getName ( ) + " (" + GuiActivator . getResources ( ) . getI18NString ( roleName ) + ") " ) ; jl_username . setFont ( jl_username . getFont ( ) . deriveFont ( Font . BOLD ) ) ; this . add ( jl_username ) ; this . addSeparator ( ) ; if ( chatContact . getName ( ) . equals ( room . getUserNickname ( ) ) ) { if ( roleIndex >= 50 ) { this . add ( this . changeRoomSubjectItem ) ; } this . add ( this . changeNicknameItem ) ; } else { if ( ! ConfigurationUtils . isPrivateMessagingInChatRoomDisabled ( ) ) this . add ( this . sendPrivateMessageItem ) ; if ( room . getUserRole ( ) . getRoleIndex ( ) >= 50 ) { if ( roleIndex <= 40 ) { this . add ( this . kickItem ) ; if ( room . getUserRole ( ) . getRoleIndex ( ) >= 60 && roleIndex < 50 ) { this . add ( this . banItem ) ; } this . addSeparator ( ) ; } if ( roleIndex <= 20 ) this . add ( this . grantVoiceItem ) ; else if ( roleIndex == 40 || roleIndex == 30 ) this . add ( this . revokeVoiceItem ) ; } if ( room . getUserRole ( ) . getRoleIndex ( ) >= 60 ) { if ( roleIndex < 40 ) this . add ( this . grantMembershipItem ) ; if ( roleIndex < 50 ) this . add ( this . grantModeratorItem ) ; else if ( roleIndex == 50 ) this . add ( this . revokeModeratorItem ) ; } } }
Initializes the menu, by adding all containing menu items.
Initializes the menu by adding all containing menu items .
// Here we build the menu when the local user cell renderer is clicked: // It means we are at least a moderator, so we can change room's // subject: // Admins and owners can ban members: // we must at least be a moderator for managing voice rights // we must at least be an admin to manage membership //                else if(roleIndex == 40) //                    this.add(this.revokeMembershipItem); // room admins can edit moderators list // only room owners can edit admins list //            if(room.getUserRole().getRoleIndex() == 70) //            { //                if(roleIndex != 60 && roleIndex >= 30) //                // room owners can grant members or unaffiliated users as admins //                    this.add(this.grantAdminItem); //                else if(roleIndex == 60) //                    this.add(this.revokeAdminItem); // //                // room owners can edit owners list //                if(roleIndex != 70 && roleIndex >= 40) //                    this.add(this.grantOwnershipItem); //                else if(roleIndex == 70) //                    this.add(this.revokeOwnershipItem); //            }