diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index 0b672ffc8..9a5412c38 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -44,7 +44,6 @@ public class UIServiceImpl implements UIService { - private static final Logger logger = Logger.getLogger(UIServiceImpl.class); private PopupDialogImpl popupDialog; diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java index 8e962f4aa..ff19dde3c 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java @@ -19,7 +19,6 @@ import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.impl.gui.main.chat.history.*; import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.event.*; @@ -336,14 +335,17 @@ private void initPluginComponents() * method. */ public void pluginComponentAdded(PluginComponentEvent event) - { + { Component c = (Component) event.getSource(); - this.addSeparator(); - this.add(c); - - this.revalidate(); - this.repaint(); + if(event.getContainerID().equals(UIService.CONTAINER_CHAT_TOOL_BAR)) + { + this.addSeparator(); + this.add(c); + + this.revalidate(); + this.repaint(); + } } /** @@ -354,7 +356,10 @@ public void pluginComponentRemoved(PluginComponentEvent event) { Component c = (Component) event.getSource(); - this.remove(c); + if(event.getContainerID().equals(UIService.CONTAINER_CHAT_TOOL_BAR)) + { + this.remove(c); + } } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java index f4db1b9f6..4ab06e110 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java @@ -31,8 +31,7 @@ */ public class ChatRoomServerRightButtonMenu extends JPopupMenu - implements ActionListener, - PluginComponentListener + implements ActionListener { private I18NString createChatRoomString = Messages.getI18NString("createChatRoom"); @@ -77,8 +76,6 @@ private void init() this.add(createChatRoomItem); this.add(joinChannelItem); - this.initPluginComponents(); - this.createChatRoomItem.setName("createChatRoom"); this.joinChannelItem.setName("joinChatRoom"); @@ -91,26 +88,6 @@ private void init() this.joinChannelItem.addActionListener(this); } - /** - * Adds all already registered plugin components to this menu. - */ - private void initPluginComponents() - { - Iterator pluginComponents = GuiActivator.getUIService() - .getComponentsForContainer( - UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU); - - if(pluginComponents.hasNext()) - this.addSeparator(); - - while (pluginComponents.hasNext()) - { - Component o = (Component)pluginComponents.next(); - - this.add(o); - } - } - /** * Handles the ActionEvent. Determines which menu item was * selected and makes the appropriate operations. @@ -141,29 +118,5 @@ else if (itemName.equals("joinChatRoom")) ); joinChannelDialog.setVisible(true); } - } - - /** - * Implements the PluginComponentListener.pluginComponentAdded - * method, in order to add the given plugin component in this container. - */ - public void pluginComponentAdded(PluginComponentEvent event) - { - Component c = (Component) event.getSource(); - - this.add(c); - - this.repaint(); - } - - /** - * Implements the PluginComponentListener.pluginComponentRemoved - * method, in order to remove the given component from this container. - */ - public void pluginComponentRemoved(PluginComponentEvent event) - { - Component c = (Component) event.getSource(); - - this.remove(c); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java index 865097836..14c2f5a32 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java @@ -717,22 +717,30 @@ public void pluginComponentAdded(PluginComponentEvent event) { Component c = (Component) event.getSource(); - this.add(c); - - if (c instanceof ContactAwareComponent) - { - ((ContactAwareComponent)c) - .setCurrentContact(contactItem); + if(event.getContainerID() + .equals(UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU)) + { + this.add(c); + + if (c instanceof ContactAwareComponent) + { + ((ContactAwareComponent)c) + .setCurrentContact(contactItem); + } + + this.repaint(); } - - this.repaint(); } public void pluginComponentRemoved(PluginComponentEvent event) { Component c = (Component) event.getSource(); - this.remove(c); + if(event.getContainerID() + .equals(UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU)) + { + this.remove(c); + } } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java index 97f5d12a2..d81d6f89e 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java @@ -229,22 +229,30 @@ public void pluginComponentAdded(PluginComponentEvent event) { Component c = (Component) event.getSource(); - this.add(c); - - if (c instanceof ContactAwareComponent) - { - ((ContactAwareComponent)c) - .setCurrentContactGroup(group); + if(event.getContainerID() + .equals(UIService.CONTAINER_GROUP_RIGHT_BUTTON_MENU)) + { + this.add(c); + + if (c instanceof ContactAwareComponent) + { + ((ContactAwareComponent)c) + .setCurrentContactGroup(group); + } + + this.repaint(); } - - this.repaint(); } public void pluginComponentRemoved(PluginComponentEvent event) { Component c = (Component) event.getSource(); - this.remove(c); + if(event.getContainerID() + .equals(UIService.CONTAINER_GROUP_RIGHT_BUTTON_MENU)) + { + this.remove(c); + } } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/QuickMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/QuickMenu.java index d80d0ef01..38084f7fc 100755 --- a/src/net/java/sip/communicator/impl/gui/main/menus/QuickMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/QuickMenu.java @@ -280,9 +280,16 @@ else if (buttonName.equals("sound")) * Implements the PluginComponentListener.pluginComponentAdded * method. */ - public void pluginComponentAdded(PluginComponentEvent event) { + public void pluginComponentAdded(PluginComponentEvent event) + { Component c = (Component) event.getSource(); + // If the container id doesn't correspond to the id of the plugin + // container we're not interested. + if(!event.getContainerID() + .equals(UIService.CONTAINER_MAIN_TOOL_BAR)) + return; + this.add(c); if (c instanceof ContactAwareComponent) @@ -313,7 +320,13 @@ else if(selectedValue instanceof MetaContactGroup) public void pluginComponentRemoved(PluginComponentEvent event) { Component c = (Component) event.getSource(); - this.remove(c); + // If the container id doesn't correspond to the id of the plugin + // container we're not interested. + if(!event.getContainerID() + .equals(UIService.CONTAINER_MAIN_TOOL_BAR)) + return; + + this.remove(c); } public void componentHidden(ComponentEvent e) diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java index d5547e0b6..ea915b293 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/ToolsMenu.java @@ -105,16 +105,22 @@ public void pluginComponentAdded(PluginComponentEvent event) { Component c = (Component) event.getSource(); - this.add(c); - - this.revalidate(); - this.repaint(); + if(event.getContainerID().equals(UIService.CONTAINER_TOOLS_MENU)) + { + this.add(c); + + this.revalidate(); + this.repaint(); + } } public void pluginComponentRemoved(PluginComponentEvent event) { Component c = (Component) event.getSource(); - this.remove(c); + if(event.getContainerID().equals(UIService.CONTAINER_TOOLS_MENU)) + { + this.remove(c); + } } } diff --git a/src/net/java/sip/communicator/service/gui/event/PluginComponentEvent.java b/src/net/java/sip/communicator/service/gui/event/PluginComponentEvent.java index 87490d60c..feb22954d 100644 --- a/src/net/java/sip/communicator/service/gui/event/PluginComponentEvent.java +++ b/src/net/java/sip/communicator/service/gui/event/PluginComponentEvent.java @@ -15,7 +15,8 @@ * @author Yana Stamcheva */ public class PluginComponentEvent - extends EventObject{ + extends EventObject +{ private int eventID = -1; @@ -31,6 +32,12 @@ public class PluginComponentEvent */ public static final int PLUGIN_COMPONENT_REMOVED = 2; + /** + * The identifier of the container to which or from which the plugin + * component is added or removed. + */ + private ContainerID containerID; + /** * Creates a new PluginComponentEvent according to the specified * parameters. @@ -40,9 +47,12 @@ public class PluginComponentEvent * @param eventID one of the PLUGIN_COMPONENT_XXX static fields indicating * the nature of the event. */ - public PluginComponentEvent(Object source, ContainerID containerID, int eventID) { + public PluginComponentEvent(Object source, ContainerID containerID, + int eventID) + { super(source); this.eventID = eventID; + this.containerID = containerID; } /** @@ -53,4 +63,15 @@ public PluginComponentEvent(Object source, ContainerID containerID, int eventID) public int getEventID(){ return eventID; } + + /** + * Returns the identifier of the container, where the plugin component, which + * is the source of this event is added or removed. + * + * @return the identifier of the plugin container + */ + public ContainerID getContainerID() + { + return containerID; + } }