Class ClientContextImpl

java.lang.Object
com.inductiveautomation.ignition.client.model.AbstractClientContext
com.inductiveautomation.factorypmi.application.runtime.ClientContextImpl
All Implemented Interfaces:
ClientContext, CommonContext, VisionClientInterface

public class ClientContextImpl extends AbstractClientContext implements VisionClientInterface
  • Method Details

    • getProject

      public RuntimeResourceCollection getProject()
      Description copied from interface: ClientContext
      Returns the project that this client is running. Note that this may be null before the client is fully logged in and started, because the context is created before the project is downloaded.
      Specified by:
      getProject in interface ClientContext
    • addExtensibleBindingType

      public void addExtensibleBindingType(BindingType binding)
      Description copied from interface: VisionClientInterface
      Adds a new binding type to be used in the extensible binding system
      Specified by:
      addExtensibleBindingType in interface VisionClientInterface
      Parameters:
      binding - The binding type to add.
    • getBindingType

      public BindingType getBindingType(String bindingTypeKey)
      Description copied from interface: VisionClientInterface
      Gets a binding type by its key.
      Specified by:
      getBindingType in interface VisionClientInterface
      Parameters:
      bindingTypeKey - The unique key for the binding type.
      Returns:
      The binding type, or null if not found.
    • getExecutionManager

      public ExecutionManager getExecutionManager()
      Description copied from interface: ClientContext
      Returns the shared task execution manager for this client
      Specified by:
      getExecutionManager in interface ClientContext
    • getLocalizationManager

      public ClientLocalizationManager getLocalizationManager()
      Specified by:
      getLocalizationManager in interface ClientContext
    • setLocalizationManager

      public void setLocalizationManager(ClientLocalizationManager mgr)
    • addWindowListener

      public void addWindowListener(VisionWindowListener listener)
      Description copied from interface: VisionClientInterface
      Adds a listener to be notified when windows are opened and closed. Only works during runtime, not designer.
      Specified by:
      addWindowListener in interface VisionClientInterface
      Parameters:
      listener - The window listener to add.
    • removeWindowListener

      public void removeWindowListener(VisionWindowListener listener)
      Description copied from interface: VisionClientInterface
      Removes a window listener.
      Specified by:
      removeWindowListener in interface VisionClientInterface
      Parameters:
      listener - The window listener to remove.
    • receiveVisionWindowEvent

      public void receiveVisionWindowEvent(VisionWindowEvent event)
      Listens to the event bus for vision window evens to push all window open/close events to any modules that have registered VisionWindowListener objects.
    • deserialize

      public Object deserialize(byte[] data, org.apache.log4j.Logger log) throws SerializationException
      Description copied from interface: ClientContext
      Convenience function to deserialize a gzipped byte array into a single object. If multiple objects are found, they will be discarded. Warnings are logged to the given logger. If data is null or empty, null is returned.
      Specified by:
      deserialize in interface ClientContext
      Throws:
      SerializationException
    • getRootPaneContainer

      public RootPaneContainer getRootPaneContainer()
      Description copied from interface: ClientContext
      Returns the RootPaneContainer that is currently the owner of the client
      Specified by:
      getRootPaneContainer in interface ClientContext
    • getModules

      public List<ModuleInfo> getModules()
      Description copied from interface: ClientContext
      Retrieve the list of all modules currently loaded in this context
      Specified by:
      getModules in interface ClientContext
    • getLicenseState

      public LicenseState getLicenseState(String moduleId)
      Description copied from interface: CommonContext
      Returns the license state for the given module
      Specified by:
      getLicenseState in interface CommonContext
    • createExpressionFunctionFactory

      protected FunctionFactory createExpressionFunctionFactory()
      Specified by:
      createExpressionFunctionFactory in class AbstractClientContext
    • loadModules

      public void loadModules(List<ModuleInfo> modules) throws ModuleLoadException
      Create LoadedModule objects to represent each client-scoped module in the list. This will instantiate, but not start up, the client module hooks.
      Throws:
      ModuleLoadException
    • startup

      public void startup()
      Overrides:
      startup in class AbstractClientContext
    • setApp

      public void setApp(FPMIApp app)
    • shutdown

      public void shutdown()
      Overrides:
      shutdown in class AbstractClientContext
    • getNavUtil

      public NavUtilities getNavUtil()
      Description copied from interface: VisionClientInterface
      Gets the NavUtilities for the primary desktop.
      Specified by:
      getNavUtil in interface VisionClientInterface
      Returns:
      The navigation utilities.
    • getNavUtil

      public NavUtilities getNavUtil(String desktopHandle)
      Description copied from interface: VisionClientInterface
      Gets the NavUtilities for a secondary desktop, by handle.
      Specified by:
      getNavUtil in interface VisionClientInterface
      Parameters:
      desktopHandle - The handle of the desktop.
      Returns:
      The navigation utilities for the specified desktop.
    • getGuiUtil

      public WindowUtilities getGuiUtil()
      Description copied from interface: VisionClientInterface
      Gets the WindowUtilities for the primary desktop.
      Specified by:
      getGuiUtil in interface VisionClientInterface
      Returns:
      The GUI utilities.
    • getGuiUtil

      public WindowUtilities getGuiUtil(String desktopHandle)
      Description copied from interface: VisionClientInterface
      Gets the WindowUtilities for a secondary desktop, by handle.
      Specified by:
      getGuiUtil in interface VisionClientInterface
      Parameters:
      desktopHandle - The handle of the desktop.
      Returns:
      The GUI utilities for the specified desktop.
    • setProject

      public void setProject(ResourceCollection project)
    • newProjectResourceListener

      protected ResourceListener newProjectResourceListener()
      Make a custom resource listener so we can keep track of some Vision-specific resources
      Overrides:
      newProjectResourceListener in class AbstractClientContext
    • getTagManager

      public ClientTagManager getTagManager()
      Description copied from interface: CommonContext
      Returns the manager that provides access to Ignition's tag system.
      Specified by:
      getTagManager in interface ClientContext
      Specified by:
      getTagManager in interface CommonContext
    • getScriptManager

      public ScriptManager getScriptManager()
      Description copied from interface: CommonContext
      Returns the ScriptManager that can be used to execute Python scripts.
      Specified by:
      getScriptManager in interface CommonContext
    • getNamedQueryManager

      public NamedQueryManager getNamedQueryManager()
      Description copied from interface: ClientContext
      Returns the appropriate named query rpc for the context. In the gateway and client, we only want to use named queries that have been saved. In the designer, we want to use the current version so that reports and bindings can be seen and used for testing before the project is saved.
      Specified by:
      getNamedQueryManager in interface ClientContext
      Returns:
      The correct NamedQueryManager implementation for the scope.
    • createDeserializer

      public XMLDeserializer createDeserializer()
      Description copied from interface: CommonContext
      Returns an instance of the XMLDeserializer that can be used to deserialize project resources. Note that this is the only safe way to obtain an instance of XMLDeserializer, because the context will pass the new deserializer around to all loaded modules, giving them a chance to initialize any custom deserialization deletes on it first.
      Specified by:
      createDeserializer in interface CommonContext
    • configureDeserializer

      public static void configureDeserializer(XMLDeserializer d)
    • configureClassNameResolver

      public static void configureClassNameResolver(ClassNameResolver r)
    • getGeneralProps

      public GeneralProps getGeneralProps()
    • getLaunchProps

      public LaunchProps getLaunchProps()
    • getLoginProps

      public LoginProps getLoginProps()
    • getUiProps

      public UIProps getUiProps()
    • getModule

      public Object getModule(String id)
      Description copied from interface: ClientContext
      Returns the running hook object that the module with the given ID contributed to this scope. This is the live hook instance, not its Class. Modules use it to reach each other's APIs at runtime.

      The return type is Object because the hook type varies by scope — a ClientModuleHook in a Vision client, a DesignerModuleHook in the Designer (see DesignerContext#getModule(String), which narrows the return type accordingly). Callers narrow the result to an interface the target module publishes for this purpose — pattern matching covers the absent-module case in the same step:

      if (context.getModule(SFCModule.MODULE_ID) instanceof ClientStepRegistryProvider sfc) {
        var registry = sfc.getStepRegistry();
      }
      

      A null result is the usual way to detect that an optional module is unavailable, so account for it unless the module is a hard dependency of yours.

      Specified by:
      getModule in interface ClientContext
      Parameters:
      id - the module ID of the module whose hook you want.
      Returns:
      the module's hook instance, or null if the module is not installed or contributes no hook to this scope.