Class Component<M extends IModel,P extends IParameterization>

java.lang.Object
com._1c.g5.aef2.components.Component<M,P>
Type Parameters:
M - the model type.
P - the parameterization type.
All Implemented Interfaces:
IComponent<M>, IEventChannel
Direct Known Subclasses:
StandardComponent

public abstract class Component<M extends IModel,P extends IParameterization> extends Object implements IComponent<M>
Base IComponent implementation.
  • Constructor Details

    • Component

      protected Component(P parameterization)
      Creates a component.
      Parameters:
      parameterization - the parameterization instance.
  • Method Details

    • getScene

      public IScene getScene()
      Specified by:
      getScene in interface IComponent<M extends IModel>
      Returns:
      the scene this component belongs to or null if component doesn't belong to a scene yet.
    • setScene

      public void setScene(IScene scene)
      Specified by:
      setScene in interface IComponent<M extends IModel>
      Parameters:
      scene - the scene to place this component in.
    • getParent

      public IComponent<?> getParent()
      Specified by:
      getParent in interface IComponent<M extends IModel>
      Returns:
      the parent component.
    • setParent

      public void setParent(IComponent<?> parent)
      Specified by:
      setParent in interface IComponent<M extends IModel>
      Parameters:
      parent - a component to set as the parent component.
    • getComponents

      public Iterable<IComponent<?>> getComponents()
      Specified by:
      getComponents in interface IComponent<M extends IModel>
      Returns:
      the child components of this component.
    • getViewModels

      public Iterable<IViewModel> getViewModels()
      Specified by:
      getViewModels in interface IComponent<M extends IModel>
      Returns:
      the view models produced by this component.
    • beginExternalUpdate

      public final void beginExternalUpdate()
      Description copied from interface: IComponent
      Begins the external update operation. All direct changes of the models associated with this component are marked as ChangeOrigin.External. End the operation with IComponent.endExternalUpdate() call, external update operations may be nested. All model direct write changes are marked as ChangeOrigin.Internal if no external update is in progress.
      Specified by:
      beginExternalUpdate in interface IComponent<M extends IModel>
    • isInExternalUpdate

      public final boolean isInExternalUpdate()
      Specified by:
      isInExternalUpdate in interface IComponent<M extends IModel>
      Returns:
      true if external update operation is in progress, false otherwise.
      See Also:
    • endExternalUpdate

      public final void endExternalUpdate()
      Description copied from interface: IComponent
      Ends the external update operation.
      Specified by:
      endExternalUpdate in interface IComponent<M extends IModel>
      See Also:
    • dispose

      public void dispose()
      Description copied from interface: IComponent
      Disposes this component, its view models and its child components.
      Specified by:
      dispose in interface IComponent<M extends IModel>
    • isDisposed

      public boolean isDisposed()
      Specified by:
      isDisposed in interface IComponent<M extends IModel>
      Returns:
      true if the component was disposed, false otherwise.
    • setModel

      public final void setModel(M model)
      Description copied from interface: IComponent
      Sets the model for this component. Component implementation may also accept the model from a constructor and call this method internally. Attaching listeners to the model should be postponed as long as possible, usually there are two safe points to start model listening: IComponent.getComponents() or IComponent.getViewModels() invocation.
      Specified by:
      setModel in interface IComponent<M extends IModel>
      Parameters:
      model - the model to set.
    • getModel

      public final M getModel()
      Specified by:
      getModel in interface IComponent<M extends IModel>
      Returns:
      the model of this component or null if component has no associated model.
    • commit

      public void commit()
      Description copied from interface: IComponent
      Commits this component changes to the model.
      Specified by:
      commit in interface IComponent<M extends IModel>
    • areChildCommitsEnabled

      public boolean areChildCommitsEnabled()
      Specified by:
      areChildCommitsEnabled in interface IComponent<M extends IModel>
      Returns:
      true if child commits are allowed, false if child commits are inhibited and this component handles a commit by itself.
    • setChildCommitsEnabled

      public void setChildCommitsEnabled(boolean value)
      Specified by:
      setChildCommitsEnabled in interface IComponent<M extends IModel>
      Parameters:
      value - true to enable child commits, false to disable them.
      See Also:
    • areChildRefreshEnabled

      public boolean areChildRefreshEnabled()
      Specified by:
      areChildRefreshEnabled in interface IComponent<M extends IModel>
      Returns:
      true if child refreshing are allowed, false if child refreshing are inhibited and this component handles a refresh by itself.
    • setChildRefreshEnable

      public void setChildRefreshEnable(boolean value)
      Specified by:
      setChildRefreshEnable in interface IComponent<M extends IModel>
      Parameters:
      value - true to enable child refreshing, false to disable them.
      See Also:
    • queueEvent

      public final void queueEvent(IEvent event)
      Description copied from interface: IEventChannel
      Queues the event to this channel.
      Specified by:
      queueEvent in interface IEventChannel
      Parameters:
      event - the event to queue.
      See Also:
    • queueAndWaitEvent

      public final void queueAndWaitEvent(IEvent event)
      Description copied from interface: IEventChannel
      Queues the event to this channel and waits for its processing done. Typically, events created as a result of the user interaction with the UI should be processed synchronously using this method.
      Specified by:
      queueAndWaitEvent in interface IEventChannel
      Parameters:
      event - the event to queue.
      See Also:
    • addListener

      public void addListener(IEventChannelListener listener)
      Description copied from interface: IEventChannel
      Adds the given listener to the channel.
      Specified by:
      addListener in interface IEventChannel
      Parameters:
      listener - the listener.
    • removeListener

      public void removeListener(IEventChannelListener listener)
      Description copied from interface: IEventChannel
      Removes the given listener from the channel.
      Specified by:
      removeListener in interface IEventChannel
      Parameters:
      listener - the listener.
    • getServiceEventQualifiers

      public Collection<IServiceEventQualifier> getServiceEventQualifiers()
      Description copied from interface: IComponent
      Returns the collection of service event qualifiers that event should be traversed to component from event tracker.
      Specified by:
      getServiceEventQualifiers in interface IComponent<M extends IModel>
      Returns:
      collection of event qualifiers.
      See Also:
    • getParameterization

      public P getParameterization()
      Returns the parameterization of the component.
      Returns:
      the parameterization of the component.
    • createComponents

      protected void createComponents()
      Creates the child components of this component. Override it to fill a component with a child components.

      Method can be called multiple times.

    • createViewModels

      protected void createViewModels()
      Creates the view models of this component. Override it to provide a view models of this component.
    • attachToModel

      protected void attachToModel()
      Attaches this component to the model. Override it to add some listeners to the model.
    • detachFromModel

      protected void detachFromModel()
      Detaches this component from the model. Override it to remove listeners from the model.
    • addComponent

      protected <C extends IComponent<?>> C addComponent(C component)
      Adds the child component.
      Returns:
      the added component.
    • removeComponent

      protected void removeComponent(IComponent<?> component)
      Removes the child component.
      Parameters:
      component - the component to remove.
    • disposeComponents

      protected void disposeComponents()
      Disposes the child components. Override it to do some additional disposal operations specific to a component.
    • addViewModel

      protected void addViewModel(IViewModel viewModel)
      Adds the view model to the view models of this component.
      Parameters:
      viewModel - the view model to add.
    • removeViewModel

      protected void removeViewModel(IViewModel viewModel)
      Removes the view model from the view models of this component.
      Parameters:
      viewModel - the view model to remove.
    • disposeViewModels

      protected void disposeViewModels()
      Disposes the view models of this component. Override it to do some additional disposal operations specific to a component.
    • areComponentsCreated

      protected final boolean areComponentsCreated()
      Returns:
      true if child components have been created, false otherwise
    • getRunnableQueue

      protected final IRunnableQueue getRunnableQueue()
      Returns:
      this component's runnable queue.
      See Also:
    • checkComponents

      protected final void checkComponents()
      Checks that the child components are actually created.
    • checkViewModels

      protected final void checkViewModels()
      Checks that the view models of this components are actually created.
    • subscribeOnEvents

      protected final void subscribeOnEvents(Class<? extends IServiceEvent> eventClass)
      Subscribes on events which is instances of the given class.
      Parameters:
      eventClass - the class of events.
    • subscribeOnEvents

      protected final void subscribeOnEvents(IServiceEventQualifier eventQualifier)
      Subscribes on events which is covered by the given qualifier.
      Parameters:
      eventQualifier - the IServiceEventQualifier instance, cannot be null.
    • unsubscribeOnEvents

      protected final void unsubscribeOnEvents(IServiceEventQualifier eventQualifier)
      Unsubscribes on events which is covered by the given qualifier.
      Parameters:
      eventQualifier - the IServiceEventQualifier instance, cannot be null.