如何在 eclipse RCP 中打开 View from 命令?

How to open the View from command in eclipse RCP?

我需要在 HandlerUtil 的帮助下使用代码打开一个视图,如何在 Eclipse RCP 中完成?

我试过 PlatformUI

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("MyView");

但我需要用 HandlerUtil

来执行它

HandlerUtil中使用getActiveWorkbenchWindow:

public class MyHandler extends AbstractHandler {
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {

    IWorkbenchPage workbenchPage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();

    workbenchPage.showView("MyView");
  }
}