Commit d883b099 authored by Simon Barner's avatar Simon Barner
Browse files

Error Markers: Avoid potential NPE

* Can be caused by dangling objects that e.g. stem from partical
  cross-project copies

Issue-Ref: 2845
Issue-Url: https://af3-developer.fortiss.org/issues/2845

Signed-off-by: Simon Barner's avatarSimon Barner <barner@fortiss.org>
parent fa6a7ff8
......@@ -5,7 +5,7 @@ LibraryView.java 6f7273ee49b9049c7267c129bd59ed27ec5872e2 GREEN
LibraryViewDragSourceAdapter.java 56ef61b214ef5d6cb5b751791a92158bda0391ec GREEN
LinkWithEditorPartListener.java c5ab74424378e7b158a805c4dd14fc03c8abeded GREEN
MarkerViewContentProvider.java 297d9a5c355047796dc938eb909fd1cf27a2cbf3 GREEN
MarkerViewPart.java 074e8e65c46daf50749d26d5eb866eef3eac2f2d GREEN
MarkerViewPart.java cbb650271b6877af205421b7cb11f930440a7ef9 YELLOW
NavigatorNewMenu.java a35e391960d1dacbe7f77982e53e1891e9382d5a GREEN
NavigatorTreeContentProvider.java 1bdefa28c5e2c2619cabbcd1946269a52db34e6c GREEN
NavigatorTreeContentSorter.java 76fc94e441ac1a8f2c5ae573f0e2b1e6fa73c31a GREEN
......
......@@ -38,6 +38,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.internal.MarkerService;
......@@ -95,9 +96,9 @@ public class MarkerViewPart extends ViewPart {
if(cell.getElement() instanceof IConstraintViolation) {
IConstraintViolation<? extends EObject> violation =
(IConstraintViolation<? extends EObject>)cell.getElement();
IModelElementHandlerService hs = IModelElementHandlerService.getInstance();
IModelElementHandler<EObject> handler =
IModelElementHandlerService.getInstance().getModelElementHandler(
violation.getSource());
hs.getModelElementHandler(violation.getSource());
cell.setText(handler != null ? handler.getName(violation.getSource()) : "");
} else {
cell.setText("");
......@@ -123,13 +124,17 @@ public class MarkerViewPart extends ViewPart {
if(cell.getElement() instanceof IConstraintViolation) {
IConstraintViolation<? extends EObject> violation =
(IConstraintViolation<? extends EObject>)cell.getElement();
EObject rootElement =
IPersistencyService.getInstance()
.getTopLevelElementFor(violation.getSource())
.getRootModelElement();
IModelElementHandler<EObject> handler =
IModelElementHandlerService.getInstance().getModelElementHandler(
rootElement);
IPersistencyService ps = IPersistencyService.getInstance();
ITopLevelElement topElement = ps.getTopLevelElementFor(violation.getSource());
IModelElementHandler<EObject> handler = null;
EObject rootElement = null;
if(topElement != null) {
rootElement = topElement.getRootModelElement();
IModelElementHandlerService hs = IModelElementHandlerService.getInstance();
handler = hs.getModelElementHandler(rootElement);
}
cell.setText(handler != null ? handler.getName(rootElement) : "");
} else {
cell.setText("");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment