Class FormManager

All Implemented Interfaces:
HasExpirationTimeout

public class FormManager extends AbstractCollaborationManager implements HasExpirationTimeout
Manager to handle form values and field highlight state. It allows to set a value for a property and toggle the highlight of a property for a user. Handlers can be set to react when a value changes or when the highlight status changes.
Author:
Vaadin Ltd
  • Constructor Details

    • FormManager

      public FormManager(ConnectionContext context, UserInfo localUser, String topicId, CollaborationEngine collaborationEngine)
      Creates a new manager for the provided connection context.

      The provided user information is used to set the highlight for the local user with highlight(String,boolean) or highlight(String,boolean,int) (the default is false).

      Parameters:
      context - the context that manages connection status, not null
      localUser - the information of the local user, not null
      topicId - the id of the topic to connect to, not null
      collaborationEngine - the collaboration engine instance to use, not null
    • FormManager

      public FormManager(Component component, UserInfo localUser, String topicId)
      Creates a new manager for the provided component.

      The provided user information is used to set the highlight for the local user with highlight(String,boolean) or highlight(String,boolean,int) (the default is false).

      Parameters:
      component - the component which holds UI access, not null
      localUser - the information of the local user, not null
      topicId - the id of the topic to connect to, not null
  • Method Details

    • setValue

      public void setValue(String propertyName, Object value)
      Sets the value for the provided property name.
      Parameters:
      propertyName - the name of the property that is being set, not null
      value - the value to set
    • highlight

      public void highlight(String propertyName, boolean highlight)
      Sets the highlight state of the provided property name for the local user. For properties that require a field index, this defaults to 0.
      Parameters:
      propertyName - the name of the property to highlight or remove highlight, not null
      highlight - the highlight state to set
    • highlight

      public void highlight(String propertyName, boolean highlight, int fieldIndex)
      Sets the highlight state at the provided field index of the provided property name for the local user.
      Parameters:
      propertyName - the name of the property to highlight or unhighlight, not null
      highlight - the highlight state to set
      fieldIndex - the field index to highlight or unhighlight
    • setPropertyChangeHandler

      public void setPropertyChangeHandler(PropertyChangeHandler handler)
      Sets a handler which will be invoked when a property changes value.

      The handler accepts a PropertyChangeHandler.PropertyChangeEvent instance as a parameter.

      Parameters:
      handler - the property change handler, or null to remove an existing handler
    • setHighlightHandler

      public void setHighlightHandler(HighlightHandler handler)
      Sets a handler which will be invoked when a highlight is set.

      The handler accepts a HighlightHandler.HighlightContext instance as a parameter and should return a Registration which will be removed when the highlight is toggled off.

      Replacing an existing handler will remove all registrations from the previous one.

      Parameters:
      handler - the highlight handler, or null to remove an existing handler
    • setExpirationTimeout

      public void setExpirationTimeout(Duration expirationTimeout)
      Sets the expiration timeout of the field property data. If set, data is cleared when expirationTimeout has passed after the last connection to the related topic is closed. If set to null, the timeout is cancelled.
      Specified by:
      setExpirationTimeout in interface HasExpirationTimeout
      Parameters:
      expirationTimeout - the expiration timeout
    • getExpirationTimeout

      public Optional<Duration> getExpirationTimeout()
      Gets the optional expiration timeout of the field property data. An empty Optional is returned if no timeout it set, which means data is not cleared when there are no connected users to the related topic.
      Specified by:
      getExpirationTimeout in interface HasExpirationTimeout
      Returns:
      the expiration timeout