Reputation: 491
I am using multiple views to display multiple table viewer. The working or functionality which I want is, when a user clicks on the views tab, the required data depending upon the view should get populated in the table.
Is there any proper event to do this ?
I want to load data when user selects a particular view tab.
I have used these two event for loading this data
First -
getViewSite().getPage().addSelectionListener(new ISelectionListener(){
@Override
public void selectionChanged(IWorkbenchPart part, ISelection lection) {
} });
for this event selectionChanged() method of all views are fired and loads data in all views .. !!
Second -
getSite().getPage().addPartListener(partListener);
private IPartListener partListener = new IPartListener() {
public void partActivated(IWorkbenchPart part) {
}
public void partBroughtToTop(IWorkbenchPart part) {
}
public void partClosed(IWorkbenchPart part) {
}
public void partDeactivated(IWorkbenchPart part) {
}
public void partOpened(IWorkbenchPart part) {
//writing code here to fill TableViewer
}
};
for this, the data is loading while creating the views.
But, I want to load data in tableviewer when a user selects particular view Tab
Upvotes: 1
Views: 1205
Reputation: 111142
You can use org.eclipse.ui.IPartListener
to listen for the view part to become activated. Use:
getSite().getPage().addPartListener(partListener);
in your view part to set up the listener.
The partActivated
method is called when the view is activated (partBroughtToTop
also sometimes).
Note: You need to check that the part is actually your view as you will receive events for all parts.
Upvotes: 1