public interface EditContext
An EditContext is typically populated by
adding a series of EditNodes
created via a Palette
, either via drag and drop creation, or when loading from a saved version, via addFromPaletteNode()
or addPaletteNodesFromXML()
.
An EditContext then provides interfaces for further editing of the components represented by EditNodes.
Modifier and Type | Method and Description |
---|---|
EditNode |
addFromPaletteNode(PaletteNode paletteNode)
Creates a new EditNode from a PaletteNode, using the
defaultPalette . |
EditNode |
addFromPaletteNode(PaletteNode paletteNode,
EditNode parentNode)
Creates a new EditNode from a PaletteNode, using the
defaultPalette . |
EditNode[] |
addFromPaletteNodes(PaletteNode[] paletteNodes)
Add the supplied
PaletteNodes to the parentNode, preserving internal
references from one supplied PaletteNode to another. |
EditNode[] |
addFromPaletteNodes(PaletteNode[] paletteNodes,
EditNode parentNode)
Add the supplied
PaletteNodes to the parentNode, preserving internal
references from one supplied PaletteNode to another. |
EditNode |
addNode(EditNode newNode)
Add a new
EditNode to the EditContext, under the specified parent. |
EditNode |
addNode(EditNode newNode,
EditNode parentNode) |
EditNode |
addNode(EditNode newNode,
EditNode parentNode,
java.lang.Integer index) |
EditNode |
addNode(EditNode newNode,
EditNode parentNode,
java.lang.Integer index,
java.lang.String parentProperty) |
EditNode |
addNode(EditNode newNode,
EditNode parentNode,
java.lang.Integer index,
java.lang.String parentProperty,
java.lang.Boolean skipParentComponentAdd)
Add a new
EditNode to the EditContext, under the specified parent. |
void |
addPaletteNodesFromJS(java.lang.String jsCode)
Add
PaletteNodes from a JavaScript source representation. |
void |
addPaletteNodesFromJS(java.lang.String jsCode,
EditNode parentNode) |
void |
addPaletteNodesFromJS(java.lang.String jsCode,
EditNode parentNode,
java.lang.String[] globals)
Add
PaletteNodes from a JavaScript source representation. |
void |
addPaletteNodesFromJSON(java.lang.String jsonString)
Recreate
EditNodes from a JSON representation of PaletteNodes (possibly created by calling EditContext.serializeAllEditNodesAsJSON() or EditContext.serializeEditNodesAsJSON() . |
void |
addPaletteNodesFromJSON(java.lang.String jsonString,
EditNode parentNode) |
void |
addPaletteNodesFromJSON(java.lang.String jsonString,
EditNode parentNode,
java.lang.String[] globals)
Recreate
EditNodes from a JSON representation of PaletteNodes (possibly created by calling EditContext.serializeAllEditNodesAsJSON() or EditContext.serializeEditNodesAsJSON() . |
void |
addPaletteNodesFromXML(java.lang.String xmlString)
Recreate
EditNodes from an XML representation of PaletteNodes (possibly created by calling EditContext.serializeAllEditNodes() or EditContext.serializeEditNodes() . |
void |
addPaletteNodesFromXML(java.lang.String xmlString,
EditNode parentNode) |
void |
addPaletteNodesFromXML(java.lang.String xmlString,
EditNode parentNode,
java.lang.String[] globals)
Recreate
EditNodes from an XML representation of PaletteNodes (possibly created by calling EditContext.serializeAllEditNodes() or EditContext.serializeEditNodes() . |
void |
destroyAll()
|
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 ). |
Palette[] |
getExtraPalettes()
Additional
Palettes to consult for metadata when deserializing Edit Nodes . |
void |
getPaletteNodesFromJS(java.lang.String jsCode,
PaletteNodeCallback callback)
Obtain
PaletteNodes from a JavaScript source representation. |
void |
getPaletteNodesFromJS(java.lang.String jsCode,
PaletteNodeCallback callback,
java.lang.String[] globals)
Obtain
PaletteNodes from a JavaScript source representation. |
void |
getPaletteNodesFromXML(java.lang.String xmlString,
PaletteNodeCallback callback)
Obtain
PaletteNodes from an XML representation, but do not add them to the
EditContext. |
boolean |
getPersistCoordinates()
If enabled, changes to a
liveObject 's position and size will be
persisted to their EditNodes . |
EditNode |
makeEditNode(PaletteNode paletteNode)
Creates and returns an EditNode using the
defaultPalette . |
void |
removeAll()
Removes all
EditNodes from the EditContext, but does not destroy the liveObjects . |
void |
removeNodeProperties(EditNode editNode,
java.lang.String[] properties)
Removes the specified properties from an editNode's serializable "defaults".
|
java.lang.String |
serializeAllEditNodes()
Serialize the tree of
EditNodes to an XML representation of PaletteNodes . |
java.lang.String |
serializeAllEditNodes(java.lang.Boolean serverless)
Serialize the tree of
EditNodes to an XML representation of PaletteNodes . |
java.lang.String |
serializeAllEditNodesAsJSON()
Encode the tree of
EditNodes to a JSON representation of PaletteNodes . |
java.lang.String |
serializeAllEditNodesAsJSON(java.lang.Boolean serverless)
Encode the tree of
EditNodes to a JSON representation of PaletteNodes . |
java.lang.String |
serializeEditNodes(EditNode[] nodes)
Serialize the provided
EditNodes to an XML representation of PaletteNodes . |
java.lang.String |
serializeEditNodes(EditNode[] nodes,
java.lang.Boolean serverless)
Serialize the provided
EditNodes to an XML representation of PaletteNodes . |
java.lang.String |
serializeEditNodesAsJSON(EditNode[] nodes)
Serialize the provided
EditNodes to a JSON representation of PaletteNodes . |
java.lang.String |
serializeEditNodesAsJSON(EditNode[] nodes,
java.lang.Boolean serverless)
Serialize the provided
EditNodes to a JSON representation of PaletteNodes . |
void |
setDefaultPalette(Palette defaultPalette)
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 ). |
void |
setExtraPalettes(Palette... extraPalettes)
Additional
Palettes to consult for metadata when deserializing Edit Nodes . |
void |
setNodeProperties(EditNode editNode,
Canvas properties)
Update an editNode's serializable "defaults" with the supplied properties.
|
void |
setNodeProperties(EditNode editNode,
Canvas properties,
java.lang.Boolean skipLiveObjectUpdate)
Update an editNode's serializable "defaults" with the supplied properties.
|
void |
setPersistCoordinates(boolean persistCoordinates)
If enabled, changes to a
liveObject 's position and size will be
persisted to their EditNodes . |
void setDefaultPalette(Palette defaultPalette)
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
.
defaultPalette
- the default Palette. Default value is nullPalette 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
.
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
.
void setExtraPalettes(Palette... extraPalettes)
Palettes
to consult for metadata when deserializing Edit Nodes
. Note that the defaultPalette
is always consulted and need not be provided
again here.extraPalettes
- Default value is nullPalette[] getExtraPalettes()
Palettes
to consult for metadata when deserializing Edit Nodes
. Note that the defaultPalette
is always consulted and need not be provided
again here.void setPersistCoordinates(boolean persistCoordinates)
liveObject
's position and size will be
persisted to their EditNodes
. This applies to both programmatic calls and
user interaction (drag reposition or drag resize).persistCoordinates
- Default value is trueboolean getPersistCoordinates()
liveObject
's position and size will be
persisted to their EditNodes
. This applies to both programmatic calls and
user interaction (drag reposition or drag resize).EditNode addFromPaletteNode(PaletteNode paletteNode)
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.paletteNode
- the palette node to use to create the new nodeaddFromPaletteNodes(com.smartgwt.client.tools.PaletteNode[])
EditNode addFromPaletteNode(PaletteNode paletteNode, EditNode parentNode)
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.paletteNode
- the palette node to use to create the new nodeparentNode
- optional the parent node if the new node should appear under a specific parentaddFromPaletteNodes(com.smartgwt.client.tools.PaletteNode[])
EditNode[] addFromPaletteNodes(PaletteNode[] paletteNodes)
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.paletteNodes
- array of PaletteNodesaddFromPaletteNode(com.smartgwt.client.tools.PaletteNode)
EditNode[] addFromPaletteNodes(PaletteNode[] paletteNodes, EditNode parentNode)
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.paletteNodes
- array of PaletteNodesparentNode
- parent to add to (defaults to the root)addFromPaletteNode(com.smartgwt.client.tools.PaletteNode)
EditNode addNode(EditNode newNode)
EditNode
to the EditContext, under the specified parent. 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.
newNode
- new node to be addedEditNode addNode(EditNode newNode, EditNode parentNode, java.lang.Integer index)
EditContext#addNode()}
EditNode addNode(EditNode newNode, EditNode parentNode, java.lang.Integer index, java.lang.String parentProperty)
EditContext#addNode()}
EditNode addNode(EditNode newNode, EditNode parentNode, java.lang.Integer index, java.lang.String parentProperty, java.lang.Boolean skipParentComponentAdd)
EditNode
to the EditContext, under the specified parent. 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.
newNode
- new node to be addedparentNode
- parent to add the new node under.index
- index within the parent's children arrayparentProperty
- the property of the liveParent to which the new node should be added, if not
auto-discoverable from the schemaskipParentComponentAdd
- whether to skip adding the liveObject to the liveParent (default false)void addPaletteNodesFromJS(java.lang.String jsCode)
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.
jsCode
- JavaScript code to eval.void addPaletteNodesFromJS(java.lang.String jsCode, EditNode parentNode)
EditContext#addPaletteNodesFromJS()}
void addPaletteNodesFromJS(java.lang.String jsCode, EditNode parentNode, java.lang.String[] globals)
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.
jsCode
- JavaScript code to eval.parentNode
- parent node (defaults to the root)globals
- widgets to allow to take their global IDsvoid addPaletteNodesFromJSON(java.lang.String jsonString)
EditNodes
from a JSON representation of PaletteNodes
(possibly created by calling EditContext.serializeAllEditNodesAsJSON()
or EditContext.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.
jsonString
- JSON stringserializeAllEditNodesAsJSON()
,
serializeEditNodesAsJSON(com.smartgwt.client.tools.EditNode[])
void addPaletteNodesFromJSON(java.lang.String jsonString, EditNode parentNode)
EditContext#addPaletteNodesFromJSON()}
void addPaletteNodesFromJSON(java.lang.String jsonString, EditNode parentNode, java.lang.String[] globals)
EditNodes
from a JSON representation of PaletteNodes
(possibly created by calling EditContext.serializeAllEditNodesAsJSON()
or EditContext.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.
jsonString
- JSON stringparentNode
- parent node (defaults to the root)globals
- widgets to allow to take their global IDsserializeAllEditNodesAsJSON()
,
serializeEditNodesAsJSON(com.smartgwt.client.tools.EditNode[])
void addPaletteNodesFromXML(java.lang.String xmlString)
EditNodes
from an XML representation of PaletteNodes
(possibly created by calling EditContext.serializeAllEditNodes()
or EditContext.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.
xmlString
- XML stringserializeAllEditNodes()
,
serializeEditNodes(com.smartgwt.client.tools.EditNode[])
void addPaletteNodesFromXML(java.lang.String xmlString, EditNode parentNode)
EditContext#addPaletteNodesFromXML()}
void addPaletteNodesFromXML(java.lang.String xmlString, EditNode parentNode, java.lang.String[] globals)
EditNodes
from an XML representation of PaletteNodes
(possibly created by calling EditContext.serializeAllEditNodes()
or EditContext.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.
xmlString
- XML stringparentNode
- parent node (defaults to the root)globals
- widgets to allow to take their global IDsserializeAllEditNodes()
,
serializeEditNodes(com.smartgwt.client.tools.EditNode[])
void destroyAll()
void getPaletteNodesFromJS(java.lang.String jsCode, PaletteNodeCallback callback)
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.
jsCode
- JavaScript code to eval.callback
- Callback used to return the PaletteNodesvoid getPaletteNodesFromJS(java.lang.String jsCode, PaletteNodeCallback callback, java.lang.String[] globals)
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.
jsCode
- JavaScript code to eval.callback
- Callback used to return the PaletteNodesglobals
- widgets to allow to take their global IDsvoid getPaletteNodesFromXML(java.lang.String xmlString, PaletteNodeCallback callback)
PaletteNodes
from an XML representation, but do not add them to the
EditContext.xmlString
- XML stringcallback
- Callback used to return the PaletteNodesserializeAllEditNodes()
,
serializeEditNodes(com.smartgwt.client.tools.EditNode[])
EditNode makeEditNode(PaletteNode paletteNode)
defaultPalette
. Does not add the newly created EditNode to the EditContext.paletteNode
- the palette node to use to create the new nodevoid removeAll()
EditNodes
from the EditContext, but does not destroy the liveObjects
.void removeNodeProperties(EditNode editNode, java.lang.String[] properties)
liveObject
is not updated by this method. To set a property to
null (rather than removing it), use setNodeProperties()
instead.editNode
- the editNode to updateproperties
- an array of property names to removesetNodeProperties(com.smartgwt.client.tools.EditNode, com.smartgwt.client.widgets.Canvas)
java.lang.String serializeAllEditNodes()
EditNodes
to an XML representation of PaletteNodes
. The result can be supplied to addPaletteNodesFromXML()
to recreate the EditNodes.addPaletteNodesFromXML(java.lang.String)
java.lang.String serializeAllEditNodes(java.lang.Boolean serverless)
EditNodes
to an XML representation of PaletteNodes
. The result can be supplied to addPaletteNodesFromXML()
to recreate the EditNodes.serverless
- If true, specify DataSources in full rather than assuming they can be downloaded from the
server. Defaults to false.addPaletteNodesFromXML(java.lang.String)
java.lang.String serializeAllEditNodesAsJSON()
EditNodes
to a JSON representation of PaletteNodes
. The result can be supplied to addPaletteNodesFromJSON()
to recreate the EditNodes.addPaletteNodesFromJSON(java.lang.String)
java.lang.String serializeAllEditNodesAsJSON(java.lang.Boolean serverless)
EditNodes
to a JSON representation of PaletteNodes
. The result can be supplied to addPaletteNodesFromJSON()
to recreate the EditNodes.serverless
- If true, specify DataSources in full rather than assuming they can be downloaded from the
server. Defaults to false.addPaletteNodesFromJSON(java.lang.String)
java.lang.String serializeEditNodes(EditNode[] nodes)
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.nodes
- EditNodes to be serializedjava.lang.String serializeEditNodes(EditNode[] nodes, java.lang.Boolean serverless)
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.nodes
- EditNodes to be serializedserverless
- If true, specify DataSources in full rather than assuming they can be downloaded from the
server. Defaults to false.java.lang.String serializeEditNodesAsJSON(EditNode[] nodes)
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.nodes
- EditNodes to be serializedjava.lang.String serializeEditNodesAsJSON(EditNode[] nodes, java.lang.Boolean serverless)
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.nodes
- EditNodes to be serializedserverless
- If true, specify DataSources in full rather than assuming they can be downloaded from the
server. Defaults to false.void setNodeProperties(EditNode editNode, Canvas properties)
removeNodeProperties()
instead.editNode
- the editNode to updateproperties
- the properties to applyremoveNodeProperties(com.smartgwt.client.tools.EditNode, java.lang.String[])
void setNodeProperties(EditNode editNode, Canvas properties, java.lang.Boolean skipLiveObjectUpdate)
removeNodeProperties()
instead.editNode
- the editNode to updateproperties
- the properties to applyskipLiveObjectUpdate
- whether to skip updating the liveObject
, e.g. if you have
already updated the liveObjectremoveNodeProperties(com.smartgwt.client.tools.EditNode, java.lang.String[])