Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.ui.navigator.resources; singleton:=true
Bundle-Version: 3.9.500.qualifier
Bundle-Version: 3.9.600.qualifier
Bundle-Activator: org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorPlugin
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import org.eclipse.core.resources.ICommand;
Expand Down Expand Up @@ -117,14 +116,15 @@ public void fillContextMenu(IMenuManager menu) {
boolean isProjectSelection = true;
boolean hasOpenProjects = false;
boolean hasClosedProjects = false;
boolean hasBuilder = true; // false if any project is closed or does not
// have builder

Iterator<IProject> projects = selectionToProjects(selection).iterator();

while (projects.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) {
IProject project = projects.next();
boolean hasBuilder = true; // false if any project is closed or does not have builder
List<IProject> projects = selectionToProjects(selection);
boolean selectionContainsNonProject = projects.size() < selection.size();

for (IProject project : projects) {
if (hasOpenProjects && hasClosedProjects && !hasBuilder && !isProjectSelection) {
// we've set all booleans of interest; no need to loop any further
break;
}
if (project == null) {
isProjectSelection = false;
continue;
Expand All @@ -139,19 +139,23 @@ public void fillContextMenu(IMenuManager menu) {
hasBuilder = false;
}
}

if (!selection.isEmpty() && isProjectSelection && !ResourcesPlugin.getWorkspace().isAutoBuilding()
&& hasBuilder) {
// Allow manual incremental build only if auto build is off.
buildAction.selectionChanged(selection);
menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, buildAction);
}
// Add the 'refresh' item if any selection is either (a) an open project, or (b)
// a non-project selection (so the 'refresh' item is not shown if all selections
// are closed projects)
if (hasOpenProjects || !isProjectSelection) {

// Add the 'refresh' item if ANY selection is either (a) an open project, or (b)
// a non-project selection.
// Put another way: the 'refresh' item is NOT shown if ALL selections are closed
// projects.
if (hasOpenProjects || selectionContainsNonProject) {
refreshAction.selectionChanged(selection);
menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, refreshAction);
}

if (isProjectSelection) {
if (hasClosedProjects) {
openProjectAction.selectionChanged(selection);
Expand Down
Loading