Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Finding a view from another perspective(IWorkbenchPage#findView() doesn't cut it!)
icon5.gif  Finding a view from another perspective [message #668492] Thu, 05 May 2011 20:49 Go to next message
SBS  is currently offline SBS Friend
Messages: 57
Registered: January 2011
Member
I am wanting to find a view that lives in a perspective other than the active perspective. How can I do it? I have tried IWorkbenchPart#findView() but it returns null for all views not in the active perspective.
Re: Finding a view from another perspective [message #668513 is a reply to message #668492] Thu, 05 May 2011 23:34 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
SBS wrote on Thu, 05 May 2011 13:49
I am wanting to find a view that lives in a perspective other than the active perspective. How can I do it? I have tried IWorkbenchPart#findView() but it returns null for all views not in the active perspective.



You have to get all of the perspectives and look for the view in each one. Annoying I know, but I think that's the only way to do it.

Like this:

		IPerspectiveDescriptor actPd = page.getPerspective();

		ResultsView rv = (ResultsView) page.findView(ResultsView.ID);
		if (rv == null) {
			IPerspectiveDescriptor[] pd = page.getOpenPerspectives();
			for (int i = 0; i < pd.length; i++) {
				try {
					getWorkbenchPage().setPerspective(pd[i]);
				} catch (Exception ex) {
					// Ignore, this can get an NPE in Eclipse, see bug 4454
				}
				rv = (ResultsView) page.findView(ResultsView.ID);
				if (rv != null) {
					break;
				}
			}
			page.setPerspective(actPd);
		}

		if (rv != null) {
			getWorkbenchPage().hideView(rv);
		}



Re: Finding a view from another perspective [message #668515 is a reply to message #668513] Fri, 06 May 2011 00:42 Go to previous message
SBS  is currently offline SBS Friend
Messages: 57
Registered: January 2011
Member
Francis Upton wrote on Thu, 05 May 2011 19:34
You have to get all of the perspectives and look for the view in each one. Annoying I know, but I think that's the only way to do it.


Thanks Francis, that seems to work quite well.

-sbs
Previous Topic:No extra console
Next Topic:createBrowser HELP!
Goto Forum:
  


Current Time: Fri Mar 29 13:27:27 GMT 2024

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

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

Back to the top