【问题标题】:Refresh view after action in Eclipse RCP在 Eclipse RCP 中操作后刷新视图
【发布时间】:2012-05-15 12:48:17
【问题描述】:

我正在编写一个 Eclipse RCP 应用程序。 我在左边有一个视图,在右边有一个编辑器。视图是一个菜单。单击菜单中的按钮,编辑器应该打开并且视图应该改变。点击后编辑器打开,但视图没有改变。

我必须关闭菜单视图并打开一个新的吗?如果是,怎么做?

如果我在 page.openEditor(..) 之前写 page.showView(ID_of_my_view_class.ID),它会在显示的控制台旁边打开一个新选项卡,其中包含日志。

当前代码:

    public Object execute(ExecutionEvent event) throws ExecutionException {
    this.log.info(this.getClass().getSimpleName() + " called");
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    KuenstlerEditorInput input = new KuenstlerEditorInput(new Kuenstler());
    try {
        page.openEditor(input, KuenstlerEditor.ID);
    } catch (PartInitException e) {
        MessageDialog.openError(window.getShell(), "Error",
                "Editor f¸r K¸nstler konnte nicht geˆffnet werden: "
                        + e.getMessage());
        this.log.error(e);
    }
    return null;
}

当我启动程序时,它看起来像这样:http://i.imgur.com/KXHAe.png 当我执行 page.showView(the_ID.ID) 命令时,它看起来像这样:http://i.imgur.com/BZ8y1.png

视图应该出现在左侧,而不是带有所有按钮的菜单。

【问题讨论】:

  • 您使用的透视图是什么?如果您有自己的透视图,则应该能够在设置透视图时设置视图的位置。否则,我认为您(但更确定)您应该能够将视图的布局信息添加到活动透视图中。
  • 感谢您的回答。我在代码下方编辑了我的问题。

标签: eclipse view eclipse-rcp rcp


【解决方案1】:

使用org.eclipse.ui.perspectives 扩展点创建透视图,然后提供IPerspectiveFactory 的实现,这将允许您定义您创建的命名视图的位置。

【讨论】:

    【解决方案2】:

    创建或获取项目的对象,然后执行以下操作: (仅适用于导航器视图) project.refreshLocal(IResource.DEPTH_INFINITE, null);

    【讨论】:

    • 您无需关闭并重新打开您的视图。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-16
    • 2019-01-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多