How to write GUI plugins
Register a plugin component
In order to add the plugin component in the desired placed in the UI you should return to the bundle activator file. Plugin components are not directly added to the UI, instead they have to register into the OSGi bundle context as implementations of one of the services in net.java.sip.communicator.service.gui.
Create an instance of your plugin component and a containerFilter as shown below. Then use bc.registerService() to register the component to the OSGi bundle.
In the example below we add the previously defined ExamplePluginMenuItem to the menu which is opened by clicking the right mouse button over a contact.
import java.util.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
public class ExamplePluginActivator implements BundleActivator
{
public void start(BundleContext bc) throws Exception
{
ExamplePluginMenuItem examplePlugin = new ExamplePluginMenuItem();
Hashtable<String, String> containerFilter
= new Hashtable<String, String>();
containerFilter.put(
Container.CONTAINER_ID,
Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.getID());
bc.registerService( PluginComponent.class.getName(),
examplePlugin,
containerFilter);
}
public void stop(BundleContext bc) throws Exception
{
}
}