Java WorkbenchPage.openEditor()不执行任何操作

Java WorkbenchPage.openEditor()不执行任何操作,java,eclipse,eclipse-plugin,eclipse-rcp,Java,Eclipse,Eclipse Plugin,Eclipse Rcp,我正在尝试使用工具栏按钮在我的RCP应用程序上用另一个编辑器打开一个文件 我有以下代码: IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IEditorPart oldEditor = page.getActiveEditor(); IFile file = ((IFileEditorInput) oldEditor.getEdi

我正在尝试使用工具栏按钮在我的RCP应用程序上用另一个编辑器打开一个文件

我有以下代码:

        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();
    }
但当我叫他行动时,他什么也没做!但也不返回错误

System.out.println()的结果看起来是正确的:

==>>org.eclipse.ui.part.FileEditorInput(/g/Network.int)>>>设计编辑器

我做错了什么

我按照建议按我的按钮

对不起,我的英语不好
关于

id值应该更像一个java包名:org.myorg.tooling.designeditor

id值应该更像一个java包名:org.myorg.tooling.designeditor

,因此需要澄清的是:您应该在plugin.xml中定义一个令牌id(例如“designeditor”)您的plugin.xml和/或manifest.MF应该为您的插件声明一个插件id(例如“org.myorg.tooling”),并且您在API调用中指定的编辑器id是两者的串联(其中有一个句点)。对,对!!我的编辑器id是“DesignEditor”,我的插件id是“IntergridPlugin.integridPlugin”,当我调用时,我调用“IntergridPlugin.integridPlugin.DesignEditor”。我尝试了
page2.openEditor(editorInput,“org.eclipse.ui.DefaultTextEditor”);
,这是一样的。所以我想澄清一下:你应该在plugin.xml中定义一个令牌id(例如,”designeditor”)和plugin.xml和/或manifest.MF应该为插件声明一个插件id(例如“org.myorg.tooling”),并且您在API调用中指定的编辑器id是两者的串联(其中有一个句点)。对吗?对!我的编辑器id是“designeditor”,我的插件id是“IntergridPlugin.integridPlugin”,当我调用时,我调用我试过使用
page2.openEditor(editorInput,“org.eclipse.ui.DefaultTextEditor”),它是一样的。