How to identify the source of a text selection event coming from a CompareEditorInput in eclipse?

Posted by tangens on Stack Overflow See other posts from Stack Overflow or by tangens
Published on 2010-03-23T21:53:39Z Indexed on 2010/04/10 7:33 UTC
Read the original article Hit count: 355

In my eclipse plugin I have the following code:

public class MyHandler extends AbstractHandler {
    @Override
    public Object execute( ExecutionEvent event ) throws ExecutionException {
        ISelection sel = HandlerUtil
            .getActiveWorkbenchWindowChecked( event )
            .getSelectionService()
            .getSelection();

        if( sel instanceof TextSelection ) {
            IEditorPart activeEditor = PlatformUI
                    .getWorkbench()
                    .getActiveWorkbenchWindow()
                    .getActivePage()
                    .getActiveEditor();
            IEditorInput editorInput = activeEditor.getEditorInput();

            if( editorInput instanceof CompareEditorInput ) {
                // here are two possible sources of the text selection, the
                // left or the right side of the compare editor.

                // How can I find out, which side it is from?
            }
        }
        return null;
    }
}

Here I'm handling a text selection event coming from an CompareEditorInput, i.e. the result of comparing two remote revisions of a file with subclipse.

Now I want to handle the text selection properly. For that I have to know if it selects some text inside the left side editor or inside the right side editor.

How can I find that out?

© Stack Overflow or respective owner

Related posts about eclipse-pde

Related posts about subclipse