use of org.eclipse.egit.core.op.GarbageCollectOperation in project egit by eclipse.
the class GarbageCollectCommand method execute.
/**
* Execute garbage collection
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// get selected nodes
final List<RepositoryNode> selectedNodes;
try {
selectedNodes = getSelectedNodes(event);
if (selectedNodes.isEmpty())
return null;
} catch (ExecutionException e) {
Activator.handleError(e.getMessage(), e, true);
return null;
}
Job job = new // $NON-NLS-1$
Job(// $NON-NLS-1$
"Collecting Garbage...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
for (RepositoryNode node : selectedNodes) {
Repository repo = node.getRepository();
String name = MessageFormat.format(UIText.GarbageCollectCommand_jobTitle, getRepositoryName(repo));
this.setName(name);
final GarbageCollectOperation op = new GarbageCollectOperation(repo);
try {
op.execute(monitor);
} catch (CoreException e) {
Activator.logError(MessageFormat.format(UIText.GarbageCollectCommand_failed, repo), e);
}
}
return Status.OK_STATUS;
}
};
IServiceLocator serviceLocator = HandlerUtil.getActiveSite(event);
if (serviceLocator != null) {
IWorkbenchSiteProgressService service = CommonUtils.getService(serviceLocator, IWorkbenchSiteProgressService.class);
service.schedule(job);
} else {
job.schedule();
}
return null;
}
Aggregations