Creating custom perspectives

Creating perspectives

To create a custom perspective it is necessary to add a new java class to a custom plugin containing the new perspective with a perspective identifier.

Custom perspective class
public class MyCustomPerspective implements IPerspectiveFactory
{
public static String PERSPECTIVE_ID = "hlr.custom.ui.perspective.MyCustomPerspective"; //$NON-NLS-1$
 
@Override
public void createInitialLayout( IPageLayout layout )
{
layout.setEditorAreaVisible( false );
}
}

Now add a contribution to the org.eclipse.ui.perspectives extension point and fill the mandatory properties marked with a *.

images/download/attachments/111935984/AddPerspectiveMod.png

Properties of "Extension Element Details"

key

value

id

PERSPECTIVE_ID of the created perspective class

name

Translatable name for the perspective.

When starting the name with the % sign it is indicating that a variable in a properties file in the plugin directory is used.

class

Java class reference which implements the IPerspectiveFactory.

icon (optional)

Relative path to the icon which will be used besides the name of the perspective.

An example custom perspective is provided in the SDK package "com.heiler.ppm.customizing.ui".

Adding views to a perspective

images/download/attachments/111935984/perspectiveExtMod.png

To add a view to a perspective it it necessary to first add a contribution to the org.eclipse.ui.perspectiveExtensions extension point.

The targetID has to be the ID from the perspective where the views should be added.

After creating the perspectiveExtension a view can be added to it.

images/download/attachments/111935984/AddCustViewToPerspectiveMod.png

Properties of "Extension Element Details" of a view in a perspectiveExtension.

key

value

id

The ID of the view you want to add.

relationship

Defines how the current view is displayed to the view given at "relative" (stated below), for example "left", "right", "bottom", "stack"

relative

The view which is the reference for the relationship above

ratio

The percentage ratio [0.01 -1] of space between the relative and the current view

When choosing relationship "stack", no ratio can be given

An example custom perspective is provided in the SDK package "com.heiler.ppm.customizing.ui".