Search in sources :

Example 21 with SubMonitor

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();
        }
    }
}
Also used : IFileSystem(org.eclipse.core.filesystem.IFileSystem) SubMonitor(org.eclipse.core.runtime.SubMonitor) IFileStore(org.eclipse.core.filesystem.IFileStore)

Example 22 with SubMonitor

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);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) RPMProject(org.eclipse.linuxtools.rpm.core.RPMProject) SubMonitor(org.eclipse.core.runtime.SubMonitor)

Example 23 with SubMonitor

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);
            }
        }
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor)

Example 24 with SubMonitor

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);
            }
        }
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) URI(org.eclipse.emf.common.util.URI)

Example 25 with SubMonitor

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();
    }
}
Also used : SubMonitor(org.eclipse.core.runtime.SubMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException) ResourceDescriptor(aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)

Aggregations

SubMonitor (org.eclipse.core.runtime.SubMonitor)61 CoreException (org.eclipse.core.runtime.CoreException)27 IStatus (org.eclipse.core.runtime.IStatus)25 Status (org.eclipse.core.runtime.Status)24 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 IOException (java.io.IOException)12 IFile (org.eclipse.core.resources.IFile)10 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)10 InputStream (java.io.InputStream)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 IPath (org.eclipse.core.runtime.IPath)9 IProject (org.eclipse.core.resources.IProject)8 File (java.io.File)7 MultiStatus (org.eclipse.core.runtime.MultiStatus)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 IContainer (org.eclipse.core.resources.IContainer)4 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)4 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)4 URI (java.net.URI)3