Skip to content

Commit

Permalink
Use SubMonintor in FileBufferOperationAction
Browse files Browse the repository at this point in the history
done() call not necessary here and convert can also show the label and
set the number of work unit.

See https://www.eclipse.org/articles/Article-Progress-Monitors/article.html
  • Loading branch information
vogella committed Dec 3, 2024
1 parent a1fd060 commit 1d4f3e6
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,15 @@ protected IStatus run(IProgressMonitor monitor) {
}

protected final IPath[] generateLocations(IFile[] files, IProgressMonitor progressMonitor) {
progressMonitor.beginTask(TextEditorMessages.FileBufferOperationAction_collectionFiles_label, files.length);
try {
Set<IPath> locations= new HashSet<>();
for (IFile file : files) {
IPath fullPath = file.getFullPath();
if (isAcceptableLocation(fullPath))
locations.add(fullPath);
progressMonitor.worked(1);
}
return locations.toArray(new IPath[locations.size()]);

} finally {
progressMonitor.done();
SubMonitor subMonitor= SubMonitor.convert(progressMonitor, TextEditorMessages.FileBufferOperationAction_collectionFiles_label, files.length);
Set<IPath> locations= new HashSet<>();
for (IFile file : files) {
IPath fullPath= file.getFullPath();
if (isAcceptableLocation(fullPath))
locations.add(fullPath);
subMonitor.worked(1);
}
return locations.toArray(new IPath[locations.size()]);
}

/**
Expand Down

0 comments on commit 1d4f3e6

Please sign in to comment.