void unknownProgress(IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor); while (hasMore()) { // Use 1% of the remaining space for each iteration processNext(subMonitor.setWorkRemaining(100).split(1)); } }
private void beginTaskImpl(String name, int totalWork) { if ((flags & SUPPRESS_BEGINTASK) == 0 && name != null) root.setTaskName(name); setWorkRemaining(totalWork); beginTaskCalled = true; }
@Override public void bundleChanged(BundleEvent event) { int eventType = event.getType(); if (eventType == BundleEvent.STARTED) { subMonitor.setWorkRemaining(5).worked(1); spinEventQueueToUpdateSplash(displayForStartupListener); } } }
@Override public void visit(IApiTypeRoot root) throws CoreException { this.monitor.setWorkRemaining(100).split(1); compareApiTypeRoot(root); }
private void createLinkedResources(PersistentModelBuilder persistentModel, SubMonitor progress) throws CoreException { progress.setWorkRemaining(this.resources.size()); Set<IPath> linkedPaths = Sets.newHashSet(); for (EclipseLinkedResource linkedFile : this.resources) { SubMonitor childProgress = progress.newChild(1); IResource file = createLinkedResource(linkedFile, childProgress); linkedPaths.add(file.getProjectRelativePath()); } persistentModel.linkedResources(linkedPaths); }
@Override public void visit(String packageName, IApiTypeRoot typeroot) { localMonitor.setWorkRemaining(100).split(1); try { compareApiTypeRoot(typeroot); } catch (CoreException e) { ApiPlugin.log(e); } } });
private void addNewMarkers(Collection<IPath> folderPaths, PersistentModelBuilder persistentModel, SubMonitor progress) throws CoreException { progress.setWorkRemaining(folderPaths.size()); for (IPath resourcePath : folderPaths) { IResource resource = this.workspaceProject.findMember(resourcePath); if (resource != null) { resource.setDerived(true, progress.newChild(1)); } else { progress.worked(1); } } persistentModel.derivedResources(folderPaths); }
private void removeOutdatedLinkedResources(PersistentModelBuilder persistentModel, SubMonitor progress) throws CoreException { PersistentModel previousModel = persistentModel.getPrevious(); Collection<IPath> linkedPaths = previousModel.isPresent() ? previousModel.getLinkedResources() : Collections.<IPath>emptyList(); progress.setWorkRemaining(linkedPaths.size()); for (IPath linkedPath : linkedPaths) { SubMonitor childProgress = progress.newChild(1); IResource linkedResource = this.project.findMember(linkedPath); if (shouldDelete(linkedResource)) { linkedResource.delete(false, childProgress); } } }
private void removePreviousMarkers(Collection<IPath> folderPaths, PersistentModelBuilder persistentModel, SubMonitor progress) throws CoreException { PersistentModel previousModel = persistentModel.getPrevious(); Collection<IPath> previouslyKnownPaths = previousModel.isPresent() ? previousModel.getDerivedResources() : Collections.<IPath>emptyList(); progress.setWorkRemaining(previouslyKnownPaths.size()); for (IPath resourcePath : previouslyKnownPaths) { IResource resource = this.workspaceProject.findMember(resourcePath); if (resource != null) { resource.setDerived(false, progress.newChild(1)); } else { progress.worked(1); } } }
private void fetch(IArtifactRepository[] repositories, IProgressMonitor mon) { SubMonitor monitor = SubMonitor.convert(mon, requestsToProcess.size()); for (int i = 0; i < repositories.length && !requestsToProcess.isEmpty() && !monitor.isCanceled(); i++) { IArtifactRequest[] requests = getRequestsForRepository(repositories[i]); publishDownloadEvent(new CollectEvent(CollectEvent.TYPE_REPOSITORY_START, repositories[i], provContext, requests)); IStatus dlStatus = repositories[i].getArtifacts(requests, monitor.newChild(requests.length)); publishDownloadEvent(new CollectEvent(CollectEvent.TYPE_REPOSITORY_END, repositories[i], provContext, requests)); if (dlStatus.getSeverity() == IStatus.CANCEL) return; filterUnfetched(); monitor.setWorkRemaining(requestsToProcess.size()); } }
private IProject addExistingEclipseProjectToWorkspace(EclipseProject project, IProjectDescription projectDescription, SubMonitor progress) throws CoreException { progress.setWorkRemaining(3); ProjectNameUpdater.ensureProjectNameIsFree(project, this.allProjects, progress.newChild(1)); IProject workspaceProject = CorePlugin.workspaceOperations().includeProject(projectDescription, ImmutableList.<String>of(), progress.newChild(1)); synchronizeOpenWorkspaceProject(project, workspaceProject, false, progress.newChild(1)); return workspaceProject; }
private void synchronizeNonWorkspaceProject(EclipseProject project, SubMonitor progress) throws CoreException { progress.setWorkRemaining(2); IProject workspaceProject; // check if an Eclipse project already exists at the location of the Gradle project to import Optional<IProjectDescription> projectDescription = CorePlugin.workspaceOperations().findProjectDescriptor(project.getProjectDirectory(), progress.newChild(1)); if (projectDescription.isPresent()) { workspaceProject = addExistingEclipseProjectToWorkspace(project, projectDescription.get(), progress.newChild(1)); } else { workspaceProject = addNewEclipseProjectToWorkspace(project, progress.newChild(1)); } this.newProjectHandler.afterProjectImported(workspaceProject); }
@Override public void runInToolingApi(CancellationTokenSource tokenSource, IProgressMonitor monitor) throws Exception { SubMonitor progress = SubMonitor.convert(monitor); progress.setWorkRemaining(2); CancellationToken token = tokenSource.token(); op1.runInToolingApi(tokenSource, progress.newChild(1)); if (monitor.isCanceled() && token.isCancellationRequested()) { throw new OperationCanceledException(); } op2.runInToolingApi(tokenSource, progress.newChild(1)); }
@Override public void run(IProgressMonitor monitor) throws CoreException { SubMonitor progress = SubMonitor.convert(monitor); progress.setTaskName("Importing root project"); progress.setWorkRemaining(3); File rootDir = ImportRootProjectOperation.this.buildConfiguration.getRootProjectDirectory(); verifyNoWorkspaceRootIsImported(rootDir, progress.newChild(1)); saveProjectConfiguration(ImportRootProjectOperation.this.buildConfiguration, rootDir, progress.newChild(1)); importRootProject(rootDir, progress.newChild(1)); } }, monitor);
private void setProjectNatures(IProject project, IFeatureModel model, SubMonitor subMonitor) throws CoreException { IProjectDescription desc = project.getDescription(); if (needsJavaNature(model)) { desc.setNatureIds(new String[] {JavaCore.NATURE_ID, PDE.FEATURE_NATURE}); } else { desc.setNatureIds(new String[] {PDE.FEATURE_NATURE}); } subMonitor.setWorkRemaining(1); project.setDescription(desc, subMonitor.split(1)); }
public void execute(IProgressMonitor monitor) { IPluginModelBase[] plugins = PluginJavaSearchUtil.getPluginImports(fImportID); SubMonitor subMonitor = SubMonitor.convert(monitor, PDEUIMessages.DependencyExtentOperation_searching + " " + fImportID + "...", 10); //$NON-NLS-1$//$NON-NLS-2$ checkForJavaDependencies(plugins, subMonitor.split(9)); subMonitor.setWorkRemaining(plugins.length); for (IPluginModelBase plugin : plugins) { checkForExtensionPointsUsed(plugin); subMonitor.worked(1); } }
private IProject addNewEclipseProjectToWorkspace(EclipseProject project, SubMonitor progress) throws CoreException { progress.setWorkRemaining(3); ProjectNameUpdater.ensureProjectNameIsFree(project, this.allProjects, progress.newChild(1)); IProject workspaceProject = CorePlugin.workspaceOperations().createProject(project.getName(), project.getProjectDirectory(), ImmutableList.<String>of(), progress.newChild(1)); synchronizeOpenWorkspaceProject(project, workspaceProject, false, progress.newChild(1)); return workspaceProject; }
private void uncoupleWorkspaceProjectFromGradle(IProject workspaceProject, SubMonitor monitor) { monitor.setWorkRemaining(4); monitor.subTask(String.format("Uncouple workspace project %s from Gradle", workspaceProject.getName())); CorePlugin.workspaceOperations().refreshProject(workspaceProject, monitor.newChild(1, SubMonitor.SUPPRESS_ALL_LABELS)); this.failures.addAll(this.configurators.unconfigureConfigurators(workspaceProject, monitor.newChild(1))); CorePlugin.workspaceOperations().removeNature(workspaceProject, GradleProjectNature.ID, monitor.newChild(1, SubMonitor.SUPPRESS_ALL_LABELS)); CorePlugin.configurationManager().deleteProjectConfiguration(workspaceProject); } }
public Map<URI, URI> renameAndTrack(Iterable<URI> renamedElementURIs, String newName, ResourceSet resourceSet, IRenameStrategy renameStrategy, IProgressMonitor monitor) { SubMonitor progress = SubMonitor.convert(monitor).setWorkRemaining(3); Map<EObject, URI> renamedElement2oldURI = resolveRenamedElements(renamedElementURIs, resourceSet); progress.worked(1); renameStrategy.applyDeclarationChange(newName, resourceSet); progress.worked(1); Map<URI, URI> old2newURI = relocateRenamedElements(renamedElement2oldURI); progress.worked(1); renameStrategy.revertDeclarationChange(resourceSet); return old2newURI; }
private void synchronizeJavaProjectInTransaction(final ProjectContext context, final EclipseProject model, final IProject project, PersistentModelBuilder persistentModel, SubMonitor progress) throws JavaModelException, CoreException { progress.setWorkRemaining(7); //old Gradle versions did not expose natures, so we need to add the Java nature explicitly CorePlugin.workspaceOperations().addNature(project, JavaCore.NATURE_ID, progress.newChild(1)); IJavaProject javaProject = JavaCore.create(project); OutputLocationUpdater.update(context, javaProject, model, progress.newChild(1)); SourceFolderUpdater.update(javaProject, ImmutableList.copyOf(model.getSourceDirectories()), progress.newChild(1)); LibraryFilter.update(javaProject, model, progress.newChild(1)); ClasspathContainerUpdater.update(javaProject, model, progress.newChild(1)); JavaSourceSettingsUpdater.update(javaProject, model, progress.newChild(1)); GradleClasspathContainerUpdater.updateFromModel(javaProject, model, this.locationToProject.values(), persistentModel, progress.newChild(1)); CorePlugin.externalLaunchConfigurationManager().updateClasspathProviders(project); }