{
IEditorPart editor = (IEditorPart) part;
IClassFile classFile = (IClassFile)editor.getEditorInput().getAdapter(IClassFile.class);
if (classFile != null)
{
PackageFragmentRoot root = SelectUtils.getRoot(classFile);
if (root != null)
{
roots.add(root);
}
}
}
else if (part instanceof IViewPart)
{
IViewPart view = (IViewPart) part;
ISelection selection = null;
if (view instanceof IPackagesViewPart)
{
IPackagesViewPart viewPart = (IPackagesViewPart) view;
TreeViewer treeViewer = viewPart.getTreeViewer();
selection = treeViewer.getSelection();
}
else if (view instanceof CommonNavigator)
{
CommonNavigator navigator = (CommonNavigator) view;
CommonViewer commonViewer = navigator.getCommonViewer();
selection = commonViewer.getSelection();
}
if (selection instanceof IStructuredSelection)
{
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
final List<IJavaElement> elements = SelectUtils.getSelectedElements(
structuredSelection.iterator(),
IJavaElement.class);
for (IJavaElement element : elements)
{
PackageFragmentRoot root = SelectUtils.getRoot(element);
if (root != null)
{
roots.add(root);
}