Class JavaJsBridge
java.lang.Object
com.inductiveautomation.perspective.designer.workspace.JavaJsBridge
- Direct Known Subclasses:
SessionPropsAdapter.SessionAdapterBridge
,ViewEditorJsBridge
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJavaJsBridge
(com.teamdev.jxbrowser.browser.Browser browser, DesignerContext context) -
Method Summary
Modifier and TypeMethodDescriptionvoid
activateComponentTool
(String componentType) void
activateComponentTool
(String componentType, String variantId) void
addComponents
(List<ComponentConfig> componentConfigs, Point point) Add components to the current deeply selected container, specifying the locationvoid
addComponents
(List<ComponentConfig> componentConfigs, Rectangle location) Add components to the current deeply selected container, specifying location and sizevoid
addComponentsToContainer
(String parentIndexPath, List<ComponentConfig> componentConfigs, Rectangle location, int[] childrenIndexes, boolean createUndoAction) Add components to a specific container, even if it isn't deeply selected.void
void
alterEventConfig
(EventConfigChange change) void
alterPropertyConfig
(PropertyConfigChange change, boolean createUndoAction) void
alterScriptConfig
(ScriptConfigChange change) abstract void
alterViewPermissions
(PermissionsConfig permissionsConfig) void
void
convertPipesToDrawing
(String path) void
void
void
void
deleteComponents
(String[] indexPaths, boolean createUndoAction) Deletes the components at the given index pathsvoid
Deletes the components currently selected in the designer store.void
Deletes the selected Pipevoid
Deletes the selected Pipevoid
void
void
void
flattenSvg
(String svg, String position, String name) protected abstract String
getChildPositionDefaults
(String componentType, boolean forInit) getComponentBaseName
(String componentType) getComponentDetails
(String componentIndexPath) protected abstract DesignerContext
<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.Gets the info needed to open a new view for editing.Gets the current view configuration from the Designer Project.Called to get the current name of the project resource associated with a view's tabId.getPropertyDefaults
(String propertyType, String componentType, String variantId, boolean forInit) Returns a json object containing the default properties registered in the component registry.protected abstract SessionPropsConfig
getSymbolicPath
(String indexPath) getSymbolStyles
(String theme) getViewConfig
(String resourcePath) protected abstract ViewConfig
protected abstract ViewConfig
getViewConfigInternal
(String resourcePath) protected abstract String
abstract CompletableFuture<PermissionsConfig>
void
insertProperty
(InsertPropertyChange change) protected CompletableFuture<JxValue>
invokeStoreFunction
(String functionName, Object... args) Invokes a method on the DesignerStore.tsx object.void
notifyViewUpdated
(String path) void
onBindingPreviewValue
(String serializedMessage) Called from a DesignerStore handler upon receiving the 'binding-edit-value-update' message.protected abstract void
void
onContextMenu
(String pointJson, boolean canConvertToDrawing, boolean isDrawing, boolean isSvg, boolean isView) protected abstract void
onContextMenuInternal
(Point point, boolean canConvertToDrawing, boolean isDrawing, boolean isSvg, boolean isView) void
onConvertToDrawing
(String path, String name, String position, String svgSource, boolean pipeMode) void
onDeepSelectionChange
(String json) protected abstract void
onDeepSelectionChangeInternal
(DeepSelection deepSelection, com.teamdev.jxbrowser.js.JsObject storeObject) void
protected abstract void
void
onErrorMessage
(String message) void
onImageDropped
(String imageSource, String dropPoint) void
onPipeModeChange
(String pipeMode) Called when the pipe mode changes.protected abstract void
onPipeModeChangeInternal
(String pipeMode) void
onPipeSelectionChange
(String pipeSelection, boolean replaceComponentSelection) Called when the pipe selection changes.protected abstract void
onPipeSelectionChangeInternal
(List<PipeSelectionDetail> details, boolean replaceComponentSelection) void
onSaveComplete
(String json) Called from a DesignerStore once the data to save has been gathered via Promisevoid
onSaveError
(String reason) Called from a DesignerStore if there was an error gathering the data to savevoid
onSelectionChange
(String rootViewPath, String detailsJson) Called when the selection changes.protected abstract void
onSelectionChangeInternal
(String rootViewPath, List<ComponentDetails> details) void
onSelectionConfigUpdated
(String changesJson) Called when one of the currently selected components config changes (bindings or event config)protected abstract void
void
onSelectionPropertyChange
(String rootViewPath, String changesJson) Called when one of the currently selected components' properties changesprotected abstract void
void
onStructureChange
(String structureJson) protected abstract void
onStructureChangeInternal
(ViewStructure structure) void
onSvgDropped
(String name, String svgSource, String dropPoint) void
onTagsDropped
(String path, String tagsJson, String dropPointJson, String modifiers) void
onUndoableAction
(String key, String json) void
void
pastePipes
(List<PipeConfig> pipe, Point point) Add pipes to the current deeply selected containervoid
void
removeChildPropertyConfigs
(String componentIndexPath, PropertyType scope, String propertyPath) void
removeProperty
(RemovePropertyChange change, boolean createUndoAction) void
renameProperty
(RenamePropertyChange change, boolean createUndoAction) void
void
replaceComponent
(String path, ComponentConfig component, boolean replaceAtLocation, boolean createUndoAction) Replaces the component at the specified path with the specified ComponentConfig.void
replaceComponentFromClipboard
(String path, String clipboardContents) Sends a message through the websocket held by the connection store.void
void
setDeepSelection
(String path) void
setPipeMode
(String pipeMode) Pipingvoid
setPipeSelection
(List<PipeSelectionDetail> details) void
setPreview
(boolean preview) void
setSelection
(List<String> selection) void
shutdown()
Must be called by the parent panel when it initiates shutdown.void
stylesUpdated
(String styles) void
wrapComponent
(String path, ViewWorkspaceActions.WrapInType type) Wraps a component at the specified Path with a specified Type of component.void
writeProperties
(WritePropertiesChange change) void
writeProperty
(WritePropertyChange change, boolean createUndoAction)
-
Field Details
-
log
-
gson
protected final com.inductiveautomation.ignition.common.gson.Gson gson
-
-
Constructor Details
-
JavaJsBridge
-
-
Method Details
-
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
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
Called from a DesignerStore if there was an error gathering the data to save- Parameters:
reason
- the reason why there was an error
-
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
-
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
-
getContextInternal
-
getSessionProps
-
getSessionPropsInternal
-
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
-
getComponentBaseName
-
onStructureChange
-
onStructureChangeInternal
-
activateComponentTool
-
activateComponentTool
-
invokeStoreFunction
Invokes a method on the DesignerStore.tsx object. -
notifyViewUpdated
-
sendRaw
Sends a message through the websocket held by the connection store. -
getComponentDetails
-
getEffectivePipeSelectionAppearance
-
setChildrenIndexes
-
writeProperty
-
writeProperties
-
insertProperty
-
renameProperty
-
removeProperty
-
alterPropertyConfig
-
alterEventConfig
-
alterScriptConfig
-
removeChildPropertyConfigs
public void removeChildPropertyConfigs(String componentIndexPath, PropertyType scope, String propertyPath) -
alterViewPermissions
-
getViewPermissions
-
onBindingPreviewValue
Called from a DesignerStore handler upon receiving the 'binding-edit-value-update' message.- Parameters:
serializedMessage
- Base64 serialized object from the gateway
-
onBindingPreviewValueInternal
-
onDeepSelectionChange
-
onDeepSelectionChangeInternal
protected abstract void onDeepSelectionChangeInternal(DeepSelection deepSelection, com.teamdev.jxbrowser.js.JsObject storeObject) -
onDeepSelectionPropsUpdated
-
onDeepSelectionPropsUpdatedInternal
-
onSelectionChange
Called when the selection changes.- Parameters:
detailsJson
- List<ComponentDetails> encoded in JSON
-
onSelectionChangeInternal
protected abstract void onSelectionChangeInternal(String rootViewPath, List<ComponentDetails> details) -
onSelectionPropertyChange
Called when one of the currently selected components' properties changes -
onSelectionPropertyChangeInternal
-
onSelectionConfigUpdated
Called when one of the currently selected components config changes (bindings or event config) -
onSelectionConfigUpdatedInternal
-
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
-
onConvertToDrawing
-
onSvgDropped
-
onTagsDropped
-
onUndoableAction
-
onErrorMessage
-
flattenSvg
-
setSelection
-
setDeepSelection
-
deleteSelected
public void deleteSelected()Deletes the components currently selected in the designer store. -
deleteComponents
Deletes the components at the given index paths -
convertComponentToDrawing
-
convertPipesToDrawing
-
convertSelectionToDrawing
public void convertSelectionToDrawing() -
flattenSelectedSvg
public void flattenSelectedSvg() -
alignSelectedComponents
public void alignSelectedComponents(CoordinateContainerDesignDelegate.AlignType type, Integer padding) -
reorderSelectedComponents
-
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 withreplaceAtLocation
- Determines if replacement should occur at the component to be replaced
-
replaceComponentFromClipboard
-
wrapComponent
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
Add components to the current deeply selected container, specifying the location -
addComponents
Add components to the current deeply selected container, specifying location and size -
copySelection
-
disableEditorEvents
public void disableEditorEvents() -
enableEditorEvents
public void enableEditorEvents() -
copyJsonToClipboard
public void copyJsonToClipboard() -
pasteJsonFromClipboard
public void pasteJsonFromClipboard() -
cutJsonToClipboard
public void cutJsonToClipboard() -
getViewConfig
- Returns:
- a
ViewConfig
's json string equivalent for a view found at the given path.
-
getViewConfigInternal
-
setPreview
public void setPreview(boolean preview) -
getSymbolicPath
-
stylesUpdated
-
reloadSymbolStyles
public void reloadSymbolStyles() -
getStyles
-
getSymbolStyles
-
setPipeMode
Piping -
onPipeModeChange
Called when the pipe mode changes. -
onPipeModeChangeInternal
-
setPipeSelection
-
onPipeSelectionChange
Called when the pipe selection changes. -
onPipeSelectionChangeInternal
protected abstract void onPipeSelectionChangeInternal(List<PipeSelectionDetail> details, boolean replaceComponentSelection) -
copySelectedPipe
-
pastePipes
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.
-