Class VSParticipantsHolder

All Implemented Interfaces:
EventListener, IGProp<GProp<?>[]>, IPropCnr, Cloneable
Direct Known Subclasses:
EditorVSParticipantsHolder

public class VSParticipantsHolder extends ReferralsHolder
This class is a child of the VirtualSpace and contains the participants in the VirtualSpace. It has routines to determine the appropriate panel to display, etc, for Gyro. The container has instances of VSParticipantReference's.
Author:
Christopher Mindus
  • Constructor Details

    • VSParticipantsHolder

      public VSParticipantsHolder()
      Creates a VSParticipantsHolder container without name.
    • VSParticipantsHolder

      public VSParticipantsHolder(Atom name)
      Creates a VSParticipantsHolder container with a name.
      Parameters:
      name - The name of the container.
  • Method Details

    • isPropPrivateAtCreation

      protected boolean isPropPrivateAtCreation()
      This property container is private and not transported to remote party.
      Overrides:
      isPropPrivateAtCreation in class GProp<GProp<?>[]>
      Returns:
      true if the property should be set to private at creation, false for default.
    • clone

      public VSParticipantsHolder clone()
      Clones the instance.
      Overrides:
      clone in class PropCnr
      Returns:
      The clone.
    • getVirtualSpace

      public VirtualSpace getVirtualSpace()
      Gets the VirtualSpace associated with this participant holder.
      Returns:
      The VirtualSpace, or null if not added yet.
    • add

      public void add(IVSParticipant participant, IComplexOperation op)
      Adds a new participant.
      Parameters:
      participant - The participant.
      op - The undo/redo operation, null to add it directly.
    • remove

      public boolean remove(IVSParticipant participant, IComplexOperation op)
      Removes an existing participant.
      Parameters:
      participant - The participant.
      op - The undo/redo operation, null to remove it directly.
      Returns:
      true for success, false for nothing performed participant not found.
    • remove

      public boolean remove(String ref, IComplexOperation op)
      Removes an existing participant.
      Parameters:
      ref - The participant reference.
      op - The undo/redo operation, null to remove it directly.
      Returns:
      true for success, false for nothing performed participant not found.
    • contains

      public boolean contains(IVSParticipant participant)
      Checks if the participant is present in this container.
      Parameters:
      participant - The participant.
      Returns:
      true if participant is found.
    • contains

      public boolean contains(String reference)
      Checks if the participant is present in this container.
    • getParticipants

      public <PC extends PropCnr> PC[] getParticipants(Class<PC> propClass)
      Gets all the participants of a certain type, e.g. UIPanel's. The result will be cached and is very fast.

      DO NOT MODIFY the return value!

      Parameters:
      propClass - The participant type.
      Returns:
      The array of the requested type.
    • onPropInvalidateCache

      protected void onPropInvalidateCache()
      Invalidates a potential cache in this property. This method is called during a synchronized state of the property. Subclasses override this method to provide a robust caching mechanism.
      Overrides:
      onPropInvalidateCache in class GProp<GProp<?>[]>
    • onEventSelf

      public void onEventSelf(GEvent event)
      Checks for state change events and fires it to listeners.
      Specified by:
      onEventSelf in interface IGProp<GProp<?>[]>
      Overrides:
      onEventSelf in class GProp<GProp<?>[]>
      Parameters:
      event - The property event.
    • setVirtualSpace

      public static boolean setVirtualSpace(IVSParticipant participant, VirtualSpace virtualSpace, IComplexOperation op)
      Sets, changes or removes the VirtualSpace reference of a participant, and keeps the participant lists in step with it in the same operation: the participant leaves the list of the VirtualSpace it referred to and joins the list of the new one. With the reference already set, a missing entry in the new VirtualSpace is added, which repairs the list.

      The old VirtualSpace is read before the reference changes, because a reference resolves again as soon as its value is set. A reference that does not resolve names no VirtualSpace, so there is no list to remove the participant from.

      This is the one implementation for the Designer, where op records every change for Undo/Redo so that one Undo restores the reference and the entry together, and for the direct path with a null op.

      Parameters:
      participant - The participant.
      virtualSpace - The new VirtualSpace, null to remove the reference.
      op - The undo/redo operation, null to perform the changes directly.
      Returns:
      true if anything changed, false if the reference and the lists were already in step.
    • removeParticipants

      public static int removeParticipants(GProp<?>[] props, IComplexOperation op)
      Removes the participants that a deletion takes away from the lists of their VirtualSpaces, in the same operation as the deletion. Call it BEFORE the properties are removed, while their VirtualSpace references still resolve.

      A deleted property takes a participant away when it is a participant's VirtualSpace reference, when it is a participant, or when participants are in its tree (a folder, a file).

      The reverse direction is kept in step the same way: a deleted list entry takes away the VirtualSpace reference of the participant it names, when that participant refers to the entry's VirtualSpace and no other entry of the list names it (a duplicate, which the verification reports). An entry that does not resolve, or whose participant refers elsewhere, is stale and goes alone.

      Parameters:
      props - The properties about to be deleted.
      op - The undo/redo operation of the deletion, null to remove the entries directly.
      Returns:
      The count of entries and references removed.
    • addParticipants

      public static int addParticipants(GProp<?>[] props, IComplexOperation op)
      Adds the participants that a paste brings in to the lists of their VirtualSpaces, in the same operation as the paste: the mirror of removeParticipants(GProp[], IComplexOperation). Call it AFTER the properties are in the tree, when their names are final and their VirtualSpace references resolve.

      A pasted property brings in a participant when it is a participant's VirtualSpace reference, when it is a participant, or when participants are in its tree (a folder, a file). Each one joins the list of the VirtualSpace its reference resolves to, under its own name: the copy of a listed panel is listed beside its original, and a panel pasted after a Cut, which removed its entry, is listed again.

      No entry is added for a reference that does not resolve (there is no list to join), for a participant that is listed already, or to a list that cannot be written (the VirtualSpace, or a container above it, is read-only). The verification of the participant's reference then reports the missing entry, with its Quick Fix, as before.

      Parameters:
      props - The properties the paste added.
      op - The undo/redo operation of the paste, null to add the entries directly.
      Returns:
      The count of entries added.
    • verify

      public boolean verify(PropVerification verification)
      Verifies this property container. The check performed is the extension of classes and that no circular reference is present.
      Specified by:
      verify in interface IGProp<GProp<?>[]>
      Overrides:
      verify in class PropCnr
      Parameters:
      verification - The property verification class.
      Returns:
      true if verification should proceed, false if disposed of and verification should not take place.
    • onVirtualSpaceVirtualized

      public void onVirtualSpaceVirtualized(VirtualSpace virtualizedVirtualSpace, IAppSessionGyro appGyro)
      Called when the VirtualSpace has been virtualized, giving the opportunity for e.g. data connectors to prepare it's virtualized counterparts if this is required.

      This call is done to the non-virtualized instance of the VirtualSpace participant.

      Client code should not call this method as it is intended to be called from the framework.

      Parameters:
      virtualizedVirtualSpace - The virtualized VirtualSpace instance.
      appGyro - The application gyro instance.