Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 17:32 Go to next message
Rashmy A is currently offline Rashmy AFriend
Messages: 149
Registered: July 2009
Senior Member
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 );


[Updated on: Fri, 22 July 2011 17:32]

Report message to a moderator

Re: Closing a view that is not in active Perspective [message #704845 is a reply to message #700003] Fri, 29 July 2011 06:09 Go to previous message
Yu  is currently offline Yu Friend
Messages: 1
Registered: July 2011
Junior Member

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

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: Sun Dec 05 21:31:49 GMT 2021

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

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

Back to the top