Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Open Perspective manually
Open Perspective manually [message #725401] Wed, 14 September 2011 12:56 Go to next message
Eclipse UserFriend
Hello,

is it possible to open or change the perspective programmatically (via code)?
I want open directly a specific perspective.

Thx
Budi
Re: Open Perspective manually [message #725449 is a reply to message #725401] Wed, 14 September 2011 16:11 Go to previous messageGo to next message
Eclipse UserFriend
Your plugin first needs to define a perspective by contributing to the
org.eclipse.ui.perspectives extension point. While defining the perspective
you will assign the perspective an ID, and this ID can then be used later on to
look it up from the perspective registry.

Here's a snippet of how to open a perspective that has already been defined. I'm assuming you are switching to the perspective from a tool bar or something similar:

ToolItem = new ToolItem (bar, SWT.PUSH);
item.setText("Swith to Resource Perspective");
item.addSelectionListener(new SelectionAdapter() {
	@Override
	public void widgetSelected(SelectionEvent e) {

	IPerspectiveRegistry reg = PlatformUI.getWorkbench().getPerspectiveRegistry();

	IPerspectiveDescriptor per = reg.findPerspectiveWithId("org.eclipse.ui.resourcePerspective");

	  if (per != null ) {			
            PlatformUI.getWorkbench.getActiveWorkbenchWindow.getActivePage(). setPerspective(per);      
	  }
	}
});


Hope this helps!

[Updated on: Wed, 14 September 2011 16:12] by Moderator

Re: Open Perspective manually [message #726193 is a reply to message #725449] Fri, 16 September 2011 14:50 Go to previous message
Eclipse UserFriend
Yes, very nice .... THX
Previous Topic:Handling multiple Projects in a RCP based Application / reusing existing eclipse components
Next Topic:Delete workbench.xml before startup
Goto Forum:
  


Current Time: Tue Jul 22 20:58:42 EDT 2025

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

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

Back to the top