mirror of https://github.com/sipwise/jitsi.git
with the dialog for chat room password.cusax-fix
parent
eb2079f63a
commit
275cbb770c
@ -0,0 +1,503 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.muc;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jitsi.service.resources.*;
|
||||
|
||||
import net.java.sip.communicator.plugin.desktoputil.chat.*;
|
||||
import net.java.sip.communicator.service.contactsource.*;
|
||||
import net.java.sip.communicator.service.customcontactactions.*;
|
||||
import net.java.sip.communicator.service.muc.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* Implements <tt>CustomContactActionsService</tt> for MUC contact source.
|
||||
*
|
||||
* @author Hristo Terezov
|
||||
*/
|
||||
public class MUCCustomContactActionService
|
||||
implements CustomContactActionsService<SourceContact>
|
||||
{
|
||||
/**
|
||||
* List of custom menu items.
|
||||
*/
|
||||
private final List<ContactActionMenuItem<SourceContact>> MUCActionMenuItems
|
||||
= new LinkedList<ContactActionMenuItem<SourceContact>>();
|
||||
|
||||
/**
|
||||
* Array of labels for the custom menu items.
|
||||
*/
|
||||
private String[] actionsLabels = {
|
||||
"service.gui.OPEN", "service.gui.JOIN",
|
||||
"service.gui.JOIN_AS", "service.gui.LEAVE",
|
||||
"service.gui.REMOVE", "service.gui.CHANGE_NICK",
|
||||
"service.gui.JOIN_AUTOMATICALLY"
|
||||
};
|
||||
|
||||
/**
|
||||
* Array of icons for the custom menu items.
|
||||
*/
|
||||
private String[] actionsIcons = {
|
||||
"service.gui.icons.CHAT_ROOM_16x16_ICON", "service.gui.icons.JOIN_ICON",
|
||||
"service.gui.icons.JOIN_AS_ICON", "service.gui.icons.LEAVE_ICON",
|
||||
"service.gui.icons.REMOVE_CHAT_ICON",
|
||||
"service.gui.icons.RENAME_16x16_ICON",
|
||||
null
|
||||
};
|
||||
|
||||
/**
|
||||
* Array of <tt>MUCCustomActionRunnable</tt> objects for the custom menu
|
||||
* items. They will be executed when the item is pressed.
|
||||
*/
|
||||
private MUCCustomActionRunnable[] actionsRunnable = {
|
||||
new MUCCustomActionRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
String[] joinOptions;
|
||||
String subject = null;
|
||||
if(chatRoomWrapper.getChatRoom() == null)
|
||||
{
|
||||
// this is not a server persistent room we must create it
|
||||
// and join
|
||||
chatRoomWrapper =
|
||||
MUCActivator.getMUCService().createChatRoom(
|
||||
chatRoomWrapper.getChatRoomName(),
|
||||
chatRoomWrapper.getParentProvider()
|
||||
.getProtocolProvider(),
|
||||
new ArrayList<String>(),
|
||||
"",
|
||||
false,
|
||||
false,
|
||||
true);
|
||||
}
|
||||
|
||||
if(!chatRoomWrapper.getChatRoom().isJoined())
|
||||
{
|
||||
String nickName = null;
|
||||
|
||||
nickName =
|
||||
ConfigurationUtils.getChatRoomProperty(
|
||||
chatRoomWrapper.getParentProvider()
|
||||
.getProtocolProvider(), chatRoomWrapper
|
||||
.getChatRoomID(), "userNickName");
|
||||
if(nickName == null)
|
||||
{
|
||||
joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions(
|
||||
chatRoomWrapper.getParentProvider()
|
||||
.getProtocolProvider(),
|
||||
chatRoomWrapper.getChatRoomID());
|
||||
nickName = joinOptions[0];
|
||||
subject = joinOptions[1];
|
||||
}
|
||||
|
||||
if (nickName != null)
|
||||
MUCActivator.getMUCService().joinChatRoom(chatRoomWrapper,
|
||||
nickName, null, subject);
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
MUCActivator.getUIService().openChatRoomWindow(chatRoomWrapper);
|
||||
}
|
||||
},
|
||||
new MUCCustomActionRunnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
String[] joinOptions;
|
||||
String subject = null;
|
||||
String nickName = null;
|
||||
|
||||
nickName =
|
||||
ConfigurationUtils.getChatRoomProperty(
|
||||
chatRoomWrapper.getParentProvider()
|
||||
.getProtocolProvider(), chatRoomWrapper
|
||||
.getChatRoomID(), "userNickName");
|
||||
if(nickName == null)
|
||||
{
|
||||
joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions(
|
||||
chatRoomWrapper.getParentProvider()
|
||||
.getProtocolProvider(),
|
||||
chatRoomWrapper.getChatRoomID());
|
||||
nickName = joinOptions[0];
|
||||
subject = joinOptions[1];
|
||||
}
|
||||
|
||||
if (nickName != null)
|
||||
MUCActivator.getMUCService().joinChatRoom(chatRoomWrapper,
|
||||
nickName, null, subject);
|
||||
}
|
||||
},
|
||||
new MUCCustomActionRunnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
String[] joinOptions;
|
||||
joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions(
|
||||
chatRoomWrapper.getParentProvider().getProtocolProvider(),
|
||||
chatRoomWrapper.getChatRoomID());
|
||||
if(joinOptions[0] == null)
|
||||
return;
|
||||
MUCActivator.getMUCService()
|
||||
.joinChatRoom(chatRoomWrapper, joinOptions[0], null,
|
||||
joinOptions[1]);
|
||||
}
|
||||
},
|
||||
new MUCCustomActionRunnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
ChatRoomWrapper leavedRoomWrapped
|
||||
= MUCActivator.getMUCService().leaveChatRoom(
|
||||
chatRoomWrapper);
|
||||
if(leavedRoomWrapped != null)
|
||||
MUCActivator.getUIService().closeChatRoomWindow(
|
||||
leavedRoomWrapped);
|
||||
}
|
||||
},
|
||||
new MUCCustomActionRunnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
ChatRoom chatRoom = chatRoomWrapper.getChatRoom();
|
||||
|
||||
if (chatRoom != null)
|
||||
{
|
||||
ChatRoomWrapper leavedRoomWrapped
|
||||
= MUCActivator.getMUCService().leaveChatRoom(
|
||||
chatRoomWrapper);
|
||||
if(leavedRoomWrapped != null)
|
||||
MUCActivator.getUIService().closeChatRoomWindow(
|
||||
leavedRoomWrapped);
|
||||
}
|
||||
|
||||
MUCActivator.getUIService().closeChatRoomWindow(chatRoomWrapper);
|
||||
|
||||
MUCActivator.getMUCService().removeChatRoom(chatRoomWrapper);
|
||||
}
|
||||
},
|
||||
new MUCCustomActionRunnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
ChatRoomJoinOptionsDialog.getJoinOptions(true,
|
||||
chatRoomWrapper.getParentProvider().getProtocolProvider(),
|
||||
chatRoomWrapper.getChatRoomID());
|
||||
}
|
||||
},
|
||||
new MUCCustomActionRunnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
chatRoomWrapper.setAutoJoin(!chatRoomWrapper.isAutojoin());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Array of <tt>EnableChecker</tt> objects for the custom menu items. They
|
||||
* are used to check if the item is enabled or disabled.
|
||||
*/
|
||||
private EnableChecker[] actionsEnabledCheckers = {
|
||||
null,
|
||||
new JoinEnableChecker(),
|
||||
new JoinEnableChecker(),
|
||||
new LeaveEnableChecker(),
|
||||
null,
|
||||
null,
|
||||
null
|
||||
};
|
||||
|
||||
/**
|
||||
* Array for the custom menu items that describes the type of the menu item.
|
||||
* If <tt>true</tt> - the item is check box.
|
||||
*/
|
||||
private boolean[] actionsIsCheckBox = {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
};
|
||||
|
||||
/**
|
||||
* The resource management service instance.
|
||||
*/
|
||||
ResourceManagementService resources = MUCActivator.getResources();
|
||||
|
||||
/**
|
||||
* Constructs the custom actions.
|
||||
*/
|
||||
public MUCCustomContactActionService()
|
||||
{
|
||||
for(int i = 0; i < actionsLabels.length; i++)
|
||||
{
|
||||
MUCActionMenuItems item = new MUCActionMenuItems(actionsLabels[i],
|
||||
actionsIcons[i], actionsRunnable[i], actionsIsCheckBox[i]);
|
||||
MUCActionMenuItems.add(item);
|
||||
if(actionsEnabledCheckers[i] != null)
|
||||
item.setEnabled(actionsEnabledCheckers[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the template class that this service has been initialized with
|
||||
*
|
||||
* @return the template class
|
||||
*/
|
||||
public Class<SourceContact> getContactSourceClass()
|
||||
{
|
||||
return SourceContact.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ContactActionMenuItem<SourceContact>>
|
||||
getCustomContactActionsMenuItems()
|
||||
{
|
||||
return MUCActionMenuItems.iterator();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterator<ContactAction<SourceContact>> getCustomContactActions()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the MUC custom menu items.
|
||||
*/
|
||||
private class MUCActionMenuItems
|
||||
implements ContactActionMenuItem<SourceContact>
|
||||
{
|
||||
/**
|
||||
* The key used to retrieve the label for the menu item.
|
||||
*/
|
||||
private String textKey;
|
||||
|
||||
/**
|
||||
* The key used to retrieve the icon for the menu item.
|
||||
*/
|
||||
private String imageKey;
|
||||
|
||||
/**
|
||||
* The action executed when the menu item is pressed.
|
||||
*/
|
||||
private MUCCustomActionRunnable actionPerformed;
|
||||
|
||||
/**
|
||||
* Object that is used to check if the item is enabled or disabled.
|
||||
*/
|
||||
private EnableChecker enabled;
|
||||
|
||||
/**
|
||||
* if <tt>true</tt> the item should be check box and if <tt>false</tt>
|
||||
* it is standard menu item.
|
||||
*/
|
||||
private boolean isCheckBox;
|
||||
|
||||
/**
|
||||
* Constructs <tt>MUCActionMenuItems</tt> instance.
|
||||
*
|
||||
* @param textKey the key used to retrieve the label for the menu item.
|
||||
* @param imageKey the key used to retrieve the icon for the menu item.
|
||||
* @param actionPerformed the action executed when the menu item is
|
||||
* pressed.
|
||||
* @param isCheckBox if <tt>true</tt> the item should be check box.
|
||||
*/
|
||||
public MUCActionMenuItems(String textKey, String imageKey,
|
||||
MUCCustomActionRunnable actionPerformed, boolean isCheckBox)
|
||||
{
|
||||
this.textKey = textKey;
|
||||
this.imageKey = imageKey;
|
||||
this.actionPerformed = actionPerformed;
|
||||
this.enabled = new EnableChecker();
|
||||
this.isCheckBox = isCheckBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(SourceContact actionSource)
|
||||
throws OperationFailedException
|
||||
{
|
||||
if(!(actionSource instanceof ChatRoomSourceContact))
|
||||
return;
|
||||
actionPerformed.setContact(actionSource);
|
||||
new Thread(actionPerformed).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getIcon()
|
||||
{
|
||||
return (imageKey == null)? null :
|
||||
resources.getImageInBytes(imageKey);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getText()
|
||||
{
|
||||
return resources.getI18NString(textKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(SourceContact actionSource)
|
||||
{
|
||||
return (actionSource instanceof ChatRoomSourceContact);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getMnemonics()
|
||||
{
|
||||
return resources.getI18nMnemonic(textKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(SourceContact actionSource)
|
||||
{
|
||||
return enabled.check(actionSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets <tt>EnabledChecker</tt> instance that will be used to check if
|
||||
* the item should be enabled or disabled.
|
||||
*
|
||||
* @param enabled the <tt>EnabledChecker</tt> instance.
|
||||
*/
|
||||
public void setEnabled(EnableChecker enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCheckBox()
|
||||
{
|
||||
return isCheckBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(SourceContact contact)
|
||||
{
|
||||
ChatRoomWrapper chatRoomWrapper = MUCActivator.getMUCService()
|
||||
.findChatRoomWrapperFromSourceContact(contact);
|
||||
return chatRoomWrapper.isAutojoin();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the menu item should be enabled or disabled. This is default
|
||||
* implementation. Always returns that the item should be enabled.
|
||||
*/
|
||||
private class EnableChecker
|
||||
{
|
||||
/**
|
||||
* Checks if the menu item should be enabled or disabled.
|
||||
*
|
||||
* @param contact the contact associated with the menu item.
|
||||
* @return always <tt>true</tt>
|
||||
*/
|
||||
public boolean check(SourceContact contact)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements <tt>EnableChecker</tt> for the join menu items.
|
||||
*/
|
||||
private class JoinEnableChecker extends EnableChecker
|
||||
{
|
||||
/**
|
||||
* Checks if the menu item should be enabled or disabled.
|
||||
*
|
||||
* @param contact the contact associated with the menu item.
|
||||
* @return <tt>true</tt> if the item should be enabled and
|
||||
* <tt>false</tt> if not.
|
||||
*/
|
||||
public boolean check(SourceContact contact)
|
||||
{
|
||||
ChatRoomWrapper chatRoomWrapper = MUCActivator.getMUCService()
|
||||
.findChatRoomWrapperFromSourceContact(contact);
|
||||
ChatRoom chatRoom = null;
|
||||
if(chatRoomWrapper != null)
|
||||
{
|
||||
chatRoom = chatRoomWrapper.getChatRoom();
|
||||
}
|
||||
|
||||
if((chatRoom != null) && chatRoom.isJoined())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements <tt>EnableChecker</tt> for the leave menu item.
|
||||
*/
|
||||
private class LeaveEnableChecker extends JoinEnableChecker
|
||||
{
|
||||
/**
|
||||
* Checks if the menu item should be enabled or disabled.
|
||||
*
|
||||
* @param contact the contact associated with the menu item.
|
||||
* @return <tt>true</tt> if the item should be enabled and
|
||||
* <tt>false</tt> if not.
|
||||
*/
|
||||
public boolean check(SourceContact contact)
|
||||
{
|
||||
return !super.check(contact);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements base properties for the MUC menu items.These properties are
|
||||
* used when the menu item is pressed.
|
||||
*/
|
||||
private abstract class MUCCustomActionRunnable implements Runnable
|
||||
{
|
||||
/**
|
||||
* The contact associated with the menu item.
|
||||
*/
|
||||
protected SourceContact contact;
|
||||
|
||||
/**
|
||||
* The contact associated with the menu item.
|
||||
*/
|
||||
protected ChatRoomWrapper chatRoomWrapper;
|
||||
|
||||
/**
|
||||
* Sets the source contact.
|
||||
* @param contact the contact to set
|
||||
*/
|
||||
public void setContact(SourceContact contact)
|
||||
{
|
||||
this.contact = contact;
|
||||
chatRoomWrapper = MUCActivator.getMUCService()
|
||||
.findChatRoomWrapperFromSourceContact(contact);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,196 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package net.java.sip.communicator.plugin.desktoputil.chat;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
|
||||
import net.java.sip.communicator.plugin.desktoputil.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* @author Ico
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Dialog with fields for nickname and subject.
|
||||
*/
|
||||
public class ChatRoomJoinOptionsDialog extends ChatOperationReasonDialog
|
||||
{
|
||||
/**
|
||||
* Serial id.
|
||||
*/
|
||||
private static final long serialVersionUID = -916498752420264164L;
|
||||
|
||||
/**
|
||||
* Text field for the subject.
|
||||
*/
|
||||
private SIPCommTextField subject = new SIPCommTextField(DesktopUtilActivator
|
||||
.getResources().getI18NString("service.gui.SUBJECT"));
|
||||
|
||||
/**
|
||||
* Label that hides and shows the subject fields panel on click.
|
||||
*/
|
||||
private JLabel cmdExpandSubjectFields;
|
||||
|
||||
/**
|
||||
* Panel that holds the subject fields.
|
||||
*/
|
||||
private JPanel subjectFieldsPannel = new JPanel(new BorderLayout());
|
||||
|
||||
/**
|
||||
* Adds the subject fields to dialog. Sets action listeners.
|
||||
*
|
||||
* @param title the title of the dialog
|
||||
* @param message the message shown in this dialog
|
||||
* @param disableOKIfReasonIsEmpty if true the OK button will be
|
||||
* disabled if the reason text is empty.
|
||||
* @param showReasonLabel specify if we want the "Reason:" label
|
||||
* @param dontDisplaySubjectFields if true the sibject fields will be
|
||||
* hidden.
|
||||
*/
|
||||
public ChatRoomJoinOptionsDialog(String title, String message,
|
||||
boolean showReasonLabel,
|
||||
boolean disableOKIfReasonIsEmpty,
|
||||
boolean dontDisplaySubjectFields)
|
||||
{
|
||||
super(title,
|
||||
message,
|
||||
showReasonLabel,
|
||||
disableOKIfReasonIsEmpty);
|
||||
|
||||
if(dontDisplaySubjectFields)
|
||||
return;
|
||||
|
||||
JPanel subjectPanel = new JPanel(new BorderLayout());
|
||||
subjectPanel.setOpaque(false);
|
||||
subjectPanel.setBorder(
|
||||
BorderFactory.createEmptyBorder(10, 0, 0, 0));
|
||||
|
||||
subjectFieldsPannel.setBorder(
|
||||
BorderFactory.createEmptyBorder(10, 30, 0, 0));
|
||||
subjectFieldsPannel.setOpaque(false);
|
||||
subjectFieldsPannel.add(subject, BorderLayout.CENTER);
|
||||
subjectFieldsPannel.setVisible(false);
|
||||
subject.setFont(getFont().deriveFont(12f));
|
||||
|
||||
cmdExpandSubjectFields = new JLabel();
|
||||
cmdExpandSubjectFields.setBorder(new EmptyBorder(0, 5, 0, 0));
|
||||
cmdExpandSubjectFields.setIcon(DesktopUtilActivator.getResources()
|
||||
.getImage("service.gui.icons.RIGHT_ARROW_ICON"));
|
||||
cmdExpandSubjectFields.setText(DesktopUtilActivator
|
||||
.getResources().getI18NString("service.gui.SET_SUBJECT"));
|
||||
cmdExpandSubjectFields.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
cmdExpandSubjectFields.setIcon(
|
||||
UtilActivator.getResources().getImage(
|
||||
subjectFieldsPannel.isVisible()
|
||||
? "service.gui.icons.RIGHT_ARROW_ICON"
|
||||
: "service.gui.icons.DOWN_ARROW_ICON"));
|
||||
|
||||
subjectFieldsPannel.setVisible(
|
||||
!subjectFieldsPannel.isVisible());
|
||||
|
||||
pack();
|
||||
}
|
||||
});
|
||||
subjectPanel.add(cmdExpandSubjectFields,BorderLayout.NORTH);
|
||||
subjectPanel.add(subjectFieldsPannel,BorderLayout.CENTER);
|
||||
addToReasonFieldPannel(subjectPanel);
|
||||
this.pack();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text entered in the subject field.
|
||||
*
|
||||
* @return the text from the subject field.
|
||||
*/
|
||||
public String getSubject()
|
||||
{
|
||||
return subject.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a dialog with a fields for the nickname and the subject of the room
|
||||
* and returns them.
|
||||
*
|
||||
* @param pps the protocol provider associated with the chat room.
|
||||
* @param chatRoomId the id of the chat room.
|
||||
* @return array with the nickname and subject values.
|
||||
*/
|
||||
public static String[] getJoinOptions(ProtocolProviderService pps,
|
||||
String chatRoomId)
|
||||
{
|
||||
return getJoinOptions(false, pps, chatRoomId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a dialog with a fields for the nickname and the subject of the room
|
||||
* and returns them.
|
||||
*
|
||||
* @param dontDisplaySubjectFields if true the subject fields will be hidden
|
||||
* @return array with the nickname and subject values.
|
||||
*/
|
||||
public static String[] getJoinOptions(boolean dontDisplaySubjectFields,
|
||||
ProtocolProviderService pps, String chatRoomId)
|
||||
{
|
||||
String nickName = null;
|
||||
ChatRoomJoinOptionsDialog reasonDialog =
|
||||
new ChatRoomJoinOptionsDialog(DesktopUtilActivator.getResources()
|
||||
.getI18NString("service.gui.CHANGE_NICKNAME"),
|
||||
DesktopUtilActivator.getResources().getI18NString(
|
||||
"service.gui.CHANGE_NICKNAME_LABEL"), false, true,
|
||||
dontDisplaySubjectFields);
|
||||
reasonDialog.setIcon(new ImageIcon(DesktopUtilActivator.getImage(
|
||||
"service.gui.icons.CHANGE_NICKNAME_16x16")));
|
||||
|
||||
final OperationSetServerStoredAccountInfo accountInfoOpSet
|
||||
= pps.getOperationSet(
|
||||
OperationSetServerStoredAccountInfo.class);
|
||||
|
||||
String displayName = "";
|
||||
if (accountInfoOpSet != null)
|
||||
{
|
||||
displayName = AccountInfoUtils.getDisplayName(accountInfoOpSet);
|
||||
}
|
||||
|
||||
if(displayName == null || displayName.length() == 0)
|
||||
{
|
||||
displayName = DesktopUtilActivator.getGlobalDisplayDetailsService()
|
||||
.getGlobalDisplayName();
|
||||
if(displayName == null || displayName.length() == 0)
|
||||
{
|
||||
displayName = pps.getAccountID().getUserID();
|
||||
if(displayName != null)
|
||||
{
|
||||
int atIndex = displayName.lastIndexOf("@");
|
||||
if (atIndex > 0)
|
||||
displayName = displayName.substring(0, atIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
reasonDialog.setReasonFieldText(displayName);
|
||||
|
||||
int result = reasonDialog.showDialog();
|
||||
|
||||
if (result == MessageDialog.OK_RETURN_CODE)
|
||||
{
|
||||
nickName = reasonDialog.getReason().trim();
|
||||
ConfigurationUtils.updateChatRoomProperty(
|
||||
pps,
|
||||
chatRoomId, "userNickName", nickName);
|
||||
|
||||
}
|
||||
String[] joinOptions = {nickName, reasonDialog.getSubject()};
|
||||
return joinOptions;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.customcontactactions;
|
||||
|
||||
import net.java.sip.communicator.service.contactsource.SourceContact;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* A custom contact action menu item, used to define an action that can be
|
||||
* represented in the contact list entry in the user interface.
|
||||
*
|
||||
* @author Hristo Terezov
|
||||
*/
|
||||
public interface ContactActionMenuItem<T>
|
||||
{
|
||||
/**
|
||||
* Invoked when an action occurs.
|
||||
*
|
||||
* @param actionSource the source of the action
|
||||
*/
|
||||
public void actionPerformed(T actionSource)
|
||||
throws OperationFailedException;
|
||||
|
||||
/**
|
||||
* The icon used by the UI to visualize this action.
|
||||
* @return the button icon.
|
||||
*/
|
||||
public byte[] getIcon();
|
||||
|
||||
/**
|
||||
* Returns the text of the component to create for this contact
|
||||
* action.
|
||||
*
|
||||
* @return the tool tip text of the component to create for this contact
|
||||
* action
|
||||
*/
|
||||
public String getText();
|
||||
|
||||
/**
|
||||
* Indicates if this action is visible for the given <tt>actionSource</tt>.
|
||||
*
|
||||
* @param actionSource the action source for which we're verifying the
|
||||
* action.
|
||||
* @return <tt>true</tt> if the action should be visible for the given
|
||||
* <tt>actionSource</tt>, <tt>false</tt> - otherwise
|
||||
*/
|
||||
public boolean isVisible(T actionSource);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public char getMnemonics();
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if the item should be enabled and <tt>false</tt>
|
||||
* - not.
|
||||
*
|
||||
* @param actionSource the action source for which we're verifying the
|
||||
* action.
|
||||
* @return <tt>true</tt> if the item should be enabled and <tt>false</tt>
|
||||
* - not.
|
||||
*/
|
||||
public boolean isEnabled(T actionSource);
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if the item should be a check box and
|
||||
* <tt>false</tt> if not
|
||||
*
|
||||
* @return <tt>true</tt> if the item should be a check box and
|
||||
* <tt>false</tt> if not
|
||||
*/
|
||||
public boolean isCheckBox();
|
||||
|
||||
/**
|
||||
* Returns the state of the item if the item is check box.
|
||||
*
|
||||
* @param actionSource the action source for which we're verifying the
|
||||
* action.
|
||||
* @return the state of the item.
|
||||
*/
|
||||
public boolean isSelected(T actionSource);
|
||||
}
|
||||
Loading…
Reference in new issue