use of org.eclipse.core.runtime.SubMonitor in project linuxtools by eclipse.
the class RemoteConnection method copyFileFromRemoteHost.
/**
* Copy a data from a path (can be a file or directory) from the remote host
* to the local host.
*
* @param remotePath The path to copy from.
* @param localPath The path to copy to.
* @param monitor The progress monitor.
* @throws CoreException If a problem during copy occurred.
*/
private void copyFileFromRemoteHost(String remotePath, String localPath, IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, 15);
try {
IFileSystem localFS = EFS.getLocalFileSystem();
IFileStore localFile = localFS.getStore(Path.fromOSString(localPath));
IFileStore rmtFile = rmtFileProxy.getResource(remotePath);
rmtFile.copy(localFile, EFS.OVERWRITE, progress);
} finally {
if (monitor != null) {
monitor.done();
}
}
}
use of org.eclipse.core.runtime.SubMonitor in project linuxtools by eclipse.
the class SRPMImportOperation method run.
/**
* @see org.eclipse.jface.operation.IRunnableWithProgress#run(IProgressMonitor)
*
* Perform the import of SRPM import. Call the build class incrementally
*/
@Override
public void run(IProgressMonitor progressMonitor) {
// Total number of work steps needed
int totalWork = 3;
rpmErrorTable = new ArrayList<>();
// $NON-NLS-1$
progressMonitor.beginTask(// $NON-NLS-1$
Messages.getString("SRPMImportOperation.Starting"), totalWork);
// Try to create an instance of the build class.
try {
RPMProject rpmProject = new RPMProject(project, projectLayout);
progressMonitor.worked(1);
// $NON-NLS-1$
progressMonitor.setTaskName(Messages.getString("SRPMImportOperation.Importing_SRPM"));
if (sourceRPM != null) {
rpmProject.importSourceRPM(sourceRPM);
progressMonitor.worked(2);
} else if (remoteSRPM != null) {
SubMonitor submonitor = SubMonitor.convert(progressMonitor, 1);
rpmProject.importSourceRPM(remoteSRPM, submonitor);
progressMonitor.worked(2);
}
} catch (CoreException e) {
rpmErrorTable.add(e);
}
progressMonitor.worked(2);
}
use of org.eclipse.core.runtime.SubMonitor in project xtext-core by eclipse.
the class ReferenceFinder method findAllReferences.
@Override
public void findAllReferences(TargetURIs targetURIs, IResourceAccess resourceAccess, IResourceDescriptions indexData, Acceptor acceptor, IProgressMonitor monitor) {
if (!targetURIs.isEmpty()) {
Iterable<IResourceDescription> allResourceDescriptions = indexData.getAllResourceDescriptions();
SubMonitor subMonitor = SubMonitor.convert(monitor, size(allResourceDescriptions) / MONITOR_CHUNK_SIZE + 1);
IProgressMonitor useMe = subMonitor.newChild(1);
int i = 0;
for (IResourceDescription resourceDescription : allResourceDescriptions) {
if (subMonitor.isCanceled())
throw new OperationCanceledException();
IReferenceFinder languageSpecific = getLanguageSpecificReferenceFinder(resourceDescription.getURI());
languageSpecific.findReferences(targetURIs, resourceDescription, resourceAccess, acceptor, useMe);
i++;
if (i % MONITOR_CHUNK_SIZE == 0) {
useMe = subMonitor.newChild(1);
}
}
}
}
use of org.eclipse.core.runtime.SubMonitor in project xtext-core by eclipse.
the class ReferenceFinder method findReferences.
@Override
public void findReferences(TargetURIs targetURIs, Set<URI> candidates, IResourceAccess resourceAccess, IResourceDescriptions descriptions, Acceptor acceptor, IProgressMonitor monitor) {
if (!targetURIs.isEmpty() && !candidates.isEmpty()) {
SubMonitor subMonitor = SubMonitor.convert(monitor, targetURIs.size() / MONITOR_CHUNK_SIZE + 1);
IProgressMonitor useMe = subMonitor.newChild(1);
int i = 0;
for (URI candidate : candidates) {
if (subMonitor.isCanceled())
throw new OperationCanceledException();
IReferenceFinder languageSpecific = getLanguageSpecificReferenceFinder(candidate);
doFindReferencesWith(languageSpecific, targetURIs, candidate, resourceAccess, descriptions, acceptor, useMe);
i++;
if (i % MONITOR_CHUNK_SIZE == 0) {
useMe = subMonitor.newChild(1);
}
}
}
}
use of org.eclipse.core.runtime.SubMonitor in project bndtools by bndtools.
the class QueryJpmDependenciesRunnable method run.
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
SubMonitor progress = SubMonitor.convert(monitor, 5);
progress.setTaskName("Querying dependencies...");
try {
Set<ResourceDescriptor> resources = repository.getResources(origin, true);
directResources = new HashSet<ResourceDescriptor>();
indirectResources = new HashSet<ResourceDescriptor>();
for (ResourceDescriptor resource : resources) {
if (resource.dependency)
indirectResources.add(resource);
else
directResources.add(resource);
}
progress.worked(5);
} catch (Exception e) {
error = "Error searching repository: " + e.getMessage();
}
}
Aggregations