Skip to content

Commit 062aa39

Browse files
Refresh option not available for some resources that are not closed projects #2538
Change made since the fix to #1438 unintentionally removed the "refresh" contextual menu for resources that are not projects. With this change the "refresh" contextual menu is shown if ANY navigator selection is either (A) an open project, or (B) a non-project resource. Put another way: the 'refresh' item is NOT shown if ALL selections are closed projects. Fixes #2538
1 parent 6a3eb35 commit 062aa39

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/ResourceMgmtActionProvider.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.lang.reflect.InvocationTargetException;
1919
import java.util.ArrayList;
2020
import java.util.Collections;
21-
import java.util.Iterator;
2221
import java.util.List;
2322

2423
import org.eclipse.core.resources.ICommand;
@@ -117,14 +116,15 @@ public void fillContextMenu(IMenuManager menu) {
117116
boolean isProjectSelection = true;
118117
boolean hasOpenProjects = false;
119118
boolean hasClosedProjects = false;
120-
boolean hasBuilder = true; // false if any project is closed or does not
121-
// have builder
122-
123-
Iterator<IProject> projects = selectionToProjects(selection).iterator();
124-
125-
while (projects.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) {
126-
IProject project = projects.next();
119+
boolean hasBuilder = true; // false if any project is closed or does not have builder
120+
List<IProject> projects = selectionToProjects(selection);
121+
boolean selectionContainsNonProject = projects.size() < selection.size();
127122

123+
for (IProject project : projects) {
124+
if (hasOpenProjects && hasClosedProjects && !hasBuilder && !isProjectSelection) {
125+
// we've set all booleans of interest; no need to loop any further
126+
break;
127+
}
128128
if (project == null) {
129129
isProjectSelection = false;
130130
continue;
@@ -139,19 +139,23 @@ public void fillContextMenu(IMenuManager menu) {
139139
hasBuilder = false;
140140
}
141141
}
142+
142143
if (!selection.isEmpty() && isProjectSelection && !ResourcesPlugin.getWorkspace().isAutoBuilding()
143144
&& hasBuilder) {
144145
// Allow manual incremental build only if auto build is off.
145146
buildAction.selectionChanged(selection);
146147
menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, buildAction);
147148
}
148-
// Add the 'refresh' item if any selection is either (a) an open project, or (b)
149-
// a non-project selection (so the 'refresh' item is not shown if all selections
150-
// are closed projects)
151-
if (hasOpenProjects || !isProjectSelection) {
149+
150+
// Add the 'refresh' item if ANY selection is either (a) an open project, or (b)
151+
// a non-project selection.
152+
// Put another way: the 'refresh' item is NOT shown if ALL selections are closed
153+
// projects.
154+
if (hasOpenProjects || selectionContainsNonProject) {
152155
refreshAction.selectionChanged(selection);
153156
menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, refreshAction);
154157
}
158+
155159
if (isProjectSelection) {
156160
if (hasClosedProjects) {
157161
openProjectAction.selectionChanged(selection);

0 commit comments

Comments
 (0)