代码非常简单,不再多加解释:

1  IWorkbench workbench  =  PlatformUI.getWorkbench();
2  IPerspectiveRegistry perspReg  =  workbench.getPerspectiveRegistry();
3  IPerspectiveDescriptor perspDesc = perspReg.findPerspectiveWithId( " com.anotherPerspective.Id " );
4  IWorkbenchWindow window  =  workbench.getActiveWorkbenchWindow();
5  if  (window  !=   null ) {   
6    IWorkbenchPage page  =  window.getActivePage();   
7    page.setPerspective(perspDesc);
8  }