如何以编程方式关闭eclipse应用程序中的视图?

时间:2013-10-01 11:12:44

标签: java eclipse eclipse-plugin eclipse-rcp

我想以编程方式关闭eclipse应用程序中的视图。 该视图是一个id为myProduct.intro的introPart 我试过了:

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.hideView(page.findView("myProduct.intro"));

但它不起作用,任何其他方式来做这个或我做错了什么?

2 个答案:

答案 0 :(得分:5)

尝试:

IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();

PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);

答案 1 :(得分:1)

您还可以使用更通用的方式:

//Get current page    
IWorkbenchPage wp=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

//Find desired view :
IViewPart myView=wp.findView("myViewId");

//Hide the view :
wp.hideView(myView);
相关问题