Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » How to obtain a ViewPart programatically
How to obtain a ViewPart programatically [message #322074] Wed, 07 November 2007 11:12 Go to next message
Eclipse UserFriend
Originally posted by: gmerin.integranova.com

Hi everyone. I'm trying to get the ViewPart of a existing View
programatically (this code is in another plugin) and I'm not able of
doing so. I was only capable of getting its ViewDescriptor using this code:

String viewId = "...";
IViewDescriptor peViewDescriptor =
PlatformUI.getWorkbench().getViewRegistry().find(
viewId);

But I'm stuck at this point. I don't find the way to obtain the ViewPart
from the ViewDescriptor.

I also tryed with this:
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
..getActivePage().showView(viewId);

but the problem is that I'm not in a Display and
..getActiveWorkbenchWindow() returns null so the code from above produces
an Exception.

Any ideas?

Thanks in advance.
Gabriel.
Re: How to obtain a ViewPart programatically [message #322085 is a reply to message #322074] Wed, 07 November 2007 12:10 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Gabriel,

Maybe you need something like this:


PlatformUI.getWorkbench().getDisplay().getSite().getShell(). getDisplay().asyncExec
(new Runnable()
{
public void run()
{

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().showView(viewId);

}
});


Gabriel Merin Cubero wrote:
> Hi everyone. I'm trying to get the ViewPart of a existing View
> programatically (this code is in another plugin) and I'm not able of
> doing so. I was only capable of getting its ViewDescriptor using this
> code:
>
> String viewId = "...";
> IViewDescriptor peViewDescriptor =
> PlatformUI.getWorkbench().getViewRegistry().find(
> viewId);
>
> But I'm stuck at this point. I don't find the way to obtain the
> ViewPart from the ViewDescriptor.
>
> I also tryed with this:
> PlatformUI.getWorkbench().getActiveWorkbenchWindow()
> .getActivePage().showView(viewId);
>
> but the problem is that I'm not in a Display and
> .getActiveWorkbenchWindow() returns null so the code from above
> produces an Exception.
>
> Any ideas?
>
> Thanks in advance.
> Gabriel.
Previous Topic:Utility of the IEditorActionBarContributor
Next Topic:Problem upgrading to 3.3.1.1
Goto Forum:
  


Current Time: Sun Jun 08 20:51:57 EDT 2025

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

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

Back to the top