@@ -113,22 +113,17 @@ public void fillActionBars(IActionBars actionBars) {
113113 @ Override
114114 public void fillContextMenu (IMenuManager menu ) {
115115 IStructuredSelection selection = (IStructuredSelection ) getContext ().getSelection ();
116- boolean isProjectSelection = true ;
117116 boolean hasOpenProjects = false ;
118117 boolean hasClosedProjects = false ;
119118 boolean hasBuilder = true ; // false if any project is closed or does not have builder
120119 List <IProject > projects = selectionToProjects (selection );
121120 boolean selectionContainsNonProject = projects .size () < selection .size ();
122121
123122 for (IProject project : projects ) {
124- if (hasOpenProjects && hasClosedProjects && !hasBuilder && ! isProjectSelection ) {
123+ if (hasOpenProjects && hasClosedProjects && !hasBuilder ) {
125124 // we've set all booleans of interest; no need to loop any further
126125 break ;
127126 }
128- if (project == null ) {
129- isProjectSelection = false ;
130- continue ;
131- }
132127 if (project .isOpen ()) {
133128 hasOpenProjects = true ;
134129 if (hasBuilder && !hasBuilder (project )) {
@@ -139,14 +134,12 @@ public void fillContextMenu(IMenuManager menu) {
139134 hasBuilder = false ;
140135 }
141136 }
142-
143- if (!selection .isEmpty () && isProjectSelection && !ResourcesPlugin .getWorkspace ().isAutoBuilding ()
137+ if (!selection .isEmpty () && !ResourcesPlugin .getWorkspace ().isAutoBuilding ()
144138 && hasBuilder ) {
145139 // Allow manual incremental build only if auto build is off.
146140 buildAction .selectionChanged (selection );
147141 menu .appendToGroup (ICommonMenuConstants .GROUP_BUILD , buildAction );
148142 }
149-
150143 // Add the 'refresh' item if ANY selection is either (a) an open project, or (b)
151144 // a non-project selection.
152145 // Put another way: the 'refresh' item is NOT shown if ALL selections are closed
@@ -155,18 +148,15 @@ public void fillContextMenu(IMenuManager menu) {
155148 refreshAction .selectionChanged (selection );
156149 menu .appendToGroup (ICommonMenuConstants .GROUP_BUILD , refreshAction );
157150 }
158-
159- if (isProjectSelection ) {
160- if (hasClosedProjects ) {
161- openProjectAction .selectionChanged (selection );
162- menu .appendToGroup (ICommonMenuConstants .GROUP_BUILD , openProjectAction );
163- }
164- if (hasOpenProjects ) {
165- closeProjectAction .selectionChanged (selection );
166- menu .appendToGroup (ICommonMenuConstants .GROUP_BUILD , closeProjectAction );
167- closeUnrelatedProjectsAction .selectionChanged (selection );
168- menu .appendToGroup (ICommonMenuConstants .GROUP_BUILD , closeUnrelatedProjectsAction );
169- }
151+ if (hasClosedProjects ) {
152+ openProjectAction .selectionChanged (selection );
153+ menu .appendToGroup (ICommonMenuConstants .GROUP_BUILD , openProjectAction );
154+ }
155+ if (hasOpenProjects ) {
156+ closeProjectAction .selectionChanged (selection );
157+ menu .appendToGroup (ICommonMenuConstants .GROUP_BUILD , closeProjectAction );
158+ closeUnrelatedProjectsAction .selectionChanged (selection );
159+ menu .appendToGroup (ICommonMenuConstants .GROUP_BUILD , closeUnrelatedProjectsAction );
170160 }
171161 }
172162
0 commit comments