Class JavaJsBridge
- java.lang.Object
-
- com.inductiveautomation.perspective.designer.workspace.JavaJsBridge
-
- Direct Known Subclasses:
SessionPropsAdapter.SessionAdapterBridge
,ViewEditorJsBridge
public abstract class JavaJsBridge extends java.lang.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 withJsAccessible
.- Since:
- 8.0.0
-
-
Constructor Summary
Constructors Constructor Description JavaJsBridge(com.teamdev.jxbrowser.browser.Browser browser)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
activateComponentTool(java.lang.String componentType)
void
activateComponentTool(java.lang.String componentType, java.lang.String variantId)
void
addComponents(java.util.List<ComponentConfig> componentConfigs, java.awt.Point point)
Add components to the current deeply selected container, specifying the locationvoid
addComponents(java.util.List<ComponentConfig> componentConfigs, java.awt.Rectangle location)
Add components to the current deeply selected container, specifying location and sizevoid
addComponentsToContainer(java.lang.String parentIndexPath, java.util.List<ComponentConfig> componentConfigs, java.awt.Rectangle location)
Add components to a specific container, even if it isn't deeply selected.void
alignSelectedComponents(CoordinateContainerDesignDelegate.AlignType type, java.lang.Integer padding)
void
alterEventConfig(EventConfigChange change)
void
alterPropertyConfig(PropertyConfigChange change)
void
alterScriptConfig(ScriptConfigChange change)
abstract void
alterViewPermissions(PermissionsConfig permissionsConfig)
void
copyJsonToClipboard()
java.util.concurrent.CompletableFuture<JxValue>
copySelection()
void
cutJsonToClipboard()
void
deleteComponents(java.lang.String[] indexPaths)
Deletes the components at the given index pathsvoid
deleteSelected()
Deletes the components currently selected in the designer store.void
disableEditorEvents()
void
enableEditorEvents()
void
flattenSelectedSvg()
void
flattenSvg(java.lang.String svg, java.lang.String position, java.lang.String name)
protected abstract java.lang.String
getBridgeDesc()
java.lang.String
getChildPositionDefaults(java.lang.String componentType, boolean forInit)
java.lang.String
getComponentBaseName(java.lang.String componentType)
java.util.concurrent.CompletableFuture<ComponentDetails>
getComponentDetails(java.lang.String componentIndexPath)
protected abstract DesignerContext
getContextInternal()
<T> java.util.concurrent.CompletableFuture<T>
getForSave(java.util.function.BiFunction<java.lang.String,com.inductiveautomation.ignition.common.gson.Gson,T> parse)
Retrieves the view config from the running View instance in the DesignerViewInstanceStore.java.lang.String
getInitMsg()
Gets the info needed to open a new view for editing.java.lang.String
getOwnViewConfig()
Gets the current view configuration from the Designer Project.java.lang.String
getOwnViewPath()
Called to get the current name of the project resource associated with a view's tabId.java.lang.String
getPropertyDefaults(java.lang.String propertyType, java.lang.String componentType, java.lang.String variantId, boolean forInit)
Returns a json object containing the default properties registered in the component registry.java.lang.String
getSessionProps()
protected abstract SessionPropsConfig
getSessionPropsInternal()
java.lang.String
getStyles()
java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>>
getSymbolicPath(java.lang.String indexPath)
java.lang.String
getViewConfig(java.lang.String resourcePath)
protected abstract ViewConfig
getViewConfigInternal()
protected abstract ViewConfig
getViewConfigInternal(java.lang.String resourcePath)
protected abstract java.lang.String
getViewPathInternal()
abstract java.util.concurrent.CompletableFuture<PermissionsConfig>
getViewPermissions()
protected java.util.concurrent.CompletableFuture<JxValue>
invokeStoreFunction(java.lang.String functionName, java.lang.Object... args)
Invokes a method on the DesignerStore.tsx object.void
notifyViewUpdated(java.lang.String path)
void
onBindingPreviewValue(java.lang.String serializedMessage)
Called from a DesignerStore handler upon receiving the 'binding-edit-value-update' message.protected abstract void
onBindingPreviewValueInternal(BindingEditValueUpdate update)
void
onContextMenu(java.lang.String pointJson, boolean isSvg, boolean isView)
protected abstract void
onContextMenuInternal(java.awt.Point point, boolean isSvg, boolean isView)
void
onDeepSelectionChange(java.lang.String json)
protected abstract void
onDeepSelectionChangeInternal(DeepSelection deepSelection, com.teamdev.jxbrowser.js.JsObject storeObject)
void
onDeepSelectionPropsUpdated(java.lang.String json)
protected abstract void
onDeepSelectionPropsUpdatedInternal(DeepSelectionUpdateEvent event)
void
onImageDropped(java.lang.String imageSource, java.lang.String dropPoint)
void
onSaveComplete(java.lang.String json)
Called from a DesignerStore once the data to save has been gathered via Promisevoid
onSaveError(java.lang.String reason)
Called from a DesignerStore if there was an error gathering the data to savevoid
onSelectionChange(java.lang.String detailsJson)
Called when the selection changes.protected abstract void
onSelectionChangeInternal(java.util.List<ComponentDetails> details)
void
onSelectionConfigUpdated(java.lang.String changesJson)
Called when one of the currently selected components config changes (bindings or event config)protected abstract void
onSelectionConfigUpdatedInternal(java.util.List<ComponentDetails> changes)
void
onSelectionPropertyChange(java.lang.String changesJson)
Called when one of the currently selected components' properties changesprotected abstract void
onSelectionPropertyChangeInternal(SelectionPropertyUpdateEvent event)
void
onStructureChange(java.lang.String structureJson)
protected abstract void
onStructureChangeInternal(ViewStructure structure)
void
onSvgDropped(java.lang.String name, java.lang.String svgSource, java.lang.String dropPoint)
void
onTagsDropped(java.lang.String path, java.lang.String tagsJson, java.lang.String dropPointJson, java.lang.String modifiers)
void
onUndoableAction(java.lang.String key, java.lang.String json)
void
pasteJsonFromClipboard()
void
removeChildPropertyConfigs(java.lang.String componentIndexPath, PropertyType scope, java.lang.String propertyPath)
void
removeProperty(java.lang.String componentIndexPath, PropertyType scope, java.lang.String pathToParent, int index)
void
removeProperty(java.lang.String componentIndexPath, PropertyType scope, java.lang.String pathToParent, java.lang.String name)
void
renameProperty(java.lang.String componentIndexPath, PropertyType scope, java.lang.String pathToParent, java.lang.String oldName, java.lang.String newName)
void
reorderSelectedComponents(ViewWorkspaceActions.ReorderType type)
void
replaceComponent(java.lang.String path, ComponentConfig component)
Replaces the component at the specified path with the specified ComponentConfig.java.util.concurrent.CompletableFuture<JxValue>
sendRaw(java.lang.String protocol, java.lang.String payloadJson)
Sends a message through the websocket held by the connection store.void
setDeepSelection(java.lang.String path)
void
setPreview(boolean preview)
void
setSelection(java.util.List<java.lang.String> selection)
void
stylesUpdated(java.lang.String styles)
void
wrapComponent(java.lang.String path, ViewWorkspaceActions.WrapInType type)
Wraps a component at the specified Path with a specified Type of component.void
write(java.lang.String componentIndexPath, PropertyType scope, java.lang.String propertyPath, java.lang.String valueAsJson)
-
-
-
Field Detail
-
log
protected final LoggerEx log
-
gson
protected final com.inductiveautomation.ignition.common.gson.Gson gson
-
-
Method Detail
-
getBridgeDesc
protected abstract java.lang.String getBridgeDesc()
-
getForSave
public <T> java.util.concurrent.CompletableFuture<T> getForSave(java.util.function.BiFunction<java.lang.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(java.lang.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(java.lang.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 java.lang.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 java.lang.String getViewPathInternal()
-
getOwnViewConfig
public java.lang.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 java.lang.String getSessionProps()
-
getSessionPropsInternal
protected abstract SessionPropsConfig getSessionPropsInternal()
-
getInitMsg
public java.lang.String getInitMsg()
Gets the info needed to open a new view for editing.
-
getPropertyDefaults
public java.lang.String getPropertyDefaults(java.lang.String propertyType, java.lang.String componentType, java.lang.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 java.lang.String getChildPositionDefaults(java.lang.String componentType, boolean forInit)
-
getComponentBaseName
public java.lang.String getComponentBaseName(java.lang.String componentType)
-
onStructureChange
public void onStructureChange(java.lang.String structureJson)
-
onStructureChangeInternal
protected abstract void onStructureChangeInternal(ViewStructure structure)
-
activateComponentTool
public void activateComponentTool(java.lang.String componentType)
-
activateComponentTool
public void activateComponentTool(java.lang.String componentType, java.lang.String variantId)
-
invokeStoreFunction
protected java.util.concurrent.CompletableFuture<JxValue> invokeStoreFunction(java.lang.String functionName, java.lang.Object... args)
Invokes a method on the DesignerStore.tsx object.
-
notifyViewUpdated
public void notifyViewUpdated(java.lang.String path)
-
sendRaw
public java.util.concurrent.CompletableFuture<JxValue> sendRaw(java.lang.String protocol, java.lang.String payloadJson)
Sends a message through the websocket held by the connection store.
-
getComponentDetails
public java.util.concurrent.CompletableFuture<ComponentDetails> getComponentDetails(java.lang.String componentIndexPath)
-
write
public void write(java.lang.String componentIndexPath, PropertyType scope, java.lang.String propertyPath, java.lang.String valueAsJson)
-
renameProperty
public void renameProperty(java.lang.String componentIndexPath, PropertyType scope, java.lang.String pathToParent, java.lang.String oldName, java.lang.String newName)
-
removeProperty
public void removeProperty(java.lang.String componentIndexPath, PropertyType scope, java.lang.String pathToParent, java.lang.String name)
-
removeProperty
public void removeProperty(java.lang.String componentIndexPath, PropertyType scope, java.lang.String pathToParent, int index)
-
alterPropertyConfig
public void alterPropertyConfig(PropertyConfigChange change)
-
alterEventConfig
public void alterEventConfig(EventConfigChange change)
-
alterScriptConfig
public void alterScriptConfig(ScriptConfigChange change)
-
removeChildPropertyConfigs
public void removeChildPropertyConfigs(java.lang.String componentIndexPath, PropertyType scope, java.lang.String propertyPath)
-
alterViewPermissions
public abstract void alterViewPermissions(PermissionsConfig permissionsConfig)
-
getViewPermissions
public abstract java.util.concurrent.CompletableFuture<PermissionsConfig> getViewPermissions()
-
onBindingPreviewValue
public void onBindingPreviewValue(java.lang.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(java.lang.String json)
-
onDeepSelectionChangeInternal
protected abstract void onDeepSelectionChangeInternal(DeepSelection deepSelection, com.teamdev.jxbrowser.js.JsObject storeObject)
-
onDeepSelectionPropsUpdated
public void onDeepSelectionPropsUpdated(java.lang.String json)
-
onDeepSelectionPropsUpdatedInternal
protected abstract void onDeepSelectionPropsUpdatedInternal(DeepSelectionUpdateEvent event)
-
onSelectionChange
public void onSelectionChange(java.lang.String detailsJson)
Called when the selection changes.- Parameters:
detailsJson
- List<ComponentDetails> encoded in JSON
-
onSelectionChangeInternal
protected abstract void onSelectionChangeInternal(java.util.List<ComponentDetails> details)
-
onSelectionPropertyChange
public void onSelectionPropertyChange(java.lang.String changesJson)
Called when one of the currently selected components' properties changes
-
onSelectionPropertyChangeInternal
protected abstract void onSelectionPropertyChangeInternal(SelectionPropertyUpdateEvent event)
-
onSelectionConfigUpdated
public void onSelectionConfigUpdated(java.lang.String changesJson)
Called when one of the currently selected components config changes (bindings or event config)
-
onSelectionConfigUpdatedInternal
protected abstract void onSelectionConfigUpdatedInternal(java.util.List<ComponentDetails> changes)
-
onContextMenu
public void onContextMenu(java.lang.String pointJson, boolean isSvg, boolean isView)
-
onContextMenuInternal
protected abstract void onContextMenuInternal(java.awt.Point point, boolean isSvg, boolean isView)
-
onImageDropped
public void onImageDropped(java.lang.String imageSource, java.lang.String dropPoint)
-
onSvgDropped
public void onSvgDropped(java.lang.String name, java.lang.String svgSource, java.lang.String dropPoint)
-
onTagsDropped
public void onTagsDropped(java.lang.String path, java.lang.String tagsJson, java.lang.String dropPointJson, java.lang.String modifiers)
-
onUndoableAction
public void onUndoableAction(java.lang.String key, java.lang.String json)
-
flattenSvg
public void flattenSvg(java.lang.String svg, java.lang.String position, java.lang.String name)
-
setSelection
public void setSelection(java.util.List<java.lang.String> selection)
-
setDeepSelection
public void setDeepSelection(java.lang.String path)
-
deleteSelected
public void deleteSelected()
Deletes the components currently selected in the designer store.
-
deleteComponents
public void deleteComponents(java.lang.String[] indexPaths)
Deletes the components at the given index paths
-
flattenSelectedSvg
public void flattenSelectedSvg()
-
alignSelectedComponents
public void alignSelectedComponents(CoordinateContainerDesignDelegate.AlignType type, java.lang.Integer padding)
-
reorderSelectedComponents
public void reorderSelectedComponents(ViewWorkspaceActions.ReorderType type)
-
replaceComponent
public void replaceComponent(java.lang.String path, ComponentConfig component)
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
-
wrapComponent
public void wrapComponent(java.lang.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(java.lang.String parentIndexPath, java.util.List<ComponentConfig> componentConfigs, @Nullable java.awt.Rectangle location)
Add components to a specific container, even if it isn't deeply selected.
-
addComponents
public void addComponents(java.util.List<ComponentConfig> componentConfigs, @Nullable java.awt.Point point)
Add components to the current deeply selected container, specifying the location
-
addComponents
public void addComponents(java.util.List<ComponentConfig> componentConfigs, java.awt.Rectangle location)
Add components to the current deeply selected container, specifying location and size
-
copySelection
public java.util.concurrent.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 java.lang.String getViewConfig(java.lang.String resourcePath)
- Returns:
- a
ViewConfig
's json string equivalent for a view found at the given path.
-
getViewConfigInternal
protected abstract ViewConfig getViewConfigInternal(java.lang.String resourcePath)
-
setPreview
public void setPreview(boolean preview)
-
getSymbolicPath
public java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> getSymbolicPath(java.lang.String indexPath)
-
stylesUpdated
public void stylesUpdated(java.lang.String styles)
-
getStyles
public java.lang.String getStyles()
-
-