首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PDE(java插件开发)

PDE(java插件开发)
EN

Stack Overflow用户
提问于 2011-05-26 22:31:30
回答 1查看 102关注 0票数 0

我正在运行execute方法,但是在下面的代码中给出了一些关于logError的错误。请帮帮我!

代码语言:javascript
复制
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;
    }
EN

回答 1

Stack Overflow用户

发布于 2011-05-26 23:44:35

我不确定您得到的是什么错误,但是您应该尝试将执行代码的内部包装在一个UIJob中。如下所示:

代码语言:javascript
复制
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;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6140279

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档