Eclipse PDE(java插件开发)
我正在运行execute方法,但是我在下面的代码中给出了一些关于logError的错误。请帮忙Eclipse PDE(java插件开发),eclipse,plugins,Eclipse,Plugins,我正在运行execute方法,但是我在下面的代码中给出了一些关于logError的错误。请帮忙 public Object execute(ExecutionEvent event) throws ExecutionException { //get the active window IWorkbenchWindow window=HandlerUtil.getActiveWorkbenchWindowChecked(event); if(win
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;
}
请编辑您的问题以包含您得到的异常。