如何识别来自 Eclipse 中 CompareEditorInput 的文本选择事件的来源?
在我的 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
。
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?
EDIT 2010-04-10:
The concrete instance of CompareEditorInput
is org.tigris.subversion.subclipse.ui.compare.SVNCompareEditorInput
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是:
org.eclipse.compare.CompareEditorInput
(其具有 java 源代码)是一个抽象类,它并不总是“左”或“右”窗格:问题是:你知道它的确切实现类型吗?这个CompareEditorInput 对象?
即:看看具体类如何处理选择很有趣:
org.eclipse.compare.internal。 ResourceCompareInput
例如处理 < code>org.eclipse.jface.viewers.IStructuredSelection,并附带 根据选择获取左右IResource
的实用函数。The issue is:
org.eclipse.compare.CompareEditorInput
(which have its java sources here) is an abstract class which has not always "left" or "right" pane:The question is: do you know the exact implementation type of this
CompareEditorInput
object?I.e: It is interesting to see how concrete classes deal with selection:
The
org.eclipse.compare.internal.ResourceCompareInput
for instance deals withorg.eclipse.jface.viewers.IStructuredSelection
, and comes with an utility function to get left and rightIResource
based on the selection.