如何选择一个树状视图节点,如点击鼠标来更新属性视图 [英] How to select a treeview node like a click of mouse to update properties view

查看:372
本文介绍了如何选择一个树状视图节点,如点击鼠标来更新属性视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Eclipse插件中有一个自定义大纲,使用类 TreeViewer 实现,我使用以下代码创建了这个大纲:

  public class MyOutlinePage extends ContentOutlinePage 
(...)
Object [] data =(...)
TreeViewer treeViewer = getTreeViewer();
treeViewer.setInput(data);

设置输入后,我需要在大纲中选择一个特定的元素。
例如,我需要在大纲中选择元素 data [2]



Im尝试使用此代码来选择大纲的引用:

  treeViewer.setSelection(new StructuredSelection(data [2])); 

如果我使用鼠标选择轮廓项,则选中轮廓,并更新属性视图 。大纲项目选择如下所示:





但是,如果我使用方法 setSelection 选择大纲项,则属性视图未更新并选择大纲项,如下所示:





我需要使用代码选择大纲项,此选择必须像鼠标点击一样更新属性视图。

解决方案

灰色高亮显示大纲视图不是活动部分。 属性视图始终显示活动零件的值。



您可以使用以下功能激活大纲视图:

  IWorkbenchPage page = PlatformUI.getWorkbench()getActiveWorkbenchWindow()getActivePage()。; 

page.showView(IPageLayout.ID_OUTLINE,null,IWorkbenchPage.VIEW_ACTIVATE);

但请注意,这将使焦点远离当前活动的任何部分。


I have a custom outline in my Eclipse plug-in, implemented using class TreeViewer and I created this outline using this code:

public class MyOutlinePage extends ContentOutlinePage
(...)
            Object[] data = (...)
            TreeViewer treeViewer = getTreeViewer();
            treeViewer.setInput(data);

After set input I need to select one specific element in outline. For example, I need to select the element data[2] in the outline.

Im trying to use this code to select the emelent of outline:

treeViewer.setSelection(new StructuredSelection(data[2]));

If I select the outline item using mouse, the outline was selected and the "Properties Views" was updated. The outline item is selected as shown:

But If I select the outline item using the method setSelection the "Properties Views" was NOT updated and the outline item is selected as shown:

I need to select outline item using code and this selection must update the "Properties View" like the click of mouse does.

解决方案

The gray highlight shows that the outline view is not the active part. The Properties view always shows values from the active part.

You can activate the Outline view with:

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

page.showView(IPageLayout.ID_OUTLINE, null, IWorkbenchPage.VIEW_ACTIVATE);

but note that this will move focus away from whatever part is currently active.

这篇关于如何选择一个树状视图节点,如点击鼠标来更新属性视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆