Class ComponentModel
- 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 runningDesignerViewModel;ComponentModels are created from the
ComponentConfigs of a saved project.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.inductiveautomation.perspective.gateway.model.ActionCollectionactionsprotected int[]addressPathprotected java.lang.StringaddressPathStringprotected BindingCollectionbindingsprotected PropertyChangeScriptCollectionchangeScriptsprotected ComponentConfigconfigprotected CustomMethodCollectioncustomMethodsprotected com.inductiveautomation.perspective.gateway.model.ExtensionFunctionCollectionextensionFunctionsprotected static LoggerExlogprotected MessageHandlerCollectionmessageHandlersprotected ComponentModelparentprotected java.util.Map<PropertyType,PropertyTree>propertiesprotected ViewModelview-
Fields inherited from interface com.inductiveautomation.perspective.gateway.api.Component
MDC_COMPONENT
-
-
Constructor Summary
Constructors Constructor Description ComponentModel(ViewModel view, ComponentConfig config, int[] addressPath, ComponentModel parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.List<ComponentModel>children()This method should always return a list containing all children, in the proper order.protected PropertyTreePermissionModelcreatePermissionModel(PropertyType scope, PropertyConfigCollection config)PropertyReferencecreatePropertyReference(java.lang.String referencePath, java.util.function.Consumer<PropertyTreeChangeEvent> subscriber, java.util.Set<Origin> acceptableOrigins)Create aPropertyReferencewith thisPerspectiveElementas the target.voiddispatch(int[] propPath, int pointer, java.util.function.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.java.util.Optional<PerspectiveElement>findChildByName(java.util.Iterator<java.lang.String> pathIterator)Attempts to locate a child at a given path.java.util.Optional<org.python.core.PyMethod>findCustomMethod(java.lang.String methodName)java.util.Optional<ExtensionFunction>findExtensionFunction(java.lang.String name)voidfireEvent(java.lang.String eventType, java.lang.String eventName, java.lang.Object eventObject)Fire an event on component.voidfocus()AuditContext.BuildergetAuditSnapshot()java.util.Optional<Component>getChild(int childId)java.util.Collection<Component>getChildren()java.lang.StringgetComponentAddressPath()Index path of the component, like "0:5"com.inductiveautomation.ignition.common.gson.JsonElementgetComponentState()LoggerExgetLogger()LoggingContextgetMdcParent()java.util.Optional<ComponentModelDelegate>getModelDelegate()java.lang.StringgetName()ComponentgetParent()PropertyTreegetPropertyTreeOf(PropertyType type)Fetch thePropertyTreeassociated with the givenPropertyTypejava.lang.StringgetQualifiedPath()java.lang.StringgetTraceId()ViewModelgetView()protected voidinitChildren(java.util.List<ComponentConfig> configChildren)protected java.util.Map<PropertyType,PropertyTree>initProperties()voidmdcSetup()Set up the MDC keys for this contextvoidmdcTeardown()Tear down the MDC keys that are added in #mdcSetupprotected com.inductiveautomation.perspective.gateway.model.ActionCollectionnewActionHandler(EventConfig config)protected voidonShutdown()Shuts down bindings and then shuts down all childrenprotected voidonStartup()Starts up the bindings and any childrenvoidrefreshBinding(PropertyKey property)protected voidsetName(java.lang.String name)-
Methods inherited from class com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
isRunning, shutdown, startup
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.AuditingContext
audit
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.Component
getPage, getSession
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.LoggingContext
mdc, mdcSetupTree, mdcTeardownTree, mdcWrap
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.PerspectiveElement
getAuditProfile
-
-
-
-
Field Detail
-
log
protected static LoggerEx log
-
view
protected final ViewModel view
-
config
protected final ComponentConfig config
-
addressPath
protected final int[] addressPath
-
addressPathString
protected final java.lang.String addressPathString
-
properties
protected final java.util.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 Detail
-
ComponentModel
public ComponentModel(@Nonnull ViewModel view, @Nonnull ComponentConfig config, @Nonnull int[] addressPath, @Nullable ComponentModel parent)
-
-
Method Detail
-
newActionHandler
protected com.inductiveautomation.perspective.gateway.model.ActionCollection newActionHandler(EventConfig config)
-
initChildren
protected void initChildren(java.util.List<ComponentConfig> configChildren)
-
findExtensionFunction
public java.util.Optional<ExtensionFunction> findExtensionFunction(java.lang.String name)
- Specified by:
findExtensionFunctionin interfaceComponent
-
initProperties
protected java.util.Map<PropertyType,PropertyTree> initProperties()
-
createPermissionModel
protected PropertyTreePermissionModel createPermissionModel(PropertyType scope, PropertyConfigCollection config)
-
setName
protected void setName(java.lang.String name)
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfacePerspectiveElement- 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 java.lang.String getQualifiedPath()
- Specified by:
getQualifiedPathin interfacePerspectiveElement- 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 java.util.Optional<org.python.core.PyMethod> findCustomMethod(java.lang.String methodName)
-
getMdcParent
public LoggingContext getMdcParent()
- Specified by:
getMdcParentin interfaceLoggingContext
-
mdcSetup
public void mdcSetup()
Description copied from interface:LoggingContextSet up the MDC keys for this context- Specified by:
mdcSetupin interfaceLoggingContext
-
mdcTeardown
public void mdcTeardown()
Description copied from interface:LoggingContextTear down the MDC keys that are added in #mdcSetup- Specified by:
mdcTeardownin interfaceLoggingContext
-
onStartup
protected void onStartup()
Starts up the bindings and any children- Specified by:
onStartupin classAbstractLifecycle
-
onShutdown
protected void onShutdown()
Shuts down bindings and then shuts down all children- Specified by:
onShutdownin classAbstractLifecycle
-
getComponentAddressPath
public java.lang.String getComponentAddressPath()
Description copied from interface:ComponentIndex path of the component, like "0:5"- Specified by:
getComponentAddressPathin interfaceComponent
-
getLogger
public LoggerEx getLogger()
- Specified by:
getLoggerin interfaceLoggingContext
-
getParent
@Nullable public Component getParent()
-
getModelDelegate
public java.util.Optional<ComponentModelDelegate> getModelDelegate()
-
refreshBinding
public void refreshBinding(PropertyKey property)
-
focus
public void focus()
-
dispatch
public void dispatch(int[] propPath, int pointer, java.util.function.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 java.util.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(java.lang.String eventType, java.lang.String eventName, java.lang.Object eventObject)Description copied from interface:ComponentFire an event on component. Can either be a 'component' event or a 'delegate' event.
-
getComponentState
public com.inductiveautomation.ignition.common.gson.JsonElement getComponentState()
-
getTraceId
public java.lang.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:PropertyTreeOwnerFetch thePropertyTreeassociated with the givenPropertyType- Specified by:
getPropertyTreeOfin interfacePropertyTreeOwner- Parameters:
type- ThePropertyTypeof thePropertyTreewe 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 java.util.Optional<PerspectiveElement> findChildByName(@Nonnull java.util.Iterator<java.lang.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:
findChildByNamein interfaceComponent- 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 java.util.Optional<Component> getChild(int childId)
-
getChildren
public java.util.Collection<Component> getChildren()
- Specified by:
getChildrenin interfaceComponent
-
getView
public ViewModel getView()
- Specified by:
getViewin interfacePerspectiveElement- Returns:
- The view within which this element exists, or null if this is a Page or Session
-
createPropertyReference
@Nonnull public PropertyReference createPropertyReference(java.lang.String referencePath, java.util.function.Consumer<PropertyTreeChangeEvent> subscriber, java.util.Set<Origin> acceptableOrigins)
Description copied from interface:PerspectiveElementCreate aPropertyReferencewith thisPerspectiveElementas the target.- Specified by:
createPropertyReferencein interfacePerspectiveElement- Parameters:
referencePath- the path to the propertysubscriber- the subscriber - aConsumerofPropertyTreeChangeEventsacceptableOrigins- theSetofOrigins in which the subscriber is interested- Returns:
- the
PropertyReference
-
getAuditSnapshot
@Nonnull public AuditContext.Builder getAuditSnapshot()
- Specified by:
getAuditSnapshotin interfaceAuditingContext- Returns:
- A new, or extended,
AuditContext.Builder, with qualified information about the current scope.
-
-