Skip to content

Commit

Permalink
[1320] Ensure selectedNode variable is always defined
Browse files Browse the repository at this point in the history
Bug: #1320
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
  • Loading branch information
pcdavid authored and sbegaudeau committed Sep 2, 2022
1 parent 7f8070e commit f17b030
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.adoc
Expand Up @@ -27,7 +27,7 @@ This allows representation precondition expressions to be more precise as they k
- https://github.com/eclipse-sirius/sirius-components/issues/1281[#1281] [form] The `LinkDescription` now requires a `displayProvider` and a `styleProvider`. The `displayProvider` is used to display the text of the hyperLink.
The GraphQL API has also been changed with two additional fields on the type `Link`: `display` and `style` (optional). The front-end use the `display` value instead of the `label` value to display the hyperlink text.
The `label` value is displayed before the widget to be consistent with other properties sections.

- https://github.com/eclipse-sirius/sirius-components/issues/1320[#1320] [diagram] The `selectedNode` variable is now always _defined_ in the context of drop hanlders and single-click tools. Previously, if the target of the drop or single-click tool was the diagram itself (instead of a node), the variable was not defined at all. Now it is defined but `null` in these cases.

=== Dependency update

Expand Down
Expand Up @@ -123,9 +123,7 @@ private IStatus executeTool(IEditingContext editingContext, IDiagramContext diag

for (Object self : objects) {
VariableManager variableManager = new VariableManager();
if (node.isPresent()) {
variableManager.put(Node.SELECTED_NODE, node.get());
}
variableManager.put(Node.SELECTED_NODE, node.orElse(null));
variableManager.put(IEditingContext.EDITING_CONTEXT, editingContext);
variableManager.put(IDiagramContext.DIAGRAM_CONTEXT, diagramContext);
variableManager.put(Environment.ENVIRONMENT, new Environment(Environment.SIRIUS_COMPONENTS));
Expand Down
Expand Up @@ -153,7 +153,7 @@ private IStatus executeTool(IEditingContext editingContext, IDiagramContext diag
variableManager.put(IEditingContext.EDITING_CONTEXT, editingContext);
variableManager.put(Environment.ENVIRONMENT, new Environment(Environment.SIRIUS_COMPONENTS));
variableManager.put(VariableManager.SELF, self.get());
node.ifPresent(selectedNode -> variableManager.put(Node.SELECTED_NODE, selectedNode));
variableManager.put(Node.SELECTED_NODE, node.orElse(null));

String selectionDescriptionId = tool.getSelectionDescriptionId();
if (selectionDescriptionId != null && selectedObjectId != null) {
Expand Down

0 comments on commit f17b030

Please sign in to comment.