如何以编程方式更改包资源管理器中的选择 [英] How to programmatically change the selection within package explorer
问题描述
为了增加我的插件的有用性,我希望通过允许用户在软件包资源管理器中打开一个项目,并在编辑器中打开它,在图表上添加交互性。
但是,我的问题是,虽然我知道如何从包资源管理器获取给定的选择,但我无法找到一种方法来更改选择或只是在包中打开一个项目有没有人可以解决这个问题?
p>我找到了解决方案。 Eclipse确实提供了直接访问
org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart
中的软件包浏览器,但不鼓励。 import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart;
...
PackageExplorerPart part = PackageExplorerPart.getFromActivePerspective();
在资源管理器中选择的任何IResource * /;
part.selectAndReveal(resource);
这将突出显示IResource 资源
必要时展开树。
I am currently developing a plugin for eclipse that analyzes dependencies and references between projects within the Eclipse Workspace and displays them in its own View in a UML-like diagram.
To increase the usefulness of my plugin, I wish to add interactivity to the diagram by allowing users to open a project in the package explorer and if applicable open it in an editor by clicking on the graph displayed.
However, my problem is that while I know how to obtain a given selection from the package explorer, I have not been able to find a way to change the selection or simply open up a project in the package explorer programmatically.
Does anyone have a solution for this problem?
I have found the solution. Eclipse does offer direct access to the package explorer in org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart
, but it is discouraged.
import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart;
...
PackageExplorerPart part= PackageExplorerPart.getFromActivePerspective();
IResource resource = /*any IResource to be selected in the explorer*/;
part.selectAndReveal(resource);
This will highlight whatever IResource resource
is and expand the tree as necessary.
这篇关于如何以编程方式更改包资源管理器中的选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!