Open Editor at Start in an EclipseRCP application

我只是一个虾纸丫 提交于 2019-12-11 10:51:32

问题


I'm currently programming on an eclipse RCP application in Java for an university project.

My problem is that I want an editor loaded at application start, but I don't know which method is the right one to start with. In the perspective I can only add views and set my editor space, but I can't set any editors.

I tried overwrite the WorkbenchWindowAdvisor.postWindowOpen() method, but this only got me an exception...


回答1:


You say you got an exception.. what was it? How did you overwrite postWindowOpen(), can you post your code? I could help you more if I knew these things.

Anyway, the following code opens the editor at application startup:

@Override
public void postWindowOpen() {

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

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

where "editorInput" is the input of your editor and "editorId" it's ID.
Also, I highly recommend reading Lars Vogel's tutorial on editors:
http://www.vogella.de/articles/EclipseEditors/article.html



来源:https://stackoverflow.com/questions/5822261/open-editor-at-start-in-an-eclipsercp-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!