[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Hiding (closing) a view

We have several perspectives in our RCP app. One of the perspectives has a view that is always displayed (the parent) and can have several other views displayed (children). We want to close these child views whenever the user switches to another perspective. The way we found to implement this was for the parent view to listen for perspectiveActivated events and to tell the children to close using a mechanism we had in place for closing the children via a "close all" button in the perspective. The children close by executing:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(this);

This worked great for our "close all" button. Initially, this did not work for perspectiveActivated because by the time the perspective got the activated event (telling it that it was no longer active), the hideView would fail because the underlying code will only hide a view for the active perspective - the view we were trying to hide would not be found. We solved this by closing the views the next time the perspective became activated - a little backwards but serviceable.

For those of you who have stuck with me through this long discourse, I have some questions:

1. Is there a better way for a view to hide itself than
   PlatformUI...hideView?
2. Can you hide views that are not in the current perspective?
   If not, does anyone know why?

Thanks in advance for your responses,
Mike Higginbotham