From 7880746ceec039ea19470b7e903b2fe14bd6e56d Mon Sep 17 00:00:00 2001 From: Vincent Lorenzo Date: Wed, 5 Jun 2019 10:15:49 +0200 Subject: Bug 547950: [Diagram][Export All Diagram] Common Bendpoint calculus fails during the export as image - fix the NPE Change-Id: I8ad4304c1aa2117361e733b854d124c4b29193c8 Signed-off-by: Vincent Lorenzo --- .../META-INF/MANIFEST.MF | 2 +- .../pom.xml | 11 +++--- .../common/figure/edge/PapyrusEdgeFigure.java | 40 ++++++++++++---------- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF index 69ea31b3d48..bca832b3af2 100755 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF @@ -82,7 +82,7 @@ Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.common.Activator Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-ClassPath: . -Bundle-Version: 3.101.100.qualifier +Bundle-Version: 3.101.200.qualifier Bundle-Localization: plugin Bundle-Name: %pluginName Bundle-ManifestVersion: 2 diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml index 6dd1ccb0a35..da88ec3c4e2 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/pom.xml @@ -1,13 +1,14 @@ - 4.0.0 - org.eclipse.papyrus - org.eclipse.papyrus.infra-gmfdiag - 0.0.1-SNAPSHOT + org.eclipse.papyrus + org.eclipse.papyrus.infra-gmfdiag + 0.0.1-SNAPSHOT org.eclipse.papyrus.infra.gmfdiag.common - 3.101.100-SNAPSHOT + 3.101.200-SNAPSHOT eclipse-plugin diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/edge/PapyrusEdgeFigure.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/edge/PapyrusEdgeFigure.java index 4f4e5e261cb..cdad0997fb6 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/edge/PapyrusEdgeFigure.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/edge/PapyrusEdgeFigure.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2013 CEA LIST. + * Copyright (c) 2013, 2019 CEA LIST. * * * All rights reserved. This program and the accompanying materials @@ -11,7 +11,7 @@ * * Contributors: * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation - * + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - bug 547950 (just fix the NPE) *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.common.figure.edge; @@ -98,7 +98,7 @@ public abstract class PapyrusEdgeFigure extends PolylineConnectionEx { */ @SuppressWarnings("unchecked") public Collection getCommonBendpointsToDraw() { - final Collection commonBendpointsToDraw = new HashSet(); + final Collection commonBendpointsToDraw = new HashSet<>(); final PointList bendPoints = getPoints(); final Map visualPartMap = getVisualPartMap(this); @@ -117,7 +117,7 @@ public abstract class PapyrusEdgeFigure extends PolylineConnectionEx { if (currentEditPart instanceof ConnectionEditPart && eClass != null) { final EditPart sourceEP = ((ConnectionEditPart) currentEditPart).getSource(); final EditPart targetEP = ((ConnectionEditPart) currentEditPart).getTarget(); - final Set allConnectionsEP = new HashSet(); + final Set allConnectionsEP = new HashSet<>(); // 2.1. get all potential editpart connections if (sourceEP instanceof AbstractGraphicalEditPart && targetEP instanceof AbstractGraphicalEditPart) { allConnectionsEP.addAll(((AbstractGraphicalEditPart) sourceEP).getSourceConnections()); @@ -128,7 +128,7 @@ public abstract class PapyrusEdgeFigure extends PolylineConnectionEx { } // 2.2 get the figure for these connections and keep only figure when its editpart has the same kind than the current one - final Set allConnections = new HashSet(); + final Set allConnections = new HashSet<>(); if (allConnectionsEP.size() > 0) { for (final Object current : allConnectionsEP) { // the editpart be instance of the same class @@ -146,7 +146,7 @@ public abstract class PapyrusEdgeFigure extends PolylineConnectionEx { } // 3. Create the list of the LineSeg of the current figure - final List refs = new ArrayList(); + final List refs = new ArrayList<>(); for (int i = 0; i < bendPoints.size() - 1; i++) { LineSeg seg = new LineSeg(bendPoints.getPoint(i), bendPoints.getPoint(i + 1)); refs.add(seg); @@ -155,13 +155,13 @@ public abstract class PapyrusEdgeFigure extends PolylineConnectionEx { // 4. find common segments between the current figure and each others link // we need to associate each common segment to the concerned link - final Map>> segs = new HashMap>>(); + final Map>> segs = new HashMap<>(); for (Connection currentConn : allConnections) { final PointList currentPoints = currentConn.getPoints(); - final Map> mapSegs = new HashMap>(); + final Map> mapSegs = new HashMap<>(); segs.put(currentConn, mapSegs); for (LineSeg refSeg : refs) { - final List commonSubSegs = new ArrayList(); + final List commonSubSegs = new ArrayList<>(); mapSegs.put(refSeg, commonSubSegs); for (int i = 0; i < currentPoints.size() - 1; i++) { LineSeg tmp = new LineSeg(currentPoints.getPoint(i), currentPoints.getPoint(i + 1)); @@ -361,10 +361,12 @@ public abstract class PapyrusEdgeFigure extends PolylineConnectionEx { if (part instanceof CoreMultiDiagramEditor) { final List visibleEditors = ((CoreMultiDiagramEditor) part).getISashWindowsContainer().getVisibleIEditorParts(); for (final IEditorPart current : visibleEditors) { - final GraphicalViewer viewer = (GraphicalViewer) current.getAdapter(GraphicalViewer.class); - final Map visualPartMap = viewer.getVisualPartMap(); - if (visualPartMap.containsKey(figure)) { - return visualPartMap; + final GraphicalViewer viewer = current.getAdapter(GraphicalViewer.class); + if (null != viewer) { + final Map visualPartMap = viewer.getVisualPartMap(); + if (visualPartMap.containsKey(figure)) { + return visualPartMap; + } } } } else { @@ -380,9 +382,11 @@ public abstract class PapyrusEdgeFigure extends PolylineConnectionEx { if (editor instanceof IDiagramWorkbenchPart) { final IDiagramWorkbenchPart de = (IDiagramWorkbenchPart) editor; final GraphicalViewer viewer = de.getDiagramGraphicalViewer(); - final Map visualPartMap = viewer.getVisualPartMap(); - if (visualPartMap.containsKey(figure)) { - return visualPartMap; + if (null != viewer) { + final Map visualPartMap = viewer.getVisualPartMap(); + if (visualPartMap.containsKey(figure)) { + return visualPartMap; + } } } } @@ -402,13 +406,13 @@ public abstract class PapyrusEdgeFigure extends PolylineConnectionEx { * @return */ public static final PointList getCommonSegment(final LineSeg seg1, final LineSeg seg2) { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(seg1.getOrigin()); list.add(seg2.getOrigin()); list.add(seg1.getTerminus()); list.add(seg2.getTerminus()); - List commonPoints = new ArrayList(); + List commonPoints = new ArrayList<>(); for (Point point : list) { if (!commonPoints.contains(point)) { if (seg1.containsPoint(point, 0) && seg2.containsPoint(point, 0)) { -- cgit v1.2.3