Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Hiding a ViewPart instead of closing
icon5.gif  Hiding a ViewPart instead of closing [message #841306] Wed, 11 April 2012 06:25 Go to next message
Kornel Muhi is currently offline Kornel MuhiFriend
Messages: 1
Registered: February 2012
Junior Member
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 16:20]

Report message to a moderator

Re: Hiding a ViewPart [message #855068 is a reply to message #841306] Tue, 24 April 2012 13:47 Go to previous messageGo to next message
Greg Pugh is currently offline Greg PughFriend
Messages: 15
Registered: July 2009
Junior Member
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 14:16 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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


Previous Topic:Proposal for refresh behavior in Project Explorer
Next Topic:eclipse Views that are dragged outside not display on perspective switching
Goto Forum:
  


Current Time: Fri Apr 26 14:55:09 GMT 2024

Powered by FUDForum. Page generated in 0.03353 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top