A small snippet which switches to a certain perspective via code:
IPerspectiveDescriptor[] perspectives =
PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives();
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if(page != null) {
for (IPerspectiveDescriptor des : perspectives) {
if (des.getId().equals("my.perspective.id")) {
page.setPerspective(des);
break;
}
}
}
return null;