Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2016-08-03 11:53:08 +0000
committerLaurent Redor2016-08-09 08:55:31 +0000
commit274602e164f3006eb8924fadc4879a8e9a62d3ac (patch)
treeec3b739a37398906b435226d966f41d5dd5c0905
parent71de945f776e3955896a63d3f9b7a5150d9bbb26 (diff)
downloadorg.eclipse.sirius-274602e164f3006eb8924fadc4879a8e9a62d3ac.tar.gz
org.eclipse.sirius-274602e164f3006eb8924fadc4879a8e9a62d3ac.tar.xz
org.eclipse.sirius-274602e164f3006eb8924fadc4879a8e9a62d3ac.zip
[496466] Correctly handle custom features list of Sirius style copy
In the case of a Paste Style (or Paste Format), the custom features list was not correctly handled. For example, if the source style had no custom feature, when it was applied to the target shape, the copy of the style had no custom feature even if some of them were different from the original style of the target shape. With this problem it is not possible to "Reset style properties to default values". Bug: 496466 Change-Id: I63a048547a44615271b403c0a27d438d30a59f8c Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java49
1 files changed, 38 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 f1827650a7..5a8e9244ea 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
@@ -23,6 +23,7 @@ import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
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.util.EcoreUtil;
import org.eclipse.gef.ConnectionEditPart;
@@ -81,6 +82,7 @@ import org.eclipse.sirius.diagram.ui.tools.api.graphical.edit.styles.IBorderItem
import org.eclipse.sirius.ext.draw2d.figure.FigureUtilities;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
import org.eclipse.sirius.viewpoint.Style;
+import org.eclipse.sirius.viewpoint.ViewpointPackage;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -460,22 +462,19 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat
// LayoutData.
Style copyOfSiriusStyle = EcoreUtil.copy(layoutData.getSiriusStyle());
if ((semanticDecorator instanceof DNode || semanticDecorator instanceof DNodeListElement) && copyOfSiriusStyle instanceof NodeStyle) {
- NodeStyle style = (NodeStyle) copyOfSiriusStyle;
if (semanticDecorator instanceof DNode) {
- DNode node = (DNode) semanticDecorator;
- node.setOwnedStyle(style);
+ computeCustomFeatures(((DNode) semanticDecorator).getOwnedStyle(), copyOfSiriusStyle);
+ ((DNode) semanticDecorator).setOwnedStyle((NodeStyle) copyOfSiriusStyle);
} else {
- DNodeListElement nodeListElement = (DNodeListElement) semanticDecorator;
- nodeListElement.setOwnedStyle(style);
+ computeCustomFeatures(((DNodeListElement) semanticDecorator).getOwnedStyle(), copyOfSiriusStyle);
+ ((DNodeListElement) semanticDecorator).setOwnedStyle((NodeStyle) copyOfSiriusStyle);
}
} else if (semanticDecorator instanceof DDiagramElementContainer && copyOfSiriusStyle instanceof ContainerStyle) {
- final DDiagramElementContainer container = (DDiagramElementContainer) semanticDecorator;
- final ContainerStyle style = (ContainerStyle) copyOfSiriusStyle;
- container.setOwnedStyle(style);
+ computeCustomFeatures(((DDiagramElementContainer) semanticDecorator).getOwnedStyle(), copyOfSiriusStyle);
+ ((DDiagramElementContainer) semanticDecorator).setOwnedStyle((ContainerStyle) copyOfSiriusStyle);
} else if (semanticDecorator instanceof DEdge && copyOfSiriusStyle instanceof EdgeStyle) {
- final DEdge edge = (DEdge) semanticDecorator;
- final EdgeStyle style = (EdgeStyle) copyOfSiriusStyle;
- edge.setOwnedStyle(style);
+ computeCustomFeatures(((DEdge) semanticDecorator).getOwnedStyle(), copyOfSiriusStyle);
+ ((DEdge) semanticDecorator).setOwnedStyle((EdgeStyle) copyOfSiriusStyle);
}
}
@@ -985,4 +984,32 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat
parentLayoutData.setLabel(labelLayoutData);
}
}
+
+ /**
+ * Check for each attribute of newStyle if it is the same in oldStyle. On
+ * the other hand, this attribute is added to the custom features of the
+ * newStyle.
+ *
+ * @param oldStyle
+ * The old style to compare with
+ * @param newStyle
+ * The new style in which to add custom features.
+ */
+ 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());
+ }
+ } else if (oldStyle.eIsSet(attribute)) {
+ newStyle.getCustomFeatures().add(attribute.getName());
+ }
+ }
+ }
+ }
}

Back to the top