Package ucar.nc2.util
Class ListenerManager
- java.lang.Object
-
- ucar.nc2.util.ListenerManager
-
@Deprecated @ThreadSafe public class ListenerManager extends Object
Deprecated.will move in ver 6Helper class for managing event listeners. It is thread safe, but better not to be adding/deleting listeners while sending events. LOOK Probably could replace with guava eventbus Example:private void createListenerManager() { lm = new ListenerManager( "ucar.nc2.util.DatasetCollectionManager$EventListener", "ucar.nc2.util.DatasetCollectionManager$Event", "setMessage"); } public void addEventListener(EventListener l) { lm.addListener(l); } public void removeEventListener(EventListener l) { lm.removeListener(l); } public class Event extends java.util.EventObject { private String message; Event(String message) { super(DatasetCollectionManager.this); this.message = message; } public String getMessage() { return message; } } public static interface EventListener { public void setMessage(DatasetCollectionManager.Event event); } lm.sendEvent(event);
-
-
Constructor Summary
Constructors Constructor Description ListenerManager(String listener_class, String event_class, String method_name)
Deprecated.Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addListener(Object l)
Deprecated.Add a listener.boolean
getEnabled()
Deprecated.boolean
hasListeners()
Deprecated.void
removeListener(Object l)
Deprecated.Remove a listener.void
sendEvent(EventObject event)
Deprecated.Send an event to all registered listeners.void
sendEventExcludeSource(EventObject event)
Deprecated.Send an event to all registered listeners, except the named one.void
setEnabled(boolean enabled)
Deprecated.
-
-
-
Constructor Detail
-
ListenerManager
public ListenerManager(String listener_class, String event_class, String method_name)
Deprecated.Constructor.- Parameters:
listener_class
- the name of the EventListener class, eg "ucar.unidata.ui.UIChangeListener"event_class
- the name of the Event class, eg "ucar.unidata.ui.UIChangeEvent"method_name
- the name of the EventListener method, eg "processChange".This method must have the signature public void method_name( event_class e)
-
-
Method Detail
-
setEnabled
public void setEnabled(boolean enabled)
Deprecated.
-
getEnabled
public boolean getEnabled()
Deprecated.
-
addListener
public void addListener(Object l)
Deprecated.Add a listener.- Parameters:
l
- listener must be of type "listener_class"
-
removeListener
public void removeListener(Object l)
Deprecated.Remove a listener.- Parameters:
l
- listener must be of type "listener_class"
-
hasListeners
public boolean hasListeners()
Deprecated.
-
sendEvent
public void sendEvent(EventObject event)
Deprecated.Send an event to all registered listeners. If an exception is thrown, remove the Listener from the list- Parameters:
event
- the event to be sent: public void method_name( event_class event)
-
sendEventExcludeSource
public void sendEventExcludeSource(EventObject event)
Deprecated.Send an event to all registered listeners, except the named one.- Parameters:
event
- the event to be sent: public void method_name( event_class event)
-
-