Class EditPane

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsWidget, LogicalStructure, HasClearHandlers, HasClickHandlers, HasDoubleClickHandlers, HasDragMoveHandlers, HasDragRepositionMoveHandlers, HasDragRepositionStartHandlers, HasDragRepositionStopHandlers, HasDragResizeMoveHandlers, HasDragResizeStartHandlers, HasDragResizeStopHandlers, HasDragStartHandlers, HasDragStopHandlers, HasDropHandlers, HasDropMoveHandlers, HasDropOutHandlers, HasDropOverHandlers, HasFocusChangedHandlers, HasHoverHandlers, HasHoverHiddenHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseStillDownHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasMovedHandlers, HasParentMovedHandlers, HasResizedHandlers, HasRightMouseDownHandlers, HasRuleContextChangedHandlers, HasScrolledHandlers, HasShowContextMenuHandlers, HasVisibilityChangedHandlers

public class EditPane extends Canvas
A container that allows drag and drop instantiation of visual components from a Palette, and direct manipulation of the position and size of those components.

Any drag onto an EditPane from a Palette will add an EditNode created from the dragged PaletteNode.

EditPane automatically creates an EditContext and provides several APIs and settings that are passthroughs to the underlying EditContext for convenience.

See Also:
  • Constructor Details

    • EditPane

      public EditPane()
    • EditPane

      public EditPane(JavaScriptObject jsObj)
  • Method Details

    • getOrCreateRef

      public static EditPane getOrCreateRef(JavaScriptObject jsObj)
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, Canvas defaults)
      Changes the defaults for Canvas AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, FormItem defaults)
      Changes the defaults for FormItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • create

      protected JavaScriptObject create()
      Overrides:
      create in class Canvas
    • setAllowNestedDrops

      public EditPane setAllowNestedDrops(Boolean allowNestedDrops) throws IllegalStateException
      Controls whether components can be dropped into other components which support child components.

      When enabled, during a drop interaction in which a PaletteNode or EditNode is the drop data, the Component Schema of the current candidate drop target is inspected to see whether that parent allows children of the type being dropped. If it does, the drop will result in a call to addNode() for a paletteNode or for an existing EditNode in the same tree.

      Specific components can disable nested drops by explicitly setting EditProxy.allowNestedDrops to false.

      This mode is enabled by default unless explicitly disabled by setting this property to false.

      Parameters:
      allowNestedDrops - New allowNestedDrops value. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getAllowNestedDrops

      public Boolean getAllowNestedDrops()
      Controls whether components can be dropped into other components which support child components.

      When enabled, during a drop interaction in which a PaletteNode or EditNode is the drop data, the Component Schema of the current candidate drop target is inspected to see whether that parent allows children of the type being dropped. If it does, the drop will result in a call to addNode() for a paletteNode or for an existing EditNode in the same tree.

      Specific components can disable nested drops by explicitly setting EditProxy.allowNestedDrops to false.

      This mode is enabled by default unless explicitly disabled by setting this property to false.

      Returns:
      Current allowNestedDrops value. Default value is null
    • setAutoEditNewNodes

      public EditPane setAutoEditNewNodes(Boolean autoEditNewNodes) throws IllegalStateException
      New nodes added to the editContext are automatically placed into edit mode if the new node's parent is in edit mode. To suppress this action set autoEditNewNodes to false.
      Parameters:
      autoEditNewNodes - New autoEditNewNodes value. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getAutoEditNewNodes

      public Boolean getAutoEditNewNodes()
      New nodes added to the editContext are automatically placed into edit mode if the new node's parent is in edit mode. To suppress this action set autoEditNewNodes to false.
      Returns:
      Current autoEditNewNodes value. Default value is null
    • setCanDragGroup

      public EditPane setCanDragGroup(Boolean canDragGroup) throws IllegalStateException
      Should the group selection box shown when canGroupSelect is true allow dragging the group as a whole?

      Treated as true if not set and canGroupSelect is true.

      Parameters:
      canDragGroup - New canDragGroup value. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getCanDragGroup

      public Boolean getCanDragGroup()
      Should the group selection box shown when canGroupSelect is true allow dragging the group as a whole?

      Treated as true if not set and canGroupSelect is true.

      Returns:
      Current canDragGroup value. Default value is null
    • setCanGroupSelect

      public EditPane setCanGroupSelect(Boolean canGroupSelect) throws IllegalStateException
      Should a group selection outline covering the outermost bounding boxes of all selected components be shown in this container?

      Treated as true if not set and hoop selection is enabled (see EditProxy.canSelectChildren and selectionType.

      Parameters:
      canGroupSelect - New canGroupSelect value. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getCanGroupSelect

      public Boolean getCanGroupSelect()
      Should a group selection outline covering the outermost bounding boxes of all selected components be shown in this container?

      Treated as true if not set and hoop selection is enabled (see EditProxy.canSelectChildren and selectionType.

      Returns:
      Current canGroupSelect value. Default value is null
    • setDefaultPalette

      public EditPane setDefaultPalette(Palette defaultPalette) throws IllegalStateException
      Palette to use when an EditNode is being created directly by this EditContext, instead of being created due to a user interaction with a palette (eg dragging from a TreePalette, or clicking on MenuPalette).

      If no defaultPalette is provided, the EditContext uses an automatically created HiddenPalette.

      If this method is called after the component has been drawn/initialized: Palette to use when an EditNode is being created directly by this EditContext, instead of being created due to a user interaction with a palette (eg dragging from a TreePalette, or clicking on MenuPalette).

      If no defaultPalette is provided, the EditContext uses an automatically created HiddenPalette.

      Parameters:
      defaultPalette - the default Palette. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getDefaultPalette

      public Palette getDefaultPalette()
      Palette to use when an EditNode is being created directly by this EditContext, instead of being created due to a user interaction with a palette (eg dragging from a TreePalette, or clicking on MenuPalette).

      If no defaultPalette is provided, the EditContext uses an automatically created HiddenPalette.

      Returns:
      Palette to use when an EditNode is being created directly by this EditContext, instead of being created due to a user interaction with a palette (eg dragging from a TreePalette, or clicking on MenuPalette).

      If no defaultPalette is provided, the EditContext uses an automatically created HiddenPalette. Default value is null

    • getEditContext

      public EditContext getEditContext() throws IllegalStateException
      An EditContext is automatically created to manage EditMode behavior. The public EditContext APIs exposed by the EditPane are passed through to this object.

      Additional editContext properties can be supplied as editContextProperties.

      This component is an AutoChild named "editContext". For an overview of how to use and configure AutoChildren, see Using AutoChildren.

      Returns:
      Returns the EditContext instance managed by the EditPane. Default value is null
      Throws:
      IllegalStateException - if this widget has not yet been rendered.
    • setEditContextProperties

      public EditPane setEditContextProperties(EditContext editContextProperties) throws IllegalStateException
      Properties to be applied to the editContext when created.
      Parameters:
      editContextProperties - New editContextProperties value. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getEditContextProperties

      public EditContext getEditContextProperties()
      Properties to be applied to the editContext when created.
      Returns:
      Current editContextProperties value. Default value is null
    • setExtraPalettes

      public EditPane setExtraPalettes(Palette... extraPalettes) throws IllegalStateException
      Additional Palettes to consult for metadata when deserializing Edit Nodes. Note that the defaultPalette is always consulted and need not be provided again here.
      Parameters:
      extraPalettes - New extraPalettes value. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getExtraPalettes

      public Palette[] getExtraPalettes()
      Additional Palettes to consult for metadata when deserializing Edit Nodes. Note that the defaultPalette is always consulted and need not be provided again here.
      Returns:
      Current extraPalettes value. Default value is null
    • setHideGroupBorderOnDrag

      public EditPane setHideGroupBorderOnDrag(Boolean hideGroupBorderOnDrag) throws IllegalStateException
      Should the group selection box shown when canGroupSelect is true be hidden during drag?

      Treated as true if not explicitly set to false.

      Parameters:
      hideGroupBorderOnDrag - New hideGroupBorderOnDrag value. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getHideGroupBorderOnDrag

      public Boolean getHideGroupBorderOnDrag()
      Should the group selection box shown when canGroupSelect is true be hidden during drag?

      Treated as true if not explicitly set to false.

      Returns:
      Current hideGroupBorderOnDrag value. Default value is null
    • setPersistCoordinates

      public EditPane setPersistCoordinates(Boolean persistCoordinates) throws IllegalStateException
      When enabled, changes to a liveObject's position and size will be persisted to their EditNodes by default. This applies to both programmatic calls and user interaction (drag reposition or drag resize).

      This feature can be disabled by either setting this property or EditProxy.persistCoordinates to false. This property affects all nodes within the EditContext whereas the latter property affects children of a single node.

      In some use-cases, like Reify, coordinates should not be persisted except when a component explicitly enables this feature. By setting this property to null no component will persist coordinates of children unless EditProxy.persistCoordinates is explicitly set to true.

      Parameters:
      persistCoordinates - New persistCoordinates value. Default value is true
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getPersistCoordinates

      public Boolean getPersistCoordinates()
      When enabled, changes to a liveObject's position and size will be persisted to their EditNodes by default. This applies to both programmatic calls and user interaction (drag reposition or drag resize).

      This feature can be disabled by either setting this property or EditProxy.persistCoordinates to false. This property affects all nodes within the EditContext whereas the latter property affects children of a single node.

      In some use-cases, like Reify, coordinates should not be persisted except when a component explicitly enables this feature. By setting this property to null no component will persist coordinates of children unless EditProxy.persistCoordinates is explicitly set to true.

      Returns:
      Current persistCoordinates value. Default value is true
    • setRootComponent

      public EditPane setRootComponent(Record rootComponent) throws IllegalStateException
      Root of data to edit. Must contain the "type" property, with the name of a valid schema or nothing will be able to be dropped on this EditContext. A "liveObject" property representing the rootComponent is also suggested. Otherwise, a live object will be created from the palette node.

      Can be retrieved at any time. Use getRootEditNode() to retrieve the EditNode created from the rootComponent.

      Parameters:
      rootComponent - New rootComponent value. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getRootComponent

      public Record getRootComponent()
      Root of data to edit. Must contain the "type" property, with the name of a valid schema or nothing will be able to be dropped on this EditContext. A "liveObject" property representing the rootComponent is also suggested. Otherwise, a live object will be created from the palette node.

      Can be retrieved at any time. Use getRootEditNode() to retrieve the EditNode created from the rootComponent.

      Returns:
      Current rootComponent value. Default value is null
      See Also:
    • setSelectedBorder

      public EditPane setSelectedBorder(String selectedBorder) throws IllegalStateException
      Set the CSS border to be applied to the selection outline of the selected components. This property is used when EditProxy.selectedAppearance is outlineMask or outlineEdges.

      This value is applied as a default to EditProxy.selectedBorder.

      Parameters:
      selectedBorder - New selectedBorder value. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getSelectedBorder

      public String getSelectedBorder()
      Set the CSS border to be applied to the selection outline of the selected components. This property is used when EditProxy.selectedAppearance is outlineMask or outlineEdges.

      This value is applied as a default to EditProxy.selectedBorder.

      Returns:
      Current selectedBorder value. Default value is null
    • setSelectedLabelBackgroundColor

      public EditPane setSelectedLabelBackgroundColor(String selectedLabelBackgroundColor) throws IllegalStateException
      The background color for the selection outline label. The default is defined on SelectionOutline.

      This value is applied as a default to EditProxy.selectedLabelBackgroundColor.

      NOTE: A selected component label is only supported when EditProxy.selectedAppearance is "outlineEdges".

      Parameters:
      selectedLabelBackgroundColor - New selectedLabelBackgroundColor value. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getSelectedLabelBackgroundColor

      public String getSelectedLabelBackgroundColor()
      The background color for the selection outline label. The default is defined on SelectionOutline.

      This value is applied as a default to EditProxy.selectedLabelBackgroundColor.

      NOTE: A selected component label is only supported when EditProxy.selectedAppearance is "outlineEdges".

      Returns:
      Current selectedLabelBackgroundColor value. Default value is null
      See Also:
    • setShowSelectedLabel

      public EditPane setShowSelectedLabel(Boolean showSelectedLabel) throws IllegalStateException
      Should the selection outline show a label for selected components? A component may also be highlighted with the selection outline and label to indicate the target of a drop. To suppress showing a label at any time set this property to false.

      To suppress labels during selection but still show them when targeted for a drop, see EditContext.showSelectedLabelOnSelect.

      NOTE: A selected component label is only supported when EditProxy.selectedAppearance is "outlineEdges".

      Parameters:
      showSelectedLabel - New showSelectedLabel value. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getShowSelectedLabel

      public Boolean getShowSelectedLabel()
      Should the selection outline show a label for selected components? A component may also be highlighted with the selection outline and label to indicate the target of a drop. To suppress showing a label at any time set this property to false.

      To suppress labels during selection but still show them when targeted for a drop, see EditContext.showSelectedLabelOnSelect.

      NOTE: A selected component label is only supported when EditProxy.selectedAppearance is "outlineEdges".

      Returns:
      Current showSelectedLabel value. Default value is null
    • setUseCopyPasteShortcuts

      public EditPane setUseCopyPasteShortcuts(Boolean useCopyPasteShortcuts) throws IllegalStateException
      If set, auto-enables EditProxy.useCopyPasteShortcuts on the EditProxy for the root editNode. This works whether there is currently a root editNode or one is added later.
      Parameters:
      useCopyPasteShortcuts - New useCopyPasteShortcuts value. Default value is null
      Returns:
      EditPane instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getUseCopyPasteShortcuts

      public Boolean getUseCopyPasteShortcuts()
      If set, auto-enables EditProxy.useCopyPasteShortcuts on the EditProxy for the root editNode. This works whether there is currently a root editNode or one is added later.
      Returns:
      Current useCopyPasteShortcuts value. Default value is null
    • addFromPaletteNode

      public EditNode addFromPaletteNode(PaletteNode paletteNode)
      Creates a new EditNode from a PaletteNode, using the defaultPalette. If you have an array of possibly inter-related PaletteNodes, then you should use addFromPaletteNodes() on the array instead, in order to preserve the relationships.
      Parameters:
      paletteNode - the palette node to use to create the new node
      Returns:
      the EditNode created from the paletteNode
      See Also:
    • addFromPaletteNode

      public EditNode addFromPaletteNode(PaletteNode paletteNode, EditNode parentNode)
      Creates a new EditNode from a PaletteNode, using the defaultPalette. If you have an array of possibly inter-related PaletteNodes, then you should use addFromPaletteNodes() on the array instead, in order to preserve the relationships.
      Parameters:
      paletteNode - the palette node to use to create the new node
      parentNode - optional the parent node if the new node should appear under a specific parent
      Returns:
      the EditNode created from the paletteNode
      See Also:
    • addFromPaletteNodes

      public EditNode[] addFromPaletteNodes(PaletteNode[] paletteNodes)
      Add the supplied PaletteNodes to the parentNode, preserving internal references from one supplied PaletteNode to another. This method should be used with an array of possibly inter-related PaletteNodes (for instance, those produced as a result of serialization via serializeAllEditNodes()) rather than calling addFromPaletteNode() on each individual PaletteNode.
      Parameters:
      paletteNodes - array of PaletteNodes
      Returns:
      an array of the EditNodes added to the parentNode
      See Also:
    • addFromPaletteNodes

      public EditNode[] addFromPaletteNodes(PaletteNode[] paletteNodes, EditNode parentNode)
      Add the supplied PaletteNodes to the parentNode, preserving internal references from one supplied PaletteNode to another. This method should be used with an array of possibly inter-related PaletteNodes (for instance, those produced as a result of serialization via serializeAllEditNodes()) rather than calling addFromPaletteNode() on each individual PaletteNode.
      Parameters:
      paletteNodes - array of PaletteNodes
      parentNode - parent to add to (defaults to the root)
      Returns:
      an array of the EditNodes added to the parentNode
      See Also:
    • addNode

      public EditNode addNode(EditNode newNode)
      Add a new EditNode to the EditContext, under the specified parent. If the parentNode is not provided it will be determined from EditContext.defaultParent.

      The EditContext will interrogate the parent and new nodes to determine what field within the parent allows a child of this type, and to find a method to add the newNode's liveObject to the parentNode's liveObject. The new relationship will then be stored in the tree of EditNodes.

      For example, when a Tab is dropped on a TabSet, the field TabSet.tabs is discovered as the correct target field via naming conventions, and the method TabSet.addTab() is likewise discovered as the correct method to add a Tab to a TabSet.

      Parameters:
      newNode - new node to be added
      Returns:
      newNodenode added
    • addNode

      public EditNode addNode(EditNode newNode, EditNode parentNode)
      See Also:
    • addNode

      public EditNode addNode(EditNode newNode, EditNode parentNode, Integer index)
      See Also:
    • addNode

      public EditNode addNode(EditNode newNode, EditNode parentNode, Integer index, String parentProperty)
      See Also:
    • addNode

      public EditNode addNode(EditNode newNode, EditNode parentNode, Integer index, String parentProperty, Boolean skipParentComponentAdd)
      See Also:
    • addNode

      public EditNode addNode(EditNode newNode, EditNode parentNode, Integer index, String parentProperty, Boolean skipParentComponentAdd, Boolean forceSingularFieldReplace)
      Add a new EditNode to the EditContext, under the specified parent. If the parentNode is not provided it will be determined from EditContext.defaultParent.

      The EditContext will interrogate the parent and new nodes to determine what field within the parent allows a child of this type, and to find a method to add the newNode's liveObject to the parentNode's liveObject. The new relationship will then be stored in the tree of EditNodes.

      For example, when a Tab is dropped on a TabSet, the field TabSet.tabs is discovered as the correct target field via naming conventions, and the method TabSet.addTab() is likewise discovered as the correct method to add a Tab to a TabSet.

      Parameters:
      newNode - new node to be added
      parentNode - parent to add the new node under.
      index - index within the parent's children array
      parentProperty - the property of the liveParent to which the new node should be added, if not auto-discoverable from the schema
      skipParentComponentAdd - whether to skip adding the liveObject to the liveParent (default false)
      forceSingularFieldReplace - whether to replace existing single field node if newNode liveObject is the same (default false)
      Returns:
      newNodenode added
    • addPaletteNodesFromJS

      public void addPaletteNodesFromJS(String jsCode)
      Add PaletteNodes from a JavaScript source representation.

      By default, components that have global IDs will not actually be allowed to take those global IDs - instead, only widgets that have one of the global IDs passed as the globals parameter will actually receive their global IDs. To override this behavior, pass the special value ALL_GLOBALS for the globals parameter.

      Parameters:
      jsCode - JavaScript code to eval.
    • addPaletteNodesFromJS

      public void addPaletteNodesFromJS(String jsCode, EditNode parentNode)
      See Also:
    • addPaletteNodesFromJS

      public void addPaletteNodesFromJS(String jsCode, EditNode parentNode, String[] globals)
      Add PaletteNodes from a JavaScript source representation.

      By default, components that have global IDs will not actually be allowed to take those global IDs - instead, only widgets that have one of the global IDs passed as the globals parameter will actually receive their global IDs. To override this behavior, pass the special value ALL_GLOBALS for the globals parameter.

      Parameters:
      jsCode - JavaScript code to eval.
      parentNode - parent node (defaults to the root)
      globals - widgets to allow to take their global IDs
    • addPaletteNodesFromJSON

      public void addPaletteNodesFromJSON(String jsonString)
      Recreate EditNodes from a JSON representation of PaletteNodes (possibly created by calling serializeAllEditNodesAsJSON() or serializeEditNodesAsJSON().

      By default, components that have global IDs will not actually be allowed to take those global IDs - instead, only widgets that have one of the global IDs passed as the globals parameter will actually receive their global IDs. To override this behavior, pass the special value ALL_GLOBALS for the globals parameter.

      Parameters:
      jsonString - JSON string representing an array of PaletteNodes
      See Also:
    • addPaletteNodesFromJSON

      public void addPaletteNodesFromJSON(String jsonString, EditNode parentNode)
      See Also:
    • addPaletteNodesFromJSON

      public void addPaletteNodesFromJSON(String jsonString, EditNode parentNode, String[] globals)
      See Also:
    • addPaletteNodesFromJSON

      public void addPaletteNodesFromJSON(String jsonString, EditNode parentNode, String[] globals, Function callback)
      Recreate EditNodes from a JSON representation of PaletteNodes (possibly created by calling serializeAllEditNodesAsJSON() or serializeEditNodesAsJSON().

      By default, components that have global IDs will not actually be allowed to take those global IDs - instead, only widgets that have one of the global IDs passed as the globals parameter will actually receive their global IDs. To override this behavior, pass the special value ALL_GLOBALS for the globals parameter.

      Parameters:
      jsonString - JSON string representing an array of PaletteNodes
      parentNode - parent to add to (defaults to the root)
      globals - widgets to allow to take their global IDs
      callback - Callback to fire after nodes have been added
      See Also:
    • addPaletteNodesFromXML

      public void addPaletteNodesFromXML(String xmlString)
      Recreate EditNodes from an XML representation of PaletteNodes (possibly created by calling serializeAllEditNodes() or serializeEditNodes().

      By default, components that have global IDs will not actually be allowed to take those global IDs - instead, only widgets that have one of the global IDs passed as the globals parameter will actually receive their global IDs. To override this behavior, pass the special value ALL_GLOBALS for the globals parameter.

      Parameters:
      xmlString - XML string
      See Also:
    • addPaletteNodesFromXML

      public void addPaletteNodesFromXML(String xmlString, EditNode parentNode)
      See Also:
    • addPaletteNodesFromXML

      public void addPaletteNodesFromXML(String xmlString, EditNode parentNode, String[] globals)
      See Also:
    • addPaletteNodesFromXML

      public void addPaletteNodesFromXML(String xmlString, EditNode parentNode, String[] globals, Function callback)
      Recreate EditNodes from an XML representation of PaletteNodes (possibly created by calling serializeAllEditNodes() or serializeEditNodes().

      By default, components that have global IDs will not actually be allowed to take those global IDs - instead, only widgets that have one of the global IDs passed as the globals parameter will actually receive their global IDs. To override this behavior, pass the special value ALL_GLOBALS for the globals parameter.

      Parameters:
      xmlString - XML string
      parentNode - parent node (defaults to the root)
      globals - widgets to allow to take their global IDs
      callback - Callback to fire after nodes have been added
      See Also:
    • copyEditNodes

      public void copyEditNodes(EditNode editNode)
      Copies the passed editNode or editNodes to an internal "clipboard" space, for later application via pasteEditNodes().
      Parameters:
      editNode -
    • copyEditNodes

      public void copyEditNodes(EditNode... editNode)
      Copies the passed editNode or editNodes to an internal "clipboard" space, for later application via pasteEditNodes().
      Parameters:
      editNode -
    • destroyAll

      public void destroyAll()
      Removes all EditNodes from the EditContext, and calls destroy() on the liveObjects.
    • enableEditing

      public void enableEditing(EditNode editNode)
      Enable edit mode for an EditNode. This is a shortcut for calling Canvas.setEditMode().
      Parameters:
      editNode - the EditNode on which to enable editing
      See Also:
    • getEditNodeTree

      public Tree getEditNodeTree()
      Gets the tree of editNodes being edited by this editContext. Standard tree traversal methods can then be used to locate desired editNodes for interaction.

      Note: the returned tree is read-only and must only be modified by calling methods on EditContext like EditContext.addNode() or EditContext.setNodeProperties().

      Returns:
      the tree of EditNodes
    • getNodeProperty

      public void getNodeProperty(EditNode editNode, String name)
      Returns the specified property from the editNode's serializable "defaults".
      Parameters:
      editNode - the editNode to query
      name - the property name to query
      See Also:
    • getPaletteNodesFromJS

      public void getPaletteNodesFromJS(String jsCode, PaletteNodeCallback callback)
      Obtain PaletteNodes from a JavaScript source representation.

      By default, components that have global IDs will not actually be allowed to take those global IDs - instead, only widgets that have one of the global IDs passed as the globals parameter will actually receive their global IDs. To override this behavior, pass the special value ALL_GLOBALS for the globals parameter.

      Parameters:
      jsCode - JavaScript code to eval.
      callback - Callback used to return the PaletteNodes
    • getPaletteNodesFromJS

      public void getPaletteNodesFromJS(String jsCode, PaletteNodeCallback callback, String[] globals)
      Obtain PaletteNodes from a JavaScript source representation.

      By default, components that have global IDs will not actually be allowed to take those global IDs - instead, only widgets that have one of the global IDs passed as the globals parameter will actually receive their global IDs. To override this behavior, pass the special value ALL_GLOBALS for the globals parameter.

      Parameters:
      jsCode - JavaScript code to eval.
      callback - Callback used to return the PaletteNodes
      globals - widgets to allow to take their global IDs
    • getPaletteNodesFromXML

      public void getPaletteNodesFromXML(String xmlString, PaletteNodeCallback callback)
      Obtain PaletteNodes from an XML representation, but do not add them to the EditContext.
      Parameters:
      xmlString - XML string
      callback - Callback used to return the PaletteNodes
      See Also:
    • getRootEditNode

      public EditNode getRootEditNode()
      Returns the root EditNode of the EditContext typically created from rootComponent.
      Returns:
      the root EditNode
    • getSaveData

      public PaletteNode[] getSaveData()
      Returns an Array of PaletteNodes representing all current EditNodes in this pane, suitable for saving and restoring via passing each paletteNode to addNode().
      Returns:
      paletteNodes suitable for saving for subsequent restoration
      See Also:
    • isNodeEditingOn

      public boolean isNodeEditingOn(EditNode editNode)
      Returns true if editNode is in edit mode.
      Parameters:
      editNode - the EditNode
      Returns:
      true if node is in edit mode
    • makeEditNode

      public EditNode makeEditNode(PaletteNode paletteNode)
      Creates and returns an EditNode using the defaultPalette. Does not add the newly created EditNode to an EditContext.
      Parameters:
      paletteNode - the palette node to use to create the new node
      Returns:
      the EditNode created from the paletteNode
    • makePaletteNode

      public PaletteNode makePaletteNode(EditNode editNode)
      Creates a PaletteNode from an EditNode in this context's editNodeTree.

      This essentially creates a new PaletteNode with the EditNode.defaults from the passed editNode. The returned paletteNode could then be used with EditContext.addFromPaletteNode() to effectively create a copy of the original editNode - specifically a new editNode with a new EditNode.liveObject created from the same defaults.

      However note that makePaletteNode() does not copy descendant nodes - use makePaletteNodeTree() for that.

      May return null if the passed editNode cannot validly by transformed into a paletteNode, for example if EditNode.canDuplicate was set false.

      Parameters:
      editNode - the editNode to use to make a paletteNode
      Returns:
      paletteNode derived from the editNode or null
    • makePaletteNodeTree

      public Tree makePaletteNodeTree(EditNode editNode)
      Creates a Tree of PaletteNodes from an EditNode in this context's editNodeTree, by using makePaletteNode() on the passed EditNode and its descendents within the editNodeTree.

      The root node of the returned Tree will be a PaletteNode derived from the passed EditNode.

      Parameters:
      editNode - root editNode to make Tree of PaletteNodes from
      Returns:
      a Tree of paletteNodes or null
    • pasteEditNodes

      public void pasteEditNodes()
      "Pastes" editNodes previously captured via copyEditNodes().

      New editNodes will be added as root-level nodes of the editNodeTree unless a targetEditNode is passed.

    • pasteEditNodes

      public void pasteEditNodes(EditNode targetEditNode)
      "Pastes" editNodes previously captured via copyEditNodes().

      New editNodes will be added as root-level nodes of the editNodeTree unless a targetEditNode is passed.

      Parameters:
      targetEditNode -
    • removeAll

      public void removeAll()
      Removes all EditNodes from the EditContext, but does not destroy the liveObjects.
    • removeNode

      public void removeNode(EditNode editNode)
      Removes EditNode from the EditContext. The editNode liveObject is not destroyed.
      Parameters:
      editNode - node to be removed
    • removeNodeProperties

      public void removeNodeProperties(EditNode editNode, String[] properties)
      Removes the specified properties from an editNode's serializable "defaults". Note that the liveObject is not updated by this method. To set a property to null (rather than removing it), use setNodeProperties() instead.
      Parameters:
      editNode - the editNode to update
      properties - an array of property names to remove
      See Also:
    • reorderNode

      public void reorderNode(EditNode parentNode, Integer index, Integer moveToIndex)
      Moves an EditNode from one child index to another in the EditContext under the specified parent.

      No changes are made to the live objects.

      Parameters:
      parentNode - parent to reorder child nodes
      index - index within the parent's children array to be moved
      moveToIndex - index within the parent's children array at which to place moved node
    • serializeAllEditNodes

      public String serializeAllEditNodes()
      Serialize the tree of EditNodes to an XML representation of PaletteNodes. The result can be supplied to addPaletteNodesFromXML() to recreate the EditNodes.
      Returns:
      an XML representation of PaletteNodes which can be used to recreate the tree of EditNodes.
      See Also:
    • serializeAllEditNodes

      public String serializeAllEditNodes(SerializationSettings settings)
      Serialize the tree of EditNodes to an XML representation of PaletteNodes. The result can be supplied to addPaletteNodesFromXML() to recreate the EditNodes.
      Parameters:
      settings - Additional serialization settings
      Returns:
      an XML representation of PaletteNodes which can be used to recreate the tree of EditNodes.
      See Also:
    • serializeAllEditNodesAsJSON

      public String serializeAllEditNodesAsJSON()
      Encode the tree of EditNodes to a JSON representation of PaletteNodes. The result can be supplied to addPaletteNodesFromJSON() to recreate the EditNodes.
      Returns:
      a JSON representation of PaletteNodes which can be used to recreate the tree of EditNodes.
      See Also:
    • serializeAllEditNodesAsJSON

      public String serializeAllEditNodesAsJSON(SerializationSettings settings)
      Encode the tree of EditNodes to a JSON representation of PaletteNodes. The result can be supplied to addPaletteNodesFromJSON() to recreate the EditNodes.
      Parameters:
      settings - Additional serialization settings
      Returns:
      a JSON representation of PaletteNodes which can be used to recreate the tree of EditNodes.
      See Also:
    • serializeEditNodes

      public String serializeEditNodes(EditNode[] nodes)
      Serialize the provided EditNodes to an XML representation of PaletteNodes. Note that the EditNodes must have been added to this EditContext. The result can be supplied to addPaletteNodesFromXML() to recreate the EditNodes.
      Parameters:
      nodes - EditNodes to be serialized
      Returns:
      an XML representtion of the provided EditNodes
    • serializeEditNodes

      public String serializeEditNodes(EditNode[] nodes, SerializationSettings settings)
      Serialize the provided EditNodes to an XML representation of PaletteNodes. Note that the EditNodes must have been added to this EditContext. The result can be supplied to addPaletteNodesFromXML() to recreate the EditNodes.
      Parameters:
      nodes - EditNodes to be serialized
      settings - Additional serialization settings
      Returns:
      an XML representtion of the provided EditNodes
    • serializeEditNodesAsJSON

      public String serializeEditNodesAsJSON(EditNode[] nodes)
      Serialize the provided EditNodes to a JSON representation of PaletteNodes. Note that the EditNodes must have been added to this EditContext. The result can be supplied to addPaletteNodesFromJSON() to recreate the EditNodes.
      Parameters:
      nodes - EditNodes to be serialized
      Returns:
      a JSON representtion of the provided EditNodes
    • serializeEditNodesAsJSON

      public String serializeEditNodesAsJSON(EditNode[] nodes, SerializationSettings settings)
      Serialize the provided EditNodes to a JSON representation of PaletteNodes. Note that the EditNodes must have been added to this EditContext. The result can be supplied to addPaletteNodesFromJSON() to recreate the EditNodes.
      Parameters:
      nodes - EditNodes to be serialized
      settings - Additional serialization settings
      Returns:
      a JSON representtion of the provided EditNodes
    • setNodeProperties

      public void setNodeProperties(EditNode editNode, Canvas properties)
      Update an editNode's serializable "defaults" with the supplied properties. If you wish to remove a property from the defaults (rather than setting it to null), then use removeNodeProperties() instead.
      Parameters:
      editNode - the editNode to update
      properties - the properties to apply
      See Also:
    • setNodeProperties

      public void setNodeProperties(EditNode editNode, Canvas properties, Boolean skipLiveObjectUpdate)
      Update an editNode's serializable "defaults" with the supplied properties. If you wish to remove a property from the defaults (rather than setting it to null), then use removeNodeProperties() instead.
      Parameters:
      editNode - the editNode to update
      properties - the properties to apply
      skipLiveObjectUpdate - whether to skip updating the liveObject, e.g. if you have already updated the liveObject
      See Also:
    • setDefaultProperties

      public static void setDefaultProperties(EditPane editPaneProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      editPaneProperties - properties that should be used as new defaults when instances of this class are created
      See Also:
    • setLogicalStructure

      public LogicalStructureObject setLogicalStructure(EditPaneLogicalStructure s)
      Setter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
    • getLogicalStructure

      public LogicalStructureObject getLogicalStructure()
      Getter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
      Specified by:
      getLogicalStructure in interface LogicalStructure
      Overrides:
      getLogicalStructure in class Canvas