1
我正在尝试制作工具栏按钮,以便在我的RCP应用上使用另一个编辑器打开一个文件!WorkbenchPage.openEditor()什么都不做
我都去下面的代码:
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
我做错了什么?
我下面this建议做我的按钮
对不起我的英语 问候
吧!已经做到了,但仍然这样做。:( –
所以只是为了阐明:你应该在你的plugin.xml中定义一个单一标识符id(例如“designeditor”),你的plugin.xml和/或manifest.MF应该为你的插件声明一个plugin-id(例如“org.myorg.tooling”),你在API调用中指定的编辑器id是两者的连接(在那里有一段时间),对吧? –
right!my editor id是“** DesignEditor **”,而我的插件ID是“** IntergridPlugin.integridPlugin **”,当我打电话时,我打电话给“** IntergridPlugin.integridPlugin.DesignEditor **。 –