WorkbenchPage.openEditor()什么也不做 [英] WorkbenchPage.openEditor() does nothing

查看:306
本文介绍了WorkbenchPage.openEditor()什么也不做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用工具栏按钮在另一个编辑器上打开我的 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)>>>> DesignEditor p>

我做错了什么?



我追踪这个建议做我的按钮



抱歉我的英文
尊敬

解决方案

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


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

解决方案

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

这篇关于WorkbenchPage.openEditor()什么也不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆