我只知道它属于org.eclipse.pde.ui的扩展点org.eclipse.ui.perspectives,看来要好好研究一下这部分的代码,才能解决隐藏Perspective,实现权限管理。
参考了别人的代码:
看了看eclipse的源代码,终于知道怎么关闭了:
IWorkbench w=PlatformUI.getWorkbench();
IPerspectiveRegistry pr=w.getPerspectiveRegistry() ;
IPerspectiveDescriptor persdes=pr.findPerspectiveWithId("perspectiveID");
WorkbenchPage p=(WorkbenchPage)w.getActiveWorkbenchWindow().getActivePage();
Perspective persp = p.getActivePerspective();
p.closePerspective(persdes,false,false);
try {
w.showPerspective("nextperspectiveID", w.getActiveWorkbenchWindow());
} catch (WorkbenchException e) {
e.printStackTrace();
}
关闭当前perspective,并打开一个新的perspective:
IWorkbench w=PlatformUI.getWorkbench();
ActionFactory.IWorkbenchAction closePerspectiveAction
= ActionFactory.CLOSE_PERSPECTIVE.create(w.getActiveWorkbenchWindow());
closePerspectiveAction.run();
try {
PlatformUI.getWorkbench().showPerspective("com.ibm.demo.saic.ui.views.NextPerspective", w.getActiveWorkbenchWindow());
} catch (WorkbenchException e) {
e.printStackTrace();
}