WorkbenchPage.openEditor() does nothing

。_饼干妹妹 提交于 2019-12-24 08:17:19

问题


I'm trying make a toolbar button to open one file with another editor on my RCP aplication!

I have de following code:

        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorPart oldEditor = page.getActiveEditor();
    IFile file = ((IFileEditorInput) oldEditor.getEditorInput()).getFile();

    IConfigurationElement[] editorsElements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.ui.editors");

    IEditorInput editorInput = new FileEditorInput(file);

    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page2 = window.getActivePage();
    try {
        page2.openEditor(editorInput, editorsElements[3].getAttribute("id"));
        System.out.println("==>>"+editorInput+">>>>"+ editorsElements[3].getAttribute("id"));
    } catch (PartInitException e) {
        e.printStackTrace();
    }

but when i call de action, he did not do anything! but also does not return error..

The result of System.out.println() looks like correct:

==>>org.eclipse.ui.part.FileEditorInput(/g/Network.int)>>>>DesignEditor

what i do wrong?

I following this advice to do my button

Sorry my english Regards


回答1:


The id value should be more like a java package name: org.myorg.tooling.designeditor



来源:https://stackoverflow.com/questions/12863111/workbenchpage-openeditor-does-nothing

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