java.lang.Object
com.inductiveautomation.perspective.designer.workspace.JavaJsBridge
Direct Known Subclasses:
SessionPropsAdapter.SessionAdapterBridge, ViewEditorJsBridge

public abstract class JavaJsBridge extends Object
This class acts as a 'bridge' between the Java and Javascript environments. It is instantiated and embedded into the js environment through JxBrowser's Java accessibility API. Calls which are made FROM javascript are annotated with JsAccessible. We must manually shut down this bridge to prevent memory leaks. See shutdown().
Since:
8.0.0
  • Field Details

    • log

      protected final LoggerEx log
    • gson

      protected final com.inductiveautomation.ignition.common.gson.Gson gson
  • Constructor Details

    • JavaJsBridge

      public JavaJsBridge(com.teamdev.jxbrowser.browser.Browser browser, DesignerContext context)
  • Method Details

    • getBridgeDesc

      protected abstract String getBridgeDesc()
    • getForSave

      public <T> CompletableFuture<T> getForSave(BiFunction<String,com.inductiveautomation.ignition.common.gson.Gson,T> parse)
      Retrieves the view config from the running View instance in the DesignerViewInstanceStore.
    • onSaveComplete

      public void onSaveComplete(String json)
      Called from a DesignerStore once the data to save has been gathered via Promise
      Parameters:
      json - JSON stringified view data or session props data
    • onSaveError

      public void onSaveError(String reason)
      Called from a DesignerStore if there was an error gathering the data to save
      Parameters:
      reason - the reason why there was an error
    • getOwnViewPath

      public String getOwnViewPath()
      Called to get the current name of the project resource associated with a view's tabId. Derives from the designer project.
      Returns:
      string representation of this View's path in the project resource.
    • getViewPathInternal

      protected abstract String getViewPathInternal()
    • getOwnViewConfig

      public String getOwnViewConfig()
      Gets the current view configuration from the Designer Project. Used as the view definition in the designer's instance store.
      Returns:
      the view config from the designer as a ViewConfig
    • getViewConfigInternal

      protected abstract ViewConfig getViewConfigInternal()
    • getContextInternal

      protected abstract DesignerContext getContextInternal()
    • getSessionProps

      public String getSessionProps()
    • getSessionPropsInternal

      protected abstract SessionPropsConfig getSessionPropsInternal()
    • getInitMsg

      public String getInitMsg()
      Gets the info needed to open a new view for editing.
    • getPropertyDefaults

      public String getPropertyDefaults(String propertyType, String componentType, String variantId, boolean forInit)
      Returns a json object containing the default properties registered in the component registry. If forInit is true, default props will include example values when found in the registered component descriptors example props.
    • getChildPositionDefaults

      public String getChildPositionDefaults(String componentType, boolean forInit)
    • getComponentBaseName

      public String getComponentBaseName(String componentType)
    • onStructureChange

      public void onStructureChange(String structureJson)
    • onStructureChangeInternal

      protected abstract void onStructureChangeInternal(ViewStructure structure)
    • activateComponentTool

      public void activateComponentTool(String componentType)
    • activateComponentTool

      public void activateComponentTool(String componentType, String variantId)
    • invokeStoreFunction

      protected CompletableFuture<JxValue> invokeStoreFunction(String functionName, Object... args)
      Invokes a method on the DesignerStore.tsx object.
    • notifyViewUpdated

      public void notifyViewUpdated(String path)
    • sendRaw

      public CompletableFuture<JxValue> sendRaw(String protocol, String payloadJson)
      Sends a message through the websocket held by the connection store.
    • getComponentDetails

      public CompletableFuture<ComponentDetails> getComponentDetails(String componentIndexPath)
    • getEffectivePipeSelectionAppearance

      public CompletableFuture<String> getEffectivePipeSelectionAppearance()
    • setChildrenIndexes

      public void setChildrenIndexes(ChildrenIndexesChange change)
    • writeProperty

      public void writeProperty(WritePropertyChange change, boolean createUndoAction)
    • writeProperties

      public void writeProperties(WritePropertiesChange change)
    • insertProperty

      public void insertProperty(InsertPropertyChange change)
    • renameProperty

      public void renameProperty(RenamePropertyChange change, boolean createUndoAction)
    • removeProperty

      public void removeProperty(RemovePropertyChange change, boolean createUndoAction)
    • alterPropertyConfig

      public void alterPropertyConfig(PropertyConfigChange change, boolean createUndoAction)
    • alterEventConfig

      public void alterEventConfig(EventConfigChange change)
    • alterScriptConfig

      public void alterScriptConfig(ScriptConfigChange change)
    • removeChildPropertyConfigs

      public void removeChildPropertyConfigs(String componentIndexPath, PropertyType scope, String propertyPath)
    • alterViewPermissions

      public abstract void alterViewPermissions(PermissionsConfig permissionsConfig)
    • getViewPermissions

      public abstract CompletableFuture<PermissionsConfig> getViewPermissions()
    • onBindingPreviewValue

      public void onBindingPreviewValue(String serializedMessage)
      Called from a DesignerStore handler upon receiving the 'binding-edit-value-update' message.
      Parameters:
      serializedMessage - Base64 serialized object from the gateway
    • onBindingPreviewValueInternal

      protected abstract void onBindingPreviewValueInternal(BindingEditValueUpdate update)
    • onDeepSelectionChange

      public void onDeepSelectionChange(String json)
    • onDeepSelectionChangeInternal

      protected abstract void onDeepSelectionChangeInternal(DeepSelection deepSelection, com.teamdev.jxbrowser.js.JsObject storeObject)
    • onDeepSelectionPropsUpdated

      public void onDeepSelectionPropsUpdated(String json)
    • onDeepSelectionPropsUpdatedInternal

      protected abstract void onDeepSelectionPropsUpdatedInternal(DeepSelectionUpdateEvent event)
    • onSelectionChange

      public void onSelectionChange(String rootViewPath, String detailsJson)
      Called when the selection changes.
      Parameters:
      detailsJson - List<ComponentDetails> encoded in JSON
    • onSelectionChangeInternal

      protected abstract void onSelectionChangeInternal(String rootViewPath, List<ComponentDetails> details)
    • onSelectionPropertyChange

      public void onSelectionPropertyChange(String rootViewPath, String changesJson)
      Called when one of the currently selected components' properties changes
    • onSelectionPropertyChangeInternal

      protected abstract void onSelectionPropertyChangeInternal(SelectionPropertyUpdateEvent event)
    • onSelectionConfigUpdated

      public void onSelectionConfigUpdated(String changesJson)
      Called when one of the currently selected components config changes (bindings or event config)
    • onSelectionConfigUpdatedInternal

      protected abstract void onSelectionConfigUpdatedInternal(List<ComponentDetails> changes)
    • onContextMenu

      public void onContextMenu(String pointJson, boolean canConvertToDrawing, boolean isDrawing, boolean isSvg, boolean isView)
    • onContextMenuInternal

      protected abstract void onContextMenuInternal(Point point, boolean canConvertToDrawing, boolean isDrawing, boolean isSvg, boolean isView)
    • onImageDropped

      public void onImageDropped(String imageSource, String dropPoint)
    • onConvertToDrawing

      public void onConvertToDrawing(String path, String name, String position, String svgSource, boolean pipeMode)
    • onSvgDropped

      public void onSvgDropped(String name, String svgSource, String dropPoint)
    • onTagsDropped

      public void onTagsDropped(String path, String tagsJson, String dropPointJson, String modifiers)
    • onUndoableAction

      public void onUndoableAction(String key, String json)
    • onErrorMessage

      public void onErrorMessage(String message)
    • flattenSvg

      public void flattenSvg(String svg, String position, String name)
    • setSelection

      public void setSelection(List<String> selection)
    • setDeepSelection

      public void setDeepSelection(String path)
    • deleteSelected

      public void deleteSelected()
      Deletes the components currently selected in the designer store.
    • deleteComponents

      public void deleteComponents(String[] indexPaths, boolean createUndoAction)
      Deletes the components at the given index paths
    • convertComponentToDrawing

      public void convertComponentToDrawing(String path)
    • convertPipesToDrawing

      public void convertPipesToDrawing(String path)
    • convertSelectionToDrawing

      public void convertSelectionToDrawing()
    • flattenSelectedSvg

      public void flattenSelectedSvg()
    • alignSelectedComponents

      public void alignSelectedComponents(CoordinateContainerDesignDelegate.AlignType type, Integer padding)
    • reorderSelectedComponents

      public void reorderSelectedComponents(ViewWorkspaceActions.ReorderType type)
    • replaceComponent

      public void replaceComponent(String path, ComponentConfig component, boolean replaceAtLocation, boolean createUndoAction)
      Replaces the component at the specified path with the specified ComponentConfig. Used to make undo-redo easy for wrapComponent.
      Parameters:
      path - The addressPathString of the Component to be replaced.
      component - The componentConfig to replace the Component with
      replaceAtLocation - Determines if replacement should occur at the component to be replaced
    • replaceComponentFromClipboard

      public void replaceComponentFromClipboard(String path, String clipboardContents)
    • wrapComponent

      public void wrapComponent(String path, ViewWorkspaceActions.WrapInType type)
      Wraps a component at the specified Path with a specified Type of component. WrapInType is not a component id, nor is there a 1:1 between the two. For example: Flex Containers have both flex_row, and flex_column.
      Parameters:
      path - The addressPathString of the Component to be wrapped. If null, the currently selected Component will be wrapped.
      type - The WrapInType to use to determine the strategy used for wrapping the Component.
    • addComponentsToContainer

      public void addComponentsToContainer(String parentIndexPath, List<ComponentConfig> componentConfigs, @Nullable Rectangle location, @Nullable int[] childrenIndexes, boolean createUndoAction)
      Add components to a specific container, even if it isn't deeply selected.
    • addComponents

      public void addComponents(List<ComponentConfig> componentConfigs, @Nullable Point point)
      Add components to the current deeply selected container, specifying the location
    • addComponents

      public void addComponents(List<ComponentConfig> componentConfigs, Rectangle location)
      Add components to the current deeply selected container, specifying location and size
    • copySelection

      public CompletableFuture<JxValue> copySelection()
    • disableEditorEvents

      public void disableEditorEvents()
    • enableEditorEvents

      public void enableEditorEvents()
    • copyJsonToClipboard

      public void copyJsonToClipboard()
    • pasteJsonFromClipboard

      public void pasteJsonFromClipboard()
    • cutJsonToClipboard

      public void cutJsonToClipboard()
    • getViewConfig

      public String getViewConfig(String resourcePath)
      Returns:
      a ViewConfig's json string equivalent for a view found at the given path.
    • getViewConfigInternal

      protected abstract ViewConfig getViewConfigInternal(String resourcePath)
    • setPreview

      public void setPreview(boolean preview)
    • getSymbolicPath

      public CompletableFuture<List<String>> getSymbolicPath(String indexPath)
    • stylesUpdated

      public void stylesUpdated(String styles)
    • reloadSymbolStyles

      public void reloadSymbolStyles()
    • getStyles

      public String getStyles()
    • getSymbolStyles

      public String getSymbolStyles(String theme)
    • setPipeMode

      public void setPipeMode(String pipeMode)
      Piping
    • onPipeModeChange

      public void onPipeModeChange(String pipeMode)
      Called when the pipe mode changes.
    • onPipeModeChangeInternal

      protected abstract void onPipeModeChangeInternal(String pipeMode)
    • setPipeSelection

      public void setPipeSelection(List<PipeSelectionDetail> details)
    • onPipeSelectionChange

      public void onPipeSelectionChange(String pipeSelection, boolean replaceComponentSelection)
      Called when the pipe selection changes.
    • onPipeSelectionChangeInternal

      protected abstract void onPipeSelectionChangeInternal(List<PipeSelectionDetail> details, boolean replaceComponentSelection)
    • copySelectedPipe

      public CompletableFuture<JxValue> copySelectedPipe()
    • pastePipes

      public void pastePipes(List<PipeConfig> pipe, @Nullable Point point)
      Add pipes to the current deeply selected container
    • deleteSelectedPipes

      public void deleteSelectedPipes()
      Deletes the selected Pipe
    • deleteSelectedPipeConnection

      public void deleteSelectedPipeConnection()
      Deletes the selected Pipe
    • shutdown

      public void shutdown()
      Must be called by the parent panel when it initiates shutdown.