diff options
| author | Maxime Porhel | 2015-09-11 14:50:48 +0000 |
|---|---|---|
| committer | Maxime Porhel | 2015-09-14 12:14:08 +0000 |
| commit | 9cf1783c487c077ba2915922ec5e8a4679a30ce0 (patch) | |
| tree | 3d30077441754e3c51ef14e11bb35f51c32fb2be | |
| parent | 993182f60d15d6d413dee22ef50f6c2c8dd8a460 (diff) | |
| download | org.eclipse.sirius-9cf1783c487c077ba2915922ec5e8a4679a30ce0.tar.gz org.eclipse.sirius-9cf1783c487c077ba2915922ec5e8a4679a30ce0.tar.xz org.eclipse.sirius-9cf1783c487c077ba2915922ec5e8a4679a30ce0.zip | |
[477211] Avoid NPE when a part without semantic element is selected
This can occurs at least with Note, Text and NoteAttachment edit parts.
This has been discovered during reproduction attempt with a Note on the
diagram.
Bug: 477211
Change-Id: I4e175fdb4996ad00c484c64650f3075f7230bffe
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/internal/util/EditPartQuery.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/util/EditPartQuery.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/util/EditPartQuery.java index 179366205b..ca0a6d408f 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/util/EditPartQuery.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/util/EditPartQuery.java @@ -322,14 +322,19 @@ public class EditPartQuery { */ public boolean isFreeFormContainerChildrenPresentation() { boolean isFreeForm = true; - EObject eContainer = part.resolveSemanticElement().eContainer(); - if (eContainer instanceof DNodeList) { + EObject semElt = part.resolveSemanticElement(); + if (semElt == null) { isFreeForm = false; - } else if (eContainer instanceof DNodeContainer) { - DNodeContainer container = (DNodeContainer) eContainer; - ContainerLayout childrenPresentation = container.getChildrenPresentation(); - if (!childrenPresentation.equals(ContainerLayout.FREE_FORM)) { + } else { + EObject eContainer = semElt.eContainer(); + if (eContainer instanceof DNodeList) { isFreeForm = false; + } else if (eContainer instanceof DNodeContainer) { + DNodeContainer container = (DNodeContainer) eContainer; + ContainerLayout childrenPresentation = container.getChildrenPresentation(); + if (!childrenPresentation.equals(ContainerLayout.FREE_FORM)) { + isFreeForm = false; + } } } return isFreeForm; @@ -419,8 +424,8 @@ public class EditPartQuery { expectedNewBounds = borderItemLocator.getValidLocation(expectedNewBounds, borderItemEditPart.getFigure()); } if (PositionConstants.NORTH == resizedSide) { - shiftingAccordingToBorderItemLocator.put((Node) borderItemEditPart.getModel(), - new Dimension(expectedNewBounds.x - currentBounds.x, expectedNewBounds.y - currentBounds.y + parentResizeSize)); + shiftingAccordingToBorderItemLocator.put((Node) borderItemEditPart.getModel(), new Dimension(expectedNewBounds.x - currentBounds.x, expectedNewBounds.y - currentBounds.y + + parentResizeSize)); } else { shiftingAccordingToBorderItemLocator.put((Node) borderItemEditPart.getModel(), new Dimension(expectedNewBounds.x - currentBounds.x, expectedNewBounds.y - currentBounds.y)); } @@ -517,8 +522,8 @@ public class EditPartQuery { expectedNewBounds = borderItemLocator.getValidLocation(expectedNewBounds, borderItemEditPart.getFigure()); } if (PositionConstants.WEST == resizedSide) { - shiftingAccordingToBorderItemLocator.put((Node) borderItemEditPart.getModel(), - new Dimension(expectedNewBounds.x - currentBounds.x + parentResizeSize, expectedNewBounds.y - currentBounds.y)); + shiftingAccordingToBorderItemLocator.put((Node) borderItemEditPart.getModel(), new Dimension(expectedNewBounds.x - currentBounds.x + parentResizeSize, expectedNewBounds.y + - currentBounds.y)); } else { shiftingAccordingToBorderItemLocator.put((Node) borderItemEditPart.getModel(), new Dimension(expectedNewBounds.x - currentBounds.x, expectedNewBounds.y - currentBounds.y)); } |
