如何解决PDEJava插件开发
| 我正在运行execute方法,但是在以下代码中,我在logError上给出了一些错误。请帮忙!public Object execute(ExecutionEvent event) throws ExecutionException {
//get the active window
IWorkbenchWindow window=HandlerUtil.getActiveWorkbenchWindowChecked(event);
if(window==null)
return null;
//get the active page
IWorkbenchPage page= window.getActivePage();
if(page==null)
return null;
//open and activate the Favorite view
try{
page.showView(ViewPart.ID);
}
catch(PartInitException e){
FavoritesLog.logError(\"Failed to open the favorites view\",e);
}
return null;
}
解决方法
不确定到底出现了什么错误,但是您应该尝试将执行代码的内部包装在UIJob中。
像这样:
public Object execute(final ExecutionEvent event) throws ExecutionException { //get the active window
Job job = new UIJob(\"Show View\") {
public IStatus runInUIThread(IProgressMonitor monitor) {
IWorkbenchWindow window=HandlerUtil.getActiveWorkbenchWindowChecked(event);
if(window==null) {
return Status.CANCEL_STATUS;
}
//get the active page
IWorkbenchPage page = window.getActivePage();
if(page==null) {
return return Status.CANCEL_STATUS;
}
//open and activate the Favorite view
try{
page.showView(ViewPart.ID);
} catch(PartInitException e){
FavoritesLog.logError(\"Failed to open the favorites view\",e);
return return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
};
job.schedule();
return null;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。