diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java
index f6cf4402d..a5d2755d7 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java
@@ -20,6 +20,7 @@
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
+import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;
// Java 1.6 has javax.swing.SwingWorker so we have to disambiguate.
@@ -855,13 +856,16 @@ public void joinChatRoom(AdHocChatRoomWrapper chatRoomWrapper)
*/
public void removeChatRoom(ChatRoomWrapper chatRoomWrapper)
{
- this.leaveChatRoom(chatRoomWrapper);
+ ChatRoom chatRoom = chatRoomWrapper.getChatRoom();
+
+ if (chatRoom != null)
+ leaveChatRoom(chatRoomWrapper);
this.closeChatRoom(chatRoomWrapper);
chatRoomList.removeChatRoom(chatRoomWrapper);
- this.fireChatRoomListChangedEvent(
+ fireChatRoomListChangedEvent(
chatRoomWrapper,
ChatRoomListChangeEvent.CHAT_ROOM_REMOVED);
}
@@ -1026,12 +1030,15 @@ public void leaveChatRoom(ChatRoomWrapper chatRoomWrapper)
if (chatRoom == null)
{
+ ResourceManagementService resources = GuiActivator.getResources();
+
new ErrorDialog(
- GuiActivator.getUIService().getMainFrame(),
- GuiActivator.getResources().getI18NString("service.gui.WARNING"),
- GuiActivator.getResources().getI18NString(
- "service.gui.CHAT_ROOM_LEAVE_NOT_CONNECTED"))
- .showDialog();
+ GuiActivator.getUIService().getMainFrame(),
+ resources.getI18NString("service.gui.WARNING"),
+ resources
+ .getI18NString(
+ "service.gui.CHAT_ROOM_LEAVE_NOT_CONNECTED"))
+ .showDialog();
return;
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomListUI.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomListUI.java
index 6df88820c..98d5c7983 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomListUI.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomListUI.java
@@ -162,31 +162,22 @@ public void mousePressed(MouseEvent e)
if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0)
{
+ JPopupMenu rightButtonMenu;
+
if(o instanceof ChatRoomProviderWrapper)
- {
- ChatRoomServerRightButtonMenu rightButtonMenu
+ rightButtonMenu
= new ChatRoomServerRightButtonMenu(
- (ChatRoomProviderWrapper) o);
-
- rightButtonMenu.setInvoker(this);
-
- rightButtonMenu.setLocation(selectedCellPoint.x,
- selectedCellPoint.y + 20);
-
- rightButtonMenu.setVisible(true);
- }
+ (ChatRoomProviderWrapper) o);
else if (o instanceof ChatRoomWrapper)
- {
- ChatRoomRightButtonMenu rightButtonMenu
+ rightButtonMenu
= new ChatRoomRightButtonMenu((ChatRoomWrapper) o);
+ else
+ return;
- rightButtonMenu.setInvoker(this);
-
- rightButtonMenu.setLocation(selectedCellPoint.x,
- selectedCellPoint.y + 20);
-
- rightButtonMenu.setVisible(true);
- }
+ rightButtonMenu.setInvoker(this);
+ rightButtonMenu
+ .setLocation(selectedCellPoint.x, selectedCellPoint.y + 20);
+ rightButtonMenu.setVisible(true);
}
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java
index f2ce8f805..bb2bee0c2 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java
@@ -14,6 +14,8 @@
import net.java.sip.communicator.impl.gui.main.chat.conference.*;
import net.java.sip.communicator.impl.gui.main.chatroomslist.joinforms.*;
import net.java.sip.communicator.impl.gui.utils.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.resources.*;
/**
* The ChatRoomsListRightButtonMenu is the menu, opened when user clicks
@@ -21,28 +23,13 @@
* contains the create chat room item.
*
* @author Yana Stamcheva
+ * @author Lubomir Marinov
*/
public class ChatRoomRightButtonMenu
extends JPopupMenu
implements ActionListener
{
- private JMenuItem leaveChatRoomItem = new JMenuItem(
- GuiActivator.getResources().getI18NString("service.gui.LEAVE"),
- new ImageIcon(ImageLoader.getImage(ImageLoader.LEAVE_ICON)));
-
- private JMenuItem joinChatRoomItem = new JMenuItem(
- GuiActivator.getResources().getI18NString("service.gui.JOIN"),
- new ImageIcon(ImageLoader.getImage(ImageLoader.JOIN_ICON)));
-
- private JMenuItem joinAsChatRoomItem = new JMenuItem(
- GuiActivator.getResources().getI18NString("service.gui.JOIN_AS"),
- new ImageIcon(ImageLoader.getImage(ImageLoader.JOIN_AS_ICON)));
-
- private JMenuItem removeChatRoomItem = new JMenuItem(
- GuiActivator.getResources().getI18NString("service.gui.REMOVE"),
- new ImageIcon(ImageLoader.getImage(ImageLoader.DELETE_16x16_ICON)));
-
- private ChatRoomWrapper chatRoomWrapper = null;
+ private final ChatRoomWrapper chatRoomWrapper;
/**
* Creates an instance of ChatRoomsListRightButtonMenu.
@@ -51,55 +38,39 @@ public class ChatRoomRightButtonMenu
*/
public ChatRoomRightButtonMenu(ChatRoomWrapper chatRoomWrapper)
{
- super();
-
this.chatRoomWrapper = chatRoomWrapper;
this.setLocation(getLocation());
- this.init();
- }
-
- /**
- * Initializes the menu, by adding all containing menu items.
- */
- private void init()
- {
- this.add(joinChatRoomItem);
- this.add(joinAsChatRoomItem);
- this.add(leaveChatRoomItem);
- this.add(removeChatRoomItem);
-
- this.joinChatRoomItem.setName("joinChatRoom");
- this.joinAsChatRoomItem.setName("joinAsChatRoom");
- this.leaveChatRoomItem.setName("leaveChatRoom");
- this.removeChatRoomItem.setName("removeChatRoom");
-
- this.joinChatRoomItem.setMnemonic(
- GuiActivator.getResources().getI18nMnemonic("service.gui.JOIN"));
-
- this.joinAsChatRoomItem.setMnemonic(
- GuiActivator.getResources().getI18nMnemonic("service.gui.JOIN_AS"));
-
- this.leaveChatRoomItem.setMnemonic(
- GuiActivator.getResources().getI18nMnemonic("service.gui.LEAVE"));
-
- this.removeChatRoomItem.setMnemonic(
- GuiActivator.getResources().getI18nMnemonic("service.gui.REMOVE"));
-
- this.joinChatRoomItem.addActionListener(this);
- this.joinAsChatRoomItem.addActionListener(this);
- this.leaveChatRoomItem.addActionListener(this);
- this.removeChatRoomItem.addActionListener(this);
-
- if (chatRoomWrapper.getChatRoom() != null
- && chatRoomWrapper.getChatRoom().isJoined())
+ JMenuItem joinChatRoomItem
+ = createMenuItem(
+ "service.gui.JOIN",
+ ImageLoader.JOIN_ICON,
+ "joinChatRoom");
+ JMenuItem joinAsChatRoomItem
+ = createMenuItem(
+ "service.gui.JOIN_AS",
+ ImageLoader.JOIN_AS_ICON,
+ "joinAsChatRoom");
+ JMenuItem leaveChatRoomItem
+ = createMenuItem(
+ "service.gui.LEAVE",
+ ImageLoader.LEAVE_ICON,
+ "leaveChatRoom");
+ createMenuItem(
+ "service.gui.REMOVE",
+ ImageLoader.DELETE_16x16_ICON,
+ "removeChatRoom");
+
+ ChatRoom chatRoom = chatRoomWrapper.getChatRoom();
+
+ if ((chatRoom != null) && chatRoom.isJoined())
{
- this.joinAsChatRoomItem.setEnabled(false);
- this.joinChatRoomItem.setEnabled(false);
+ joinAsChatRoomItem.setEnabled(false);
+ joinChatRoomItem.setEnabled(false);
}
else
- this.leaveChatRoomItem.setEnabled(false);
+ leaveChatRoomItem.setEnabled(false);
}
/**
@@ -117,7 +88,6 @@ public void actionPerformed(ActionEvent e)
if (itemName.equals("removeChatRoom"))
{
conferenceManager.removeChatRoom(chatRoomWrapper);
-
}
else if (itemName.equals("leaveChatRoom"))
{
@@ -135,4 +105,37 @@ else if(itemName.equals("joinAsChatRoom"))
authWindow.setVisible(true);
}
}
+
+ /**
+ * Creates a new JMenuItem and adds it to this JPopupMenu.
+ *
+ * @param textKey the key of the internationalized string in the resources
+ * of the application which represents the text of the new
+ * JMenuItem
+ * @param iconID the ImageID of the image in the resources of the
+ * application which represents the icon of the new JMenuItem
+ * @param name the name of the new JMenuItem
+ * @return a new JMenuItem instance which has been added to this
+ * JPopupMenu
+ */
+ private JMenuItem createMenuItem(
+ String textKey,
+ ImageID iconID,
+ String name)
+ {
+ ResourceManagementService resources = GuiActivator.getResources();
+ JMenuItem menuItem
+ = new JMenuItem(
+ resources.getI18NString(textKey),
+ new ImageIcon(ImageLoader.getImage(iconID)));
+
+ menuItem.setMnemonic(resources.getI18nMnemonic(textKey));
+ menuItem.setName(name);
+
+ menuItem.addActionListener(this);
+
+ add(menuItem);
+
+ return menuItem;
+ }
}