Class VSFieldEvent

All Implemented Interfaces:
IMessageBox

public class VSFieldEvent extends VSBaseEventWithTrigger<VSField>
The VirtualSpace Field Value Event is a multi-purpose event that is used for validation and conversion of a value type between two native types, e.g. to convert a Value from an SQL Time instance to a Boolean (where the Boolean meaning could be "Working Hours 08:00-17:00").

The class has 4 members that are public and read-only: operation, sourceType, targetType, and originalValue.

The VALIDATE event is fired when the VirtualSpace Field Value needs validation of the value to set.

The CONVERT_TO_NATIVE or CONVERT_FROM_NATIVE is fired when required (but cached result is kept).

Author:
Christopher Mindus
  • Field Details

    • operation

      public final VSFieldEvent.Op operation
      The operation.
    • originalValue

      public final Object originalValue
      The original value, null when none applies.
    • sourceType

      public final Value.Type sourceType
      The convert-from-type of Value.

      This value is also set to the validating value.

    • targetType

      public final Value.Type targetType
      The convert-to-type of value.

      This value is also set to the validating value.

  • Constructor Details

    • VSFieldEvent

      public VSFieldEvent(VSField source, VSFieldEvent.Op operation, Object value, Value.Type sourceType, Value.Type targetType, GProp<?> trigger)
      Constructs the event for an action to use with value conversion.
      Parameters:
      source - The field.
      operation - Operation to perform.
      value - The value to convert.
      sourceType - The source value type.
      targetType - The target value type.
      Throws:
      NullPointerException - If the source is null.
    • VSFieldEvent

      public VSFieldEvent(VSField source, Value value, GProp<?> trigger)
      Constructs the validation event for an action with a property being the trigger source, e.g. an UIButton or UICheckBox.
      Parameters:
      source - The field.
      value - The value being validated.
      trigger - The trigger property, null for none.
      Throws:
      NullPointerException - If the source or field Raw value is null.
      IllegalArgumentException - If the native form doesn't match what is expected.
  • Method Details

    • getSource

      public VSField getSource()
      Gets the VirtualSpace Field that is the source of the event.
      Overrides:
      getSource in class BaseEvent<VSField>
      Returns:
      The VirtualSpace Field as source.
    • setConvertedValue

      public void setConvertedValue(Object value)
      Sets the converted value and marks the event as handled.
      Parameters:
      value - The value as requested by the conversion.
      Throws:
      NullPointerException - If the value is null.
      IllegalArgumentException - If the value class is not matching the expected conversion in toType.
    • getConvertedValue

      public Object getConvertedValue()
      Gets the converted value.
      Returns:
      The converted value, or null if not yet converted.
    • setMessage

      public void setMessage(PlainKString message, VSFieldEvent.Category category)
      Sets the validation message.
      Parameters:
      message - The message to set, null to clear message (category will not be changed).
      category - The Category NONE (-1, default value), INFORMATION (0), WARNING (1) or ERROR (2).
      Throws:
      NullPointerException - If message or category is null.
    • getCategory

      public VSFieldEvent.Category getCategory()
      Gets the message category.
      Returns:
      The Category NONE (-1, default value), INFORMATION (0), WARNING (1) or ERROR (2).
    • getMessage

      public PlainKString getMessage()
      Gets the message.
      Returns:
      A message, or null for none.
    • stopPropagation

      public void stopPropagation()
      Stops propagation of the event in the event processor chain.
    • doStopPropagation

      public boolean doStopPropagation()
      Checks if propagation is stopped.
    • setHandled

      public void setHandled()
      Marks the event as handled and no further processing by other processors should be done.
    • hasBeenHandled

      public boolean hasBeenHandled()
      Checks if the event has been handled and no further processing by other processors should be done.
    • paramString

      protected String paramString()
      Gets the parameter string.
      Overrides:
      paramString in class VSBaseEventWithTrigger<VSField>