javaeclipseviewmultiple-instances

Opening Multiple instances of the same view in eclipse


So im relativley new to this view/perspective development and have come across a problem. My views only open once and another instance cannot be opened again even when I load different data.

Ive looked everywhere and all i can find people saying is that I need a secondary id etc... but no explaination of where to go to do this or how to go about this.

I need instances of my views to be opend multiple times if possible all with different data. these views are opened and controlled through a tree view i have created.

These views are currently just an extension of the Java perspective in eclipse 4.5.2.

Any pointers in the right direction would be a great help!


Solution

  • You specify the secondary id for the view when you show it using IWorkbenchPage.showView:

    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    
    page.showView("view id", "secondary id", IWorkbenchPage.VIEW_ACTIVATE);
    

    "secondary id" must be different for each instance of the view.