diff options
6 files changed, 92 insertions, 110 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/ImageSelectorService.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/ImageSelectorService.java index 6482dd5248..58905d5ee9 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/ImageSelectorService.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/api/image/ImageSelectorService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2015 THALES GLOBAL SERVICES and others. + * Copyright (c) 2012, 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 @@ -56,6 +56,7 @@ import org.eclipse.sirius.viewpoint.Customizable; import org.eclipse.sirius.viewpoint.LabelStyle; import org.eclipse.sirius.viewpoint.Style; import org.eclipse.sirius.viewpoint.ViewpointPackage; +import org.eclipse.sirius.viewpoint.description.style.StyleDescription; import org.eclipse.ui.IEditorPart; /** @@ -157,8 +158,8 @@ public class ImageSelectorService { if (basicLabelStyle instanceof WorkspaceImage) { updateWorkspacePathCmd = SetCommand.create(domain, basicLabelStyle, DiagramPackage.Literals.WORKSPACE_IMAGE__WORKSPACE_PATH, workspacePath); if (!basicLabelStyle.getCustomFeatures().contains(DiagramPackage.Literals.WORKSPACE_IMAGE__WORKSPACE_PATH.getName())) { - updateWorkspacePathCmd = updateWorkspacePathCmd.chain(AddCommand.create(domain, basicLabelStyle, ViewpointPackage.Literals.CUSTOMIZABLE__CUSTOM_FEATURES, - DiagramPackage.Literals.WORKSPACE_IMAGE__WORKSPACE_PATH.getName())); + updateWorkspacePathCmd = updateWorkspacePathCmd.chain( + AddCommand.create(domain, basicLabelStyle, ViewpointPackage.Literals.CUSTOMIZABLE__CUSTOM_FEATURES, DiagramPackage.Literals.WORKSPACE_IMAGE__WORKSPACE_PATH.getName())); } } else { Object feature = getFeature(basicLabelStyle); @@ -231,8 +232,9 @@ public class ImageSelectorService { workspaceImage.setBorderLineStyle(oldStyle.getBorderLineStyle()); workspaceImage.setBorderSize(oldStyle.getBorderSize()); - if (oldStyle.getDescription() instanceof BorderedStyleDescription) { - BorderedStyleDescription oldDesc = (BorderedStyleDescription) oldStyle.getDescription(); + StyleDescription oldDescription = oldStyle.getDescription(); + if (oldDescription instanceof BorderedStyleDescription) { + BorderedStyleDescription oldDesc = (BorderedStyleDescription) oldDescription; workspaceImageDescription.setBorderColor(oldDesc.getBorderColor()); workspaceImageDescription.setBorderLineStyle(oldDesc.getBorderLineStyle()); workspaceImageDescription.setBorderSizeComputationExpression(oldDesc.getBorderSizeComputationExpression()); diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramContainerEditPartOperation.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramContainerEditPartOperation.java index ae6551b64e..dc950813ef 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramContainerEditPartOperation.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramContainerEditPartOperation.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 @@ -55,6 +55,7 @@ import org.eclipse.sirius.ui.tools.api.color.VisualBindingManager; import org.eclipse.sirius.viewpoint.DStylizable; import org.eclipse.sirius.viewpoint.RGBValues; import org.eclipse.sirius.viewpoint.Style; +import org.eclipse.sirius.viewpoint.description.style.StyleDescription; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -452,17 +453,25 @@ public final class DiagramContainerEditPartOperation { private static Dimension getCornerDimension(EObject eObj) { final Dimension corner = new Dimension(0, 0); + StyleDescription styleDescription = getStyleDecription(eObj); + if (styleDescription instanceof ContainerStyleDescription) { + final ContainerStyleDescription description = (ContainerStyleDescription) styleDescription; + if (description.isRoundedCorner()) { + corner.height = description.getArcHeight(); + corner.width = description.getArcWidth(); + } + } + return corner; + } + + private static StyleDescription getStyleDecription(EObject eObj) { if (eObj instanceof DStylizable) { final Style style = ((DStylizable) eObj).getStyle(); - if (style != null && style.getDescription() instanceof ContainerStyleDescription) { - final ContainerStyleDescription description = (ContainerStyleDescription) style.getDescription(); - if (description.isRoundedCorner()) { - corner.height = description.getArcHeight(); - corner.width = description.getArcWidth(); - } + if (style != null) { + return style.getDescription(); } } - return corner; + return null; } /** diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/GMFBoundsUpdater.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/GMFBoundsUpdater.java index aa8624a12a..a2d721a692 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/GMFBoundsUpdater.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/listeners/GMFBoundsUpdater.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 @@ -39,9 +39,10 @@ import org.eclipse.sirius.diagram.ui.business.api.view.SiriusGMFHelper; import org.eclipse.sirius.diagram.ui.business.internal.query.WorkspaceImageQuery; import org.eclipse.sirius.diagram.ui.provider.Messages; import org.eclipse.sirius.diagram.ui.tools.api.layout.LayoutUtils; +import org.eclipse.sirius.viewpoint.description.style.StyleDescription; /** - * A ResourceSet listener to resize image with this default size. + * A ResourceSet listener to resize image with its default size. * * @author jdupont */ @@ -123,8 +124,9 @@ public class GMFBoundsUpdater extends ResourceSetListenerImpl { differentPath = false; } } - isWorkspaceImageStyleResized = dDiagramElement.getStyle().getDescription() instanceof WorkspaceImageDescription - && ((WorkspaceImageDescription) dDiagramElement.getStyle().getDescription()).getSizeComputationExpression().equals("-1") && differentPath; //$NON-NLS-1$ + StyleDescription description = dDiagramElement.getStyle().getDescription(); + isWorkspaceImageStyleResized = description instanceof WorkspaceImageDescription + && ((WorkspaceImageDescription) description).getSizeComputationExpression().equals("-1") && differentPath; //$NON-NLS-1$ return isWorkspaceImageStyleResized; } @@ -162,11 +164,12 @@ public class GMFBoundsUpdater extends ResourceSetListenerImpl { for (DDiagramElement element : elementsToResize) { Node node = SiriusGMFHelper.getGmfNode(element, session); Size size = (Size) node.getLayoutConstraint(); - if (element.getStyle().getDescription() instanceof WorkspaceImageDescription) { - Dimension defaultDimension = new WorkspaceImageQuery((WorkspaceImageDescription) element.getStyle().getDescription()).getDefaultDimension(); + StyleDescription styleDescription = element.getStyle().getDescription(); + if (styleDescription instanceof WorkspaceImageDescription) { + Dimension defaultDimension = new WorkspaceImageQuery((WorkspaceImageDescription) styleDescription).getDefaultDimension(); size.setHeight(defaultDimension.height); size.setWidth(defaultDimension.width); - } else if (element.getStyle().getDescription() instanceof NodeStyleDescription) { + } else if (styleDescription instanceof NodeStyleDescription) { size.setHeight(((DNode) element).getHeight() * LayoutUtils.SCALE); size.setWidth(((DNode) element).getWidth() * LayoutUtils.SCALE); } diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/EdgeMappingHelper.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/EdgeMappingHelper.java index 8facd7221a..2099b7718f 100644 --- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/EdgeMappingHelper.java +++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/EdgeMappingHelper.java @@ -56,6 +56,7 @@ import org.eclipse.sirius.tools.api.ui.resource.ISiriusMessages; import org.eclipse.sirius.viewpoint.DSemanticDecorator; import org.eclipse.sirius.viewpoint.SiriusPlugin; import org.eclipse.sirius.viewpoint.description.style.BasicLabelStyleDescription; +import org.eclipse.sirius.viewpoint.description.style.StyleDescription; import org.eclipse.sirius.viewpoint.description.style.StylePackage; import com.google.common.collect.Lists; @@ -207,10 +208,6 @@ public final class EdgeMappingHelper { // Get the best style according to conditionals styles final EdgeStyle style = (EdgeStyle) new MappingHelper(interpreter).getBestStyle(edgeMapping, newEdge.getTarget(), diagram, container, diagram); EdgeStyleDescription styleDescription = null; - if (style != null && style.getDescription() instanceof EdgeStyleDescription) { - styleDescription = (EdgeStyleDescription) style.getDescription(); - } - DiagramElementMappingHelper.refreshSemanticElements(edgeMapping, newEdge, interpreter); // The optional path. @@ -218,6 +215,10 @@ public final class EdgeMappingHelper { if (style != null) { newEdge.setOwnedStyle(style); + StyleDescription description = style.getDescription(); + if (description instanceof EdgeStyleDescription) { + styleDescription = (EdgeStyleDescription) description; + } } if (newEdge.getOwnedStyle() != null) { Option<EdgeStyle> noPreviousStyle = Options.newNone(); diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/StyleHelper.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/StyleHelper.java index 3690beaad2..13405116e4 100644 --- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/StyleHelper.java +++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/StyleHelper.java @@ -176,7 +176,7 @@ public final class StyleHelper { if (description instanceof EdgeStyleDescription) { updateEdgeStyle((EdgeStyleDescription) description, (EdgeStyle) style, (Option<EdgeStyle>) previousStyle); } - refreshColors(style, previousStyle); + refreshColors(description, style, previousStyle); } } @@ -237,7 +237,7 @@ public final class StyleHelper { } Option<EdgeStyle> noPreviousStyle = Options.newNone(); updateEdgeStyle(description, style, noPreviousStyle); - refreshColors(style, noPreviousStyle); + refreshColors(description, style, noPreviousStyle); return style; } @@ -346,12 +346,14 @@ public final class StyleHelper { edgeStyle.setCenterLabelStyle(previousStyle.get().getCenterLabelStyle()); } } - if (edgeDescription.getCenterLabelStyleDescription() != null && edgeStyle.getCenterLabelStyle() == null - && !edgeStyle.getCustomFeatures().contains(DiagramPackage.Literals.EDGE_STYLE__CENTER_LABEL_STYLE.getName())) { - CenterLabelStyle centerLabelStyle = DiagramFactory.eINSTANCE.createCenterLabelStyle(); + + CenterLabelStyleDescription centerLabelStyleDesc = edgeDescription.getCenterLabelStyleDescription(); + CenterLabelStyle centerLabelStyle = edgeStyle.getCenterLabelStyle(); + if (centerLabelStyleDesc != null && centerLabelStyle == null && !edgeStyle.getCustomFeatures().contains(DiagramPackage.Literals.EDGE_STYLE__CENTER_LABEL_STYLE.getName())) { + centerLabelStyle = DiagramFactory.eINSTANCE.createCenterLabelStyle(); edgeStyle.setCenterLabelStyle(centerLabelStyle); } - updateEdgeLabel(edgeDescription.getCenterLabelStyleDescription(), edgeStyle.getCenterLabelStyle()); + updateEdgeLabel(centerLabelStyleDesc, centerLabelStyle); if (previousStyle.some()) { if (previousStyle.get().getCustomFeatures().contains(DiagramPackage.Literals.EDGE_STYLE__BEGIN_LABEL_STYLE.getName())) { @@ -359,12 +361,14 @@ public final class StyleHelper { edgeStyle.setBeginLabelStyle(previousStyle.get().getBeginLabelStyle()); } } - if (edgeDescription.getBeginLabelStyleDescription() != null && edgeStyle.getBeginLabelStyle() == null - && !edgeStyle.getCustomFeatures().contains(DiagramPackage.Literals.EDGE_STYLE__BEGIN_LABEL_STYLE.getName())) { - BeginLabelStyle beginLabelStyle = DiagramFactory.eINSTANCE.createBeginLabelStyle(); + + BeginLabelStyleDescription beginLabelStyleDec = edgeDescription.getBeginLabelStyleDescription(); + BeginLabelStyle beginLabelStyle = edgeStyle.getBeginLabelStyle(); + if (beginLabelStyleDec != null && beginLabelStyle == null && !edgeStyle.getCustomFeatures().contains(DiagramPackage.Literals.EDGE_STYLE__BEGIN_LABEL_STYLE.getName())) { + beginLabelStyle = DiagramFactory.eINSTANCE.createBeginLabelStyle(); edgeStyle.setBeginLabelStyle(beginLabelStyle); } - updateEdgeLabel(edgeDescription.getBeginLabelStyleDescription(), edgeStyle.getBeginLabelStyle()); + updateEdgeLabel(beginLabelStyleDec, beginLabelStyle); if (previousStyle.some()) { if (previousStyle.get().getCustomFeatures().contains(DiagramPackage.Literals.EDGE_STYLE__END_LABEL_STYLE.getName())) { @@ -372,12 +376,15 @@ public final class StyleHelper { edgeStyle.setBeginLabelStyle(previousStyle.get().getBeginLabelStyle()); } } - if (edgeDescription.getEndLabelStyleDescription() != null && edgeStyle.getEndLabelStyle() == null - && !edgeStyle.getCustomFeatures().contains(DiagramPackage.Literals.EDGE_STYLE__END_LABEL_STYLE.getName())) { - EndLabelStyle endLabelStyle = DiagramFactory.eINSTANCE.createEndLabelStyle(); + + EndLabelStyleDescription endLabelStyleDesc = edgeDescription.getEndLabelStyleDescription(); + EndLabelStyle endLabelStyle = edgeStyle.getEndLabelStyle(); + if (endLabelStyleDesc != null && endLabelStyle == null && !edgeStyle.getCustomFeatures().contains(DiagramPackage.Literals.EDGE_STYLE__END_LABEL_STYLE.getName())) { + endLabelStyle = DiagramFactory.eINSTANCE.createEndLabelStyle(); edgeStyle.setEndLabelStyle(endLabelStyle); } - updateEdgeLabel(edgeDescription.getEndLabelStyleDescription(), edgeStyle.getEndLabelStyle()); + + updateEdgeLabel(endLabelStyleDesc, endLabelStyle); } private void updateEdgeCenteringInformations(EdgeStyleDescription edgeDescription, EdgeStyle edgeStyle, Option<EdgeStyle> previousStyle) { @@ -480,18 +487,6 @@ public final class StyleHelper { } private void updateEdgeLabel(BasicLabelStyleDescription description, BasicLabelStyle style) { - if (description instanceof BeginLabelStyleDescription && style instanceof BeginLabelStyle && ((BeginLabelStyle) style).getDescription() != description) { - ((BeginLabelStyle) style).setDescription(description); - } - - if (description instanceof EndLabelStyleDescription && style instanceof EndLabelStyle && ((EndLabelStyle) style).getDescription() != description) { - ((EndLabelStyle) style).setDescription(description); - } - - if (description instanceof CenterLabelStyleDescription && style instanceof CenterLabelStyle && ((CenterLabelStyle) style).getDescription() != description) { - ((CenterLabelStyle) style).setDescription(description); - } - if (description != null && style != null) { Option<NodeStyle> noPreviousStyle = Options.newNone(); updateBasicLabelStyleFeatures(description, style, noPreviousStyle); @@ -575,7 +570,7 @@ public final class StyleHelper { if (style != null) { style.setHideLabelByDefault(description.isHideLabelByDefault()); Option<Style> noPreviousStyle = Options.newNone(); - refreshColors(style, noPreviousStyle); + refreshColors(description, style, noPreviousStyle); } return style; @@ -672,7 +667,7 @@ public final class StyleHelper { style.setLabelPosition(description.getLabelPosition()); style.setHideLabelByDefault(description.isHideLabelByDefault()); Option<Style> noPreviousStyle = Options.newNone(); - refreshColors(style, noPreviousStyle); + refreshColors(description, style, noPreviousStyle); } return style; } @@ -973,8 +968,8 @@ public final class StyleHelper { image.setWorkspacePath(((WorkspaceImage) previousStyle.get()).getWorkspacePath()); image.getCustomFeatures().add(DiagramPackage.Literals.WORKSPACE_IMAGE__WORKSPACE_PATH.getName()); } else { - if (image.getWorkspacePath() == null || !image.getWorkspacePath().equals(description.getWorkspacePath()) - && !image.getCustomFeatures().contains(DiagramPackage.Literals.WORKSPACE_IMAGE__WORKSPACE_PATH.getName())) { + if (image.getWorkspacePath() == null + || !image.getWorkspacePath().equals(description.getWorkspacePath()) && !image.getCustomFeatures().contains(DiagramPackage.Literals.WORKSPACE_IMAGE__WORKSPACE_PATH.getName())) { image.setWorkspacePath(description.getWorkspacePath()); } } @@ -1319,94 +1314,62 @@ public final class StyleHelper { /** * Refreshes all colors of the given style. * + * @param description + * the description. * @param style * the style. * @param previousStyle * the previous style (if existing) to keep compatible * customization. */ - protected void refreshColors(final Style style, Option<? extends Style> previousStyle) { + protected void refreshColors(StyleDescription description, final Style style, Option<? extends Style> previousStyle) { EObject context = style.eContainer(); /* * If there is no description we won't have a lot of chance to update * anything.. */ - if (style.getDescription() != null) { + if (description != null) { if (context != null) { if (context instanceof DSemanticDecorator) { context = ((DSemanticDecorator) context).getTarget(); } - colorUpdater.updateColors(context, style, style.getDescription(), previousStyle); - refreshEdgeStyleWithContext(style, context, previousStyle); + colorUpdater.updateColors(context, style, description, previousStyle); + refreshEdgeLabelColors(context, style, description, previousStyle); } else { - colorUpdater.updateColors(style, style.getDescription(), previousStyle); - refreshEdgeStyle(style, previousStyle); + colorUpdater.updateColors(style, description, previousStyle); + refreshEdgeLabelColors(null, style, description, previousStyle); } } - } - /** - * @param style - */ - private void refreshEdgeStyle(final Style style, Option<? extends Style> previousStyle) { - if (style instanceof EdgeStyle && (!previousStyle.some() || previousStyle.get() instanceof EdgeStyle)) { - CenterLabelStyle centerLabelStyle = ((EdgeStyle) style).getCenterLabelStyle(); - if (centerLabelStyle != null) { - Option<CenterLabelStyle> previousCenterLabelStyle = Options.newNone(); - if (previousStyle.some()) { - previousCenterLabelStyle = Options.newSome(((EdgeStyle) previousStyle.get()).getCenterLabelStyle()); - } - colorUpdater.updateColors(centerLabelStyle, centerLabelStyle.getDescription(), previousCenterLabelStyle); - } - BeginLabelStyle beginLabelStyle = ((EdgeStyle) style).getBeginLabelStyle(); - if (beginLabelStyle != null) { - Option<BeginLabelStyle> previousBeginLabelStyle = Options.newNone(); - if (previousStyle.some()) { - previousBeginLabelStyle = Options.newSome(((EdgeStyle) previousStyle.get()).getBeginLabelStyle()); - } - colorUpdater.updateColors(beginLabelStyle, beginLabelStyle.getDescription(), previousBeginLabelStyle); - } - EndLabelStyle endLabelStyle = ((EdgeStyle) style).getEndLabelStyle(); - if (endLabelStyle != null) { - Option<EndLabelStyle> previousEndLabelStyle = Options.newNone(); - if (previousStyle.some()) { - previousEndLabelStyle = Options.newSome(((EdgeStyle) previousStyle.get()).getEndLabelStyle()); - } - colorUpdater.updateColors(endLabelStyle, endLabelStyle.getDescription(), previousEndLabelStyle); - } - } - } + private void refreshEdgeLabelColors(final EObject context, Style style, StyleDescription description, Option<? extends Style> previousStyle) { + if (style instanceof EdgeStyle && description instanceof EdgeStyleDescription) { + EdgeStyleDescription edgeStyleDescription = (EdgeStyleDescription) description; + EdgeStyle edgeStyle = (EdgeStyle) style; - /** - * @param style - * @param context - */ - private void refreshEdgeStyleWithContext(final Style style, EObject context, Option<? extends Style> previousStyle) { - if (style instanceof EdgeStyle) { - CenterLabelStyle centerLabelStyle = ((EdgeStyle) style).getCenterLabelStyle(); + CenterLabelStyle centerLabelStyle = edgeStyle.getCenterLabelStyle(); if (centerLabelStyle != null) { Option<CenterLabelStyle> previousCenterLabelStyle = Options.newNone(); if (previousStyle.some()) { previousCenterLabelStyle = Options.newSome(((EdgeStyle) previousStyle.get()).getCenterLabelStyle()); } - colorUpdater.updateColors(context, centerLabelStyle, centerLabelStyle.getDescription(), previousCenterLabelStyle); + colorUpdater.updateColors(context, centerLabelStyle, edgeStyleDescription.getCenterLabelStyleDescription(), previousCenterLabelStyle); } - BeginLabelStyle beginLabelStyle = ((EdgeStyle) style).getBeginLabelStyle(); + BeginLabelStyle beginLabelStyle = edgeStyle.getBeginLabelStyle(); if (beginLabelStyle != null) { Option<BeginLabelStyle> previousBeginLabelStyle = Options.newNone(); if (previousStyle.some()) { previousBeginLabelStyle = Options.newSome(((EdgeStyle) previousStyle.get()).getBeginLabelStyle()); } - colorUpdater.updateColors(context, beginLabelStyle, beginLabelStyle.getDescription(), previousBeginLabelStyle); + colorUpdater.updateColors(context, beginLabelStyle, edgeStyleDescription.getBeginLabelStyleDescription(), previousBeginLabelStyle); } - EndLabelStyle endLabelStyle = ((EdgeStyle) style).getEndLabelStyle(); + EndLabelStyle endLabelStyle = edgeStyle.getEndLabelStyle(); if (endLabelStyle != null) { Option<EndLabelStyle> previousEndLabelStyle = Options.newNone(); if (previousStyle.some()) { previousEndLabelStyle = Options.newSome(((EdgeStyle) previousStyle.get()).getEndLabelStyle()); } - colorUpdater.updateColors(context, endLabelStyle, endLabelStyle.getDescription(), previousEndLabelStyle); + colorUpdater.updateColors(context, endLabelStyle, edgeStyleDescription.getEndLabelStyleDescription(), previousEndLabelStyle); } } } @@ -1449,8 +1412,8 @@ public final class StyleHelper { * @return if the description is the same type as the style */ private boolean isDifferentDescription(Style bestStyle, Style currentStyle) { - return !EqualityHelper.areEquals(bestStyle.getDescription(), currentStyle.getDescription()) || !bestStyle.getClass().equals(currentStyle.getClass()) - && currentStyle.getCustomFeatures().isEmpty(); + return !EqualityHelper.areEquals(bestStyle.getDescription(), currentStyle.getDescription()) + || !bestStyle.getClass().equals(currentStyle.getClass()) && currentStyle.getCustomFeatures().isEmpty(); } /** diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/DDiagramElementContainerExperimentalQuery.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/DDiagramElementContainerExperimentalQuery.java index 7ef70f8873..1bbd723376 100644 --- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/DDiagramElementContainerExperimentalQuery.java +++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/DDiagramElementContainerExperimentalQuery.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2015 THALES GLOBAL SERVICES and others. + * Copyright (c) 2013, 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 @@ -18,6 +18,7 @@ import org.eclipse.sirius.diagram.description.style.FlatContainerStyleDescriptio import org.eclipse.sirius.ext.base.Option; import org.eclipse.sirius.ext.base.Options; import org.eclipse.sirius.viewpoint.description.style.LabelBorderStyleDescription; +import org.eclipse.sirius.viewpoint.description.style.StyleDescription; /** * Queries for DDiagramElementContainer. @@ -96,9 +97,12 @@ public class DDiagramElementContainerExperimentalQuery { * @return an {@link Option} with the found label border style if it exists. */ public Option<LabelBorderStyleDescription> getLabelBorderStyle() { - if (container.getStyle() instanceof FlatContainerStyle && container.getStyle().getDescription() instanceof FlatContainerStyleDescription) { - FlatContainerStyleDescription fcsd = (FlatContainerStyleDescription) container.getStyle().getDescription(); - return Options.newSome(fcsd.getLabelBorderStyle()); + if (container.getStyle() instanceof FlatContainerStyle) { + StyleDescription description = container.getStyle().getDescription(); + if (description instanceof FlatContainerStyleDescription) { + FlatContainerStyleDescription fcsd = (FlatContainerStyleDescription) description; + return Options.newSome(fcsd.getLabelBorderStyle()); + } } return Options.newNone(); } |