Class ViewModel
- java.lang.Object
-
- com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
-
- com.inductiveautomation.perspective.gateway.model.ViewModel
-
- All Implemented Interfaces:
AuditingContext
,LoggingContext
,PerspectiveElement
,PropertyTreeOwner
,View
- Direct Known Subclasses:
DesignerViewModel
public class ViewModel extends AbstractLifecycle implements View
- Since:
- 8.0
-
-
Field Summary
Fields Modifier and Type Field Description protected com.inductiveautomation.perspective.gateway.model.ActionCollection
actions
protected BindingCollection
bindings
protected PropertyChangeScriptCollection
changeScripts
protected ViewConfig
config
protected ViewInstanceId
id
protected java.util.Set<java.lang.String>
inputParams
protected static LoggerEx
log
protected PageModel
page
protected java.util.Map<PropertyType,PropertyTree>
properties
protected ComponentModel
rootContainer
static java.lang.ThreadLocal<ViewModel>
VIEW
-
Constructor Summary
Constructors Constructor Description ViewModel(PageModel page, ViewInstanceId id, ViewConfig config, com.inductiveautomation.ignition.common.gson.JsonObject inputParams)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PropertyTreePermissionModel
createPermissionModel(PropertyType scope, PropertyConfigCollection config)
PropertyReference
createPropertyReference(java.lang.String referencePath, java.util.function.Consumer<PropertyTreeChangeEvent> subscriber, java.util.Set<Origin> acceptableOrigins)
Create aPropertyReference
with thisPerspectiveElement
as the target.boolean
equals(java.lang.Object o)
java.util.Optional<PerspectiveElement>
findChildByIndexLocation(java.lang.String indexLocation)
Tries to look up a component by its index location.java.util.Optional<PerspectiveElement>
findChildByPath(java.lang.String path)
Tries to look up a component by its name path.AuditContext.Builder
getAuditSnapshot()
long
getBirthDate()
ViewConfig
getConfig()
ViewInstanceId
getId()
LoggerEx
getLogger()
LoggingContext
getMdcParent()
java.lang.String
getName()
Page
getPage()
PropertyTree
getPropertyTreeOf(PropertyType type)
Fetch thePropertyTree
associated with the givenPropertyType
java.lang.String
getQualifiedPath()
ComponentModel
getRootContainer()
Session
getSession()
ViewModel
getView()
com.google.common.eventbus.EventBus
getViewEventBus()
com.inductiveautomation.ignition.common.gson.JsonObject
getViewInfo()
Provides information pertaining to this View Model object including it's instance id, and information about it's children.com.inductiveautomation.ignition.common.gson.JsonElement
getViewState()
boolean
hasAbandonedViewTimeout()
int
hashCode()
protected void
initRoot(ComponentConfig rootConfig)
void
mdcSetup()
Set up the MDC keys for this contextvoid
mdcTeardown()
Tear down the MDC keys that are added in #mdcSetupprotected com.inductiveautomation.perspective.gateway.model.ActionCollection
newActionHandler(EventConfig config)
void
onEventFired(EventFiredMsg message)
protected void
onShutdown()
protected void
onStartup()
void
refreshBinding(PropertyKey property)
void
restart(com.inductiveautomation.ignition.common.gson.JsonObject params)
void
setAbandonedViewTimeout(java.util.concurrent.ScheduledFuture<?> newTimeout)
void
setBirthDate(long birthDate)
java.lang.String
toString()
-
Methods inherited from class com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
isRunning, shutdown, startup
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.AuditingContext
audit
-
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
public static final java.lang.ThreadLocal<ViewModel> VIEW
-
id
protected final ViewInstanceId id
-
config
protected final ViewConfig config
-
page
protected final PageModel page
-
inputParams
protected final java.util.Set<java.lang.String> inputParams
-
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
-
rootContainer
protected ComponentModel rootContainer
-
-
Constructor Detail
-
ViewModel
public ViewModel(@Nonnull PageModel page, ViewInstanceId id, ViewConfig config, com.inductiveautomation.ignition.common.gson.JsonObject inputParams)
-
-
Method Detail
-
getBirthDate
public long getBirthDate()
-
getConfig
public ViewConfig getConfig()
-
getSession
@Nonnull public Session getSession()
- Specified by:
getSession
in interfacePerspectiveElement
- Returns:
- The session that this element is a part of.
-
createPropertyReference
@Nonnull public PropertyReference createPropertyReference(java.lang.String referencePath, java.util.function.Consumer<PropertyTreeChangeEvent> subscriber, java.util.Set<Origin> acceptableOrigins)
Description copied from interface:PerspectiveElement
Create aPropertyReference
with thisPerspectiveElement
as the target.- Specified by:
createPropertyReference
in interfacePerspectiveElement
- Parameters:
referencePath
- the path to the propertysubscriber
- the subscriber - aConsumer
ofPropertyTreeChangeEvent
sacceptableOrigins
- theSet
ofOrigin
s in which the subscriber is interested- Returns:
- the
PropertyReference
-
getName
public java.lang.String getName()
- Specified by:
getName
in 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:
getQualifiedPath
in 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.
-
getViewEventBus
public com.google.common.eventbus.EventBus getViewEventBus()
- Specified by:
getViewEventBus
in interfaceView
-
newActionHandler
protected com.inductiveautomation.perspective.gateway.model.ActionCollection newActionHandler(EventConfig config)
-
setAbandonedViewTimeout
public void setAbandonedViewTimeout(java.util.concurrent.ScheduledFuture<?> newTimeout)
-
setBirthDate
public void setBirthDate(long birthDate)
-
hasAbandonedViewTimeout
public boolean hasAbandonedViewTimeout()
-
restart
public void restart(com.inductiveautomation.ignition.common.gson.JsonObject params)
-
refreshBinding
public void refreshBinding(PropertyKey property)
-
initRoot
protected void initRoot(ComponentConfig rootConfig)
-
createPermissionModel
protected PropertyTreePermissionModel createPermissionModel(PropertyType scope, PropertyConfigCollection config)
-
onEventFired
public void onEventFired(EventFiredMsg message)
-
getId
public ViewInstanceId getId()
-
getView
public ViewModel getView()
- Specified by:
getView
in interfacePerspectiveElement
- Returns:
- The view within which this element exists, or null if this is a Page or Session
-
getPage
public Page getPage()
- Specified by:
getPage
in interfacePerspectiveElement
- Returns:
- The Page that this element is part of. Will return null if this is the Session
-
getMdcParent
@Nullable public LoggingContext getMdcParent()
- Specified by:
getMdcParent
in interfaceLoggingContext
-
mdcSetup
public void mdcSetup()
Description copied from interface:LoggingContext
Set up the MDC keys for this context- Specified by:
mdcSetup
in interfaceLoggingContext
-
mdcTeardown
public void mdcTeardown()
Description copied from interface:LoggingContext
Tear down the MDC keys that are added in #mdcSetup- Specified by:
mdcTeardown
in interfaceLoggingContext
-
onStartup
protected void onStartup()
- Specified by:
onStartup
in classAbstractLifecycle
-
getRootContainer
public ComponentModel getRootContainer()
- Specified by:
getRootContainer
in interfaceView
-
onShutdown
protected void onShutdown()
- Specified by:
onShutdown
in classAbstractLifecycle
-
findChildByIndexLocation
public java.util.Optional<PerspectiveElement> findChildByIndexLocation(java.lang.String indexLocation)
Description copied from interface:View
Tries to look up a component by its index location. Some examples:- "": returns the view
- "0": returns the root container
- "0:4" returns a child of the root container at index 4
- Specified by:
findChildByIndexLocation
in interfaceView
-
findChildByPath
public java.util.Optional<PerspectiveElement> findChildByPath(java.lang.String path)
Description copied from interface:View
Tries to look up a component by its name path. Some examples:- "/": returns the view
- "/root": returns the root container if the root container's name is "root"
- "/root/foo": returns a component called "foo" contained with in the root container called "root"
- Specified by:
findChildByPath
in interfaceView
-
getPropertyTreeOf
@Nullable public PropertyTree getPropertyTreeOf(@Nullable PropertyType type)
Description copied from interface:PropertyTreeOwner
Fetch thePropertyTree
associated with the givenPropertyType
- Specified by:
getPropertyTreeOf
in interfacePropertyTreeOwner
- Parameters:
type
- ThePropertyType
of thePropertyTree
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
-
getLogger
public LoggerEx getLogger()
- Specified by:
getLogger
in interfaceLoggingContext
-
getViewState
public com.inductiveautomation.ignition.common.gson.JsonElement getViewState()
-
getViewInfo
public com.inductiveautomation.ignition.common.gson.JsonObject getViewInfo()
Provides information pertaining to this View Model object including it's instance id, and information about it's children.- Returns:
- Returns a JsonObject representing information pertaining to this View Model object.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getAuditSnapshot
@Nonnull public AuditContext.Builder getAuditSnapshot()
- Specified by:
getAuditSnapshot
in interfaceAuditingContext
- Returns:
- A new, or extended,
AuditContext.Builder
, with qualified information about the current scope.
-
-