2011-04-28 53 views
1

我目前正在为大学项目编写Java的eclipse RCP应用程序。在EclipseRCP应用程序的开始处打开编辑器

我的问题是我想在应用程序启动时加载一个编辑器,但我不知道哪一种方法是正确的。从视角来看,我只能添加视图并设置编辑空间,但我无法设置任何编辑器。

我试图覆盖WorkbenchWindowAdvisor.postWindowOpen()方法,但这只是让我异常...

回答

4

你说你有一个异常..是什么呢?你是如何覆盖postWindowOpen()的,你可以发布你的代码吗?如果我知道这些事情,我可以帮助你更多。

不管怎样,下面的代码打开应用程序启动时编辑:

@Override 
public void postWindowOpen() { 

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); 

    try { 
     page.openEditor(editorInput, editorId); 
    } catch (PartInitException e) { 
     // Handle the exception here 
    } 
} 

其中“editorInput”是你的编辑器和输入“editorId”它的ID。
另外,我强烈建议在编辑阅读拉斯沃格尔的教程:
http://www.vogella.de/articles/EclipseEditors/article.html

+0

好,谢谢,已经得到它。我认为missunderstood了一些与editorinput的东西;-) – Pro90 2011-04-28 22:54:24

相关问题