IWorkbenchWindow iwindow = iworkbench.getActiveWorkbenchWindow();
if (iwindow == null) {
return;
}
ISelectionService service = iwindow.getSelectionService();
if (service == null) {
return;
}
service.addSelectionListener(new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
System.out.println(">>"+selection);
new ViewContentProvider().buildModel();
}
});
structured = (IStructuredSelection) service.getSelection("org.eclipse.jdt.ui.PackageExplorer");
if (structured == null) {
structured = (IStructuredSelection) service.getSelection("org.eclipse.ui.navigator.ProjectExplorer");
if (structured == null) {
return;
}
}
}