随笔-112  评论-73  文章-0  trackbacks-0
在Eclipse RCP 开发中从菜单中打开Editor 的方法如下:

public class OpenEditorHander extends AbstractHandler implements IHandler {

    @Override
    
public Object execute(ExecutionEvent event) throws ExecutionException {
        
// HandlerUtil.getActiveWorkbenchWindow(event).close();
        IEditorInput editorInput = new DBConfigEditInput();
        IWorkbenchPage workbenchPage 
= PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow().getActivePage();
        IEditorPart editorPart 
=workbenchPage.findEditor(editorInput);
        
try {
            workbenchPage.openEditor(editorInput, 
"sm.core.ui.DBConfig");
        } 
catch (PartInitException e) {
            e.printStackTrace();
        }
        
return null;
    }
}



posted on 2009-02-07 19:35 Libo 阅读(1959) 评论(4)  编辑  收藏 所属分类: Eclipse RCP

评论:
# re: Eclipse RCP 从菜单打开Editor 2009-02-10 23:40 | 与你同飞
多谢分享  回复  更多评论
  
# re: Eclipse RCP 从菜单打开Editor 2009-06-08 09:16 | ccat
sm.core.ui.DBConfig
这个ID要事先写在plugin.xml中吧?  回复  更多评论
  
# re: Eclipse RCP 从菜单打开Editor[未登录] 2009-06-09 08:40 | Libo
@ccat
是的。这个是Editor的ID,在plugin.xml中配置.  回复  更多评论
  
# re: Eclipse RCP 从菜单打开Editor 2009-09-08 22:38 | endswel
那如何像eclipse project explorer
那样点击左边的树
可以在右边显示editor呢
你这样可以实现,
但是如果我想打开editor1,editor2
但现在我想回到editor1怎么办?  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: