Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Open Perspective manually
Open Perspective manually [message #725401] Wed, 14 September 2011 16:56 Go to next message
budili Missing name is currently offline budili Missing nameFriend
Messages: 64
Registered: May 2010
Member
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 20:11 Go to previous messageGo to next message
John Steele is currently offline John SteeleFriend
Messages: 33
Registered: June 2010
Location: Seattle, WA
Member
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 20:12]

Report message to a moderator

Re: Open Perspective manually [message #726193 is a reply to message #725449] Fri, 16 September 2011 18:50 Go to previous message
budili Missing name is currently offline budili Missing nameFriend
Messages: 64
Registered: May 2010
Member
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: Thu Apr 25 02:04:20 GMT 2024

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

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

Back to the top