final Iterator<IWorkbenchPart> itr = parts.iterator();
while (itr.hasNext()) {
final IWorkbenchPart part = itr.next();
// get the part's ISetSelectionTarget implementation
ISetSelectionTarget target = null;
if (part instanceof ISetSelectionTarget) {
target = (ISetSelectionTarget) part;
} else {
target = (ISetSelectionTarget) part.getAdapter(ISetSelectionTarget.class);
}
if (target != null) {
// select and reveal resource
final ISetSelectionTarget finalTarget = target;
window.getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
finalTarget.selectReveal(selection);
}
});
}
}
}