Reverts some changes from previous build. Fixes tests.

cusax-fix
Damian Minkov 13 years ago
parent 4c18b35618
commit e2ef092f63

@ -27,10 +27,9 @@
*
* @author Nicolas Chamouard
* @author Lubomir Marinov
* @author Damian Minkov
*/
public class OsDependentActivator
extends AbstractServiceDependentActivator
implements BundleActivator
{
/**
* A currently valid bundle context.
@ -55,11 +54,13 @@ public class OsDependentActivator
/**
* Called when this bundle is started.
*
* @param dependentService the ui service.
* @param bc The execution context of the bundle being started.
* @throws Exception If
*/
public void start(Object dependentService)
public void start(BundleContext bc)
throws Exception
{
uiService = (UIService)dependentService;
bundleContext = bc;
try
{
@ -104,25 +105,6 @@ public void start(Object dependentService)
}
}
/**
* The class of the service which this activator is interested in.
* @return the class name of the ui service.
*/
public Class getDependentServiceClass()
{
return UIService.class;
}
/**
* Setting context to the activator, as soon as we have one.
*
* @param context the context to set.
*/
public void setBundleContext(BundleContext context)
{
bundleContext = context;
}
/**
* Called when this bundle is stopped so the Framework can perform the
* bundle-specific activities necessary to stop the bundle.
@ -188,6 +170,15 @@ public static ShutdownService getShutdownService()
*/
public static UIService getUIService()
{
if(uiService == null)
{
ServiceReference serviceRef = bundleContext
.getServiceReference(UIService.class.getName());
if (serviceRef != null)
uiService = (UIService) bundleContext.getService(serviceRef);
}
return uiService;
}

@ -37,7 +37,6 @@
* @author Yana Stamcheva
* @author Lyubomir Marinov
* @author Symphorien Wanko
* @author Damian Minkov
*/
public class SystrayServiceJdicImpl
implements SystrayService
@ -163,6 +162,33 @@ private void initSystray()
{
UIService uiService = OsDependentActivator.getUIService();
if (uiService == null)
{
/*
* Delay the call to the #initSystray() method until the UIService
* implementation becomes available.
*/
try
{
OsDependentActivator.bundleContext.addServiceListener(
new DelayedInitSystrayServiceListener(),
'('
+ Constants.OBJECTCLASS
+ '='
+ UIService.class.getName()
+ ')');
}
catch (InvalidSyntaxException ise)
{
/*
* Oh, it should not really happen. Besides, it is not clear at
* the time of this writing what is supposed to happen in the
* case of such an exception here.
*/
}
return;
}
menu = TrayMenuFactory.createTrayMenu(this, systray.isSwing());
boolean isMac = OSUtils.IS_MAC;
@ -378,7 +404,6 @@ public void popupMenuCanceled(PopupMenuEvent e)
if ((activePopupHandler == null) && (pmh != null))
setActivePopupMessageHandler(pmh);
SwingUtilities.invokeLater(new Runnable()
{
public void run()
@ -707,4 +732,35 @@ else if (serviceEvent.getType() == ServiceEvent.UNREGISTERING)
}
}
}
/**
* Implements a <tt>ServiceListener</tt> which waits for an
* <tt>UIService</tt> implementation to become available, invokes
* {@link #initSystray()} and unregisters itself.
*/
private class DelayedInitSystrayServiceListener
implements ServiceListener
{
public void serviceChanged(ServiceEvent serviceEvent)
{
if (serviceEvent.getType() == ServiceEvent.REGISTERED)
{
UIService uiService = OsDependentActivator.getUIService();
if (uiService != null)
{
/*
* This ServiceListener has successfully waited for an
* UIService implementation to become available so it no
* longer need to listen.
*/
OsDependentActivator.bundleContext.removeServiceListener(
this);
if (!initialized)
initSystray();
}
}
}
}
}

Loading…
Cancel
Save