Mohamed Iqzas
Mohamed Iqzas

Reputation: 1046

Open a view in specific postion in Eclipse

I use the following code to open a view in Eclipse workbench based application:

HandlerUtil.getActiveWorkbenchWindow(paramExecutionEvent).getActivePage().showView("viewId");

This view which I am opening is defined in an external plugin and I don't have control on its source. I just open the view by knowing the view-id.

The current perspective has one main active view on top, and three views open below the main view arranged next to each other.

By default it opens next to the main top view, thereby hiding the main view. But I want to open this specific view below the main view along with the three secondary views, so that the main top view is still visible.

I do not have access to source of any of these views or the perspective definition in plugin.xml. I am opening this view by having a custom menu in my plugin.

Kindly help in achieve this. Thanks in Advance!

Upvotes: 0

Views: 431

Answers (1)

greg-449
greg-449

Reputation: 111216

You can use the org.eclipse.ui.perspectiveExtensions extension point in your plug-in to add a definition for the view position in a perspective. Use the view element to position a view.

For example:

<extension point="org.eclipse.ui.perspectiveExtensions"> 
    <perspectiveExtension 
        targetID="org.eclipse.ui.resourcePerspective"> 
        <view id="org.eclipse.jdt.ui.TypeHierarchy" 
            relative="org.eclipse.ui.views.ResourceNavigator" 
            relationship="left" 
            ratio="0.50"/> 
    </perspectiveExtension> 
</extension> 

This is adding to the org.eclipse.ui.resourcePerspective perspective. It defines the position of the org.eclipse.jdt.ui.TypeHierarchy relative to the org.eclipse.ui.views.ResourceNavigator view.

Upvotes: 1

Related Questions