I need to open multiple view from a same view class with different data.
For more detail. I have TreeViewer with six TreeParent. Now, when I select one parent my application will show a view and if I click other one that will not show anymore. Now I want show view for each tree item I clicked.
Any suggestion?
My current code:
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
// TODO Auto-generated method stub
ITreeSelection iTreeSelection = (ITreeSelection) viewer
.getSelection();
Object firstElement = iTreeSelection.getFirstElement();
try {
IWorkbenchWindow iWorkbenchWindow = PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
View.setTree(firstElement);
iWorkbenchWindow.getActivePage().showView(View.ID);
} catch (Exception e) {
// TODO: handle exception
}
}
});`
You can open multiple copies of the same view by using a 'secondary id' to distinguish the views. You the alternative version of showView
for this:
IWorkbenchPage activePage = iWorkbenchWindow.getActivePage();
activePage.showView(View.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
where secondaryId
is a string that identifies the particular instance of the view.