Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close a ViewPart in Eclipse?

Tags:

eclipse

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.

like image 996
zvikico Avatar asked Feb 03 '23 10:02

zvikico


1 Answers

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.

like image 156
zvikico Avatar answered Feb 06 '23 00:02

zvikico