Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbrun2017-01-11 08:53:37 +0000
committercbrun2017-01-17 14:28:44 +0000
commit04eb3e080b4c91c88d2256a6073820c82a560407 (patch)
tree5d3cf78f6d5d289685bc07887bf95ae9fd6de2c5
parentb2d20d1dcc345ef83d43ae7b39759fae09567d2a (diff)
downloadorg.eclipse.sirius-04eb3e080b4c91c88d2256a6073820c82a560407.tar.gz
org.eclipse.sirius-04eb3e080b4c91c88d2256a6073820c82a560407.tar.xz
org.eclipse.sirius-04eb3e080b4c91c88d2256a6073820c82a560407.zip
[510126] Declare variables in RepresentationNavigationDesc attributes
Add the code and supporting test cases so that the variables which are children of any RepresentationNavigationDescription subclass are available in the InterpretedExpression attributes of the instance (in navigation name expression, browse expression..) Also add more specific type inference for the DiagramNavigationDescription case so that the 'container' and 'containerView' variables have the most refined type possible. Bug: 510126 Change-Id: Ie4474eb31e13a370e85e3a392fc1beec582b2aca Signed-off-by: Cedric Brun <cedric.brun@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionQuery.java122
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign14
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/description/AbstractInterpretedExpressionQuery.java25
3 files changed, 96 insertions, 65 deletions
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionQuery.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionQuery.java
index 912d3d081e..2a75358901 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionQuery.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionQuery.java
@@ -58,6 +58,7 @@ import org.eclipse.sirius.diagram.description.tool.ContainerCreationDescription;
import org.eclipse.sirius.diagram.description.tool.CreateEdgeView;
import org.eclipse.sirius.diagram.description.tool.CreateView;
import org.eclipse.sirius.diagram.description.tool.DeleteElementDescription;
+import org.eclipse.sirius.diagram.description.tool.DiagramNavigationDescription;
import org.eclipse.sirius.diagram.description.tool.DirectEditLabel;
import org.eclipse.sirius.diagram.description.tool.EdgeCreationDescription;
import org.eclipse.sirius.diagram.description.tool.NodeCreationDescription;
@@ -255,60 +256,7 @@ public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpres
@Override
protected void addVariablesFromToolContext(EObject toolContext) {
if (toolContext != null) {
- if (toolContext instanceof EdgeCreationDescription) {
- EdgeCreationDescription tool = (EdgeCreationDescription) toolContext;
- declareEdgeSourceTargets(availableVariables, tool.getEdgeMappings(), tool.getExtraSourceMappings(), tool.getExtraTargetMappings());
- }
- if (toolContext instanceof ReconnectEdgeDescription) {
- ReconnectEdgeDescription tool = (ReconnectEdgeDescription) toolContext;
- declareEdgeSourceTargets(availableVariables, tool.getMappings(), Collections.<DiagramElementMapping> emptyList(), Collections.<DiagramElementMapping> emptyList());
- availableVariables.put("otherEnd", EDGE_TARGET_POSSIBILITIES); //$NON-NLS-1$
- availableVariables.put("edgeView", VariableType.fromString(DIAGRAM_D_EDGE_TYPE)); //$NON-NLS-1$
-
- Collection<String> possibleSources = Lists.newArrayList();
- for (EdgeMapping eMapping : tool.getMappings()) {
- collectSemanticElementType(possibleSources, eMapping);
- }
- refineVariableType(availableVariables, IInterpreterSiriusVariables.ELEMENT, possibleSources);
-
- }
- if (toolContext instanceof NodeCreationDescription) {
- NodeCreationDescription tool = (NodeCreationDescription) toolContext;
- Collection<String> possibleSemanticTypes = Sets.newLinkedHashSet();
- /*
- * gather types for the "container" variable.
- */
- for (AbstractNodeMapping np : tool.getExtraMappings()) {
- String domainClass = np.getDomainClass();
- if (!StringUtil.isEmpty(domainClass)) {
- possibleSemanticTypes.add(domainClass);
- }
- }
- Collection<String> possibleViewTypes = Sets.newLinkedHashSet();
- collectPotentialContainerTypes(possibleSemanticTypes, possibleViewTypes, tool.getNodeMappings());
-
- refineVariableType(availableVariables, IInterpreterSiriusVariables.CONTAINER, possibleSemanticTypes);
- refineVariableType(availableVariables, IInterpreterSiriusVariables.CONTAINER_VIEW, possibleViewTypes);
- }
-
- if (toolContext instanceof ContainerCreationDescription) {
- ContainerCreationDescription tool = (ContainerCreationDescription) toolContext;
- Collection<String> possibleTypes = Sets.newLinkedHashSet();
- /*
- * gather types for the "container" variable.
- */
- for (AbstractNodeMapping np : tool.getExtraMappings()) {
- String domainClass = np.getDomainClass();
- if (!StringUtil.isEmpty(domainClass)) {
- possibleTypes.add(domainClass);
- }
- }
- Collection<String> possibleViewTypes = Sets.newLinkedHashSet();
- collectPotentialContainerTypes(possibleTypes, possibleViewTypes, tool.getContainerMappings());
- refineVariableType(availableVariables, IInterpreterSiriusVariables.CONTAINER_VIEW, possibleViewTypes);
-
- refineVariableType(availableVariables, IInterpreterSiriusVariables.CONTAINER, possibleTypes);
- }
+ addVariablesForCreationTools(toolContext);
if (toolContext instanceof DeleteElementDescription) {
DeleteElementDescription tool = (DeleteElementDescription) toolContext;
@@ -346,6 +294,72 @@ public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpres
}
}
}
+ if (toolContext instanceof DiagramNavigationDescription) {
+ DiagramNavigationDescription tool = (DiagramNavigationDescription) toolContext;
+ Collection<String> possibleContainerSemanticTypes = Sets.newLinkedHashSet();
+ Collection<String> possibleContainerViewTypes = Sets.newLinkedHashSet();
+ collectPotentialContainerTypes(possibleContainerSemanticTypes, possibleContainerViewTypes, Lists.newArrayList(Iterables.filter(tool.getMappings(), DiagramElementMapping.class)));
+ refineVariableType(availableVariables, tool.getContainerVariable().getName(), possibleContainerSemanticTypes);
+ refineVariableType(availableVariables, tool.getContainerViewVariable().getName(), possibleContainerViewTypes);
+ }
+
+ }
+ }
+
+ private void addVariablesForCreationTools(EObject toolContext) {
+ if (toolContext instanceof EdgeCreationDescription) {
+ EdgeCreationDescription tool = (EdgeCreationDescription) toolContext;
+ declareEdgeSourceTargets(availableVariables, tool.getEdgeMappings(), tool.getExtraSourceMappings(), tool.getExtraTargetMappings());
+ }
+ if (toolContext instanceof ReconnectEdgeDescription) {
+ ReconnectEdgeDescription tool = (ReconnectEdgeDescription) toolContext;
+ declareEdgeSourceTargets(availableVariables, tool.getMappings(), Collections.<DiagramElementMapping> emptyList(), Collections.<DiagramElementMapping> emptyList());
+ availableVariables.put("otherEnd", EDGE_TARGET_POSSIBILITIES); //$NON-NLS-1$
+ availableVariables.put("edgeView", VariableType.fromString(DIAGRAM_D_EDGE_TYPE)); //$NON-NLS-1$
+
+ Collection<String> possibleSources = Lists.newArrayList();
+ for (EdgeMapping eMapping : tool.getMappings()) {
+ collectSemanticElementType(possibleSources, eMapping);
+ }
+ refineVariableType(availableVariables, IInterpreterSiriusVariables.ELEMENT, possibleSources);
+
+ }
+ if (toolContext instanceof NodeCreationDescription) {
+ NodeCreationDescription tool = (NodeCreationDescription) toolContext;
+ Collection<String> possibleSemanticTypes = Sets.newLinkedHashSet();
+ /*
+ * gather types for the "container" variable.
+ */
+ for (AbstractNodeMapping np : tool.getExtraMappings()) {
+ String domainClass = np.getDomainClass();
+ if (!StringUtil.isEmpty(domainClass)) {
+ possibleSemanticTypes.add(domainClass);
+ }
+ }
+ Collection<String> possibleViewTypes = Sets.newLinkedHashSet();
+ collectPotentialContainerTypes(possibleSemanticTypes, possibleViewTypes, tool.getNodeMappings());
+
+ refineVariableType(availableVariables, IInterpreterSiriusVariables.CONTAINER, possibleSemanticTypes);
+ refineVariableType(availableVariables, IInterpreterSiriusVariables.CONTAINER_VIEW, possibleViewTypes);
+ }
+
+ if (toolContext instanceof ContainerCreationDescription) {
+ ContainerCreationDescription tool = (ContainerCreationDescription) toolContext;
+ Collection<String> possibleTypes = Sets.newLinkedHashSet();
+ /*
+ * gather types for the "container" variable.
+ */
+ for (AbstractNodeMapping np : tool.getExtraMappings()) {
+ String domainClass = np.getDomainClass();
+ if (!StringUtil.isEmpty(domainClass)) {
+ possibleTypes.add(domainClass);
+ }
+ }
+ Collection<String> possibleViewTypes = Sets.newLinkedHashSet();
+ collectPotentialContainerTypes(possibleTypes, possibleViewTypes, tool.getContainerMappings());
+ refineVariableType(availableVariables, IInterpreterSiriusVariables.CONTAINER_VIEW, possibleViewTypes);
+
+ refineVariableType(availableVariables, IInterpreterSiriusVariables.CONTAINER, possibleTypes);
}
}
diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign b/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign
index f399e345c8..29c456bf8e 100644
--- a/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign
+++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign
@@ -33,7 +33,7 @@
</ownedRules>
</validationSet>
<defaultLayer name="Default">
- <nodeMappings name="ParticipantNode" deletionDescription="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@toolSections.0/@ownedTools[name='Delete%20ParticipantNode']" labelDirectEdit="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@toolSections.0/@ownedTools[name='MultipleTypes']" domainClass="interactions.Participant">
+ <nodeMappings name="ParticipantNode" navigationDescriptions="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@toolSections.0/@ownedTools[name='ToTable']" deletionDescription="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@toolSections.0/@ownedTools[name='Delete%20ParticipantNode']" labelDirectEdit="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@toolSections.0/@ownedTools[name='MultipleTypes']" domainClass="interactions.Participant">
<style xsi:type="style:BundledImageDescription" resizeKind="NSEW">
<borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
<labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
@@ -159,7 +159,7 @@
</style>
</conditionnalStyles>
</containerMappings>
- <containerMappings name="InteractionContainer" preconditionExpression="aql:containerView.edges->size() > 0" domainClass="interactions.Interaction">
+ <containerMappings name="InteractionContainer" navigationDescriptions="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']/@defaultLayer/@toolSections.0/@ownedTools[name='toDiagram']" preconditionExpression="aql:containerView.edges->size() > 0" domainClass="interactions.Interaction">
<subContainerMappings name="InteractionContainerInContainer" semanticCandidatesExpression="var:self" domainClass="interactions.Interaction">
<style xsi:type="style:WorkspaceImageDescription" borderSizeComputationExpression="1" arcWidth="1" arcHeight="1" workspacePath="/org.eclipse.emf.ecore.edit/icons/full/obj16/EClass.gif">
<borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
@@ -482,6 +482,16 @@
</initialOperation>
</menuItemDescription>
</ownedTools>
+ <ownedTools xsi:type="tool_1:DiagramNavigationDescription" name="toDiagram" precondition="aql:container.ownedInteractions->size() > 0 and containerView.edges->size() > 0" navigationNameExpression="aql:diagramName + ' ' + containerView.documentation + container.ownedInteractions->size()" diagramDescription="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='SelfTypeInference']">
+ <containerViewVariable name="containerView"/>
+ <containerVariable name="container"/>
+ <representationNameVariable name="diagramName"/>
+ </ownedTools>
+ <ownedTools xsi:type="description_2:TableNavigationDescription" name="ToTable" navigationNameExpression="var:tableName" tableDescription="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='EditionTable']">
+ <containerViewVariable name="containerView"/>
+ <containerVariable name="container"/>
+ <representationNameVariable name="tableName"/>
+ </ownedTools>
<subSections name="Ignored">
<ownedTools xsi:type="tool_1:DirectEditLabel" name="ElementType">
<mask mask="{0}"/>
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/description/AbstractInterpretedExpressionQuery.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/description/AbstractInterpretedExpressionQuery.java
index e3392b0587..28d827cbb9 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/description/AbstractInterpretedExpressionQuery.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/description/AbstractInterpretedExpressionQuery.java
@@ -34,12 +34,12 @@ import org.eclipse.sirius.ext.base.Options;
import org.eclipse.sirius.ext.emf.AllContents;
import org.eclipse.sirius.tools.api.interpreter.context.SiriusInterpreterContextFactory;
import org.eclipse.sirius.viewpoint.ViewpointPackage;
+import org.eclipse.sirius.viewpoint.description.AbstractVariable;
import org.eclipse.sirius.viewpoint.description.DescriptionPackage;
import org.eclipse.sirius.viewpoint.description.JavaExtension;
import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
import org.eclipse.sirius.viewpoint.description.Viewpoint;
import org.eclipse.sirius.viewpoint.description.tool.AbstractToolDescription;
-import org.eclipse.sirius.viewpoint.description.AbstractVariable;
import org.eclipse.sirius.viewpoint.description.tool.ChangeContext;
import org.eclipse.sirius.viewpoint.description.tool.CreateInstance;
import org.eclipse.sirius.viewpoint.description.tool.EditMaskVariables;
@@ -49,6 +49,7 @@ import org.eclipse.sirius.viewpoint.description.tool.If;
import org.eclipse.sirius.viewpoint.description.tool.InitialOperation;
import org.eclipse.sirius.viewpoint.description.tool.ModelOperation;
import org.eclipse.sirius.viewpoint.description.tool.OperationAction;
+import org.eclipse.sirius.viewpoint.description.tool.RepresentationNavigationDescription;
import org.eclipse.sirius.viewpoint.description.tool.ToolDescription;
import org.eclipse.sirius.viewpoint.description.tool.ToolPackage;
import org.eclipse.sirius.viewpoint.description.tool.VariableContainer;
@@ -294,7 +295,7 @@ public abstract class AbstractInterpretedExpressionQuery implements IInterpreted
* the containerView variable is accessible in any Model
* operation which is a child of the ToolDescription.
*/
- availableVariables.put("containerView", DSEMANTIC_DECORATOR); //$NON-NLS-1$
+ availableVariables.put("containerView", DSEMANTIC_DECORATOR); //$NON-NLS-1$
/*
* Infer type of variables using the tool precondition.
*/
@@ -311,7 +312,12 @@ public abstract class AbstractInterpretedExpressionQuery implements IInterpreted
}
}
-
+ if (operationContext instanceof RepresentationNavigationDescription) {
+ RepresentationNavigationDescription tool = (RepresentationNavigationDescription) operationContext;
+ if (tool.getRepresentationNameVariable() != null && !StringUtil.isEmpty(tool.getRepresentationNameVariable().getName())) {
+ availableVariables.put(tool.getRepresentationNameVariable().getName(), VariableType.fromJavaClass(java.lang.String.class)); // $NON-NLS-1$
+ }
+ }
addVariablesFromToolContext(operationContext);
}
collectLocalVariablesDefinitions();
@@ -386,13 +392,14 @@ public abstract class AbstractInterpretedExpressionQuery implements IInterpreted
*/
found = new EObjectQuery(target).getFirstAncestorOfType(org.eclipse.sirius.viewpoint.description.validation.ValidationPackage.eINSTANCE.getValidationRule());
if (!found.some()) {
- if (this.target instanceof OperationAction) {
+ if (this.target instanceof OperationAction || this.target instanceof RepresentationNavigationDescription) {
/*
- * OperationAction represents its own context for its
- * interpreted expression attributes, the variables which are
- * child of the OperationAction instance (like 'views') are
- * available in the precondition and elements to select
- * expressions.
+ * OperationAction and RepresentationNavigationDescription are
+ * representing their own context for their interpreted
+ * expression attributes, the variables which are child of the
+ * OperationAction and RepresentationNavigationDescription
+ * instance (like 'views', 'container') are also available in
+ * the precondition and elements to select expressions.
*/
found = Options.fromNullable(this.target);
} else {

Back to the top