我正在开发一个多页编辑器,它可以在多页编辑器的不同选项卡中加载打开多个文件(例如java、html)。文件将使用与文件类型关联的默认编辑器打开,这些默认编辑器作为选项卡嵌入到多页编辑器中。
以下是我如何决定加载哪个编辑器(对于文件类型):
void createPage() throws PartInitException
{
// get editor registry
IEditorRegistry editorRegistry = Activator.getDefault().getWorkbench().getEditorRegistry();
// loop through mappings until the extension matches.
IEditorDescriptor editorDescriptor = editorRegistry.getDefaultEditor(((IFileEditorInput)getEditorInput()).getFile().getName());
// if no editor was found that is associated to the file extension
if (editorDescriptor == null)
{
IEditorRegistry registry = Activator.getDefault().getWorkbench().getEditorRegistry();
editorDescriptor = registry.findEditor(EditorsUI.DEFAULT_TEXT_EDITOR_ID);
}
IConfigurationElement configuration = ((EditorDescriptor) editorDescriptor).getConfigurationElement();
String className = configuration.getAttribute("class");
IEditorPart editor;
try
{
editor = (IEditorPart) WorkbenchPlugin.createExtension(configuration, "class");
} catch (CoreException e) {
throw new RuntimeException(e);
}
final int index = addPage(editor, getEditorInput());
setPageText(index, "TAB_NAME");
}
但是,当加载到选项卡中时,标记出现功能在Java编辑器中不起作用。
但是,如果我同时在多选项卡编辑器和单独的java编辑器中打开文件,并在单独的java编辑器中选择一个变量,则会突出显示单独java编辑器中的其他事件以及嵌入在多页编辑器中的java编辑器。
因此,该功能似乎已启用并加载,只是在嵌入式编辑器中选择时不执行标记引用功能。
需要做些什么更改,以便我可以从嵌入在多选项卡编辑器中的java编辑器中使用标记事件功能?
我的理解是,markoccurrences是一个中心服务,所以我假设我丢失了在编辑器中选择了某个内容时更新此服务的部分。你知道该怎么做才能更新服务吗?
注意:只有在java编辑器嵌入到多页编辑器中时才会出现此问题。