Class VSRelativeReference<TARGET extends VSComponent>

java.lang.Object
com.iizix.prop.GProp<String>
com.iizix.prop.StringProp
com.iizix.prop.vs.VSRelativeReference<TARGET>
All Implemented Interfaces:
EventListener, IGProp<String>, IPropReference, IReferencingGProp, Cloneable
Direct Known Subclasses:
VSActionReference, VSColumnReference, VSComponentReference, VSFieldReference, VSFocusReference, VSGroupReference, VSOnUIEvent, VSTableColumnReference, VSTableReference

public abstract class VSRelativeReference<TARGET extends VSComponent> extends StringProp implements IPropReference, IReferencingGProp
The VirtualSpace Relative Reference property class hold the reference to a VirtualSpace.
Author:
Christopher Mindus
  • Field Details

    • reference

      protected PropReference reference
      The instance of the property reference.
    • vsRefBase

      protected String vsRefBase
      The current VSReference base.
    • currentTarget

      protected TARGET extends VSComponent currentTarget
      The current target reference.
    • fixedTarget

      protected TARGET extends VSComponent fixedTarget
      The current target reference. This reference may be virtualized or not depending on if this reference is located in the VirtualSpace being virtualized (not probable), or if it's located in e.g. a panel that is virtualized caused by a VirtualSpace. This instance is then kept as long as the reference string is not changed. If it is changed, this relative-reference-property reverts back to non-fixed mode.
  • Constructor Details

    • VSRelativeReference

      public VSRelativeReference()
      Creates a VirtualSpace Reference property with no name and with a null value.
    • VSRelativeReference

      public VSRelativeReference(Atom propertyAtom)
      Creates a VirtualSpace Reference property with the specified name with a null value.
      Parameters:
      propertyAtom - the property atom.
    • VSRelativeReference

      public VSRelativeReference(Atom propertyAtom, String newValue)
      Creates a VirtualSpace Reference property with the specified name and value.
      Parameters:
      propertyAtom - the property atom.
      newValue - the new string value for the property.
  • Method Details

    • isPropPrivateAtCreation

      protected boolean isPropPrivateAtCreation()
      Called upon creation of the property to check it's private state. This is used by properties that are not distributed to the remote party.
      Overrides:
      isPropPrivateAtCreation in class GProp<String>
      Returns:
      true, always.
    • disposeReference

      protected void disposeReference()
      Disposes and clears the reference.
    • onPropDispose

      protected void onPropDispose()
      Property disposed of: dispose of reference.
      Overrides:
      onPropDispose in class GProp<String>
    • clone

      public VSRelativeReference<TARGET> clone()
      Overrides clone to clear existing reference.
      Overrides:
      clone in class StringProp
      Returns:
      A new cloned String property.
    • virtualize

      protected VSRelativeReference<TARGET> virtualize(IAppSessionGyro appGyro, IClientSessionGyro clientGyro, VirtualSpace virtualSpace) throws CloneNotSupportedException, PropException
      Call this method to "virtualize" a property tree. This method is used at runtime in the Server for the application session of virtual instances of VirtualSpace, but also virtual instances of panels, for the individual client session. The VirtualSpace is virtualized once for the application session and is shared for parallel client sessions.

      This method is similar to cloning, but enables references that are already resolved to remain if they point to a shared instance, e.g. the VirtualSpace pointing to its participants in the application property container shared instance, or a panel with references to text IDs, assets, etc.

      It is up to the property class to handle this by overriding this method.

      Overrides:
      virtualize in class GProp<String>
      Parameters:
      appGyro - The application gyro instance performing the virtualization.
      clientGyro - The client gyro session, can be null if not initialized from the client gyro.
      virtualSpace - The virtualized VirtualSpace.
      Returns:
      The virtualized property.
      Throws:
      CloneNotSupportedException - If a subclass doesn't allow cloning, e.g. the client properties.
      PropException - For property errors during the virtualization.
      IllegalStateException - IllegalStateException if the property is in an invalid state, e.g. in virtualizing state or if in
    • equalsErrors

      protected boolean equalsErrors(PropError pe1, PropError pe2, int how)
      Processes error property verification. The default processing is to verify the two error properties pe1 and pe2 for equality if includeErrors is 0 or 1, and returns true if the value is 2=no comparison with error properties.

      Override to verify property errors for reference properties.

      Overrides:
      equalsErrors in class GProp<String>
      Parameters:
      pe1 - The first error property, may be null.
      pe2 - The second error property, may be null.
      how - Flags EQC_* values for equal checking.
      Returns:
      Equality flag depending on includeErrors value.
    • onEventSelf

      public final void onEventSelf(GEvent event)
      Called when a property event is send to this property.

      A subclass can override this method to perform appropriate processing and is not required to call super.onEventSelf(e).

      Specified by:
      onEventSelf in interface IGProp<TARGET extends VSComponent>
      Overrides:
      onEventSelf in class GProp<String>
      Parameters:
      event - The property event.
    • onReferenceEvent

      protected void onReferenceEvent(ResolveReferencesEvent event)
      Called to perform reference resolving. A property should override this method if it needs to perform reference resolving and validation.

      Subclasses override this method and only subclasses extending PropCnr needs to call super.onReferenceEvent(ResolveReferenceEvent event).

      Overrides:
      onReferenceEvent in class GProp<String>
      Parameters:
      event - The resolve references event.
    • onPropParentChanged

      protected final void onPropParentChanged(PropCnr oldParent, PropCnr newParent)
      The parent has been changed, if added to a container or moved, recheck the reference.
      Overrides:
      onPropParentChanged in class GProp<String>
      Parameters:
      oldParent - The old parent (or null if none).
      newParent - The new parent (or null if none).
    • resolve

      public void resolve(boolean doReCheck, GEvent event)
      Resolves the reference.
      Parameters:
      doReCheck - Performs a re-check in case e.g. reference class type changes.
      event - The triggering event, null for none.
    • getReference

      public String getReference()
      Gets the full reference string.
      Returns:
      The full reference string, or another reference string for failure in case it cannot be retrieved, or null for no reference defined.
    • onVSReferenceChanged

      protected void onVSReferenceChanged(GEvent event)
      Rechecks the reference, the VSReference has changed.
    • setInvalid

      protected void setInvalid()
      Sets as invalid.
    • createReference

      protected void createReference(GEvent event)
      Creates the reference.
    • resolve

      protected final void resolve(PropReference ref, boolean doReCheck, GEvent event)
      Resolves the reference.
    • onReferenceEvent

      public void onReferenceEvent(PropReference reference, IPropReference.ReferenceChangeEvent event, GEvent triggerEvent)
      Called when a property reference event occurs. The events are ReferenceChangeEvent.FOUND, FOUND_WRONG_CLASS, RENAMED, MOVED, NEW_PROPERTY, BROKEN.
      Specified by:
      onReferenceEvent in interface IPropReference
      Parameters:
      reference - The property reference object.
      event - The event.
      triggerEvent - The event that triggered this reference event, null for none.
    • clearError

      protected final void clearError()
      Clears the error.
    • addError

      protected final void addError(String err)
      Adds an error.
    • targetChanged

      protected final void targetChanged(GProp<?> prop)
      Internal method called when target changes.
    • getVSTarget

      public final TARGET getVSTarget()
      Gets the target VS component.
      Returns:
      The target resolved, null for none (or not a valid reference).
    • isReferenceValid

      public boolean isReferenceValid(GProp<?> property)
      Validates the property reference that has been looked up. Override to provide additional functionality than checking for property class type matching with getPropertyClass().
      Specified by:
      isReferenceValid in interface IPropReference
      Parameters:
      property - The property to validate.
      Returns:
      true if valid, false otherwise.
    • onVirtualizationCompleted

      protected void onVirtualizationCompleted(IAppSessionGyro appGyro, IClientSessionGyro clientGyro, VirtualSpace virtualSpace, boolean isPostResolve)
      Called when virtualization completed.

      This method is called to the entire tree of the newly virtualized property container.

      Overrides:
      onVirtualizationCompleted in class GProp<String>
      Parameters:
      appGyro - The application gyro instance performing the virtualization.
      clientGyro - The client gyro session, can be null if not initialized from the client gyro.
      virtualSpace - The virtualized VirtualSpace.
      isPostResolve - Flag indicating this call is done after references are attempted to be resolved.
    • paramString

      protected String paramString()
      Returns the parameter string representing the state of this event. This string is useful for debugging. Subclasses adds extra information to the string by preceding it with a comma followed by the extra information.
      Overrides:
      paramString in class GProp<String>
      Returns:
      the parameter string of this event.
    • getPropertyClass

      public abstract Class<? extends GProp<?>> getPropertyClass()
      Gets the class wanted.
    • getReferenceType

      public abstract IPropReference.IRefType getReferenceType()
      Gets the reference Type.
      Specified by:
      getReferenceType in interface IPropReference
      Specified by:
      getReferenceType in interface IReferencingGProp
      Returns:
      The reference type, generally a value from the enum IPropReference.RefType, otherwise a static final implementation of the reference type with locale support.
    • onResolved

      protected abstract void onResolved(TARGET target)
      Called when the property reference has been resolved.
      Parameters:
      target - The target reference.
    • onRemoved

      protected abstract void onRemoved(TARGET oldTarget)
      Called when the property reference has been disposed of e.g. due to new reference or pure disposal of this property.
      Parameters:
      oldTarget - The old target reference.