diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties index 0fd74bf58..aa3252a7e 100644 --- a/resources/languages/resources.properties +++ b/resources/languages/resources.properties @@ -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} diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomSubjectPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomSubjectPanel.java index 5e8b28659..745365fc0 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomSubjectPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomSubjectPanel.java @@ -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 Logger used by the ChatRoomSubjectPanel 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 ChatRoomLocalUserRoleChangeEvent 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. */