From ff794611fb381b9e3e975ce855a57e87e0ba5b00 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Fri, 16 Mar 2012 09:59:23 +0000 Subject: [PATCH] Keeps reference to PluginContainers or they will not be notified for events. --- .../impl/gui/main/menus/HelpMenu.java | 13 +----- .../gui/main/presence/AccountStatusPanel.java | 44 ++++++++++++------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java index 14ce1f25f..4a3c0ae55 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/HelpMenu.java @@ -25,8 +25,7 @@ */ public class HelpMenu extends SIPCommMenu - implements ActionListener, - PluginComponentListener + implements ActionListener { /** * The PluginContainer which implements the logic related to @@ -60,14 +59,4 @@ public HelpMenu(MainFrame mainFrame) public void actionPerformed(ActionEvent e) { } - - public void pluginComponentAdded(PluginComponentEvent event) - { - pluginContainer.pluginComponentAdded(event); - } - - public void pluginComponentRemoved(PluginComponentEvent event) - { - pluginContainer.pluginComponentRemoved(event); - } } diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/AccountStatusPanel.java b/src/net/java/sip/communicator/impl/gui/main/presence/AccountStatusPanel.java index a40ee12bb..1f6280898 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/AccountStatusPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/AccountStatusPanel.java @@ -99,6 +99,18 @@ public class AccountStatusPanel private String currentLastName; + /** + * Keep reference to plugin container or it will loose its + * listener. + */ + private final PluginContainer southPluginContainer; + + /** + * Keep reference to plugin container or it will loose its + * listener. + */ + private final PluginContainer mainToolbarPluginContainer; + /** * Creates an instance of AccountStatusPanel by specifying the * main window, where this panel is added. @@ -140,7 +152,7 @@ public AccountStatusPanel(MainFrame mainFrame) toolbarPluginPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); - new PluginContainer(toolbarPluginPanel, + mainToolbarPluginContainer = new PluginContainer(toolbarPluginPanel, Container.CONTAINER_MAIN_TOOL_BAR); statusToolsPanel.add(toolbarPluginPanel, BorderLayout.EAST); @@ -155,7 +167,7 @@ public AccountStatusPanel(MainFrame mainFrame) southPluginPanel = new TransparentPanel(new BorderLayout()); - new PluginContainer( + southPluginContainer = new PluginContainer( southPluginPanel, Container.CONTAINER_ACCOUNT_SOUTH); @@ -465,19 +477,18 @@ public void paintComponent(Graphics g) public void pluginComponentAdded(PluginComponentEvent event) { PluginComponent pluginComponent = event.getPluginComponent(); - String containerID = pluginComponent.getContainer().getID(); + Container containerID = pluginComponent.getContainer(); Object component = pluginComponent.getComponent(); if (!(component instanceof Component)) return; - if (containerID.equals(Container.CONTAINER_MAIN_TOOL_BAR)) - toolbarPluginPanel.add((Component) component); - else if (containerID.equals(Container.CONTAINER_ACCOUNT_SOUTH)) - southPluginPanel.add((Component) component); - - this.revalidate(); - this.repaint(); + if (containerID.equals(Container.CONTAINER_MAIN_TOOL_BAR) + || containerID.equals(Container.CONTAINER_ACCOUNT_SOUTH)) + { + this.revalidate(); + this.repaint(); + } } /** @@ -495,13 +506,12 @@ public void pluginComponentRemoved(PluginComponentEvent event) if (!(component instanceof Component)) return; - if (pluginContainer.equals(Container.CONTAINER_MAIN_TOOL_BAR)) - toolbarPluginPanel.remove((Component) component); - else if (pluginContainer.equals(Container.CONTAINER_ACCOUNT_SOUTH)) - southPluginPanel.remove((Component) component); - - this.revalidate(); - this.repaint(); + if (pluginContainer.equals(Container.CONTAINER_MAIN_TOOL_BAR) + || pluginContainer.equals(Container.CONTAINER_ACCOUNT_SOUTH)) + { + this.revalidate(); + this.repaint(); + } } /**