Hiding a ViewPart instead of closing [message #841306] |
Wed, 11 April 2012 02:25  |
Eclipse User |
|
|
|
Hello!
I have a ViewPart, and it is important for me to keep it's contents if the user "closes it" and opens it up again in the same Eclipse session. But when you click on the upper-right X it closes the view and disposes it's contents - also, recreating the whole contents is not really an option because there would be several ways how the user can get this window - through different operations - and, in general, if he makes no change, just opens it up again, it would be unnecessary to recreate the very same contents instead of just showing it.
Since I have not found anything usable regarding how to hide a viewpart instead of closing it, I would like to ask you if someone was able to do this?
I've read a solution where someone disabled the closing of a view by implementing ISaveablePart2, but this prevents closing of Eclipse too (since it tries to close this ViewPart but fails) - so this way I need to listen somehow to the Eclipse closing event, to re-enable the closeable property of this ViewPart.
Also, the IWorkbenchPage hideView() method is also useless in this case, because instead of hiding it it actually disposes the view.
Any ideas?
[Updated on: Wed, 11 April 2012 12:20] by Moderator
|
|
|
Re: Hiding a ViewPart [message #855068 is a reply to message #841306] |
Tue, 24 April 2012 09:47   |
Eclipse User |
|
|
|
On 11/04/2012 07:25, Kornel Muhi wrote:
> Hello!
>
> I have a ViewPart, which is important for me to keep it's contents if the user "closes it", and opens it up again in the same Eclipse session. But
> when you click on the upper-right X it closes the view and disposes it's contents - also, recreating the whole contents is not really an option
> because there would be several ways how the user can get this window - through different operations - and, in general, if he makes no change, just
> opens it up again, it would be unnecessary to recreate the very same contents instead of just showing it.
>
> Since I have not found anything usable regarding how to hide a viewpart instead of closing it, I would like to ask you if someone was able to do this?
>
> I've read a solution where someone disabled the closing of a view by implementing ISaveablePart2, but this prevents closing of Eclipse too (since it
> tries to close this ViewPart but fails) - so this way I need to listen somehow to the Eclipse closing event, to re-enable the closeable property of
> this ViewPart.
>
> Also, the IWorkbenchPage hideView() method is also useless in this case, because instead of hiding it it actually disposes the view.
>
> Any ideas?
If you use a Perspective then you can stop the view from being closed using IViewLayout.setCloseable(false)
|
|
|
Re: Hiding a ViewPart [message #855098 is a reply to message #855068] |
Tue, 24 April 2012 10:16  |
Eclipse User |
|
|
|
Hiding a view will hide it in that perspective. If it wasn't open in any other perspective, it closes that part.
If you have calculated state that you would like to maintain within one session while your view is closed, the most common pattern is to provide some kind of manager in your plugin activator that can hold calculated data for that view (basically decouple the calculated state from the view that displays it). There can be one view per WorkbenchWindow, so depending on what kind of data you display you might have to handle multiple instances of your calculated data.
PW
|
|
|
Powered by
FUDForum. Page generated in 0.09041 seconds