Display views in custom eclipse perspective

user10490295 :

I have a perspective which i have made, and a bunch of views i would like to be able to display on this perspective. If i go Window -> Show View -> Other and then select my view it works fine. However i would like to show a view by default upon opening the perspective and place it where the project explorer usually would be.

But nothing i do seems to change anything and i cannot find any reason why. I have been using this code to try to change the location of this view but it doesn't even open the view by default. can someone point me in the right direction on how to open a view by default and place it where the project explorer usually would be?

public class PerspectiveFactory1 implements IPerspectiveFactory {
    public void createInitialLayout(IPageLayout layout) {
        layout.addView("VIEW_ID_HERE", IPageLayout.LEFT,
            IPageLayout.RATIO_MAX, IPageLayout.ID_PROJECT_EXPLORER);
   }
}

Thanks in advance

Here is my plugin.xml

<plugin>
   <extension
         point="org.eclipse.ui.perspectives">
      <perspective
            class="packageName.PerspectiveFactory1"
            fixed="true"
            id="PerspectiveID"
            name="Software Application">
      </perspective>
   </extension>
   <extension
         point="org.eclipse.ui.perspectiveExtensions">
      <perspectiveExtension
            targetID="PerspectiveID">
         <view
               class="packageName.ShowApplications"
               icon="icons/sample.gif"
               id="packageName.ShowApplications"
                   minimized="false"
                   moveable="false"
                   name="listApps"
                   ratio="0.5"
                   relationship="left"
                   visible="true">
             </view>
greg-449 :

Since you don't have the project explorer in that perspective you can't use its id in the reference id parameter to addView. Instead use the editor area id which is always allowed:

layout.addView("view id", IPageLayout.LEFT,
    0.3f, layout.getEditorArea());

You may also have to Reset the perspective if it has been open before to get the new layout picked up (Window > Perspective > Reset Perspective).

The view must be defined using the org.eclipse.ui.views extension point.

You can also use the org.eclipse.ui.perspectiveExtensions to define the position of a view in the perspective instead of the perspective factory - but this still requires the view to be defined using org.eclipse.ui.views.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=160804&siteId=1