Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbrun2016-01-21 10:12:23 +0000
committerPierre-Charles David2017-01-10 09:07:49 +0000
commit48270ead5dfd583d865c994827d858695a7acaf3 (patch)
tree1f217dee6ff0d5c4e2939b16e7fb896ef200d371
parent42b80ef4095e0fd74a0f29de04086d3c24237a49 (diff)
downloadorg.eclipse.sirius-48270ead5dfd583d865c994827d858695a7acaf3.tar.gz
org.eclipse.sirius-48270ead5dfd583d865c994827d858695a7acaf3.tar.xz
org.eclipse.sirius-48270ead5dfd583d865c994827d858695a7acaf3.zip
[486165] Replace use of diagram.EdgeTarget with known subtypes
EdgeTarget type has very little information which could be considered useful in the context of VSM queries (it only has outgoing and incoming edges references). More useful features: the "target" reference for instance, which will *always be there* considering the known subtypes of EdgeTarget. Bug: 486165 Change-Id: I4d869ddfc2b482c33bdd0641c7353f82e37b9d6c Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionQuery.java10
-rw-r--r--plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/AbstractInterpretedExpressionTestCase.java20
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/vsm/interpreted/expression/variables/DiagramVariablesTest.java3
3 files changed, 27 insertions, 6 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 1606784030..51af6ba533 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
@@ -75,6 +75,8 @@ import com.google.common.collect.Sets;
*/
public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpressionQuery implements IInterpretedExpressionQuery {
+ private static final String DIAGRAM_D_DIAGRAM_ELEMENT_CONTAINER = "diagram.DDiagramElementContainer"; //$NON-NLS-1$
+
private static final String DIAGRAM_D_SEMANTIC_DIAGRAM = "diagram.DSemanticDiagram"; //$NON-NLS-1$
private static final String DIAGRAM_D_NODE = "diagram.DNode"; //$NON-NLS-1$
@@ -85,7 +87,7 @@ public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpres
private static final String DIAGRAM_D_EDGE_TYPE = "diagram.DEdge"; //$NON-NLS-1$
- private static final String DIAGRAM_EDGE_TARGET_TYPE = "diagram.EdgeTarget"; //$NON-NLS-1$
+ private static final VariableType EDGE_TARGET_POSSIBILITIES = VariableType.fromStrings(Sets.newHashSet(DIAGRAM_D_EDGE_TYPE, DIAGRAM_D_NODE, DIAGRAM_D_DIAGRAM_ELEMENT_CONTAINER));
/**
* Default constructor.
@@ -179,9 +181,9 @@ public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpres
if (target instanceof EdgeCreationDescription && ToolPackage.Literals.ABSTRACT_TOOL_DESCRIPTION__PRECONDITION.equals(feature)) {
availableVariables.put("diagram", VariableType.fromString("diagram.DDiagram")); //$NON-NLS-1$ //$NON-NLS-2$
availableVariables.put("preSource", VariableType.fromString("ecore.EObject")); //$NON-NLS-1$ //$NON-NLS-2$
- availableVariables.put("preSourceView", VariableType.fromString(DIAGRAM_EDGE_TARGET_TYPE)); //$NON-NLS-1$
+ availableVariables.put("preSourceView", EDGE_TARGET_POSSIBILITIES); //$NON-NLS-1$
availableVariables.put("preTarget", VariableType.fromString("ecore.EObject")); //$NON-NLS-1$ //$NON-NLS-2$
- availableVariables.put("preTargetView", VariableType.fromString(DIAGRAM_EDGE_TARGET_TYPE)); //$NON-NLS-1$
+ availableVariables.put("preTargetView", EDGE_TARGET_POSSIBILITIES); //$NON-NLS-1$
}
return availableVariables;
@@ -208,7 +210,7 @@ public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpres
if (toolContext instanceof ReconnectEdgeDescription) {
ReconnectEdgeDescription tool = (ReconnectEdgeDescription) toolContext;
declareEdgeSourceTargets(availableVariables, tool.getMappings(), Collections.<DiagramElementMapping> emptyList(), Collections.<DiagramElementMapping> emptyList());
- availableVariables.put("otherEnd", VariableType.fromString(DIAGRAM_EDGE_TARGET_TYPE)); //$NON-NLS-1$
+ 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();
diff --git a/plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/AbstractInterpretedExpressionTestCase.java b/plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/AbstractInterpretedExpressionTestCase.java
index 0f739ce380..d66230686f 100644
--- a/plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/AbstractInterpretedExpressionTestCase.java
+++ b/plugins/org.eclipse.sirius.tests.junit.support/src/org/eclipse/sirius/tests/support/api/AbstractInterpretedExpressionTestCase.java
@@ -275,8 +275,26 @@ public abstract class AbstractInterpretedExpressionTestCase extends TestCase {
* the variable types
*/
protected void assertVariableExistenceAndType(AbstractToolDescription tool, String expectedVariable, String expectedType, Set<String> variables, Map<String, VariableType> variablesToType) {
+ assertVariableExistenceAndType(tool, expectedVariable, VariableType.fromString(expectedType), variables, variablesToType);
+ }
+
+ /**
+ * Assert variable existence and test type.
+ *
+ * @param tool
+ * the tool owning the variable
+ * @param expectedVariable
+ * the expected variable
+ * @param expectedType
+ * the expected type
+ * @param variables
+ * the variables
+ * @param variablesToType
+ * the variable types
+ */
+ protected void assertVariableExistenceAndType(AbstractToolDescription tool, String expectedVariable, VariableType expectedType, Set<String> variables, Map<String, VariableType> variablesToType) {
assertVariableExistence(tool, expectedVariable, variables);
- assertEquals("The interpreter context for " + tool.eClass().getName() + " has a bad variable type for variable " + expectedVariable, VariableType.fromString(expectedType).toString(),
+ assertEquals("The interpreter context for " + tool.eClass().getName() + " has a bad variable type for variable " + expectedVariable, expectedType.toString(),
variablesToType.get(expectedVariable).toString());
}
}
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/vsm/interpreted/expression/variables/DiagramVariablesTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/vsm/interpreted/expression/variables/DiagramVariablesTest.java
index 45cf16e0ac..9da0b43fbd 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/vsm/interpreted/expression/variables/DiagramVariablesTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/vsm/interpreted/expression/variables/DiagramVariablesTest.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.sirius.tests.unit.api.vsm.interpreted.expression.variables;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
@@ -180,7 +181,7 @@ public class DiagramVariablesTest extends AbstractInterpretedExpressionTestCase
assertVariableExistence(createReconnectEdgeDescription, "element", variables);
// check variables from create operation
- assertVariableExistenceAndType(createReconnectEdgeDescription, "otherEnd", "diagram.EdgeTarget", variables, variablesToType);
+ assertVariableExistenceAndType(createReconnectEdgeDescription, "otherEnd", VariableType.fromStrings(Arrays.asList("diagram.DEdge","diagram.DDiagramElementContainer","diagram.DNode")), variables, variablesToType);
assertVariableExistenceAndType(createReconnectEdgeDescription, "edgeView", "diagram.DEdge", variables, variablesToType);
}
}

Back to the top