Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Closing a view that is not in active Perspective
Closing a view that is not in active Perspective [message #700003] Fri, 22 July 2011 13:32 Go to next message
Eclipse UserFriend
Hello,
There is a need for me to close a View that might be open in a perspective that is no currently active. How can I achieve this?

I tried to implement IPerspectiveListener in which I check if the perspective being activated is the open I'm interested in and try to close it.

It works as long as my view is also active. If I want to close views that are not hidden or deactivated then I cannot do it.

Any suggestions on how I can achieve this?
This is the code that used:
if( perspective.getId().equals( MyPerspective.ID ) )
IViewReference[] viewRefs = page.getViewReferences( MyrView.VIEW_ID );
if( viewRefs != null )
for( IViewReference vr : viewRefs )
IViewPart vp = vr.getView( false ); -> vp is null if the view is not active
if( vp instanceof MyrView )
if( ( (MyView) vp ).getToBeClosed() )
page.hideView( vp );


Thanks!

[Updated on: Fri, 22 July 2011 13:32] by Moderator

Re: Closing a view that is not in active Perspective [message #704845 is a reply to message #700003] Fri, 29 July 2011 02:09 Go to previous message
Eclipse UserFriend

IViewPart[] viewParts = window.getActivePage().getViews();
for (IViewPart view : viewParts)
{
if (view instanceof BaseView)
{
window.getActivePage().hideView(view);
}
}

Let the view you defined extend BaseView, then you can close these views.

Previous Topic:OpenOffice in Eclipse RCP
Next Topic:Dynamic Class Loading
Goto Forum:
  


Current Time: Wed Jul 23 19:44:43 EDT 2025

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

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

Back to the top