How to enable "Mark Occurrences" in a Java editor that loads into a multi-page editor?

I am working on a multi-page editor that loads several separate files (e.g. java, html) into separate tabs of a multi-page editor. Files are opened by default by editors associated with the file type, and these editors are, by default, embedded in the multi-page editor as tabs.

This is how I determine which editor to load (for 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-page tab editor is created without any problems and the correct editors are loaded inside the tabs.

But the "Mark Occurrences" function does not work in the Java editor when loading on a tab.

, . java , . java java, java, java, . , , , , , .

, java, ?

, Mark Occurences , , , , - . , , ?

. , java .

+3
1

org.eclipse.jdt.internal.ui.javaeditor.JavaEditor org.eclipse.jdt.ui , . .

. org.eclipse.jdt.internal.ui.javaeditor.ToggleMarkOccurrencesAction JavaEditors ( CompilationUnitEditor, "" ).

PreferenceConstants.EDITOR_MARK_OCCURRENCES PreferenceStore JavaPlugin.

ToggleMarkOccurrencesAction, IEditorActionBarContributor (. Org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditorActionContributor)

0

Source: https://habr.com/ru/post/1756000/


All Articles