Eclipse RCP 通过 ID 获取元素

发布于 2024-09-13 10:36:30 字数 348 浏览 1 评论 0原文

我还不太了解 RCP,但我已经阅读了很多文档。我不知道我的问题是否有意义;如果没有,我深表歉意,并请求您尝试理解我的意思并给出某种答案。

我有一个树视图元素,上面有一个双击侦听器。在窗口的另一部分有一个布局文件夹,其中包含应该是双击项目的检查器的视图。

我知道让另一个检查器出现的唯一方法是:

getActivePage().showView(Inspector.ID). 

showView() 没有提供任何将额外信息传递给视图的机会,因此它可以知道要检查哪个元素吗?

不同方向的指针表示赞赏。沃格尔教程好像没有讲这个,或者说我没看懂。

I don't know RCP very well yet, but I've been reading a lot of the docs. I don't know if my question makes sense; I apologize if not and beg that you try to work out what I mean and come up with some kind of answer.

I have a tree view element, which has a double click listener on it. In another part of the window there is a layout folder which contains views that are supposed to be inspectors for the items double-clicked on.

The only way I know to make another inspector appear is:

getActivePage().showView(Inspector.ID). 

showView() doesn't give any opportunity to pass extra information to the view, so can it know which element to inspect?

Pointers in different directions appreciated. The Vogel tutorial doesn't seem to cover this, or I don't understand it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

话少情深 2024-09-20 10:36:30

您可以检查文章是否链接到编辑器可以在这里为您提供帮助。
也就是说,不要尝试访问正确的视图,而是为编辑器定义一个侦听器:

private IPartListener2 partListener2 = new IPartListener2() {
  public void partActivated(IWorkbenchPartReference ref) {
    if (ref.getPart(true) instanceof IEditorPart)
      editorActivated(getViewSite().getPage().getActiveEditor());
}

这样,您可以返回正确的编辑器,并要求该编辑器进行视图相应更新所需的一切。

You could check if the article "Link to Editor" can help you here.
That is, instead of trying to access the right view, define a Listener for the Editors:

private IPartListener2 partListener2 = new IPartListener2() {
  public void partActivated(IWorkbenchPartReference ref) {
    if (ref.getPart(true) instanceof IEditorPart)
      editorActivated(getViewSite().getPage().getActiveEditor());
}

That way, you can get back the right Editor, and ask that Editor all you need for your View to update accordingly.

南汐寒笙箫 2024-09-20 10:36:30

您可以使用选择服务。 Inspector 视图应该注册为 SelectionListener。具有树的另一个视图应该注册一个 SelectionProvider。该视图应该侦听树中的双击,然后更新选择

You can use the SelectionService. The Inspector view should register as a SelectionListener. And the other view with the tree should register a SelectionProvider. This view should listen for the double click in the tree and then update the selection

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文