如何以编程方式更改包资源管理器中的选择

编程入门 行业动态 更新时间:2024-10-27 16:28:21
本文介绍了如何以编程方式更改包资源管理器中的选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在开发一个eclipse的插件,用于分析Eclipse Workspace中项目之间的依赖关系和引用,并以类似UML的方式将其显示在自己的View中。

为了增加我的插件的有用性,我希望通过允许用户在软件包资源管理器中打开一个项目,并在编辑器中打开它,在图表上添加交互性。

但是,我的问题是,虽然我知道如何从包资源管理器获取给定的选择,但我无法找到一种方法来更改选择或只是在包中打开一个项目有没有人可以解决这个问题?

解决方案

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.

更多推荐

如何以编程方式更改包资源管理器中的选择

本文发布于:2023-11-03 19:54:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555940.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:资源管理   器中   方式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!