简体   繁体   中英

Eclipse RCP - relative field of view perspective extension not working

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM