【问题标题】:How to open the View from command in eclipse RCP?如何在 Eclipse RCP 中打开 View from 命令?
【发布时间】:2019-01-20 08:03:26
【问题描述】:
我需要在 HandlerUtil 的帮助下使用代码打开一个视图,我该如何在 Eclipse RCP 中做到这一点?
我试过PlatformUI。
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("MyView");
但我需要使用HandlerUtil 执行它
【问题讨论】:
标签:
eclipse-plugin
eclipse-rcp
【解决方案1】:
在HandlerUtil 中使用getActiveWorkbenchWindow:
public class MyHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPage workbenchPage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
workbenchPage.showView("MyView");
}
}