CODEXE

Create a custom perspective

What's a perspective?

An eclipse perspective is the collection of views and editors. it's like a desktop of your application from which the developer can choose the views should be shown on the initial layout. We often need to have a custom perspective for our plugin or RCP application in practice.

How to create a custom perspective?

1. Open plugin.xml and select the "Extension" tab

2. Click Add button and add a perspective extension(org.eclipse.ui.perspectives)

org.eclipse.ui.perspective

3. Edit the ID(CustomPlugin.perspective), Name(Custom Perspective) and Class Name of perspective(customplugin.PrespectiveFactory)

create a custom perspective

4. Click the "class*" to create the class. If the Java class is not created, the error "org.eclipse.core.runtime.CoreException: Plug-in CustomPlugin was unable to load class customplugin.PerspectiveFactory" occur when you run the code.

perspective factory

5. Currently, it's no need to add code in the createInitialLayout method.

public class PerspectiveFactory implements IPerspectiveFactory {
	  @Override
	  public void createInitialLayout(IPageLayout layout) {
	  // TODO Auto-generated method stub
	  }
  }
			  

6. Run the application and click the "Open Perspective" shortcut

open a custom perspective

7. The "Custom Perspective" exists in the perspective list. Click to open it

show perspective

8. A custom Eclipse perspective

open perspective