diff options
author | Damian Minkov <damencho@jitsi.org> | 2012-11-21 11:18:22 +0000 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2012-11-21 11:18:22 +0000 |
commit | e2ef092f63761dccd574e0b10b9e6f0f06bc852d (patch) | |
tree | 215262f6af4c5d6d044077cd2de9736b15870630 /src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java | |
parent | 4c18b35618bbca851d247826f9d340e4209bb96f (diff) | |
download | jitsi-e2ef092f63761dccd574e0b10b9e6f0f06bc852d.zip jitsi-e2ef092f63761dccd574e0b10b9e6f0f06bc852d.tar.gz jitsi-e2ef092f63761dccd574e0b10b9e6f0f06bc852d.tar.bz2 |
Reverts some changes from previous build. Fixes tests.
Diffstat (limited to 'src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java')
-rw-r--r-- | src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java b/src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java index 0fc9e00..d6f9446 100644 --- a/src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java +++ b/src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java @@ -37,7 +37,6 @@ import com.apple.eawt.*; * @author Yana Stamcheva * @author Lyubomir Marinov * @author Symphorien Wanko - * @author Damian Minkov */ public class SystrayServiceJdicImpl implements SystrayService @@ -163,6 +162,33 @@ public class SystrayServiceJdicImpl { 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 class SystrayServiceJdicImpl if ((activePopupHandler == null) && (pmh != null)) setActivePopupMessageHandler(pmh); - SwingUtilities.invokeLater(new Runnable() { public void run() @@ -707,4 +732,35 @@ public class SystrayServiceJdicImpl } } } + + /** + * 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(); + } + } + } + } } |