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 13:32 Go to next message
Rashmy A is currently offline Rashmy A
Messages: 149
Registered: July 2009
Senior Member
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]

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 02:09 Go to previous message
Yu  is currently offline Yu
Messages: 1
Registered: July 2011
Junior Member

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: Sun Apr 20 23:13:05 EDT 2014

Powered by FUDForum. Page generated in 0.02056 seconds