[545122] Avoid potential NPEs
Bug: 545122
Change-Id: I48a3432ef1721259ff47004112fed57270ef4349
Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/DEdgeBeginNameViewFactory.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/DEdgeBeginNameViewFactory.java
index a7e24af..90a09fb 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/DEdgeBeginNameViewFactory.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/DEdgeBeginNameViewFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2019 THALES GLOBAL SERVICES.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -52,6 +52,7 @@
/**
* @not-generated
*/
+ @Override
public View createView(final IAdaptable semanticAdapter, final View containerView, final String semanticHint, final int index, final boolean persisted, final PreferencesHint preferencesHint) {
final Node view = (Node) super.createView(semanticAdapter, containerView, semanticHint, index, persisted, preferencesHint);
final Location location = (Location) view.getLayoutConstraint();
@@ -60,15 +61,14 @@
view.setVisible(!new DDiagramElementQuery(dEdge).isLabelHidden());
final EdgeLabelLayoutData data = SiriusLayoutDataManager.INSTANCE.getLabelData(dEdge);
- int x;
- int y;
- if (data == null) {
- x = mapMode.DPtoLP(0);
- y = mapMode.DPtoLP(10);
- } else {
+ int x = mapMode.DPtoLP(0);
+ int y = mapMode.DPtoLP(10);
+ if (data != null) {
final Point labelLocation = data.getLocation();
- x = labelLocation.x;
- y = labelLocation.y;
+ if (labelLocation != null) {
+ x = labelLocation.x;
+ y = labelLocation.y;
+ }
final Rectangle labelBounds = data.getLabelBounds();
if (labelBounds != null && location instanceof Bounds) {
((Bounds) location).setWidth(labelBounds.width);
@@ -84,6 +84,7 @@
/**
* @was-generated
*/
+ @Override
protected List<?> createStyles(final View view) {
return new ArrayList<>();
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/DEdgeEndNameViewFactory.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/DEdgeEndNameViewFactory.java
index 4cb44e3..310141d 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/DEdgeEndNameViewFactory.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/DEdgeEndNameViewFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2019 THALES GLOBAL SERVICES.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -52,6 +52,7 @@
/**
* @not-generated
*/
+ @Override
public View createView(final IAdaptable semanticAdapter, final View containerView, final String semanticHint, final int index, final boolean persisted, final PreferencesHint preferencesHint) {
final Node view = (Node) super.createView(semanticAdapter, containerView, semanticHint, index, persisted, preferencesHint);
final Location location = (Location) view.getLayoutConstraint();
@@ -60,15 +61,14 @@
view.setVisible(!new DDiagramElementQuery(dEdge).isLabelHidden());
final EdgeLabelLayoutData data = SiriusLayoutDataManager.INSTANCE.getLabelData(dEdge);
- int x;
- int y;
- if (data == null) {
- x = mapMode.DPtoLP(0);
- y = mapMode.DPtoLP(10);
- } else {
+ int x = mapMode.DPtoLP(0);
+ int y = mapMode.DPtoLP(10);
+ if (data != null) {
final Point labelLocation = data.getLocation();
- x = labelLocation.x;
- y = labelLocation.y;
+ if (labelLocation != null) {
+ x = labelLocation.x;
+ y = labelLocation.y;
+ }
final Rectangle labelBounds = data.getLabelBounds();
if (labelBounds != null && location instanceof Bounds) {
((Bounds) location).setWidth(labelBounds.width);
@@ -84,6 +84,7 @@
/**
* @was-generated
*/
+ @Override
protected List<?> createStyles(final View view) {
return new ArrayList<>();
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/DEdgeNameViewFactory.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/DEdgeNameViewFactory.java
index b623941..f0b3cde 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/DEdgeNameViewFactory.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/view/factories/DEdgeNameViewFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2019 THALES GLOBAL SERVICES.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -52,6 +52,7 @@
/**
* @not-generated
*/
+ @Override
public View createView(final IAdaptable semanticAdapter, final View containerView, final String semanticHint, final int index, final boolean persisted, final PreferencesHint preferencesHint) {
final Node view = (Node) super.createView(semanticAdapter, containerView, semanticHint, index, persisted, preferencesHint);
final Location location = (Location) view.getLayoutConstraint();
@@ -60,15 +61,14 @@
view.setVisible(!new DDiagramElementQuery(dEdge).isLabelHidden());
final EdgeLabelLayoutData data = SiriusLayoutDataManager.INSTANCE.getLabelData(dEdge);
- int x;
- int y;
- if (data == null) {
- x = mapMode.DPtoLP(0);
- y = mapMode.DPtoLP(-10);
- } else {
+ int x = mapMode.DPtoLP(0);
+ int y = mapMode.DPtoLP(-10);
+ if (data != null) {
final Point labelLocation = data.getLocation();
- x = labelLocation.x;
- y = labelLocation.y;
+ if (labelLocation != null) {
+ x = labelLocation.x;
+ y = labelLocation.y;
+ }
final Rectangle labelBounds = data.getLabelBounds();
if (labelBounds != null && location instanceof Bounds) {
((Bounds) location).setWidth(labelBounds.width);
@@ -84,6 +84,7 @@
/**
* @was-generated
*/
+ @Override
protected List<?> createStyles(final View view) {
return new ArrayList<>();
}