代码切换透视图:
PlatformUI.getWorkbench().showPerspective("要切换的透视图id", PlatformUI.getWorkbench().getActiveWorkbenchWindow());
销毁透视图: //执行完毕后会回到默认(Default)的透视图
IWorkbench w=PlatformUI.getWorkbench();
IPerspectiveRegistry pr=w.getPerspectiveRegistry() ;
IPerspectiveDescriptor descriptor = pr.findPerspectiveWithId("要销毁的透视图id");
WorkbenchPage p=(WorkbenchPage)w.getActiveWorkbenchWindow().getActivePage();
Perspective persp = p.getActivePerspective();
p.closePerspective(descriptor,false,false);
配置文件显示透视图切换按钮:
在rcp项目的根目录新建plugin_customization.ini文件,内容如下:
#设置视图标题栏的弧线型外观
org.eclipse.ui./SHOW_TRADITIONAL_STYLE_TABS = false
#
# 显示在右侧上方 默认为左侧
org.eclipse.ui/DOCK_PERSPECTIVE_BAR=TOP_RIGHT