Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban Dugueperoux2016-03-21 13:23:31 +0000
committerLaurent Redor2016-04-25 11:59:46 +0000
commitd5f32547b60d19b08be6b68ff45fd5206712f6cd (patch)
tree6ca77e36f927008d6301626366b8aa62232a1615
parentdd2fe3b8a5f88f8e14c570cd6970f5c332487a32 (diff)
downloadorg.eclipse.sirius-d5f32547b60d19b08be6b68ff45fd5206712f6cd.tar.gz
org.eclipse.sirius-d5f32547b60d19b08be6b68ff45fd5206712f6cd.tar.xz
org.eclipse.sirius-d5f32547b60d19b08be6b68ff45fd5206712f6cd.zip
[470297] Have Style customization works for Enum literal/many attributes
- Update BestStyleDescriptionRegistry & EAttributeCustomizationQuery to manage this case. - To be backward compatible with the old way of using FontFormat, singleton value is supported for multi-valued EAttribute. For example having an interpreted expression returning 'bold' instead of [bold/] works for an EAttributeCustomization. - Update RefreshWithCustomizationTests to test this case. Bug: 470297 Change-Id: Ic4744f30e817ea4564431b675f07e2d1e772780f Signed-off-by: Esteban Dugueperoux <esteban.dugueperoux@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/BestStyleDescriptionRegistry.java58
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/EAttributeCustomizationQuery.java12
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/customization/RefreshWithCustomizationTests.java96
3 files changed, 115 insertions, 51 deletions
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/BestStyleDescriptionRegistry.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/BestStyleDescriptionRegistry.java
index 7dc1f5250d..7b43a1fc59 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/BestStyleDescriptionRegistry.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/BestStyleDescriptionRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 THALES GLOBAL SERVICES.
+ * Copyright (c) 2012, 2016 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,7 @@
package org.eclipse.sirius.diagram.business.internal.metamodel.helper;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -18,9 +19,11 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.emf.common.util.Enumerator;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -176,29 +179,60 @@ public class BestStyleDescriptionRegistry extends HashMap<BestStyleDescriptionKe
Set<EObject> realEltsToCustomize = getRealElementsToCustomize(styleDescription, customizedStyleDescription, appliedOn, eAttributeCustomization);
if (!realEltsToCustomize.isEmpty()) {
EAttributeCustomizationQuery eAttributeCustomizationQuery = new EAttributeCustomizationQuery(eAttributeCustomization);
- String newAttributeValue = eAttributeCustomizationQuery.getNewAttributeValue(bestStyleDescriptionKey, interpreter);
+ Object newAttributeValue = eAttributeCustomizationQuery.getNewAttributeValue(bestStyleDescriptionKey, interpreter);
for (EObject realEltToCustomize : realEltsToCustomize) {
EStructuralFeature eStructuralFeature = realEltToCustomize.eClass().getEStructuralFeature(attributeName);
if (eStructuralFeature instanceof EAttribute && newAttributeValue != null) {
EAttribute eAttribute = (EAttribute) eStructuralFeature;
- EDataType eAttributeType = eAttribute.getEAttributeType();
- Class<?> instanceClass = eAttributeType.getInstanceClass();
- if (instanceClass.isPrimitive()) {
+ Object convertedNewValue = getConvertedValue(newAttributeValue, eAttribute);
+ Class<?> instanceClass = eAttribute.getEAttributeType().getInstanceClass();
+ if (eAttribute.isMany()) {
+ instanceClass = Collection.class;
+ } else if (instanceClass.isPrimitive()) {
instanceClass = Primitives.wrap(instanceClass);
}
- Object convertedObject = EcoreUtil.createFromString(eAttributeType, newAttributeValue);
- if (eAttribute.isMany() && convertedObject != null && instanceClass.isAssignableFrom(convertedObject.getClass())) {
- List<Object> manyConvertedObject = new ArrayList<Object>();
- manyConvertedObject.add(convertedObject);
- realEltToCustomize.eSet(eAttribute, manyConvertedObject);
- } else if (convertedObject != null && instanceClass.isAssignableFrom(convertedObject.getClass())) {
- realEltToCustomize.eSet(eAttribute, convertedObject);
+ if (convertedNewValue != null && instanceClass.isAssignableFrom(convertedNewValue.getClass())) {
+ realEltToCustomize.eSet(eAttribute, convertedNewValue);
}
}
}
}
}
+ private Object getConvertedValue(Object newAttributeValue, EAttribute eAttribute) {
+ Object convertedValue = newAttributeValue;
+ EDataType eAttributeType = eAttribute.getEAttributeType();
+ if (eAttribute.isMany()) {
+ List<Object> manyConvertedObject = new ArrayList<Object>();
+ if (newAttributeValue instanceof Collection<?>) {
+ Collection<?> newAttributeValues = (Collection<?>) newAttributeValue;
+ for (Object newAttributeStringValue : newAttributeValues) {
+ manyConvertedObject.add(getConvertedValue(newAttributeStringValue, eAttributeType));
+ }
+ } else {
+ // Even if the newAttributeValue must be a collection, we manage
+ // the singleton value
+ manyConvertedObject.add(getConvertedValue(newAttributeValue, eAttributeType));
+ }
+ convertedValue = manyConvertedObject;
+ } else {
+ convertedValue = getConvertedValue(newAttributeValue, eAttributeType);
+ }
+ return convertedValue;
+ }
+
+ private Object getConvertedValue(Object newAttributeValue, EDataType eAttributeType) {
+ Object convertedValue = newAttributeValue;
+ if (newAttributeValue instanceof String) {
+ String newAttributeStringValue = (String) newAttributeValue;
+ Object convertedObject = EcoreUtil.createFromString(eAttributeType, newAttributeStringValue);
+ convertedValue = convertedObject;
+ } else if (eAttributeType instanceof EEnum & newAttributeValue instanceof Enumerator) {
+ convertedValue = newAttributeValue;
+ }
+ return convertedValue;
+ }
+
private void applyEReferenceCustomization(EReferenceCustomization eReferenceCustomization, StyleDescription styleDescription, StyleDescription customizedStyleDescription, Set<EObject> appliedOn) {
Set<EObject> realEltsToCustomize = getRealElementsToCustomize(styleDescription, customizedStyleDescription, appliedOn, eReferenceCustomization);
for (EObject realEltToCustomize : realEltsToCustomize) {
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/EAttributeCustomizationQuery.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/EAttributeCustomizationQuery.java
index 7ca9ff5086..19098acda5 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/EAttributeCustomizationQuery.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/EAttributeCustomizationQuery.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 THALES GLOBAL SERVICES.
+ * Copyright (c) 2012, 2016 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -37,22 +37,22 @@ public class EAttributeCustomizationQuery extends org.eclipse.sirius.business.in
/**
* Get the new value computed for the current
- * {@link EAttributeCustomization} in a string representation.
+ * {@link EAttributeCustomization}.
*
* @param bestStyleDescriptionKey
* the {@link BestStyleDescriptionKey} identifying the best
* StyleDescription to customize
* @param interpreter
* the interpreter used to get the new value
- * @return the new value as a string representation
+ * @return the new value
*/
- public String getNewAttributeValue(BestStyleDescriptionKey bestStyleDescriptionKey, IInterpreter interpreter) {
- String newAttributeValue = null;
+ public Object getNewAttributeValue(BestStyleDescriptionKey bestStyleDescriptionKey, IInterpreter interpreter) {
+ Object newAttributeValue = null;
if (eAttributeCustomization.getValue() != null && !StringUtil.isEmpty(eAttributeCustomization.getValue().trim())) {
interpreter.setVariable(IInterpreterSiriusVariables.VIEW, bestStyleDescriptionKey.getViewVariable());
interpreter.setVariable(IInterpreterSiriusVariables.CONTAINER, bestStyleDescriptionKey.getContainerVariable());
- newAttributeValue = RuntimeLoggerManager.INSTANCE.decorate(interpreter).evaluateString(bestStyleDescriptionKey.getModelElement(), eAttributeCustomization,
+ newAttributeValue = RuntimeLoggerManager.INSTANCE.decorate(interpreter).evaluate(bestStyleDescriptionKey.getModelElement(), eAttributeCustomization,
DescriptionPackage.eINSTANCE.getEAttributeCustomization_Value());
interpreter.unSetVariable(IInterpreterSiriusVariables.VIEW);
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/customization/RefreshWithCustomizationTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/customization/RefreshWithCustomizationTests.java
index b7389ca81f..b3cca1409a 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/customization/RefreshWithCustomizationTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/refresh/customization/RefreshWithCustomizationTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2016 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -26,6 +26,7 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.sirius.business.api.color.AbstractColorUpdater;
import org.eclipse.sirius.business.api.dialect.DialectManager;
import org.eclipse.sirius.business.api.session.SessionStatus;
@@ -122,8 +123,8 @@ public class RefreshWithCustomizationTests extends SiriusDiagramTestCase {
EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + MODELER_EXTB_RESOURCE_NAME, "/" + TEMPORARY_PROJECT_NAME + "/" + MODELER_EXTB_RESOURCE_NAME);
EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SEMANTIC_RESOURCE_NAME, "/" + TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_RESOURCE_NAME);
EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID, PATH + "/" + SESSION_RESOURCE_NAME, "/" + TEMPORARY_PROJECT_NAME + "/" + SESSION_RESOURCE_NAME);
- Collections.addAll(modelerList, TEMPORARY_PROJECT_NAME + "/" + MODELER_RESOURCE_NAME, TEMPORARY_PROJECT_NAME + "/" + MODELER_EXTA_RESOURCE_NAME, TEMPORARY_PROJECT_NAME + "/"
- + MODELER_EXTB_RESOURCE_NAME);
+ Collections.addAll(modelerList, TEMPORARY_PROJECT_NAME + "/" + MODELER_RESOURCE_NAME, TEMPORARY_PROJECT_NAME + "/" + MODELER_EXTA_RESOURCE_NAME,
+ TEMPORARY_PROJECT_NAME + "/" + MODELER_EXTB_RESOURCE_NAME);
genericSetUp(Collections.singletonList(TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_RESOURCE_NAME), modelerList, TEMPORARY_PROJECT_NAME + "/" + SESSION_RESOURCE_NAME);
Iterator<DRepresentation> iterator = DialectManager.INSTANCE.getAllRepresentations(session).iterator();
@@ -193,15 +194,12 @@ public class RefreshWithCustomizationTests extends SiriusDiagramTestCase {
assertMessage = "The backgroundColor mustn't have changed as the EReferenceCustomization is disabled with the predicateExpression";
assertTrue(assertMessage, AbstractColorUpdater.areEquals(p1OriginalBackgroundColor, (RGBValues) p1.getStyle().eGet(DiagramPackage.Literals.FLAT_CONTAINER_STYLE__BACKGROUND_COLOR)));
assertTrue(assertMessage, AbstractColorUpdater.areEquals(eClass1OriginalBackgroundColor, (RGBValues) eClass1.getStyle().eGet(DiagramPackage.Literals.FLAT_CONTAINER_STYLE__BACKGROUND_COLOR)));
- assertTrue(assertMessage, AbstractColorUpdater.areEquals(eClass11OriginalBackgroundColor, (RGBValues) eClass11.getStyle().eGet(DiagramPackage.Literals.FLAT_CONTAINER_STYLE__BACKGROUND_COLOR)));
- assertTrue(
- assertMessage,
- AbstractColorUpdater.areEquals(eClass1AttributeOriginalBackgroundColor,
- (RGBValues) ((GaugeCompositeStyle) eClass1Attribute.getStyle()).getSections().get(0).eGet(DiagramPackage.Literals.GAUGE_SECTION__BACKGROUND_COLOR)));
- assertTrue(
- assertMessage,
- AbstractColorUpdater.areEquals(eClass11AttributeOriginalBackgroundColor,
- (RGBValues) ((GaugeCompositeStyle) eClass11Attribute.getStyle()).getSections().get(0).eGet(DiagramPackage.Literals.GAUGE_SECTION__BACKGROUND_COLOR)));
+ assertTrue(assertMessage,
+ AbstractColorUpdater.areEquals(eClass11OriginalBackgroundColor, (RGBValues) eClass11.getStyle().eGet(DiagramPackage.Literals.FLAT_CONTAINER_STYLE__BACKGROUND_COLOR)));
+ assertTrue(assertMessage, AbstractColorUpdater.areEquals(eClass1AttributeOriginalBackgroundColor,
+ (RGBValues) ((GaugeCompositeStyle) eClass1Attribute.getStyle()).getSections().get(0).eGet(DiagramPackage.Literals.GAUGE_SECTION__BACKGROUND_COLOR)));
+ assertTrue(assertMessage, AbstractColorUpdater.areEquals(eClass11AttributeOriginalBackgroundColor,
+ (RGBValues) ((GaugeCompositeStyle) eClass11Attribute.getStyle()).getSections().get(0).eGet(DiagramPackage.Literals.GAUGE_SECTION__BACKGROUND_COLOR)));
session.save(new NullProgressMonitor());
refresh(dDiagram);
@@ -209,6 +207,25 @@ public class RefreshWithCustomizationTests extends SiriusDiagramTestCase {
}
+ public void testMultiValuatedEAttribute() {
+ changeEAttributeCustomization(eAttributeCustomizationLabelFormat, "aql:OrderedSet{viewpoint::FontFormat::bold, viewpoint::FontFormat::italic}");
+ // Disable the EReferenceCustomization (enabled by default)
+ vsmElementCustomization1 = (VSMElementCustomization) EcoreUtil.resolve(vsmElementCustomization1, session.getTransactionalEditingDomain().getResourceSet());
+ vsmElementCustomization2 = (VSMElementCustomization) EcoreUtil.resolve(vsmElementCustomization2, session.getTransactionalEditingDomain().getResourceSet());
+ enableVSMElementCustomization(vsmElementCustomization2, false);
+ layerContributingCustomization = (AdditionalLayer) EcoreUtil.resolve(layerContributingCustomization, session.getTransactionalEditingDomain().getResourceSet());
+ // Activate layer that contains customizations
+ activateLayer(dDiagram, layerContributingCustomization.getName());
+ TestsUtil.synchronizationWithUIThread();
+ eAttributeCustomizationLabelFormat = (EAttributeCustomization) vsmElementCustomization1.getFeatureCustomizations().get(1);
+
+ List<FontFormat> fontFormat = new ArrayList<FontFormat>();
+ fontFormat.add(FontFormat.ITALIC_LITERAL);
+ fontFormat.add(FontFormat.BOLD_LITERAL);
+ String assertMessage = "The new label Font Format must be that of the EAttributeCustomization.value interpretation result";
+ assertEquals(assertMessage, fontFormat, eClass11Attribute.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT));
+ }
+
/**
* Test a style description element {@link EReference} customization through
* a {@link EReferenceCustomization}.
@@ -245,14 +262,10 @@ public class RefreshWithCustomizationTests extends SiriusDiagramTestCase {
assertTrue(assertMessage, AbstractColorUpdater.areEquals(customizedRGBValues, (RGBValues) p1.getStyle().eGet(DiagramPackage.Literals.FLAT_CONTAINER_STYLE__BACKGROUND_COLOR)));
assertTrue(assertMessage, AbstractColorUpdater.areEquals(customizedRGBValues, (RGBValues) eClass1.getStyle().eGet(DiagramPackage.Literals.FLAT_CONTAINER_STYLE__BACKGROUND_COLOR)));
assertTrue(assertMessage, AbstractColorUpdater.areEquals(customizedRGBValues, (RGBValues) eClass11.getStyle().eGet(DiagramPackage.Literals.FLAT_CONTAINER_STYLE__BACKGROUND_COLOR)));
- assertTrue(
- assertMessage,
- AbstractColorUpdater.areEquals(customizedRGBValues,
- (RGBValues) ((GaugeCompositeStyle) eClass1Attribute.getStyle()).getSections().get(0).eGet(DiagramPackage.Literals.GAUGE_SECTION__BACKGROUND_COLOR)));
- assertTrue(
- assertMessage,
- AbstractColorUpdater.areEquals(customizedRGBValues,
- (RGBValues) ((GaugeCompositeStyle) eClass11Attribute.getStyle()).getSections().get(0).eGet(DiagramPackage.Literals.GAUGE_SECTION__BACKGROUND_COLOR)));
+ assertTrue(assertMessage, AbstractColorUpdater.areEquals(customizedRGBValues,
+ (RGBValues) ((GaugeCompositeStyle) eClass1Attribute.getStyle()).getSections().get(0).eGet(DiagramPackage.Literals.GAUGE_SECTION__BACKGROUND_COLOR)));
+ assertTrue(assertMessage, AbstractColorUpdater.areEquals(customizedRGBValues,
+ (RGBValues) ((GaugeCompositeStyle) eClass11Attribute.getStyle()).getSections().get(0).eGet(DiagramPackage.Literals.GAUGE_SECTION__BACKGROUND_COLOR)));
session.save(new NullProgressMonitor());
refresh(dDiagram);
@@ -292,14 +305,10 @@ public class RefreshWithCustomizationTests extends SiriusDiagramTestCase {
assertTrue(assertMessage, AbstractColorUpdater.areEquals(customizedRGBValues, (RGBValues) p1.getStyle().eGet(DiagramPackage.Literals.FLAT_CONTAINER_STYLE__BACKGROUND_COLOR)));
assertTrue(assertMessage, AbstractColorUpdater.areEquals(customizedRGBValues, (RGBValues) eClass1.getStyle().eGet(DiagramPackage.Literals.FLAT_CONTAINER_STYLE__BACKGROUND_COLOR)));
assertTrue(assertMessage, AbstractColorUpdater.areEquals(customizedRGBValues, (RGBValues) eClass11.getStyle().eGet(DiagramPackage.Literals.FLAT_CONTAINER_STYLE__BACKGROUND_COLOR)));
- assertTrue(
- assertMessage,
- AbstractColorUpdater.areEquals(customizedRGBValues,
- (RGBValues) ((GaugeCompositeStyle) eClass1Attribute.getStyle()).getSections().get(0).eGet(DiagramPackage.Literals.GAUGE_SECTION__BACKGROUND_COLOR)));
- assertTrue(
- assertMessage,
- AbstractColorUpdater.areEquals(customizedRGBValues,
- (RGBValues) ((GaugeCompositeStyle) eClass11Attribute.getStyle()).getSections().get(0).eGet(DiagramPackage.Literals.GAUGE_SECTION__BACKGROUND_COLOR)));
+ assertTrue(assertMessage, AbstractColorUpdater.areEquals(customizedRGBValues,
+ (RGBValues) ((GaugeCompositeStyle) eClass1Attribute.getStyle()).getSections().get(0).eGet(DiagramPackage.Literals.GAUGE_SECTION__BACKGROUND_COLOR)));
+ assertTrue(assertMessage, AbstractColorUpdater.areEquals(customizedRGBValues,
+ (RGBValues) ((GaugeCompositeStyle) eClass11Attribute.getStyle()).getSections().get(0).eGet(DiagramPackage.Literals.GAUGE_SECTION__BACKGROUND_COLOR)));
session.save(new NullProgressMonitor());
refresh(dDiagram);
@@ -317,8 +326,8 @@ public class RefreshWithCustomizationTests extends SiriusDiagramTestCase {
DNodeContainer p1Bis = (DNodeContainer) dDiagramBis.getOwnedDiagramElements().get(0);
DNodeList eClass1Bis = (DNodeList) dDiagramBis.getOwnedDiagramElements().get(1);
DNodeList eClass11Bis = (DNodeList) p1Bis.getOwnedDiagramElements().get(0);
- DNodeListElement eClass1AttributeBis = (DNodeListElement) eClass1Bis.getOwnedElements().get(0);
- DNodeListElement eClass11AttributeBis = (DNodeListElement) eClass11Bis.getOwnedElements().get(0);
+ DNodeListElement eClass1AttributeBis = eClass1Bis.getOwnedElements().get(0);
+ DNodeListElement eClass11AttributeBis = eClass11Bis.getOwnedElements().get(0);
DEdge dEdgeBis = dDiagramBis.getEdges().get(0);
Integer p1BisLabelSize = (Integer) p1Bis.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_SIZE);
@@ -389,8 +398,8 @@ public class RefreshWithCustomizationTests extends SiriusDiagramTestCase {
DNodeContainer p1Bis = (DNodeContainer) dDiagram.getOwnedDiagramElements().get(0);
DNodeList eClass1Bis = (DNodeList) dDiagram.getOwnedDiagramElements().get(1);
DNodeList eClass11Bis = (DNodeList) p1Bis.getOwnedDiagramElements().get(0);
- DNodeListElement eClass1AttributeBis = (DNodeListElement) eClass1Bis.getOwnedElements().get(0);
- DNodeListElement eClass11AttributeBis = (DNodeListElement) eClass11Bis.getOwnedElements().get(0);
+ DNodeListElement eClass1AttributeBis = eClass1Bis.getOwnedElements().get(0);
+ DNodeListElement eClass11AttributeBis = eClass11Bis.getOwnedElements().get(0);
DEdge dEdgeBis = dDiagram.getEdges().get(0);
List<FontFormat> p1BisLabelFormat = (List<FontFormat>) p1Bis.getStyle().eGet(ViewpointPackage.Literals.BASIC_LABEL_STYLE__LABEL_FORMAT);
@@ -471,7 +480,28 @@ public class RefreshWithCustomizationTests extends SiriusDiagramTestCase {
String uriFragment = resource.getURIFragment(vsmElementCustomization);
URI uri = resource.getURI().appendFragment(uriFragment);
EObject eObject = new ResourceSetImpl().getEObject(uri, true);
- eObject.eSet(DescriptionPackage.Literals.VSM_ELEMENT_CUSTOMIZATION__PREDICATE_EXPRESSION, "[" + Boolean.valueOf(enable).toString() + "/]");
+ eObject.eSet(DescriptionPackage.Literals.VSM_ELEMENT_CUSTOMIZATION__PREDICATE_EXPRESSION, Boolean.valueOf(enable).toString());
+ try {
+ eObject.eResource().save(Collections.emptyMap());
+ } catch (IOException e) {
+ fail(e.getLocalizedMessage());
+ }
+ }
+
+ /**
+ * Change the {@link EAttributeCustomization#getValue()}.
+ *
+ * @param eAttributeCustomization
+ * the specified {@link EAttributeCustomization}
+ * @param valueExpression
+ * the value expression to compute the new value
+ */
+ private void changeEAttributeCustomization(EAttributeCustomization eAttributeCustomization, String valueExpression) {
+ Resource resource = eAttributeCustomization.eResource();
+ String uriFragment = resource.getURIFragment(eAttributeCustomization);
+ URI uri = resource.getURI().appendFragment(uriFragment);
+ EObject eObject = new ResourceSetImpl().getEObject(uri, true);
+ eObject.eSet(DescriptionPackage.Literals.EATTRIBUTE_CUSTOMIZATION__VALUE, valueExpression);
try {
eObject.eResource().save(Collections.emptyMap());
} catch (IOException e) {

Back to the top