Wednesday, March 28, 2012

How to create a new Perspective using Extension Point

  1. Create a new Plug-in Project.
  2. Open “MANIFEST.MF” file from Plug-in project.
  3. Go to the “Extension” tab in the plug-in editor.
  4. Click “Add…” button. “New Extension” dialog box will be opened. Select “org.eclipse.ui.perspectives” from the list shown under “Extension Points” tab.

Add Extension Point in Plug-in project

  1. Click “Finish”.
  2. A new perspective extension is now created. Now provide the id*, name* and class* information accordingly.
Give id*, name* and class* information on perspective extension

  1. To create a class, click on the class*:  -> A “New Java Class” dialog box will be opened. Click “Finish” to create a new java class to the give package location.
Create class for perspective


  1. Save all unsaved files.
  2. To run the project, R-Click on the project -> Run As -> Eclipse Application.
Run Plug-in project

  1. A new instance of an Eclipse will be opened.
  2. Go to Window -> Open Perspective -> Other…
  3. “Open Perspective” dialog box will be opened. Select your perspective name from the list and click OK.
Open Perspective dialog box

  1. One blank perspective will be opened.
  2. Now close this test eclipse window and go back to the development eclipse window to modify this perspective.
  3. Open this newly created java class and modify it using the following code snippet:


  1. Run the project and see the effect of the code in newly launched test eclipse workbench.
"My Perspective" workbench

NB: If you don’t see the different in your perspective, just reset it using this following command.
Window -> Reset Perspective… -> Yes


Attachment: To Download this project click here.

8 comments:

  1. Simple and easy to understand! Thanks alot!

    ReplyDelete
  2. Hi Debabrata...would you please explain how two extenion points can interact? for example..below scenario:

    b. Add some functionality like interface for adding two numbers. Using that in create a class that implement that interface and add two numbers.
    c. Create second new plugin and by using first plugin, add two numbers with new class implementation in second plugin.

    ReplyDelete
    Replies
    1. Hi,
      I'm added one topic in my blog as per your request.
      Please have a look this following link:
      http://projectdev.blogspot.in/2012/03/how-to-create-eclipse-extension-point.html

      and, if you have any further clarification, please revert back to me.

      Delete
  3. hi i want to implement a drag and drop functionality like window builder(it should generate code when u drag from ui to the editor.please help me with this.
    http://stackoverflow.com/questions/22253936/eclipse-drag-and-drop-on-text-editor

    ReplyDelete
    Replies
    1. Hi Junaid,
      I'll look into this features and get back to you soon.
      Thanks in advance.

      Delete
  4. Hi Debabrata.
    I would like to create a perspective using 3 views called ViewChart1, ViewChart2 and ViewChart3. These 3 views implement ViewPart and have been defined by me in order to display some charts. I would like to know how to override createInitialLayout so as to add these views in my perspective extension.
    Thank you in advance.

    ReplyDelete
  5. I read carefully your tutorial and finally managed to display the views of my perspective. Still, I want to thank you for your good tutorial.

    ReplyDelete
    Replies
    1. Thanks Alvine. If you need any help regarding eclipse plug-ins in future please get back to me again.
      Thanks again.

      Delete