|
38 | 38 | import org.eclipse.ui.IFileEditorInput;
|
39 | 39 | import org.eclipse.ui.console.MessageConsoleStream;
|
40 | 40 | import org.eclipse.ui.IWorkbenchPage;
|
| 41 | +import org.eclipse.ui.IWorkbenchWindow; |
| 42 | +import org.eclipse.ui.IWorkbench; |
41 | 43 | import org.eclipse.ui.PlatformUI;
|
42 | 44 | import org.eclipse.ui.IEditorInput;
|
43 | 45 | import org.eclipse.ui.IEditorPart;
|
@@ -74,15 +76,23 @@ public void setOptions(Map<String, ?> options) {
|
74 | 76 | }
|
75 | 77 |
|
76 | 78 | private String getSourceFilePath() {
|
77 |
| - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); |
78 |
| - if (page != null) { |
79 |
| - IEditorPart activeEditor = page.getActiveEditor(); |
80 |
| - if (activeEditor != null) { |
81 |
| - IEditorInput editorInput = activeEditor.getEditorInput(); |
82 |
| - if (editorInput != null) { |
83 |
| - IPath filePath = getSourceFilePathFromEditorInput(editorInput); |
84 |
| - if (filePath != null) { |
85 |
| - return filePath.toOSString(); |
| 79 | + IWorkbench wb = PlatformUI.getWorkbench(); |
| 80 | + if (wb != null) |
| 81 | + { |
| 82 | + IWorkbenchWindow window = wb.getActiveWorkbenchWindow(); |
| 83 | + if (window != null) |
| 84 | + { |
| 85 | + IWorkbenchPage page = window.getActivePage(); |
| 86 | + if (page != null) { |
| 87 | + IEditorPart activeEditor = page.getActiveEditor(); |
| 88 | + if (activeEditor != null) { |
| 89 | + IEditorInput editorInput = activeEditor.getEditorInput(); |
| 90 | + if (editorInput != null) { |
| 91 | + IPath filePath = getSourceFilePathFromEditorInput(editorInput); |
| 92 | + if (filePath != null) { |
| 93 | + return filePath.toOSString(); |
| 94 | + } |
| 95 | + } |
86 | 96 | }
|
87 | 97 | }
|
88 | 98 | }
|
|
0 commit comments