Eclipse RCP - relative field of view perspective extension not working

帅比萌擦擦* 提交于 2019-12-22 00:47:32

问题


Greetings fellow Stackoverflownians,

Currently developing an Eclipse RCP app.

I'm trying to make a view appear in the right place when the perspective is reset.

In my plugin.xml:

<perspectiveExtension
            targetID="the.perspective.id">
         <view
               id="the.first.view.id"
               relationship="stack"
               relative="org.eclipse.ui.navigator.ProjectExplorer"
               visible="false">
         </view>
         <view
               id="the.second.view.id"
               relationship="left"
               relative="org.eclipse.ui.navigator.ProjectExplorer"
               visible="true">
         </view>
      </perspectiveExtension>

Where the first and second views are declared in the views extension point.

As per eclipse.org:

stack indicates that the view will be stacked with the relative view in a folder

The issue is that when I reset the perspective, I get the view in a separate place (more exactly, to the right) occupying ~50% of the workbench.

Should the ProjectExplorer view be declared once more in my plugin.xml, so that the stack value of the relative field would work?

EDIT: I've looked in another plugin project

<view
              id="org.eclipse.search.ui.views.SearchView"
              minimized="false"
              relationship="stack"
              relative="dreisoft.tresos.launcher2.api.views.ErrorLog"
              visible="false">
        </view>

This seems to work, and I've looked in the IPerspectiveFactory, and the createInitialLayout is empty. Despite that, this works.

Respectfully yours,

Vlad


回答1:


This is a bit odd. I've tried your method a while ago and it didn't work for me either. Instead, take a programmatical approach.

With the use of the IPageLayout you receive in the createInitialLayout method of your Perspective, try creating a IPlaceholderFolderLayout:

final IPlaceholderFolderLayout folder = layout.createPlaceholderFolder("main.editor.area", IPageLayout.TOP, 0.8f, layout.getEditorArea()); //$NON-NLS-1$

You can position each view in that folder with the help of those parameters. Then add your view to that folder:

folder.addPlaceholder("your.view.ID" + ":*"); //$NON-NLS-1$

I recommend you make static final String constants of your IDs.



来源:https://stackoverflow.com/questions/19724259/eclipse-rcp-relative-field-of-view-perspective-extension-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!