Dispatches calls to addPopupMessageListener before we have initialized the SystrayService (waiting for UIService).

cusax-fix
Damian Minkov 13 years ago
parent 6476071892
commit 29cf3a8243

@ -10,6 +10,7 @@
import java.awt.event.*;
import java.net.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
import javax.swing.event.*;
@ -127,6 +128,12 @@ public class SystrayServiceJdicImpl
private final SystrayPopupMessageListener popupMessageListener
= new SystrayPopupMessageListenerImpl();
/**
* List of listeners from early received calls to addPopupMessageListener.
* Calls to addPopupMessageListener before the UIService is registered.
*/
private List<SystrayPopupMessageListener> earlyAddedListeners = null;
/**
* Initializes a new <tt>SystrayServiceJdicImpl</tt> instance.
*/
@ -432,6 +439,8 @@ public void showPopupMessage(PopupMessage popupMessage)
/**
* Implements the <tt>SystrayService.addPopupMessageListener</tt> method.
* If <tt>activePopupHandler</tt> is still not available record the listener
* so we can add him later.
*
* @param listener the listener to add
*/
@ -439,6 +448,14 @@ public void addPopupMessageListener(SystrayPopupMessageListener listener)
{
if (activePopupHandler != null)
activePopupHandler.addPopupMessageListener(listener);
else
{
if(earlyAddedListeners == null)
earlyAddedListeners =
new ArrayList<SystrayPopupMessageListener>();
earlyAddedListeners.add(listener);
}
}
/**
@ -590,6 +607,17 @@ public PopupMessageHandler setActivePopupMessageHandler(
+ newHandler);
}
activePopupHandler = newHandler;
// if we have received calls to addPopupMessageListener before
// the UIService is registered we should add those listeners
if(earlyAddedListeners != null)
{
for(SystrayPopupMessageListener l : earlyAddedListeners)
activePopupHandler.addPopupMessageListener(l);
earlyAddedListeners.clear();
earlyAddedListeners = null;
}
return oldHandler;
}

Loading…
Cancel
Save