|
18 | 18 | import java.lang.reflect.InvocationTargetException; |
19 | 19 | import java.net.URI; |
20 | 20 | import java.util.ArrayList; |
| 21 | +import java.util.Collections; |
21 | 22 | import java.util.Iterator; |
22 | 23 | import java.util.List; |
23 | 24 |
|
|
36 | 37 | import org.eclipse.core.runtime.Status; |
37 | 38 | import org.eclipse.core.runtime.SubMonitor; |
38 | 39 | import org.eclipse.core.runtime.jobs.ISchedulingRule; |
| 40 | +import org.eclipse.core.runtime.jobs.Job; |
39 | 41 | import org.eclipse.core.runtime.jobs.MultiRule; |
40 | 42 | import org.eclipse.jface.dialogs.IDialogConstants; |
41 | 43 | import org.eclipse.jface.dialogs.MessageDialog; |
@@ -217,36 +219,33 @@ final public void refreshAll() { |
217 | 219 |
|
218 | 220 | @Override |
219 | 221 | final protected IRunnableWithProgress createOperation(final IStatus[] errorStatus) { |
220 | | - ISchedulingRule rule = null; |
221 | | - IResourceRuleFactory factory = ResourcesPlugin.getWorkspace().getRuleFactory(); |
222 | | - |
223 | 222 | List<? extends IResource> actionResources = new ArrayList<>(getActionResources()); |
224 | 223 | if (shouldPerformResourcePruning()) { |
225 | 224 | actionResources = pruneResources(actionResources); |
226 | 225 | } |
227 | 226 | final List<? extends IResource> resources = actionResources; |
228 | 227 |
|
229 | | - Iterator<? extends IResource> res = resources.iterator(); |
230 | | - while (res.hasNext()) { |
231 | | - rule = MultiRule.combine(rule, factory.refreshRule(res.next())); |
232 | | - } |
233 | | - return new WorkspaceModifyOperation(rule) { |
| 228 | + return new IRunnableWithProgress() { |
234 | 229 | @Override |
235 | | - public void execute(IProgressMonitor mon) { |
236 | | - SubMonitor subMonitor = SubMonitor.convert(mon, resources.size()); |
237 | | - MultiStatus errors = null; |
| 230 | + public void run(IProgressMonitor mon) { |
| 231 | + SubMonitor subMonitor = SubMonitor.convert(mon); |
238 | 232 | subMonitor.setTaskName(getOperationMessage()); |
239 | | - Iterator<? extends IResource> resourcesEnum = resources.iterator(); |
240 | | - while (resourcesEnum.hasNext()) { |
| 233 | + List<IStatus> errors = Collections.synchronizedList(new ArrayList<>()); |
| 234 | + resources.parallelStream().forEach(resource -> { |
241 | 235 | try { |
242 | | - IResource resource = resourcesEnum.next(); |
243 | | - refreshResource(resource, subMonitor.split(1)); |
| 236 | + refreshResource(resource, null); |
244 | 237 | } catch (CoreException e) { |
245 | | - errors = recordError(errors, e); |
| 238 | + errors.add(e.getStatus()); |
246 | 239 | } |
247 | | - } |
248 | | - if (errors != null) { |
249 | | - errorStatus[0] = errors; |
| 240 | + }); |
| 241 | + |
| 242 | + if (!errors.isEmpty()) { |
| 243 | + MultiStatus multiStatus = new MultiStatus(IDEWorkbenchPlugin.IDE_WORKBENCH, IStatus.ERROR, |
| 244 | + getProblemsMessage(), null); |
| 245 | + for (IStatus s : errors) { |
| 246 | + multiStatus.merge(s); |
| 247 | + } |
| 248 | + errorStatus[0] = multiStatus; |
250 | 249 | } |
251 | 250 | } |
252 | 251 | }; |
@@ -287,29 +286,24 @@ protected void refreshResource(IResource resource, IProgressMonitor monitor) thr |
287 | 286 | public void run() { |
288 | 287 | final IStatus[] errorStatus = new IStatus[1]; |
289 | 288 | errorStatus[0] = Status.OK_STATUS; |
290 | | - final WorkspaceModifyOperation op = (WorkspaceModifyOperation) createOperation(errorStatus); |
291 | | - WorkspaceJob job = new WorkspaceJob("refresh") { //$NON-NLS-1$ |
| 289 | + final IRunnableWithProgress op = createOperation(errorStatus); |
| 290 | + Job job = new Job("refresh") { //$NON-NLS-1$ |
292 | 291 |
|
293 | 292 | @Override |
294 | | - public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { |
| 293 | + public IStatus run(IProgressMonitor monitor) { |
295 | 294 | try { |
296 | 295 | op.run(monitor); |
297 | 296 | } catch (InvocationTargetException e) { |
298 | | - String msg = NLS.bind( |
299 | | - IDEWorkbenchMessages.WorkspaceAction_logTitle, getClass() |
300 | | - .getName(), e.getTargetException()); |
301 | | - throw new CoreException(StatusUtil.newStatus(IStatus.ERROR, msg, e.getTargetException())); |
| 297 | + String msg = NLS.bind(IDEWorkbenchMessages.WorkspaceAction_logTitle, getClass().getName(), |
| 298 | + e.getTargetException()); |
| 299 | + return StatusUtil.newStatus(IStatus.ERROR, msg, e.getTargetException()); |
302 | 300 | } catch (InterruptedException e) { |
303 | 301 | return Status.CANCEL_STATUS; |
304 | 302 | } |
305 | 303 | return errorStatus[0]; |
306 | 304 | } |
307 | 305 |
|
308 | 306 | }; |
309 | | - ISchedulingRule rule = op.getRule(); |
310 | | - if (rule != null) { |
311 | | - job.setRule(rule); |
312 | | - } |
313 | 307 | job.setUser(true); |
314 | 308 | job.schedule(); |
315 | 309 | } |
|
0 commit comments