|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.pogamut.base.communication.worldview.react.EventReact<EVENT>
EVENT
- public abstract class EventReact<EVENT extends IWorldEvent>
This abstract class allows you to easily hook a specific event-handling behavior. It automatically
register a listener for a specified IWorldEvent
for you and calls react(IWorldEvent)
method automatically.
If you need to react only once to the event, use EventReactOnce
.
Use enable()
and disable()
to enable react / disable react. The reaction is enabled
as default.
WARNING:Use as anonymous class, but save it as a field of your class! Note, that we're using weak-references to listeners and if you do not save pointer to the object, it will be gc()ed!
Field Summary | |
---|---|
protected java.lang.Class<EVENT> |
reactEventClass
|
protected IWorldEventListener<EVENT> |
reactListener
|
protected IWorldView |
reactWorldView
|
Constructor Summary | |
---|---|
EventReact(java.lang.Class<EVENT> eventClass,
IWorldView worldView)
|
Method Summary | |
---|---|
void |
disable()
Disables the reaction. |
void |
enable()
Enables the reaction. |
protected void |
postReact(EVENT event)
post- react(IWorldEvent) hook allowing you to do additional work after the react method. |
protected void |
preReact(EVENT event)
pre- react(IWorldEvent) hook allowing you to do additional work before the react method. |
protected abstract void |
react(EVENT event)
React upon event notification. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected IWorldEventListener<EVENT extends IWorldEvent> reactListener
protected IWorldView reactWorldView
protected java.lang.Class<EVENT extends IWorldEvent> reactEventClass
Constructor Detail |
---|
public EventReact(java.lang.Class<EVENT> eventClass, IWorldView worldView)
Method Detail |
---|
public void disable()
public void enable()
protected void preReact(EVENT event)
react(IWorldEvent)
hook allowing you to do additional work before the react method.
event
- protected abstract void react(EVENT event)
event
- protected void postReact(EVENT event)
react(IWorldEvent)
hook allowing you to do additional work after the react method.
event
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |