首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jface TreeViewer setSelection

Jface TreeViewer setSelection
EN

Stack Overflow用户
提问于 2011-12-23 18:21:09
回答 1查看 2.7K关注 0票数 2

当匹配的编辑器被激活时,我正在尝试选择一个树节点。

代码如下:

代码语言:javascript
复制
private void selectNodeInTree(IEditorPart activatedEditor) {
   IEditorInput input = activatedEditor.getEditorInput();
   StructuredSelection selection = new StructuredSelection(input); //Selection is not null!

   treeViewer.setSelection(selection, true); 
}

但是没有选择任何内容,我遗漏了什么?

EN

回答 1

Stack Overflow用户

发布于 2011-12-24 17:54:15

显而易见的答案是input不在您的树中。也许您的树中有文件,并且您想要执行以下操作:

代码语言:javascript
复制
IFile file = (IFile) input.getAdapter(IFile.class);
StructuredSelection selection = new StructuredSelection(file);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8614868

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档