|
3 | 3 | import java.io.IOException; |
4 | 4 | import java.io.OutputStream; |
5 | 5 |
|
| 6 | +import org.eclipse.jface.dialogs.MessageDialog; |
| 7 | +import org.eclipse.jface.preference.PreferenceDialog; |
6 | 8 | import org.eclipse.swt.SWT; |
7 | 9 | import org.eclipse.swt.widgets.Display; |
| 10 | +import org.eclipse.swt.widgets.Shell; |
8 | 11 | import org.eclipse.ui.IWorkbenchPage; |
| 12 | +import org.eclipse.ui.IWorkbenchWindow; |
9 | 13 | import org.eclipse.ui.PartInitException; |
10 | 14 | import org.eclipse.ui.PlatformUI; |
11 | 15 | import org.eclipse.ui.console.ConsolePlugin; |
|
15 | 19 | import org.eclipse.ui.console.IConsoleView; |
16 | 20 | import org.eclipse.ui.console.MessageConsole; |
17 | 21 | import org.eclipse.ui.console.MessageConsoleStream; |
| 22 | +import org.eclipse.ui.dialogs.PreferencesUtil; |
| 23 | + |
| 24 | +import com.googlecode.cppcheclipse.core.CppcheclipsePlugin; |
| 25 | +import com.googlecode.cppcheclipse.ui.preferences.BinaryPathPreferencePage; |
18 | 26 |
|
19 | 27 | /** |
20 | 28 | * Wrapper around a console window, which can output an existing InputSteam. |
@@ -111,11 +119,30 @@ public void println(String line) throws IOException { |
111 | 119 | * |
112 | 120 | * @see com.googlecode.cppcheclipse.command.IConsole#show() |
113 | 121 | */ |
114 | | - public void show() throws PartInitException { |
115 | | - IWorkbenchPage page = PlatformUI.getWorkbench() |
116 | | - .getActiveWorkbenchWindow().getActivePage(); |
117 | | - String id = IConsoleConstants.ID_CONSOLE_VIEW; |
118 | | - IConsoleView view = (IConsoleView) page.showView(id); |
119 | | - view.display(messageConsole); |
| 122 | + public void show() { |
| 123 | + |
| 124 | + Runnable runnable = new Runnable() { |
| 125 | + public void run() { |
| 126 | + // this should only be called from GUI thread |
| 127 | + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
| 128 | + if (window == null) { |
| 129 | + CppcheclipsePlugin.logError("Could not show console because there is no active workbench window"); |
| 130 | + return; |
| 131 | + } |
| 132 | + IWorkbenchPage page = window.getActivePage(); |
| 133 | + if (page == null) { |
| 134 | + CppcheclipsePlugin.logError("Could not show console because there is no active page"); |
| 135 | + return; |
| 136 | + } |
| 137 | + try { |
| 138 | + IConsoleView view = (IConsoleView) page.showView(IConsoleConstants.ID_CONSOLE_VIEW); |
| 139 | + view.display(messageConsole); |
| 140 | + } catch (PartInitException e) { |
| 141 | + CppcheclipsePlugin.logError("Could not show console", e); |
| 142 | + } |
| 143 | + |
| 144 | + } |
| 145 | + }; |
| 146 | + Display.getDefault().asyncExec(runnable); |
120 | 147 | } |
121 | 148 | } |
0 commit comments