|
Re: Open Perspective manually [message #725449 is a reply to message #725401] |
Wed, 14 September 2011 20:11 |
John Steele 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03784 seconds