I am working on a multi page editor that loads opens multiple files (e.g. java, html) in separate tabs of a multi page editor. The files get opened with the default editors associated with the file type and these default editors are embedded in the multi page editor as tabs.
Here is how I am determining which editor to load (for a file type):
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");
}
The multi tab editor gets created without any problems and the correct editors are loaded within the tabs.
But the ‘Mark Occurrences’ functionality is not working in the Java Editor when loaded in a tab.
I validated that mark occurrences is turned on. When I select a variable in the java editor in my multi page editor tab it does not highlight the other occurrences of the variable. But if I open the file in my multi tab editor and in a separate java editor at the same time and select a variable in the separate java editor it will highlight the other occurrences in the separate java editor as well as the java editor that is embedded in my multi page editor. So the functionality seems to be enabled and loaded, it just does not execute the mark occurrences functionality when the selecting happens in the embedded editor.
What needs to be changed so that I can use the mark occurrences functionality from within the java editor that is embedded in my multi tab editor?
My understanding is that Mark Occurences is a central service so I assume I am missing the part that updates this service when something gets selected in my editor. Any idea on what needs to be done so the service gets updated?
Note: This problem only happens if the java editor is embedded in a multi page editor.