Class GEvent
- All Implemented Interfaces:
IPostEventProcessing
- Direct Known Subclasses:
BubbleEvent
,ResolveReferencesEvent
,SinkEvent
- Author:
- Christopher Mindus
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Operations enumeration when sending the from theGProp.onEvent
method.Field Summary
Modifier and TypeFieldDescriptionstatic final int
Event ID for property added event.static final int
Event ID for property attribute changed event.static final int
Event ID for property container added.static final int
Event ID for container focus.static final int
Event ID for a property container move to another container event.static final int
Event ID for property name changed event of a container.static final int
Event ID for Asset files changes in conjunction with AssetReference (only in the Designer).static final int
Event ID for Java Class changes in conjunction with ClassReference (only in the Designer).static final int
Event ID for Java Method renamed in conjunction with ClassReference (only in the Designer).static final int
Event ID for KString event.static final int
Event ID for property update for the Eclipse Common Navigator viewer (only in the Designer).static final int
Event ID for VSReference resolving in conjunction with VSRelativeReference (only in the Designer).static final int
Event ID for property disposed changed event.static final int
Event ID for component focus.static final int
Event ID for property moved from container event.static final int
Event ID for property moved to container event.static final int
Event ID for project renamed.static final int
Event ID to query properties for references.static final int
Event ID for a RefreshEvent.static final int
Event ID for property removed event.static final int
Event ID for property name changed event.static final int
Event ID for property container reordered.static final int
Event ID for resolve references.static final int
Event ID for property value changed event.static final int
Event ID for Remote Property Event.Constructor Summary
ConstructorDescriptionConstructs the generic event with specified originator without progress monitor.GEvent
(GProp<?> source, int eventID, boolean isRemoteInduced, IPropProgressMonitor monitor) Constructs the generic event with specified originator.GEvent
(GProp<?> source, int eventID, IPropProgressMonitor monitor) Constructs the generic event with specified originator that has a progress monitor and is not remote induced.Method Summary
Modifier and TypeMethodDescriptionvoid
addPostProcessor
(EventListener postProcessor) Adds a post-event processor that will be called when the event has completed its notification process.final void
cancel()
Cancel even propagation of this event.final void
consume()
Consumes this event.protected EventListener
getAlternateDestination
(GProp<?> destination, GEvent.Operation operation, int operationIndex) Gets the alternate property destination for an event about to be sent.final int
Gets the event ID.Gets the name string of the event.static String
getEventName
(int eventID) Gets the name of aneventID
.GProp
<?> Gets the event owner.Gets the current operation.abstract GEvent.Operation[]
Gets the Operations order describing what Operation the property that receives the event should process.getPostProcessors
(GProp<?> dispatcher) Gets the post-processors.final GProp
<?> Gets the current sender of the event.final GProp
<?> Gets the source of the event.IGProp
<?> Returns the trigger of this event, if any.final boolean
Checks if this event has been cancelled.boolean
Returns the state for a property container if this event is received in theonEventSelf
method as a helper for it would need to clear the property container cache.final boolean
Checks if this event has been consumed.boolean
isEventProcessed
(GProp<?> property, GEvent.Operation operation, int operationIndex) Checks if this Operation at specified index should be processed or not by the specified property.boolean
isPropertyChange
(IGProp<?> property) Checks if the event is a property value change.boolean
isPropertyChange
(PropCnr pc, Atom name) Checks if the event is a modification change of any property in the specified container.boolean
isPropertyChange
(PropCnr pc, String name) Checks if the event is a modification change of any property in the specified container.boolean
Checks if the event is a modification change of any property in the specified container.boolean
Checks if the event is a modification change of any property in the specified container or any of its children.boolean
Returns true if this is a refresh event.final boolean
Flag indicating this change is induced from a remote party.boolean
Returns if this event is a verify event for a container that processes verification.protected StringBuilder
paramString
(StringBuilder buf) Returns the parameter string representing the state of this event.final void
send
(GProp<?> sender, EventListener listener) Sends this event to the event listener in question, with "safe" processing, i.e.final void
send
(GProp<?> sender, GProp<?> receiver, GEvent.Operation operation, int operationIndex) Sends this event to the property in question, with "safe" processing, i.e.final void
sendSelf
(GProp<?> senderAndReceiver, GEvent.Operation operation, int operationIndex) Sends this event to the property itself in question, with "safe" processing, i.e.void
setInitialProperty
(GProp<?> initialDispatcher) Assigns the initial sender property that should perform post processing of events.void
setOperation
(GEvent.Operation operation) Sets the current operation.void
setProgressMonitor
(IPropProgressMonitor monitor) Sets the progress monitor if not already done.toString()
Returns a string representation of this component and its values.
Field Details
PROP_ATTR_CHANGED
public static final int PROP_ATTR_CHANGEDEvent ID for property attribute changed event.It is a bubbling event.
Event class:
com.iizix.event.PropAttrEvent
.- See Also:
PROP_VALUE_CHANGED
public static final int PROP_VALUE_CHANGEDEvent ID for property value changed event.It is a bubbling event.
Event class:
com.iizix.event.PropValueEvent
.- See Also:
PROP_ADDED
public static final int PROP_ADDEDEvent ID for property added event.It is a bubbling event.
Event class:
com.iizix.event.PropCnrEvent
.- See Also:
PROP_REMOVED
public static final int PROP_REMOVEDEvent ID for property removed event.It is a bubbling event.
Event class:
com.iizix.event.PropCnrEvent
.- See Also:
PROP_RENAMED
public static final int PROP_RENAMEDEvent ID for property name changed event.It is a bubbling event.
Event class:
com.iizix.event.PropNameEvent
.- See Also:
PROP_DISPOSED
public static final int PROP_DISPOSEDEvent ID for property disposed changed event.It is a bubbling event.
Event class:
com.iizix.event.PropDisposeEvent
.- See Also:
PROP_MOVED_FROM
public static final int PROP_MOVED_FROMEvent ID for property moved from container event. This event is triggered when the property already has been moved from the original container, and to the destination. This event is sent from the moved container and send upwards in the property hierarchy.It is a bubbling event.
Event class:
com.iizix.event.PropMoveEvent
.- See Also:
PROP_MOVED_TO
public static final int PROP_MOVED_TOEvent ID for property moved to container event. This event is triggered when the property already has been moved from the original container, and to the destination. This event is sent from the moved property already located in the moved-to-container and send upwards in the property hierarchy. Thus a property listening for move events should process this Moved-To event and not the Moved-From event.It is a bubbling event.
Event class:
com.iizix.event.PropMoveEvent
.- See Also:
PROP_REORDERED
public static final int PROP_REORDEREDEvent ID for property container reordered.It is a bubbling event.
Event class:
com.iizix.event.PropReorderEvent
.- See Also:
PROP_CNR_ADDED
public static final int PROP_CNR_ADDEDEvent ID for property container added.This is a sinking event.
Event class:
com.iizix.event.ParentCnrAddedEvent
.- See Also:
PROP_CNR_RENAMED
public static final int PROP_CNR_RENAMEDEvent ID for property name changed event of a container.This is a sinking event.
Event class:
com.iizix.event.PropNameEvent
.- See Also:
PROP_CNR_MOVED
public static final int PROP_CNR_MOVEDEvent ID for a property container move to another container event. This event is triggered when the property container already has been moved from the original container, and to the destination.This is a sinking event.
Event class:
com.iizix.event.ParentCnrMoveEvent
.- See Also:
PROP_FOCUS
public static final int PROP_FOCUSEvent ID for component focus.This is a bubbling event.
Event class:
com.iizix.event.PropFocusEvent
.- See Also:
PROP_CNR_FOCUS
public static final int PROP_CNR_FOCUSEvent ID for container focus.This is a sinking event.
Event class:
com.iizix.event.PropCnrFocusEvent
.- See Also:
PROP_RESOLVE_REFERENCES_DIRECT
public static final int PROP_RESOLVE_REFERENCES_DIRECTEvent ID for resolve references.This is a sinking event.
Event class:
com.iizix.event.ResolveReferencesEvent
.- See Also:
PROP_PROJECT_RENAMED
public static final int PROP_PROJECT_RENAMEDEvent ID for project renamed.This is a sinking event.
Event class:
com.iizix.event.ProjectNameEvent
.- See Also:
PROP_QUERY_DESIGNER_PROPS
public static final int PROP_QUERY_DESIGNER_PROPSEvent ID to query properties for references.This is a sinking event.
Event class:
com.iizigo.event.QueryDesignerPropEvent
.- See Also:
PROP_DESIGNER_VIEWER_UPDATE
public static final int PROP_DESIGNER_VIEWER_UPDATEEvent ID for property update for the Eclipse Common Navigator viewer (only in the Designer).It is a bubbling event.
Event class:
com.iizigo.event.CommonDesignerEvent
.- See Also:
PROP_DESIGNER_VS_REFERENCE
public static final int PROP_DESIGNER_VS_REFERENCEEvent ID for VSReference resolving in conjunction with VSRelativeReference (only in the Designer). The event is fired when a VSReference is resolved or broken, causing VSRelativeReference instances to re-check their state.It is a sinking event.
Event class:
com.iizix.event.VSReferenceEvent
.- See Also:
PROP_DESIGNER_ASSET_CHANGED
public static final int PROP_DESIGNER_ASSET_CHANGEDEvent ID for Asset files changes in conjunction with AssetReference (only in the Designer). The event is fired when a file property container notices a change of the file or if it removed, to re-check their state.It is a sinking event.
Event class:
com.iizix.event.AssetEvent
.- See Also:
PROP_DESIGNER_JAVA_CLASS_CHANGED
public static final int PROP_DESIGNER_JAVA_CLASS_CHANGEDEvent ID for Java Class changes in conjunction with ClassReference (only in the Designer). The event is fired when a Java source has been compiled and parsed, or if it has been reconciled. All annotations are up-to-date when the event is received.It is a sinking event.
Event class:
com.iizigo.java.event.JavaClassEvent
.- See Also:
PROP_DESIGNER_JAVA_METHOD_RENAMED
public static final int PROP_DESIGNER_JAVA_METHOD_RENAMEDEvent ID for Java Method renamed in conjunction with ClassReference (only in the Designer). The event is fired when a Java source has been compiled and parsed, or if it has been reconciled. All annotations are up-to-date when the event is received.It is a sinking event.
Event class:
com.iizigo.java.event.JavaMethodEvent
.- See Also:
PROP_DESIGNER_KSTRING
public static final int PROP_DESIGNER_KSTRINGEvent ID for KString event.It is a sinking event.
Event class:
com.iizigo.java.event.KStringEvent
.- See Also:
PROP_REFRESH
public static final int PROP_REFRESHEvent ID for a RefreshEvent.It is a sinking event.
Event class:
com.iizix.event.RefreshEvent
.- See Also:
REMOTE
public static final int REMOTEEvent ID for Remote Property Event.It is a bubbling event.
Event class:
com.iizix.event.RemoteEvent
.- See Also:
Constructor Details
GEvent
Constructs the generic event with specified originator without progress monitor.- Parameters:
source
- The source object.eventID
- The event ID, seeGEvent.PROP_*
.isRemoteInduced
- Flag indicating this change is induced from a remote party.- Throws:
NullPointerException
- If source isnull
.
GEvent
Constructs the generic event with specified originator that has a progress monitor and is not remote induced.- Parameters:
source
- The source object.eventID
- The event ID, seeGEvent.PROP_*
.monitor
- The progress monitor, null for none.- Throws:
NullPointerException
- If source isnull
.
GEvent
Constructs the generic event with specified originator.- Parameters:
source
- The source object.eventID
- The event ID, seeGEvent.PROP_*
.isRemoteInduced
- Flag indicating this change is induced from a remote party.monitor
- The progress monitor, null for none.- Throws:
NullPointerException
- If source isnull
.
Method Details
getEventName
Gets the name of aneventID
.setProgressMonitor
Sets the progress monitor if not already done. This method has no effect if the monitor is already set.getEventID
public final int getEventID()Gets the event ID.getEventName
Gets the name string of the event. Same asGEvent.getEventName(event.getEventID())
.- Returns:
- A string representation of the event ID.
getSource
Gets the source of the event.- Returns:
- The Generic Property for the event, the source, or originator.
getEventTarget
Gets the event owner. The owner is the one the message relates to e.g. the property for value change or the property being added or removed for property container events.- Returns:
- The Generic Property for the event, the source, or originator.
isRemoteInduced
public final boolean isRemoteInduced()Flag indicating this change is induced from a remote party.getOperation
Gets the current operation.setOperation
Sets the current operation. This method should not be called, it is intended forGProp.onEvent
.- Throws:
NullPointerException
- Ifoperation
is null.
isConsumed
public final boolean isConsumed()Checks if this event has been consumed.Consumed events are still propagating, so this flag is more of informational purpose.
- Returns:
- true indicates event is consumed, false indicates event is not yet consumed.
consume
public final void consume()Consumes this event.Consumed events are still propagating, so this flag is more of informational purpose.
isCancelled
public final boolean isCancelled()Checks if this event has been cancelled.- Returns:
- true indicates event is cancelled, false indicates event is not cancelled.
cancel
public final void cancel()Cancel even propagation of this event.getOperations
Gets the Operations order describing what Operation the property that receives the event should process. This Operations order defines e.g. if the event is bubbling, sinking or just private.Subclasses must implement this Operations order. They should NOT use both Sinking and Bubbling Operations, this will cause an infinite loop or stack overflow due to recursion.
- Returns:
- The order of the Operations, per Event-implementing class dependent, normally a static final array.
toString
Returns a string representation of this component and its values.paramString
Returns the parameter string representing the state of this event. This string is useful for debugging. Super classes adds extra information to the string by preceding it with a comma followed by the extra information.- Parameters:
buf
- The StringBuilder to append the string to.- Returns:
- The StringBuilder, i.e. the
buf
input parameter.
send
Sends this event to the event listener in question, with "safe" processing, i.e. that potential exceptions are caught and logged.This method is intended to be called from
GProp.onEvent(event)
. Do not call this method.This event's operation, retrieved by
getOperation()
is set to LISTENERS.- Parameters:
sender
- The sender property.listener
- The event listener.
send
public final void send(GProp<?> sender, GProp<?> receiver, GEvent.Operation operation, int operationIndex) Sends this event to the property in question, with "safe" processing, i.e. that potential exceptions are caught and logged.This method is intended to be called from
GProp.onEvent(event)
. Do not call this method.- Parameters:
sender
- The sender property.receiver
- The receiving property.operation
- The Operation.operationIndex
- The current index in the Operation array provided by this event'sgetOperations()
method.
sendSelf
public final void sendSelf(GProp<?> senderAndReceiver, GEvent.Operation operation, int operationIndex) Sends this event to the property itself in question, with "safe" processing, i.e. that potential exceptions are caught and logged. The method called for the property (that might be altered using getAlternateDestination) isonEventSelf
rather thanonEvent
.This method is intended to be called from
GProp.onEvent(event)
. Do not call this method.- Parameters:
senderAndReceiver
- The sender and received property.operation
- The Operation.operationIndex
- The current index in the Operation array provided by this event'sgetOperations()
method.
getSender
Gets the current sender of the event.getAlternateDestination
protected EventListener getAlternateDestination(GProp<?> destination, GEvent.Operation operation, int operationIndex) Gets the alternate property destination for an event about to be sent. The default is to return the same destination, but subclasses can choose to return another property that would be "more suitable" to receive the event, i.e. the property that would really do the processing. This enables performance enhancements to be done for a particular event.This method also enables an event to skip sending the event to a property by returning
null
in this method.Subclasses can override this method to provide fine-tuned behavior.
- Parameters:
destination
- The destination property.operation
- The Operation.operationIndex
- The current index in the Operation array provided by this event'sgetOperations()
method.- Returns:
destination
by default. Ifnull
is returned, this event will not be sent.
isEventProcessed
Checks if this Operation at specified index should be processed or not by the specified property.An event can fine-tune event distribution with this mechanism, thus improving performance.
This method is intended to be called from
GProp.onEvent(event)
. Do not call this method.- Parameters:
property
- The property processing the event inGEvent.onEvent(event)
.operation
- The Operation.operationIndex
- The current index in the Operation array provided by this event'sgetOperations()
method.- Returns:
- true by default. If false is returned, an event could cause e.g. the CHILDREN operation processing to be skipped for certain properties.
isClearCacheEvent
public boolean isClearCacheEvent()Returns the state for a property container if this event is received in theonEventSelf
method as a helper for it would need to clear the property container cache.- Returns:
- true if the event would require the property container to clear its cache.
isVerifyEvent
public boolean isVerifyEvent()Returns if this event is a verify event for a container that processes verification.- Returns:
- true if the event should trigger container verification, false otherwise.
addPostProcessor
Adds a post-event processor that will be called when the event has completed its notification process. This method can be called at any time during the event notification phase, but calls to this method when post-processing is executing is not going to change the post-processors, thus will thepostProcessor
not be called.Note: the post-processors are called no matter if the event has been canceled, so the processor may have to check the cancel state.
Calling this method with the same
postProcessor
more than once does not add it again.- Specified by:
addPostProcessor
in interfaceIPostEventProcessing
- Parameters:
postProcessor
- Processor to add.- Throws:
NullPointerException
- If thepostProcessor
is null.
setInitialProperty
Assigns the initial sender property that should perform post processing of events. This method should only be called from the initial GProp that sends the event the first time. This is done from the GProp.onEvent method and should not be called elsewhere.- Specified by:
setInitialProperty
in interfaceIPostEventProcessing
- Parameters:
initialDispatcher
- The initial dispatcher.
getPostProcessors
Gets the post-processors.- Specified by:
getPostProcessors
in interfaceIPostEventProcessing
- Parameters:
dispatcher
- The property retrieving the post-processors, null for none.- Returns:
- An array of the post-processors to call after all normal event notification, null for none.
isPropertyChange
Checks if the event is a property value change.- Parameters:
property
- The property.- Returns:
- true if the property just got changed in the container due to this event, false otherwise.
isPropertyChange
Checks if the event is a modification change of any property in the specified container.- Parameters:
pc
- The property container.name
- The property name to check for change.- Returns:
- true if the property just got changed in the container due to this event, false otherwise.
isPropertyChange
Checks if the event is a modification change of any property in the specified container.- Parameters:
pc
- The property container.name
- The property name to check for change.- Returns:
- true if the property just got changed in the container due to this event, false otherwise.
isPropertyChangeIn
Checks if the event is a modification change of any property in the specified container.- Parameters:
pc
- The property container.- Returns:
- true if a property just got changed in the container due to this event, false otherwise.
getTrigger
Returns the trigger of this event, if any.- Returns:
- Trigger property of this event, null for none.
isPropertyChangeInTree
Checks if the event is a modification change of any property in the specified container or any of its children.- Parameters:
pc
- The property container.- Returns:
- true if a property just got changed in the container tree due to this event, false otherwise.
isRefreshEvent
public boolean isRefreshEvent()Returns true if this is a refresh event.- Returns:
- true if this is a RefreshEvent, false otherwise. Always false if not overridden, e.g. by
RefreshEvent
.