You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an element (from the explorer) is dropped on a diagram, we invoke the diagram's drop handler.
If the element was dropped on a node, the drop handler has access to the selectedNode variable which points to it (a Node). If the element was dropped directly on the diagram's background howewer, the selectedNode variable is not defined at all.
This is fine for drop handlers which are defined directly in Java, as they can inspect the VariableManager they are passed to see in which case they are and choose the appropriate behavior.
For drop handlers which are defined using the View DSL however, their is no way to do this. There is no operation to test if some variable is defined, and if an AQL expression uses the selectedNode variable and is invoked in a context it is not defined, this raises an error.
One possibility would be to define the variable to null when dropping on the diagram's background, but it feels like a hack.
In addition, the name selectedNode is not very well chosen IMO. There is nothing "selected" (in the sense of the workbench's selection) here.
Another approach would be to define a new variable with a more explicit name, say dropTarget, which is always defined but will be either the Diagram or the Node. This way an AQL expression can refer this variable and e.g. pass it to a Java service:
aql:dropTarget.onDrop(self)
publicEObjectonDrop(Diagramdiagram, EObjectself) {
// Dropped on the diagam background
}
publicEObjectonDrop(Nodenode, EObjectself) {
// Dropped on a particular node
}
If we go this way, the selectedNode could be deprecated, or completely removed.
The text was updated successfully, but these errors were encountered:
When an element (from the explorer) is dropped on a diagram, we invoke the diagram's drop handler.
If the element was dropped on a node, the drop handler has access to the
selectedNode
variable which points to it (aNode
). If the element was dropped directly on the diagram's background howewer, theselectedNode
variable is not defined at all.This is fine for drop handlers which are defined directly in Java, as they can inspect the
VariableManager
they are passed to see in which case they are and choose the appropriate behavior.For drop handlers which are defined using the View DSL however, their is no way to do this. There is no operation to test if some variable is defined, and if an AQL expression uses the
selectedNode
variable and is invoked in a context it is not defined, this raises an error.One possibility would be to define the variable to
null
when dropping on the diagram's background, but it feels like a hack.In addition, the name
selectedNode
is not very well chosen IMO. There is nothing "selected" (in the sense of the workbench's selection) here.Another approach would be to define a new variable with a more explicit name, say
dropTarget
, which is always defined but will be either theDiagram
or theNode
. This way an AQL expression can refer this variable and e.g. pass it to a Java service:aql:dropTarget.onDrop(self)
If we go this way, the
selectedNode
could be deprecated, or completely removed.The text was updated successfully, but these errors were encountered: