Updates callinfo plugin to be able to add its button to more locations.

cusax-fix
Damian Minkov 13 years ago
parent 11997123d4
commit d9ea78e35d

@ -484,6 +484,8 @@ plugin.whiteboard.TEXT2_ICON=resources/images/plugin/whiteboard/text2.png
# contactinfo plugin icons
plugin.contactinfo.CONTACT_INFO_ICON=resources/images/plugin/contactinfo/userInfo16x16.png
plugin.contactinfo.CONTACT_INFO_TOOLBAR=resources/images/plugin/contactinfo/chatWindowUserInfo.png
plugin.contactinfo.CONTACT_INFO_CALL_WINDOW=resources/images/plugin/contactinfo/callUserInfo.png
# keybinding
plugin.keybinding.PLUGIN_ICON=resources/images/plugin/keybindingchooser/pluginIcon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

@ -3,9 +3,11 @@
import java.util.*;
import net.java.sip.communicator.service.browserlauncher.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.*;
import org.jitsi.service.configuration.*;
import org.osgi.framework.*;
/**
@ -18,8 +20,32 @@ public class ContactInfoActivator implements BundleActivator
{
private Logger logger = Logger.getLogger(ContactInfoActivator.class);
/**
* Indicates if the contact info button is enabled in the chat window.
*/
private static final String ENABLED_IN_CHAT_WINDOW_PROP
= "net.java.sip.communicator.plugin.contactinfo." +
"ENABLED_IN_CHAT_WINDOW_PROP";
/**
* Indicates if the contact info button is enabled in the call window.
*/
private static final String ENABLED_IN_CALL_WINDOW_PROP
= "net.java.sip.communicator.plugin.contactinfo." +
"ENABLED_IN_CALL_WINDOW_PROP";
private static BrowserLauncherService browserLauncherService;
/**
* The image loader service implementation.
*/
private static ImageLoaderService imageLoaderService = null;
/**
* The contact list service implementation.
*/
private static MetaContactListService metaCListService;
static BundleContext bundleContext;
/**
@ -41,7 +67,33 @@ public void start(BundleContext bc) throws Exception
cinfoMenuItem,
containerFilter);
if (logger.isInfoEnabled())
if(getConfigService().getBoolean(ENABLED_IN_CHAT_WINDOW_PROP, false))
{
containerFilter = new Hashtable<String, String>();
containerFilter.put(
Container.CONTAINER_ID,
Container.CONTAINER_CHAT_TOOL_BAR.getID());
bundleContext.registerService(
PluginComponent.class.getName(),
new ContactInfoMenuItem(Container.CONTAINER_CHAT_TOOL_BAR),
containerFilter);
}
if(getConfigService().getBoolean(ENABLED_IN_CALL_WINDOW_PROP, false))
{
containerFilter = new Hashtable<String, String>();
containerFilter.put(
Container.CONTAINER_ID,
Container.CONTAINER_CALL_DIALOG.getID());
bundleContext.registerService(
PluginComponent.class.getName(),
new ContactInfoMenuItem(Container.CONTAINER_CALL_DIALOG),
containerFilter);
}
if (logger.isInfoEnabled())
logger.info("CONTACT INFO... [REGISTERED]");
}
@ -68,4 +120,53 @@ public static BrowserLauncherService getBrowserLauncher()
return browserLauncherService;
}
}
/**
* Returns the imageLoaderService instance, if missing query osgi for it.
* @return the imageLoaderService.
*/
public static ImageLoaderService getImageLoaderService()
{
if(imageLoaderService == null)
{
imageLoaderService =
ServiceUtils.getService(
bundleContext,
ImageLoaderService.class);
}
return imageLoaderService;
}
/**
* Returns the <tt>MetaContactListService</tt> obtained from the bundle
* context.
* @return the <tt>MetaContactListService</tt> obtained from the bundle
* context
*/
public static MetaContactListService getContactListService()
{
if (metaCListService == null)
{
metaCListService
= ServiceUtils.getService(
bundleContext,
MetaContactListService.class);
}
return metaCListService;
}
/**
* Returns a reference to a ConfigurationService implementation currently
* registered in the bundle context or null if no such implementation was
* found.
*
* @return a currently valid implementation of the ConfigurationService.
*/
public static ConfigurationService getConfigService()
{
return ServiceUtils.getService(bundleContext,
ConfigurationService.class);
}
}

@ -11,9 +11,12 @@
import javax.swing.*;
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.gui.Container;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.resources.*;
/**
*
@ -23,16 +26,29 @@ public class ContactInfoMenuItem
extends AbstractPluginComponent
implements ActionListener
{
private JMenuItem menuItem = null;
private AbstractButton menuItem = null;
private MetaContact metaContact;
/**
* The button index, for now placed on last position.
*/
private final static int CONTACT_INFO_BUTTON_IX = 50;
/**
* Creates a <tt>ContactInfoMenuItem</tt>.
*/
public ContactInfoMenuItem()
{
super(Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU);
this(Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU);
}
/**
* Creates a <tt>ContactInfoMenuItem</tt>.
*/
public ContactInfoMenuItem(Container container)
{
super(container);
}
/**
@ -45,11 +61,32 @@ public void setCurrentContact(MetaContact metaContact)
this.metaContact = metaContact;
}
/*
* Implements PluginComponent#setCurrentContact(Contact).
* @param contact the currently selected contact
*/
@Override
public void setCurrentContact(Contact contact)
{
if(metaContact == null)
{
// search for the metacontact
MetaContactListService mcs =
ContactInfoActivator.getContactListService();
metaContact =
mcs.findMetaContactByContact(contact);
}
}
/**
* Initializes and shows the contact details dialog.
*/
public void actionPerformed(ActionEvent e)
{
if(metaContact == null)
return;
ContactInfoDialog cinfoDialog = new ContactInfoDialog(metaContact);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
@ -69,14 +106,59 @@ public String getName()
return getMenuItem().getText();
}
private JMenuItem getMenuItem()
private AbstractButton getMenuItem()
{
if(menuItem == null)
{
menuItem =
new JMenuItem(Resources.getString("service.gui.CONTACT_INFO"),
new ImageIcon(Resources.getImage(
"plugin.contactinfo.CONTACT_INFO_ICON")));
if(getContainer().equals(Container.CONTAINER_CHAT_TOOL_BAR))
{
menuItem =
new SIPCommButton(null,
(Image)ContactInfoActivator.getImageLoaderService()
.getImage(new ImageID(
"plugin.contactinfo.CONTACT_INFO_TOOLBAR")))
{
/**
* Returns the button index.
* @return the button index.
*/
public int getIndex()
{
return CONTACT_INFO_BUTTON_IX;
}
};
menuItem.setPreferredSize(new Dimension(25, 25));
menuItem.setToolTipText(
Resources.getString("service.gui.CONTACT_INFO"));
}
else if(getContainer().equals(Container.CONTAINER_CALL_DIALOG))
{
menuItem =
new SIPCommButton(null,
(Image)ContactInfoActivator.getImageLoaderService()
.getImage(new ImageID(
"plugin.contactinfo.CONTACT_INFO_CALL_WINDOW")))
{
/**
* Returns the button index.
* @return the button index.
*/
public int getIndex()
{
return CONTACT_INFO_BUTTON_IX;
}
};
menuItem.setPreferredSize(new Dimension(44, 38));
menuItem.setToolTipText(
Resources.getString("service.gui.CONTACT_INFO"));
}
else
menuItem =
new JMenuItem(
Resources.getString("service.gui.CONTACT_INFO"),
new ImageIcon(Resources.getImage(
"plugin.contactinfo.CONTACT_INFO_ICON")));
menuItem.addActionListener(this);
}

@ -12,6 +12,7 @@ Import-Package: org.osgi.framework,
net.java.sip.communicator.service.gui.event,
net.java.sip.communicator.service.protocol,
org.jitsi.service.resources, net.java.sip.communicator.service.resources,
org.jitsi.service.configuration,
net.java.sip.communicator.util,
net.java.sip.communicator.plugin.desktoputil,
javax.swing,

Loading…
Cancel
Save