Source:
<code>public void fillContextMenu(IMenuManager menu) { IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); boolean isProjectSelection = true; boolean hasOpenProjects = false; boolean hasClosedProjects = false; boolean hasBuilder = true; <START> Iterator<?> resources = selection.iterator(); <END> while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) { Object next = resources.next(); IProject project = null; if (next instanceof IProject) { project = (IProject) next; } else if (next instanceof IAdaptable) { project = (IProject) ((IAdaptable) next).getAdapter(IProject.class); } if (project == null) { isProjectSelection = false; continue; } if (project.isOpen()) { hasOpenProjects = true; if (hasBuilder && !hasBuilder(project)) { hasBuilder = false; } } else { hasClosedProjects = true; hasBuilder = false; } } if (!selection.isEmpty() && isProjectSelection && !ResourcesPlugin.getWorkspace().isAutoBuilding() && hasBuilder) { buildAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, buildAction); } if (!hasClosedProjects) { refreshAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, refreshAction); } if (isProjectSelection) { if (hasClosedProjects) { openProjectAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, openProjectAction); } if (hasOpenProjects) { closeProjectAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, closeProjectAction); closeUnrelatedProjectsAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, closeUnrelatedProjectsAction); } } }</code><technical_language>be: Iterator<Object></technical_language>

Target:
public void fillContextMenu(IMenuManager menu) { IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); boolean isProjectSelection = true; boolean hasOpenProjects = false; boolean hasClosedProjects = false; boolean hasBuilder = true; Iterator<Object> resources = selection.iterator(); while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) { Object next = resources.next(); IProject project = null; if (next instanceof IProject) { project = (IProject) next; } else if (next instanceof IAdaptable) { project = (IProject) ((IAdaptable) next).getAdapter(IProject.class); } if (project == null) { isProjectSelection = false; continue; } if (project.isOpen()) { hasOpenProjects = true; if (hasBuilder && !hasBuilder(project)) { hasBuilder = false; } } else { hasClosedProjects = true; hasBuilder = false; } } if (!selection.isEmpty() && isProjectSelection && !ResourcesPlugin.getWorkspace().isAutoBuilding() && hasBuilder) { buildAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, buildAction); } if (!hasClosedProjects) { refreshAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, refreshAction); } if (isProjectSelection) { if (hasClosedProjects) { openProjectAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, openProjectAction); } if (hasOpenProjects) { closeProjectAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, closeProjectAction); closeUnrelatedProjectsAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, closeUnrelatedProjectsAction); } } }