Skip to content

Commit

Permalink
[1695] Add a precondition expression on node descriptions in view DSL
Browse files Browse the repository at this point in the history
Also add some new variables:
- diagramEvent to know which event is occurring during a diagram
rendering
- previousDiagram to know the previous states of the graphical elements
during a diagram rendering

Bug: #1695
Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
  • Loading branch information
AxelRICHARD committed Feb 10, 2023
1 parent 61f86b6 commit a42c2e0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public Element render() {
VariableManager variableManager = this.props.getVariableManager();
DiagramDescription diagramDescription = this.props.getDiagramDescription();
var optionalPreviousDiagram = this.props.getPreviousDiagram();
variableManager.put(DiagramComponentProps.PREVIOUS_DIAGRAM, optionalPreviousDiagram.orElse(null));

String label = diagramDescription.getLabelProvider().apply(variableManager);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2022 Obeo and others.
* Copyright (c) 2019, 2023 Obeo and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -32,6 +32,9 @@
*/
@Immutable
public final class DiagramComponentProps implements IProps {

public static final String PREVIOUS_DIAGRAM = "previousDiagram";

private VariableManager variableManager;

private DiagramDescription diagramDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public Element render() {
for (Object semanticElement : semanticElements) {
VariableManager nodeVariableManager = variableManager.createChild();
nodeVariableManager.put(VariableManager.SELF, semanticElement);
nodeVariableManager.put(IDiagramEvent.DIAGRAM_EVENT, optionalDiagramEvent.orElse(null));

String targetObjectId = nodeDescription.getTargetObjectIdProvider().apply(nodeVariableManager);
var optionalPreviousNode = nodesRequestor.getByTargetObjectId(targetObjectId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021 THALES GLOBAL SERVICES.
* Copyright (c) 2021, 2023 THALES GLOBAL SERVICES.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -17,6 +17,11 @@
*
* @author fbarbin
*/
@SuppressWarnings("checkstyle:InterfaceIsType")
public interface IDiagramEvent {

/**
* The name of the variable used to store and retrieve the diagram event from a variable manager.
*/
String DIAGRAM_EVENT = "diagramEvent";
}

0 comments on commit a42c2e0

Please sign in to comment.