Revision 48005c5f
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java | ||
---|---|---|
103 | 103 |
* @return a boolean. |
104 | 104 |
*/ |
105 | 105 |
public static boolean closeAll() { |
106 |
return getActivePage().closeAllEditors(true); |
|
106 |
if(getActivePage()!=null){ |
|
107 |
return getActivePage().closeAllEditors(true); |
|
108 |
} |
|
109 |
return false; |
|
107 | 110 |
} |
108 | 111 |
|
109 | 112 |
/** |
... | ... | |
217 | 220 |
* @return a {@link org.eclipse.ui.IViewPart} object. |
218 | 221 |
*/ |
219 | 222 |
public static IViewPart getView(String id, boolean restore) { |
220 |
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
|
223 |
IWorkbench workbench = PlatformUI.getWorkbench(); |
|
224 |
IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); |
|
221 | 225 |
IViewReference[] references = null; |
222 |
if(activeWorkbenchWindow!=null){ |
|
223 |
references = PlatformUI.getWorkbench() |
|
224 |
.getActiveWorkbenchWindow().getActivePage().getViewReferences(); |
|
226 |
if(activeWorkbenchWindow!=null && activeWorkbenchWindow.getActivePage()!=null){ |
|
227 |
references = activeWorkbenchWindow.getActivePage().getViewReferences(); |
|
225 | 228 |
} |
226 |
else if(PlatformUI.getWorkbench().getWorkbenchWindows().length>0){
|
|
227 |
references = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getActivePage().getViewReferences();
|
|
229 |
else if(workbench.getWorkbenchWindows().length>0 && workbench.getWorkbenchWindows()[0].getActivePage()!=null){
|
|
230 |
references = workbench.getWorkbenchWindows()[0].getActivePage().getViewReferences();
|
|
228 | 231 |
} |
229 | 232 |
if(references!=null){ |
230 | 233 |
for (IViewReference reference : references) { |
Also available in: Unified diff
Fix potential NPE