From: Patrick Plitzner Date: Tue, 15 Nov 2016 14:10:12 +0000 (+0100) Subject: Fix potential NPE X-Git-Tag: 4.4.0^2~27 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/48005c5f653367a7ad23ea786dc864b7f9737fa3 Fix potential NPE --- diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java index fdaa3e0c4..24f0c8a8f 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java @@ -103,7 +103,10 @@ public abstract class AbstractUtility { * @return a boolean. */ public static boolean closeAll() { - return getActivePage().closeAllEditors(true); + if(getActivePage()!=null){ + return getActivePage().closeAllEditors(true); + } + return false; } /** @@ -217,14 +220,14 @@ public abstract class AbstractUtility { * @return a {@link org.eclipse.ui.IViewPart} object. */ public static IViewPart getView(String id, boolean restore) { - IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); IViewReference[] references = null; - if(activeWorkbenchWindow!=null){ - references = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage().getViewReferences(); + if(activeWorkbenchWindow!=null && activeWorkbenchWindow.getActivePage()!=null){ + references = activeWorkbenchWindow.getActivePage().getViewReferences(); } - else if(PlatformUI.getWorkbench().getWorkbenchWindows().length>0){ - references = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getActivePage().getViewReferences(); + else if(workbench.getWorkbenchWindows().length>0 && workbench.getWorkbenchWindows()[0].getActivePage()!=null){ + references = workbench.getWorkbenchWindows()[0].getActivePage().getViewReferences(); } if(references!=null){ for (IViewReference reference : references) {