For single instance views, a single id is sufficient to uniquely identify the ViewPart. This id is defined in the plugin.xml through the extension point org.eclipse.ui.views.

But sometimes it needs to have the multiple instance of the same ViewPart. For identifying the multiple instance of the same view, combination of two ids is used. One is the primary id, which is the same as described above and a secondary id, which is different for the different instance of the views.

Steps involving in creating multiple instance of a ViewPart:

  • First add the view in plugin.xml by using the org.eclipse.ui.views extension point.
 <extension point="org.eclipse.ui.views">
  <view name="View" class="MyPackage.View" id="viewID" allowMultiple="true" >
  </view>
</extension>
  • Now create a placeholder in the perspective by using createInitialLayout(IPageLayout layout) method of the perspective.
   IFolderLayout folder1 = layout.createFolder("folder1", 
    IPageLayout.TOP, 0.5f, layout.getEditorArea());

  folder1.addPlaceholder("viewID:viewSecondaryID*");

Now instances of the ViewPart can be created dynamically by using the following the code:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().
    getActivePage().showView(String viewID,String secondaryID,int Mode);