when a PluginComponentEvent is received should check the container id in order to add it or remove it from the appropriate container

cusax-fix
Yana Stamcheva 20 years ago
parent 43187890db
commit bb4dd31981

@ -44,7 +44,6 @@
public class UIServiceImpl
implements UIService
{
private static final Logger logger = Logger.getLogger(UIServiceImpl.class);
private PopupDialogImpl popupDialog;

@ -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);
}
}
}

@ -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 <tt>ActionEvent</tt>. 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 <tt>PluginComponentListener.pluginComponentAdded</tt>
* 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 <tt>PluginComponentListener.pluginComponentRemoved</tt>
* method, in order to remove the given component from this container.
*/
public void pluginComponentRemoved(PluginComponentEvent event)
{
Component c = (Component) event.getSource();
this.remove(c);
}
}

@ -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);
}
}
/**

@ -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);
}
}
/**

@ -280,9 +280,16 @@ else if (buttonName.equals("sound"))
* Implements the <code>PluginComponentListener.pluginComponentAdded</code>
* 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)

@ -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);
}
}
}

@ -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;
}
}

Loading…
Cancel
Save