diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2009-03-25 14:49:04 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2009-03-25 14:49:04 +0000 |
commit | ad0f39d8a2d43e853bfc631d7bf2742b1e62fc82 (patch) | |
tree | b7fa6fe93d29148e169fb58f367d5ccfdaa3ba9d /src/net/java | |
parent | 308d34533c8a4728b9b72508bedcb1536291489f (diff) | |
download | jitsi-ad0f39d8a2d43e853bfc631d7bf2742b1e62fc82.zip jitsi-ad0f39d8a2d43e853bfc631d7bf2742b1e62fc82.tar.gz jitsi-ad0f39d8a2d43e853bfc631d7bf2742b1e62fc82.tar.bz2 |
Fixes issue #615 (Multiple "My chat rooms...", "About SIP Communicator" dialogs).
Diffstat (limited to 'src/net/java')
6 files changed, 79 insertions, 18 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/menus/FileMenu.java b/src/net/java/sip/communicator/impl/gui/main/chat/menus/FileMenu.java index eac8a61..00d58e9 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/menus/FileMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/menus/FileMenu.java @@ -85,12 +85,7 @@ public class FileMenu extends SIPCommMenu if (itemText.equalsIgnoreCase("myChatRooms")) { - ChatRoomListDialog chatRoomsDialog - = new ChatRoomListDialog( - GuiActivator.getUIService().getMainFrame()); - - chatRoomsDialog.setPreferredSize(new Dimension(500, 400)); - chatRoomsDialog.setVisible(true); + ChatRoomListDialog.showChatRoomListDialog(); } else if (itemText.equalsIgnoreCase("service.gui.CLOSE")) { diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomListDialog.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomListDialog.java index a8125c8..c45fa46 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomListDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomListDialog.java @@ -12,7 +12,6 @@ import java.awt.event.*; import javax.swing.*; import net.java.sip.communicator.impl.gui.*; - import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.chatroomslist.createforms.*; import net.java.sip.communicator.impl.gui.main.chatroomslist.joinforms.*; @@ -24,11 +23,48 @@ import net.java.sip.communicator.util.swing.*; * chat rooms, etc. * * @author Yana Stamcheva + * @authro Lubomir Marinov */ public class ChatRoomListDialog extends SIPCommDialog implements ActionListener { + + /** + * The global/shared <code>ChatRoomListDialog</code> currently showing. + */ + private static ChatRoomListDialog chatRoomListDialog; + + /** + * Shows a <code>ChatRoomListDialog</code> creating it first if necessary. + * The shown instance is shared in order to prevent displaying multiple + * instances of one and the same <code>ChatRoomListDialog</code>. + */ + public static void showChatRoomListDialog() + { + if (chatRoomListDialog == null) + { + chatRoomListDialog + = new ChatRoomListDialog( + GuiActivator.getUIService().getMainFrame()); + chatRoomListDialog.setPreferredSize(new Dimension(500, 400)); + + /* + * When the global/shared ChatRoomListDialog closes, don't keep a + * reference to it and let it be garbage-collected. + */ + chatRoomListDialog.addWindowListener(new WindowAdapter() + { + public void windowClosed(WindowEvent e) + { + if (chatRoomListDialog == e.getWindow()) + chatRoomListDialog = null; + } + }); + } + chatRoomListDialog.setVisible(true); + } + private static final String CREATE_CHAT_ROOM = "CreateChatRoom"; private static final String JOIN_CHAT_ROOM = "JoinChatRoom"; diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ActionMenuPanel.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ActionMenuPanel.java index 3bba8b3..bb45165 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ActionMenuPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ActionMenuPanel.java @@ -192,11 +192,7 @@ public class ActionMenuPanel } else if (buttonName.equals("chatRooms")) { - ChatRoomListDialog chatRoomsDialog = new ChatRoomListDialog( - GuiActivator.getUIService().getMainFrame()); - - chatRoomsDialog.setPreferredSize(new Dimension(500, 400)); - chatRoomsDialog.setVisible(true); + ChatRoomListDialog.showChatRoomListDialog(); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java index 7f8896c..dcd971e 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java @@ -140,11 +140,7 @@ public class FileMenu } else if (itemName.equals("myChatRooms")) { - ChatRoomListDialog chatRoomsDialog - = new ChatRoomListDialog(parentWindow); - - chatRoomsDialog.setPreferredSize(new Dimension(500, 400)); - chatRoomsDialog.setVisible(true); + ChatRoomListDialog.showChatRoomListDialog(); } } diff --git a/src/net/java/sip/communicator/plugin/branding/AboutWindow.java b/src/net/java/sip/communicator/plugin/branding/AboutWindow.java index 281c4da..0226aa1 100644 --- a/src/net/java/sip/communicator/plugin/branding/AboutWindow.java +++ b/src/net/java/sip/communicator/plugin/branding/AboutWindow.java @@ -26,6 +26,39 @@ public class AboutWindow extends JDialog
implements HyperlinkListener, ActionListener, ExportedWindow
{
+
+ /**
+ * The global/shared <code>AboutWindow</code> currently showing.
+ */
+ private static AboutWindow aboutWindow;
+
+ /**
+ * Shows a <code>AboutWindow</code> creating it first if necessary. The
+ * shown instance is shared in order to prevent displaying multiple
+ * instances of one and the same <code>AboutWindow</code>.
+ */
+ public static void showAboutWindow()
+ {
+ if (aboutWindow == null)
+ {
+ aboutWindow = new AboutWindow(null);
+
+ /*
+ * When the global/shared AboutWindow closes, don't keep a reference
+ * to it and let it be garbage-collected.
+ */
+ aboutWindow.addWindowListener(new WindowAdapter()
+ {
+ public void windowClosed(WindowEvent e)
+ {
+ if (aboutWindow == e.getWindow())
+ aboutWindow = null;
+ }
+ });
+ }
+ aboutWindow.setVisible(true);
+ }
+
private static final int DEFAULT_TEXT_INDENT
= BrandingActivator.getResources()
.getSettingsInt("plugin.branding.ABOUT_TEXT_INDENT");
diff --git a/src/net/java/sip/communicator/plugin/branding/AboutWindowPluginComponent.java b/src/net/java/sip/communicator/plugin/branding/AboutWindowPluginComponent.java index ca5e59e..590ba58 100644 --- a/src/net/java/sip/communicator/plugin/branding/AboutWindowPluginComponent.java +++ b/src/net/java/sip/communicator/plugin/branding/AboutWindowPluginComponent.java @@ -16,9 +16,14 @@ import net.java.sip.communicator.service.gui.*; public class AboutWindowPluginComponent
implements PluginComponent
{
+
+ /**
+ * Invokes the default action associated with Help > About regardless of the
+ * specifics of its visual representation.
+ */
public static void actionPerformed()
{
- new AboutWindow(null).setVisible(true);
+ AboutWindow.showAboutWindow();
}
private final JMenuItem aboutMenuItem
|