Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Porhel2015-12-23 11:02:12 +0000
committerMaxime Porhel2016-01-05 10:19:43 +0000
commit335a0c927b6a3658bddb0112dce63736d551a0ee (patch)
tree67aba9ef153d23278b297287802a08ab19ec1623
parent85e088a4b005aa22b863089e5eee02e13632d2d5 (diff)
downloadorg.eclipse.sirius-335a0c927b6a3658bddb0112dce63736d551a0ee.tar.gz
org.eclipse.sirius-335a0c927b6a3658bddb0112dce63736d551a0ee.tar.xz
org.eclipse.sirius-335a0c927b6a3658bddb0112dce63736d551a0ee.zip
[485119] Update OneLineMarginBorder.dash pattern type
graphics.setLineDash(dash) was previously always called, but this causes NPE in org.eclipse.gmf.runtime.draw2d.ui.render.awt.internal.graphics. GraphicsToGraphics2DAdaptor and its sub-implementations. For exemple it occurs when it tries to transform the int[] into a float[] on Windows (image copy in the system clipboard) or on all systems when CopyToImageUtil is used. SWTGraphics is used in the editor and correctly handle null value. We cannot choose to call setLineDash(float[]) as org.eclipse.gmf.runtime.draw2d.ui.internal.graphics.ScaledGraphics and its sub-immplementations do not implement it, even if they delegates the final behavior to SWTGraphics at runtime. The chosen solution consists in calling the setLineDash(int []) only when the array is not null and the style CUSTOM as done in org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities. paintGridWithStyle(Graphics, IFigure, Point, int, int, int, int[]) Bug: 485119 Cherry-picked-from: 484507 Change-Id: Ie86eaafb80535ca1345d5cd85ae62a481784cdc8 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/tools/api/figure/OneLineMarginBorder.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/OneLineMarginBorder.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/OneLineMarginBorder.java
index dd4a904eb2..9e66ce3666 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/OneLineMarginBorder.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/figure/OneLineMarginBorder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 THALES GLOBAL SERVICES.
+ * 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
@@ -16,6 +16,7 @@ import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.gmf.runtime.draw2d.ui.figures.OneLineBorder;
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
+import org.eclipse.swt.SWT;
/**
* Specific {@link OneLineBorder} with dash capabilities, two more supported
@@ -53,8 +54,9 @@ public class OneLineMarginBorder extends OneLineBorder {
*/
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
- graphics.setLineDash(dash);
-
+ if (dash != null && getStyle() == SWT.LINE_CUSTOM) {
+ graphics.setLineDash(dash);
+ }
super.paint(figure, graphics, insets);
int one = MapModeUtil.getMapMode(figure).DPtoLP(1);

Back to the top