eclipse RCP - 使 IFolder 在最后一个视图关闭后持续存在

发布于 2024-10-02 18:20:36 字数 948 浏览 0 评论 0原文

我使用 Java 1.6 创建了一个 IFolder,其中包含一个占位符,用于在 XP 上的 eclipse Helios 上的 RCP 中查看我的视图;

    IFolderLayout mainFolder = layout.createFolder("mainfolder, 
            IPageLayout.LEFT, (float) 100.0, layout.getEditorArea());
    mainFolder.addPlaceholder("myview:*");

这按预期工作,有一个灰色区域,该区域在创建时由 myview 和后续视图填充。但是,如果最后一个视图关闭,整个 IFolder 区域就会消失,并且未来的视图将在工作台的错误区域/文件夹中实例化。

我看到一些人早在 06 年就提到了这个问题,但我找不到任何解决方案,而且我不想在最后一个文件夹消失时继续强制重置视角。

http://dev.eclipse.org/newslists/news.eclipse .platform.rcp/msg15873.html http://www.eclipsezone.com/eclipse/forums/t53312.html#91951958

我想我可能必须挂钩关闭视图方法来检查它是否是最后一个视图并重新创建 IFolder。

似乎有一种方法可以防止布局关闭;

layout.getViewLayout("myview").setCloseable (false);
layout.getViewLayout("myview:*").setCloseable (false);

但我似乎无法阻止文件夹崩溃......

I have created an IFolder with a placeholder for my views in RCP on eclipse Helios on XP with Java 1.6 like so;

    IFolderLayout mainFolder = layout.createFolder("mainfolder, 
            IPageLayout.LEFT, (float) 100.0, layout.getEditorArea());
    mainFolder.addPlaceholder("myview:*");

And this works as expected with a greyed out area, which is populated by the myview when it is created and with subsequent views. However if the last view is ever closed, the whole IFolder area disappears and future views are instantiated in the wrong area/folder of the workbench.

I see a few people mentioning this problem back in 06, but I can't find any solutions and I don't want to keep force resetting the perspective just when the last folder has gone.

http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/msg15873.html
http://www.eclipsezone.com/eclipse/forums/t53312.html#91951958

I am thinking that I might have to hook the close view method to check to see if it is the last view and re-create the IFolder.

there seems to be a method to prevent the layout from closing;

layout.getViewLayout("myview").setCloseable (false);
layout.getViewLayout("myview:*").setCloseable (false);

but I can't seem to get that to effect the folder from collapsing...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空心↖ 2024-10-09 18:20:36

试试这个:

覆盖 WorkbenchWindowAdvisor 中的 isDurableFolder(...) 方法,使其看起来像这样:

    @Override
    public boolean isDurableFolder(String perspectiveId, String folderId) {
        if( "my.perspective".equals(perspectiveId) && "my.mainfolder".equals(folderId) ) {
              return true; 
        }
        return super.isDurableFolder(perspectiveId, folderId);
    }

替换 my.perspective>my.mainfolder 包含您的视角和文件夹的 ID。这将为您的文件夹创建一个持久的ViewStack

仅供参考:默认情况下,WorkbenchWindowAdvisor#isDurableFolder(...) 返回 false。这会导致 PageLayout#createFolder(...) 将 ViewStack 创建为持久的。方法 PageLayout#createPlaceholderFolder(...) 无法设置 ViewStack 持久!

Try this:

Overwrite the method isDurableFolder(...) in your WorkbenchWindowAdvisor so that it looks like this:

    @Override
    public boolean isDurableFolder(String perspectiveId, String folderId) {
        if( "my.perspective".equals(perspectiveId) && "my.mainfolder".equals(folderId) ) {
              return true; 
        }
        return super.isDurableFolder(perspectiveId, folderId);
    }

Replace my.perspective and my.mainfolder with the ID of your Perspective and Folder. This will create a durable ViewStack for your Folder.

FYI: By default the WorkbenchWindowAdvisor#isDurableFolder(...) returns false. This causes PageLayout#createFolder(...) to create the ViewStack as not durable. The Method PageLayout#createPlaceholderFolder(...) is not able to set the ViewStack durable!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文