Updates chat room configuration button on local user role change.

cusax-fix
Damian Minkov 12 years ago
parent 4fda65bcd9
commit a1b0335bb3

@ -103,7 +103,7 @@ service.gui.CHANGE_VIDEO_QUALITY=Change remote video quality
service.gui.CHAT_ROOM_ALREADY_JOINED=The {0} chat room is already joined.
service.gui.CHAT_ROOM_CONFIGURATION={0} chat room configuration
service.gui.CHAT_ROOM_CONFIGURATION_FAILED=Failed to obtain the {0} chat room configuration form.
service.gui.CHAT_ROOM_CONFIGURATION_FORBIDDEN=Could not obtain the {0} chat room configuration form. Only administrators of the chat room could see and change the configuration form.
service.gui.CHAT_ROOM_CONFIGURATION_FORBIDDEN=Could not obtain the {0} chat room configuration form. Only owners of the chat room could see and change the configuration form.
service.gui.CHAT_ROOM_CONFIGURATION_SUBMIT_FAILED=An error occurred while trying to submit the configuration form for chat room {0}.
service.gui.CHAT_ROOM_USER_JOINED=has joined {0}
service.gui.CHAT_ROOM_USER_LEFT=has left {0}

@ -15,6 +15,7 @@
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.skin.*;
@ -30,7 +31,8 @@
*/
public class ChatRoomSubjectPanel
extends TransparentPanel
implements Skinnable
implements Skinnable,
ChatRoomLocalUserRoleListener
{
/**
* The <tt>Logger</tt> used by the <tt>ChatRoomSubjectPanel</tt> class and
@ -79,23 +81,45 @@ public ChatRoomSubjectPanel(ConferenceChatSession chatSession)
add(subjectLabel, BorderLayout.WEST);
add(subjectField, BorderLayout.CENTER);
chatSession.addLocalUserRoleListener(this);
updateConfigButton();
}
/**
* Updates the config button state add or remove depending on the
* user role.
*/
private synchronized void updateConfigButton()
{
ChatRoomMemberRole role = ((ChatRoomWrapper)chatSession.getDescriptor())
.getChatRoom().getUserRole();
if(!ConfigurationUtils.isChatRoomConfigDisabled()
&& (role.equals(ChatRoomMemberRole.ADMINISTRATOR)
|| role.equals(ChatRoomMemberRole.MODERATOR)
|| role.equals(ChatRoomMemberRole.OWNER)))
&& role.equals(ChatRoomMemberRole.OWNER))
{
configButton
= new JButton(
new ImageIcon(
ImageLoader.getImage(
ImageLoader.CHAT_ROOM_CONFIG)));
configButton.setPreferredSize(new Dimension(26, 26));
configButton.addActionListener(new ConfigButtonActionListener());
add(configButton, BorderLayout.EAST);
if(configButton == null)
{
configButton
= new JButton(
new ImageIcon(
ImageLoader.getImage(
ImageLoader.CHAT_ROOM_CONFIG)));
configButton.setPreferredSize(new Dimension(26, 26));
configButton.addActionListener(new ConfigButtonActionListener());
add(configButton, BorderLayout.EAST);
revalidate();
repaint();
}
}
else if(configButton != null)
{
remove(configButton);
configButton = null;
revalidate();
repaint();
}
}
@ -123,6 +147,29 @@ public void setSubject(String subject)
subjectField.setText(subject);
}
/**
* Fired when local user role has changed.
* @param evt the <tt>ChatRoomLocalUserRoleChangeEvent</tt> instance
*/
@Override
public void localUserRoleChanged(final ChatRoomLocalUserRoleChangeEvent evt)
{
if(!SwingUtilities.isEventDispatchThread())
{
SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
localUserRoleChanged(evt);
}
});
return;
}
updateConfigButton();
}
/**
* Opens the configuration dialog when the configure buttons is pressed.
*/

Loading…
Cancel
Save