在我的 Eclipse 插件中,我有以下代码:
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;
}
}
在这里,我正在处理来自 的文本选择事件,即将CompareEditorInput
文件的两个远程版本与 subclipse 进行比较的结果。
现在我想正确处理文本选择。为此,我必须知道它是在左侧编辑器内还是在右侧编辑器内选择一些文本。
我怎样才能知道呢?
编辑 2010-04-10:
的具体实例CompareEditorInput
是org.tigris.subversion.subclipse.ui.compare.SVNCompareEditorInput
。