如何在Eclipse中关闭ViewPart? [英] How to close a ViewPart in Eclipse?

查看:443
本文介绍了如何在Eclipse中关闭ViewPart?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中有一个视图(由一个扩展 org.eclipse.ui.part.ViewPart 的类实现),我需要关闭它。我的意思是完全接近,不只是隐藏。我想要一个新的ViewPart实例创建时,用户(或我的代码)要求再次打开视图。



我找到的唯一方法是 IWorkbenchPage.hideView 隐藏视图,但不完全处理它。在视图中调用处理也没有影响。



BTW,我的观点被定义为 allowMultiple =false但是我尝试使用



任何帮助将不胜感激。

解决方案

我最终发现问题。如果视图在多个角度打开,则将其隐藏在一个视角上将不会关闭。可以遍历所有打开的透视图并查找视图。隐藏它在所有的角度将关闭它。


I have a view in Eclipse (implemented by a class which extends org.eclipse.ui.part.ViewPart) which I need to close. I mean completely close, not just hide. I want a new ViewPart instance to be created when the user (or my code) asks to open the view again.

The only method I found was IWorkbenchPage.hideView which hides the view, but does not completely dispose of it. Invoking dispose on the view has no affect, either.

BTW, my view is defined as allowMultiple="false" but I tried with true and that didn't make any difference.

Any help will be appreciated.

解决方案

I found the problem eventually. If the view is open on more than one perspective, hiding it on one perspective will not close it. It is possible to iterate over all the open perspective and look for the view. Hiding it on all perspectives will close it.

这篇关于如何在Eclipse中关闭ViewPart?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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