RCP: getActiveWorkbenchWindow() returns null
来源:互联网 发布:mac不能调节音量 编辑:程序博客网 时间:2024/06/10 11:05
RCP: getActiveWorkbenchWindow() returns null
Winzard结束后,想要打开一个editor,不过 getActiveWorkbenchWindow() returns null
问题及解决如下:
原因:
getActiveWorkbenchWindow()
null can be returned for the active workbench window if:
there is a non-workbench window active (modal dialog)
you are not in a "UI thread". You will need to investigate
Display.asyncExec and Display.syncExec
--------------------------------------------------------------------------------
In my wizard page I ve the following code to open a diagram when the wizard process is ended :
private void openEditor(IFile file) {
try {
IWorkbenchWindow dwindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = dwindow.getActivePage();
if (page != null) {
IDE.openEditor(page, file, true);
}
} catch (PartInitException pie) {
Logger.error("Unable to open the Editor", pie);//$NON-NLS-1$
throw new PageException("Unable to open the Editor", pie);
}
}
but when I execute it I got a null pointer exception while I'm trying to call workbench.getActiveWorkbenchWindow(); the workbench is not null and don't know why it's append
-------------------------------------------------------------------------------
Finaly solved by using
private void openEditor(IFile file) {
final IFile aFile = file;
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
IWorkbenchWindow dwindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = dwindow.getActivePage();
if (page != null) {
try {
IDE.openEditor(page, aFile, true);
}catch (PartInitException pie) {
Logger.error("Unable to open the Editor", pie);//$NON-NLS-1$
throw new PageException("Unable to open the Editor", pie);
}
}
}
});
}
- RCP: getActiveWorkbenchWindow() returns null
- getActiveWorkbenchWindow() return null 解决办法
- getActiveWorkbenchWindow() return null 解决办法
- CFReadStreamCopyProperty() returns NULL?
- geoCoder.getFromLocationName returns null
- getActionBar() returns null
- getResourceAsStream returns null
- getContentResolver().insert returns null
- DocumentBuilder.parse() returns [#Document: null]
- Oracle returns NULL after join
- BrowserManager Returns null - Flex 4.5
- BitMapFactory.decodeFile always returns null.
- [Android-Tips] findviewbyid function returns null
- Type.GetType(string typeName) returns null !?
- cvCaptureFromCam is working but cvQueryFrame returns NULL
- [BIRT报表]Platform.createFactoryObject returns null
- Android 设置铃声,getContentResolver().insert returns null
- Android 设置铃声,getContentResolver().insert returns null
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解(转载)
- leetcode第一刷_Search Insert Position
- 消费电子行业进入“自由连接”时代
- Android的Fragment左右滑动
- chrome和IE不能访问外网的解决办法
- RCP: getActiveWorkbenchWindow() returns null
- 关于学习Hadoop中未总结的资料
- C++中CallBack类的使用方法
- 日前,王珞丹(微博)(微信号:Iamwangluodan )在
- 转]udev实现原理(含检测U盘拔插例子)
- IT精神打造传统服务业
- shell脚本练手4道题
- 关于学习方法(转载)
- ScrollView的阻尼回弹效果实现(仿qq空间)