Skip to content

Commit 1d4f3e6

Browse files
committed
Use SubMonintor in FileBufferOperationAction
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
1 parent a1fd060 commit 1d4f3e6

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileBufferOperationAction.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,15 @@ protected IStatus run(IProgressMonitor monitor) {
198198
}
199199

200200
protected final IPath[] generateLocations(IFile[] files, IProgressMonitor progressMonitor) {
201-
progressMonitor.beginTask(TextEditorMessages.FileBufferOperationAction_collectionFiles_label, files.length);
202-
try {
203-
Set<IPath> locations= new HashSet<>();
204-
for (IFile file : files) {
205-
IPath fullPath = file.getFullPath();
206-
if (isAcceptableLocation(fullPath))
207-
locations.add(fullPath);
208-
progressMonitor.worked(1);
209-
}
210-
return locations.toArray(new IPath[locations.size()]);
211-
212-
} finally {
213-
progressMonitor.done();
201+
SubMonitor subMonitor= SubMonitor.convert(progressMonitor, TextEditorMessages.FileBufferOperationAction_collectionFiles_label, files.length);
202+
Set<IPath> locations= new HashSet<>();
203+
for (IFile file : files) {
204+
IPath fullPath= file.getFullPath();
205+
if (isAcceptableLocation(fullPath))
206+
locations.add(fullPath);
207+
subMonitor.worked(1);
214208
}
209+
return locations.toArray(new IPath[locations.size()]);
215210
}
216211

217212
/**

0 commit comments

Comments
 (0)