Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Porhel2015-08-26 09:41:59 +0000
committerMaxime Porhel2015-08-27 08:54:17 +0000
commit69d9e9b4e4da54c7f62b783036719ce42f3c5056 (patch)
tree11b007d15e7b763dda9bbd8a63ae386e30bd0105
parent313416a5257555eddb1d62e1ba6412af68b36d28 (diff)
downloadorg.eclipse.sirius-69d9e9b4e4da54c7f62b783036719ce42f3c5056.tar.gz
org.eclipse.sirius-69d9e9b4e4da54c7f62b783036719ce42f3c5056.tar.xz
org.eclipse.sirius-69d9e9b4e4da54c7f62b783036719ce42f3c5056.zip
[472033] Correctly configure region border when image is used.
Force setOutline to false for all regions shapes: the border is drawn by a line margin border and not by the shape. This commit also correctly refresh the primaryShape: in case of background figure deep change, the primary shape can change but we used to configure the previous one. Bug: 472033 Change-Id: I4e3f8539234fe556149b9e98f9c65dd112d37e03 Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/edit/internal/part/DiagramContainerEditPartOperation.java25
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/RegionRoundedGradientRectangle.java2
2 files changed, 20 insertions, 7 deletions
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 00df895aac..138ec95741 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
@@ -140,10 +140,12 @@ public final class DiagramContainerEditPartOperation {
final DDiagramElement diagElement = self.resolveDiagramElement();
if (diagElement instanceof DDiagramElementContainer) {
final DDiagramElementContainer ddec = (DDiagramElementContainer) diagElement;
- final ViewNodeContainerFigureDesc primaryShape = self.getPrimaryShape();
final ContainerStyle style = ddec.getOwnedStyle();
- refreshBackgroundFigure(self, ddec, primaryShape, style);
+ // Change the primary shape if needed.
+ refreshBackgroundFigure(self, ddec, style);
+
+ final ViewNodeContainerFigureDesc primaryShape = self.getPrimaryShape();
refreshBorder(self, primaryShape, style);
if (primaryShape instanceof GradientRoundedRectangle) {
@@ -159,8 +161,11 @@ public final class DiagramContainerEditPartOperation {
}
}
- private static void refreshBackgroundFigure(final AbstractDiagramElementContainerEditPart self, final DDiagramElementContainer ddec, final ViewNodeContainerFigureDesc primaryShape,
- final ContainerStyle style) {
+ /**
+ * This method might refresh the background figure, or change it regarding
+ * how the style has evolved.
+ */
+ private static void refreshBackgroundFigure(final AbstractDiagramElementContainerEditPart self, final DDiagramElementContainer ddec, final ContainerStyle style) {
// Update the background figure when the workspace image path changes.
if (self.getBackgroundFigure() instanceof IWorkspaceImageFigure && ddec.getOwnedStyle() != null) {
@@ -168,6 +173,7 @@ public final class DiagramContainerEditPartOperation {
}
// Update the background figure when the background gradient style
+ ViewNodeContainerFigureDesc primaryShape = self.getPrimaryShape();
if (primaryShape instanceof GradientRoundedRectangle && style instanceof FlatContainerStyle) {
if (((GradientRoundedRectangle) primaryShape).getBackgroundStyle() != ((FlatContainerStyle) style).getBackgroundStyle()) {
self.reInitFigure();
@@ -261,6 +267,8 @@ public final class DiagramContainerEditPartOperation {
}
private static ViewNodeContainerFigureDesc refreshBorder(final AbstractDiagramElementContainerEditPart self, final ViewNodeContainerFigureDesc primaryShape, final ContainerStyle style) {
+ final int parentStackDirection = self.getParentStackDirection();
+
LineStyle borderLineStyle = LineStyle.SOLID_LITERAL;
int borderSize = 0;
if (style != null) {
@@ -269,10 +277,14 @@ public final class DiagramContainerEditPartOperation {
borderSize = style.getBorderSize().intValue();
}
}
+
+ // Refresh border size and style of the primary shape.
if (primaryShape instanceof Shape) {
Shape shape = (Shape) primaryShape;
shape.setLineWidth(borderSize);
- shape.setOutline(borderSize > 0);
+ // Deactivate the outline of the shape if there is no border or if
+ // this is a region.
+ shape.setOutline(borderSize > 0 && parentStackDirection == PositionConstants.NONE);
DiagramElementEditPartOperation.setLineStyle(shape, borderLineStyle, false);
} else if (primaryShape instanceof NodeFigure) {
NodeFigure nodeFigure = (NodeFigure) primaryShape;
@@ -287,6 +299,7 @@ public final class DiagramContainerEditPartOperation {
labelOffset = 0;
}
+ // Handle border line style, corner dimension and/or margin
if (primaryShape != null && primaryShape.getBorder() instanceof LineBorder) {
LineBorder lineBorder = (LineBorder) primaryShape.getBorder();
lineBorder.setWidth(borderSize);
@@ -300,7 +313,7 @@ public final class DiagramContainerEditPartOperation {
} else if (primaryShape != null && primaryShape.getBorder() instanceof MarginBorder) {
MarginBorder margin = null;
int borderMagin = borderSize;
- switch (self.getParentStackDirection()) {
+ switch (parentStackDirection) {
case PositionConstants.NORTH_SOUTH:
borderMagin = isFirstRegionPart(self) ? 0 : Math.max(0, borderSize - 1);
margin = new MarginBorder(borderMagin + labelOffset, 0, 0, 0);
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/RegionRoundedGradientRectangle.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/RegionRoundedGradientRectangle.java
index e645d4cee7..65d6ecb34a 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/RegionRoundedGradientRectangle.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/RegionRoundedGradientRectangle.java
@@ -33,7 +33,7 @@ import org.eclipse.sirius.diagram.ui.tools.api.figure.GradientRoundedRectangle;
* outline corresponding to a standard RoundedCorner with the same corner
* dimension.
*
- * outlineShape(Graphics) will never be call as setOutline will do nothing and
+ * outlineShape(Graphics) will never be called as setOutline will do nothing and
* the outline is set to false
*
* @author mporhel

Back to the top