java.lang.Object
com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
com.inductiveautomation.perspective.gateway.model.ComponentModel
All Implemented Interfaces:
AuditingContext, Component, LoggingContext, PerspectiveElement, PropertyTreeOwner
Direct Known Subclasses:
DesignerComponentModel

public class ComponentModel extends AbstractLifecycle implements Component
The model for a running client component, of which many may exist forming the complete component tree for a running DesignerViewModel;

ComponentModels are created from the ComponentConfigs of a saved project.

  • Field Details

    • log

      protected static LoggerEx log
    • view

      protected final ViewModel view
    • config

      protected final ComponentConfig config
    • addressPath

      protected final int[] addressPath
    • addressPathString

      protected final String addressPathString
    • properties

      protected final Map<PropertyType,PropertyTree> properties
    • bindings

      protected final BindingCollection bindings
    • changeScripts

      protected final PropertyChangeScriptCollection changeScripts
    • actions

      protected final com.inductiveautomation.perspective.gateway.model.ActionCollection actions
    • customMethods

      protected final CustomMethodCollection customMethods
    • messageHandlers

      protected final MessageHandlerCollection messageHandlers
    • extensionFunctions

      protected final com.inductiveautomation.perspective.gateway.model.ExtensionFunctionCollection extensionFunctions
    • parent

      protected final ComponentModel parent
  • Constructor Details

  • Method Details

    • newActionHandler

      protected com.inductiveautomation.perspective.gateway.model.ActionCollection newActionHandler(EventConfig config)
    • initChildren

      protected void initChildren(List<ComponentConfig> configChildren)
    • findExtensionFunction

      public Optional<ExtensionFunction> findExtensionFunction(String name)
      Specified by:
      findExtensionFunction in interface Component
    • initProperties

      protected Map<PropertyType,PropertyTree> initProperties()
    • createPermissionModel

      protected PropertyTreePermissionModel createPermissionModel(PropertyType scope, PropertyConfigCollection config)
    • setName

      protected void setName(String name)
    • getName

      public String getName()
      Specified by:
      getName in interface PerspectiveElement
      Returns:
      The name of the element. If this is a component, it will be the name of the component. If this is a View, the name will be "view". If this is a Page, the name will be "page". If this is the session, the name will be "session".
    • getQualifiedPath

      public String getQualifiedPath()
      Specified by:
      getQualifiedPath in interface PerspectiveElement
      Returns:
      The qualified name of the element. If session or page, this is just the name. If a view or component, is the logical path starting at the view id.
    • findCustomMethod

      public Optional<org.python.core.PyMethod> findCustomMethod(String methodName)
    • getPropertyConfig

      public Optional<PropertyConfig> getPropertyConfig(PropertyKey property)
      Specified by:
      getPropertyConfig in interface Component
    • getMdcParent

      public LoggingContext getMdcParent()
      Specified by:
      getMdcParent in interface LoggingContext
    • mdcSetup

      public void mdcSetup()
      Description copied from interface: LoggingContext
      Set up the MDC keys for this context
      Specified by:
      mdcSetup in interface LoggingContext
    • mdcTeardown

      public void mdcTeardown()
      Description copied from interface: LoggingContext
      Tear down the MDC keys that are added in #mdcSetup
      Specified by:
      mdcTeardown in interface LoggingContext
    • onStartup

      protected void onStartup()
      Starts up the bindings and any children
      Specified by:
      onStartup in class AbstractLifecycle
    • onShutdown

      protected void onShutdown()
      Shuts down bindings and then shuts down all children
      Specified by:
      onShutdown in class AbstractLifecycle
    • getComponentAddressPath

      public String getComponentAddressPath()
      Description copied from interface: Component
      Index path of the component, like "0:5"
      Specified by:
      getComponentAddressPath in interface Component
    • getLogger

      public LoggerEx getLogger()
      Specified by:
      getLogger in interface LoggingContext
    • getParent

      @Nullable public Component getParent()
      Specified by:
      getParent in interface Component
      Returns:
      parent component, or null if this a root container.
    • getModelDelegate

      public Optional<ComponentModelDelegate> getModelDelegate()
    • refreshBinding

      public void refreshBinding(PropertyKey property)
    • focus

      public void focus()
    • requestTooltip

      public void requestTooltip()
    • removeTooltip

      public void removeTooltip()
    • requestContextMenu

      public void requestContextMenu()
    • removeContextMenu

      public void removeContextMenu()
    • requestPrint

      public void requestPrint(com.inductiveautomation.ignition.common.gson.JsonObject config)
    • dispatch

      public void dispatch(int[] propPath, int pointer, Consumer<ComponentModel> task)
      Call that will walk down the component tree given a path of indices, and then execute a task on the component indicated by the path.
    • children

      @Nonnull protected List<ComponentModel> children()
      This method should always return a list containing all children, in the proper order. Note that though all children are present and in the correct order, their index values may not be representative of their actual child ID (as is the case in the designer, where index and id diverge as changes are made to children).
      Returns:
      a list of child component models, which may be empty but will never be null.
    • fireEvent

      public void fireEvent(String eventType, String eventName, Object eventObject)
      Description copied from interface: Component
      Fire an event on component. Can either be a 'component' event or a 'delegate' event.
      Specified by:
      fireEvent in interface Component
    • getComponentState

      public com.inductiveautomation.ignition.common.gson.JsonElement getComponentState()
    • getBindingCount

      public int getBindingCount()
    • getTraceId

      public String getTraceId()
      Returns:
      A string suitable for identifying this component in log messages. Will contain the address path, name, and component type, like "ia.display.label-MyLabel-0:5"
    • getPropertyTreeOf

      @Nullable public PropertyTree getPropertyTreeOf(@Nullable PropertyType type)
      Description copied from interface: PropertyTreeOwner
      Fetch the PropertyTree associated with the given PropertyType
      Specified by:
      getPropertyTreeOf in interface PropertyTreeOwner
      Parameters:
      type - The PropertyType of the PropertyTree we want to fetch
      Returns:
      The PropertyTree or null if this PropertyTreeOwner does not manage a PropertyTree for the given PropertyType or if a null PropertyType is given
    • findChildByName

      @Nonnull public Optional<PerspectiveElement> findChildByName(@Nonnull Iterator<String> pathIterator)
      Attempts to locate a child at a given path. If the iterator is exhausted (hasNext() returns false), then this method will return itself. Otherwise, the iterator's values are interpreted as names of children and this method will call into a child's implementation of findChildByName.
      Specified by:
      findChildByName in interface Component
      Parameters:
      pathIterator - an iterator whose next value is the name of a child of this component, or if the iterator is exhausted, then this component is the one that will be returned.
      Returns:
      an optional of the component being searched for, empty if not found.
    • getChild

      public Optional<Component> getChild(int childId)
      Specified by:
      getChild in interface Component
    • getChildren

      public Collection<Component> getChildren()
      Specified by:
      getChildren in interface Component
    • getView

      @Nonnull public ViewModel getView()
      Specified by:
      getView in interface Component
      Specified by:
      getView in interface PerspectiveElement
      Returns:
      The view within which this element exists, or null if this is a Page or Session
    • getType

      public String getType()
      Description copied from interface: Component
      The type ID of this component, like "ia.display.label"
      Specified by:
      getType in interface Component
    • createPropertyReference

      @Nonnull public PropertyReference createPropertyReference(String referencePath, Consumer<PropertyTreeChangeEvent> subscriber, Set<Origin> acceptableOrigins)
      Description copied from interface: PerspectiveElement
      Create a PropertyReference with this PerspectiveElement as the target.
      Specified by:
      createPropertyReference in interface PerspectiveElement
      Parameters:
      referencePath - the path to the property
      subscriber - the subscriber - a Consumer of PropertyTreeChangeEvents
      acceptableOrigins - the Set of Origins in which the subscriber is interested
      Returns:
      the PropertyReference
    • getAuditSnapshot

      @Nonnull public AuditContext.Builder getAuditSnapshot()
      Specified by:
      getAuditSnapshot in interface AuditingContext
      Returns:
      A new, or extended, AuditContext.Builder, with qualified information about the current scope.