Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The selectedNode variable is not defined at all when dropping on a diagram's background #1320

Closed
pcdavid opened this issue Aug 3, 2022 · 0 comments · Fixed by #1331
Closed

Comments

@pcdavid
Copy link
Member

pcdavid commented Aug 3, 2022

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)

public EObject onDrop(Diagram diagram, EObject self) {
  // Dropped on the diagam background
}

public EObject onDrop(Node node, EObject self) {
  // Dropped on a particular node
}

If we go this way, the selectedNode could be deprecated, or completely removed.

@pcdavid pcdavid self-assigned this Aug 5, 2022
pcdavid added a commit that referenced this issue Aug 16, 2022
Bug: #1320
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
@pcdavid pcdavid linked a pull request Aug 16, 2022 that will close this issue
39 tasks
pcdavid added a commit that referenced this issue Aug 24, 2022
Bug: #1320
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
sbegaudeau pushed a commit that referenced this issue Sep 2, 2022
Bug: #1320
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
@sbegaudeau sbegaudeau added this to the 2022.9.0 milestone Sep 2, 2022
sbegaudeau pushed a commit that referenced this issue Sep 2, 2022
Bug: #1320
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants