diff options
| author | Laurent Redor | 2016-08-11 09:32:37 +0000 |
|---|---|---|
| committer | Laurent Redor | 2016-08-11 09:32:37 +0000 |
| commit | 8646070af5e9215f0d6b0c2ecb23d6975238d7d3 (patch) | |
| tree | a890ced67bda03e461611344fa23dbc96526565b | |
| parent | 0c854ec4222cf95ea8a68d5aba59841e32af2d07 (diff) | |
| download | org.eclipse.sirius-8646070af5e9215f0d6b0c2ecb23d6975238d7d3.tar.gz org.eclipse.sirius-8646070af5e9215f0d6b0c2ecb23d6975238d7d3.tar.xz org.eclipse.sirius-8646070af5e9215f0d6b0c2ecb23d6975238d7d3.zip | |
[496466] Fix pb with different kind of style
Fix pb explain in bugzilla 496466 comment 32 [1].
[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=496466#c32
Bug: 496466
Change-Id: I113ef1f62a4b0bb0048943510c1750c5d665810b
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
2 files changed, 64 insertions, 11 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java index 5a8e9244ea..7e842461ff 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java @@ -25,6 +25,7 @@ import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.gef.ConnectionEditPart; import org.eclipse.gef.EditPartViewer; @@ -998,18 +999,62 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat protected void computeCustomFeatures(Style oldStyle, Style newStyle) { for (EAttribute attribute : newStyle.eClass().getEAllAttributes()) { if (!ViewpointPackage.Literals.CUSTOMIZABLE__CUSTOM_FEATURES.equals(attribute)) { - if (oldStyle.eClass().getEStructuralFeature(attribute.getName()) == null) { - // When the attribute does not exist in old style, it is - // considered as custom - newStyle.getCustomFeatures().add(attribute.getName()); - } else if (newStyle.eIsSet(attribute)) { - if (!newStyle.eGet(attribute).equals(oldStyle.eGet(attribute))) { - newStyle.getCustomFeatures().add(attribute.getName()); + EAttribute attributeOfOldStyle = getCorrespondingEAttribute(attribute, oldStyle); + if (attributeOfOldStyle != null) { + if (newStyle.eIsSet(attribute)) { + if (!newStyle.eGet(attribute).equals(oldStyle.eGet(attributeOfOldStyle))) { + newStyle.getCustomFeatures().add(attributeOfOldStyle.getName()); + } + } else if (oldStyle.eIsSet(attributeOfOldStyle)) { + newStyle.getCustomFeatures().add(attributeOfOldStyle.getName()); } - } else if (oldStyle.eIsSet(attribute)) { - newStyle.getCustomFeatures().add(attribute.getName()); } } } } + + private EAttribute getCorrespondingEAttribute(EAttribute attribute, Style style) { + EAttribute result = null; + if (style.eClass().getFeatureID(attribute) != -1) { + result = attribute; + } else { + // This attribute does not exist in the style. Check specific + // mapping cases. + EStructuralFeature structuralFeature = style.eClass().getEStructuralFeature(attribute.getName()); + if (structuralFeature instanceof EAttribute) { + result = (EAttribute) structuralFeature; + } else if ("color".equals(attribute.getName())) { //$NON-NLS-1$ + structuralFeature = style.eClass().getEStructuralFeature("backgroundColor"); //$NON-NLS-1$ + if (structuralFeature instanceof EAttribute) { + result = (EAttribute) structuralFeature; + } + } else if ("backgroundColor".equals(attribute.getName())) { //$NON-NLS-1$ + structuralFeature = style.eClass().getEStructuralFeature("color"); //$NON-NLS-1$ + if (structuralFeature instanceof EAttribute) { + result = (EAttribute) structuralFeature; + } + } else if ("width".equals(attribute.getName())) { //$NON-NLS-1$ + structuralFeature = style.eClass().getEStructuralFeature("horizontalDiameter"); //$NON-NLS-1$ + if (structuralFeature instanceof EAttribute) { + result = (EAttribute) structuralFeature; + } + } else if ("horizontalDiameter".equals(attribute.getName())) { //$NON-NLS-1$ + structuralFeature = style.eClass().getEStructuralFeature("width"); //$NON-NLS-1$ + if (structuralFeature instanceof EAttribute) { + result = (EAttribute) structuralFeature; + } + } else if ("height".equals(attribute.getName())) { //$NON-NLS-1$ + structuralFeature = style.eClass().getEStructuralFeature("verticalDiameter"); //$NON-NLS-1$ + if (structuralFeature instanceof EAttribute) { + result = (EAttribute) structuralFeature; + } + } else if ("verticalDiameter".equals(attribute.getName())) { //$NON-NLS-1$ + structuralFeature = style.eClass().getEStructuralFeature("height"); //$NON-NLS-1$ + if (structuralFeature instanceof EAttribute) { + result = (EAttribute) structuralFeature; + } + } + } + return result; + } } diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/color/DiagramStyleColorUpdater.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/color/DiagramStyleColorUpdater.java index bd992ccffd..eac71ca299 100644 --- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/color/DiagramStyleColorUpdater.java +++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/color/DiagramStyleColorUpdater.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES and others. + * Copyright (c) 2007, 2016 THALES GLOBAL SERVICES and others. * 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 @@ -98,6 +98,15 @@ public class DiagramStyleColorUpdater extends AbstractColorUpdater { if (descToStyleForColorFeatures.containsValue(feature) && description != null) { if (previousStyle.some() && previousStyle.get().getCustomFeatures().contains(feature.getName())) { EStructuralFeature eStructuralFeature = previousStyle.get().eClass().getEStructuralFeature(feature.getName()); + if (eStructuralFeature == null) { + // If we don't found a matching feature, we search in + // specific matching cases + if ("color".equals(feature.getName())) { //$NON-NLS-1$ + eStructuralFeature = previousStyle.get().eClass().getEStructuralFeature("backgroundColor"); //$NON-NLS-1$ + } else if ("backgroundColor".equals(feature.getName())) { //$NON-NLS-1$ + eStructuralFeature = previousStyle.get().eClass().getEStructuralFeature("color"); //$NON-NLS-1$ + } + } // If we don't found a matching feature, we ignore the // customization (probably a not compatible // customization). @@ -134,7 +143,6 @@ public class DiagramStyleColorUpdater extends AbstractColorUpdater { return eAllReferences; } - /** * Update the colors of a style instance using the specified description. * |
