私の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
ここでは、ファイルの 2 つのリモート リビジョンをサブクリップと比較した結果であるからのテキスト選択イベントを処理しています。
ここで、テキストの選択を適切に処理したいと思います。そのためには、左側のエディターまたは右側のエディター内のテキストを選択するかどうかを知る必要があります。
どうすればそれを見つけることができますか?
編集 2010-04-10:
の具体的なインスタンスはCompareEditorInput
ですorg.tigris.subversion.subclipse.ui.compare.SVNCompareEditorInput
。