Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh option not available for some resources that are not closed p… #2542

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) {
DaveCarpeneto marked this conversation as resolved.
Show resolved Hide resolved
isProjectSelection = false;
continue;
Expand All @@ -139,19 +139,23 @@ public void fillContextMenu(IMenuManager menu) {
hasBuilder = false;
}
}

DaveCarpeneto marked this conversation as resolved.
Show resolved Hide resolved
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