繁体   English   中英

根据编辑器ID打开Eclipse编辑器

[英]Open eclipse editor based on Editor Id

有什么办法可以让我获得所有可用的编辑器,而不仅仅是窗口中当前打开的编辑器。

请帮忙

编辑器注册表具有许多API,这些API会告诉您有关可用编辑器的信息。

通过以下方式获取注册表:

IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();

您可以使用以下命令找到可用于文件的所有编辑器:

IEditorDescriptor[] editors = registry.getEditors("filename.ext");

或者,您可以找到具有给定ID的编辑器:

IEditorDescriptor editor = registry.findEditor("editor id");

没有什么可以列出注册表已知的每个编辑器。

org.eclipse.ui.ide.IDE类还具有许多获取编辑器描述符和打开编辑器的方法。

要使用特定的编辑器打开文件,请使用:

IDE.openEditor(page, file, "editor id");

其中pageIWorkbenchPagefile是要打开的IFile 这等效于:

page.openEditor(new FileEditorInput(file), "editor id");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM