/** * @see IProgressMonitor */ public void beginTask(String name, int totalWork) { if (this.progressMonitor != null) { this.progressMonitor.beginTask(name, totalWork); } } /*
/** * @see IProgressMonitor */ @Override public void beginTask(String name, int totalWork) { if (this.progressMonitor != null) { this.progressMonitor.beginTask(name, totalWork); } } /*
/** * @see IProgressMonitor */ public void beginTask(String name, int totalWork) { if (this.progressMonitor != null) { this.progressMonitor.beginTask(name, totalWork); } } /*
public void beginTask(String name, int totalWork) { monitor.beginTask(name, totalWork); }
private InstallableUnitDAG calculate( Map<IInstallableUnit, Set<IRequirement>> providers, Map<IRequirement, Set<IInstallableUnit>> requirements, SubMonitor monitor ) { monitor.beginTask( "", requirements.size() ); // don't ask why Map<IInstallableUnit, InstallableUnitInfo> result = new LinkedHashMap<IInstallableUnit, InstallableUnitInfo>(); for ( IInstallableUnit unit : roots ) { calculate( result, providers, requirements, unit, new LinkedList<IInstallableUnit>(), new LinkedHashSet<IInstallableUnit>(), monitor ); } return new InstallableUnitDAG( result ); }
@Override protected IStatus run(IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor, 0); try { subMonitor.beginTask(progressMessage, 0); process = new ProcessBuilder(command).start(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { CompletableFuture.runAsync(() -> { reader.lines().forEachOrdered(line -> logToConsole(line)); }); if (process.waitFor() != 0) { if (!subMonitor.isCanceled()) { AcutePlugin.showError(errorTitle, errorMessage); } return Status.CANCEL_STATUS; } } return Status.OK_STATUS; } catch (IOException e) { AcutePlugin.showError(errorTitle, errorMessage, e); return Status.CANCEL_STATUS; } catch (InterruptedException e) { AcutePlugin.showError(errorTitle, errorMessage, e); Thread.currentThread().interrupt(); return Status.CANCEL_STATUS; } }
@Override protected IStatus run(IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor); subMonitor.beginTask("Looking up " + name, 2); try { subMonitor.worked(1); result[0] = doFindSourceElements(name); } catch (CoreException e) { result[0] = e; } finally { subMonitor.done(); } return Status.OK_STATUS; } };
public void createReferenceUpdates(ElementRenameArguments elementRenameArguments, Iterable<IReferenceDescription> referenceDescriptions, IRefactoringUpdateAcceptor updateAcceptor, IProgressMonitor monitor) { SubMonitor progress = SubMonitor.convert(monitor, 100); progress.beginTask("Sort references by project", 1); Multimap<IProject, IReferenceDescription> project2references = sorter.sortByProject(referenceDescriptions); SubMonitor allProjectsProgress = progress.newChild(98).setWorkRemaining(project2references.keySet().size()); for (IProject project : project2references.keySet()) { if (allProjectsProgress.isCanceled()) break; Multimap<URI, IReferenceDescription> resource2references = sorter.sortByResource(project2references .get(project)); ResourceSet resourceSet = resourceSetProvider.get(project); StatusWrapper status = updateAcceptor.getRefactoringStatus(); createClusteredReferenceUpdates(elementRenameArguments, resource2references, resourceSet, updateAcceptor, status, allProjectsProgress.newChild(1)); } }
protected void deleteOutputFolderContents(IProject project, SubMonitor progress) throws CoreException { final Set<IResource> resourcesToDelete = new HashSet<>(); final IFolder outFolder = project.getFolder("target"); if (!outFolder.exists()) { return; } outFolder.accept(new IResourceVisitor() { @Override public boolean visit(IResource resource) throws CoreException { boolean isOutFolder = Objects.equals(outFolder, resource); if (!isOutFolder) { resourcesToDelete.add(resource); } return isOutFolder; } }); progress.beginTask("Delete existing Artifacts", resourcesToDelete.size()); for (IResource r : resourcesToDelete) { try { r.delete(IResource.FORCE, progress.newChild(1)); } catch (CoreException e) { SdkLog.warning("Unable to delete resource '{}'.", r.getFullPath().toOSString(), e); } } }
taskList.run(taskListState, monitor.newChild(0)); monitor.beginTask(Messages.TaskListIndex_task_rebuilding_index, taskListState.indexableTasks.size()); try { final IndexWriter writer = new IndexWriter(directory, TaskAnalyzer.instance(), true,
public static CloudFoundryOperations createExternalClientLogin(final String location, String userName, String password, boolean selfSigned, IProgressMonitor monitor) throws CoreException { SubMonitor progress = SubMonitor.convert(monitor); progress.beginTask("Connecting", IProgressMonitor.UNKNOWN); //$NON-NLS-1$ try { final CloudFoundryOperations client = createClient(location, userName, password, selfSigned); new ClientRequest<Void>(Messages.VALIDATING_CREDENTIALS) { @Override protected Void doRun(CloudFoundryOperations client, SubMonitor progress) throws CoreException { CloudFoundryLoginHandler operationsHandler = new CloudFoundryLoginHandler(client); int attempts = 5; operationsHandler.login(progress, attempts, CloudOperationsConstants.LOGIN_INTERVAL); return null; } @Override protected CloudFoundryOperations getClient(IProgressMonitor monitor) throws CoreException { return client; } }.run(monitor); return client; } catch (RuntimeException t) { throw CloudErrorUtil.checkServerCommunicationError(t); } finally { progress.done(); } }
for (Project project : projects) { SubMonitor mon = submon.newChild(10, 0); mon.beginTask("", 100); //TODO that is not exactly accurate, but at least it moves :-) String message = "Indexing {0}"; submon.setTaskName(MessageFormat.format(message, project.getName()));
public static void register(String location, String userName, String password, boolean selfSigned, IProgressMonitor monitor) throws CoreException { SubMonitor progress = SubMonitor.convert(monitor); progress.beginTask("Connecting", IProgressMonitor.UNKNOWN); //$NON-NLS-1$ try { CloudFoundryOperations client = createClient(location, userName, password, selfSigned); client.register(userName, password); } catch (RestClientException e) { throw CloudErrorUtil.toCoreException(e); } catch (RuntimeException e) { // try to guard against IOException in parsing response throw CloudErrorUtil.checkServerCommunicationError(e); } finally { progress.done(); } }
private void doRemoveProject(IProgressMonitor monitor) throws InvocationTargetException { // Test if the project is inside the workspace final boolean noProgressMonitor = this.currProjectLocation == null; final SubMonitor subMonitor = SubMonitor.convert(noProgressMonitor ? null : monitor, 3); subMonitor.beginTask(NewWizardMessages.NewJavaProjectWizardPageTwo_operation_remove, 3); try { try { final URI projLoc = this.currProject.getLocationURI(); final boolean removeContent = !this.keepContent && this.currProject.isSynchronized(IResource.DEPTH_INFINITE); if (!removeContent) { restoreExistingFolders(projLoc); } this.currProject.delete(removeContent, false, subMonitor.newChild(2)); restoreExistingFiles(projLoc, subMonitor.newChild(1)); } finally { // fIsAutobuild must be set CoreUtility.setAutoBuilding(this.isAutobuild.booleanValue()); this.isAutobuild = null; } } catch (CoreException e) { throw new InvocationTargetException(e); } finally { subMonitor.done(); this.currProject = null; this.keepContent = false; } }
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { Object[] projects = checkedset.toArray(new IProject[checkedset.size()]); IProject project = null; SubMonitor localmonitor = SubMonitor.convert(monitor); localmonitor.beginTask(IApiToolsConstants.EMPTY_STRING, projects.length); localmonitor.setTaskName(WizardMessages.ApiToolingSetupWizardPage_7); refactoring.resetRefactoring(); boolean remove = removecxml.getSelection(); CompositeChange pchange = null; for(int i = 0; i < projects.length; i++) { project = (IProject) projects[i]; pchange = new CompositeChange(project.getName()); refactoring.addChange(pchange); pchange.add(new ProjectUpdateChange(project)); localmonitor.subTask(MessageFormat.format(WizardMessages.ApiToolingSetupWizardPage_4, new String[] {project.getName()})); IResource cxml = project.findMember(IApiCoreConstants.COMPONENT_XML_NAME); if(cxml != null) { //collect the changes for doc createTagChanges(pchange, JavaCore.create(project), new File(cxml.getLocationURI())); if(remove) { pchange.add(new DeleteResourceChange(cxml.getFullPath(), true)); } } Util.updateMonitor(localmonitor, 1); } } };
public Change perform(IProgressMonitor pm) throws CoreException { SubMonitor localmonitor = SubMonitor.convert(pm); localmonitor.beginTask(IApiToolsConstants.EMPTY_STRING, 1); localmonitor.setTaskName(WizardMessages.ProjectUpdateChange_adding_nature_and_builder); IProjectDescription description = this.fProject.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length] = ApiPlugin.NATURE_ID; description.setNatureIds(newNatures); this.fProject.setDescription(description, localmonitor); IJavaProject javaProject = JavaCore.create(this.fProject); // make sure we get rid of the previous api description file ApiDescriptionManager.getManager().clean(javaProject, true, true); // we want a full build of the converted project next time a build is triggered if (ResourcesPlugin.getWorkspace().isAutoBuilding()) { Util.getBuildJob(new IProject[] { this.fProject }).schedule(); } else { /* * If autobuild is off, clear the last build state to force a full build of * this project on the next build. */ BuildState.setLastBuiltState(this.fProject, null); } Util.updateMonitor(localmonitor, 1); return null; } }
private IRepository<T> loadRepository(URI location, String suffix, String type, int flags, SubMonitor monitor) throws ProvisionException { IExtension[] providers = findMatchingRepositoryExtensions(suffix, type); // Loop over the candidates and return the first one that successfully loads monitor.beginTask(null, providers.length * 10); for (int i = 0; i < providers.length; i++) try { IRepository<T> repo = factoryLoad(location, providers[i], flags, monitor); if (repo != null) return repo; } catch (ProvisionException e) { if (e.getStatus().getCode() != ProvisionException.REPOSITORY_NOT_FOUND) throw e; } catch (OperationCanceledException e) { //always propagate cancelation throw e; } catch (Exception e) { //catch and log unexpected errors and move onto the next factory log("Unexpected error loading extension: " + providers[i].getUniqueIdentifier(), e); //$NON-NLS-1$ } catch (LinkageError e) { //catch and log unexpected errors and move onto the next factory log("Unexpected error loading extension: " + providers[i].getUniqueIdentifier(), e); //$NON-NLS-1$ } return null; }
private IRepository<T> loadRepository(URI location, String suffix, String type, int flags, SubMonitor monitor) throws ProvisionException { IExtension[] providers = findMatchingRepositoryExtensions(suffix, type); // Loop over the candidates and return the first one that successfully loads monitor.beginTask(null, providers.length * 10); for (int i = 0; i < providers.length; i++) try { IRepository<T> repo = factoryLoad(location, providers[i], flags, monitor); if (repo != null) return repo; } catch (ProvisionException e) { if (e.getStatus().getCode() != ProvisionException.REPOSITORY_NOT_FOUND) throw e; } catch (OperationCanceledException e) { //always propagate cancelation throw e; } catch (Exception e) { //catch and log unexpected errors and move onto the next factory log("Unexpected error loading extension: " + providers[i].getUniqueIdentifier(), e); //$NON-NLS-1$ } catch (LinkageError e) { //catch and log unexpected errors and move onto the next factory log("Unexpected error loading extension: " + providers[i].getUniqueIdentifier(), e); //$NON-NLS-1$ } return null; }
@Override public Change perform(IProgressMonitor pm) throws CoreException { SubMonitor localmonitor = SubMonitor.convert(pm); localmonitor.beginTask(IApiToolsConstants.EMPTY_STRING, 1); localmonitor.setTaskName(WizardMessages.ProjectUpdateChange_adding_nature_and_builder); IProjectDescription description = this.fProject.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length] = ApiPlugin.NATURE_ID; description.setNatureIds(newNatures); this.fProject.setDescription(description, localmonitor); IJavaProject javaProject = JavaCore.create(this.fProject); // make sure we get rid of the previous api description file ApiDescriptionManager.getManager().clean(javaProject, true, true); // we want a full build of the converted project next time a build is // triggered if (ResourcesPlugin.getWorkspace().isAutoBuilding()) { Util.getBuildJob(new IProject[] { this.fProject }).schedule(); } else { /* * If autobuild is off, clear the last build state to force a full * build of this project on the next build. */ BuildState.setLastBuiltState(this.fProject, null); } localmonitor.split(1); return null; } }
@Override public void run(IProgressMonitor monitor) throws CoreException { SubMonitor subMonitor = SubMonitor.convert(monitor); subMonitor.beginTask( NLS.bind(Messages.CloudBehaviourOperations_REFRESHING_APPS_AND_SERVICES, getBehaviour() .getCloudFoundryServer().getServer().getId()), 100); if (getModule() != null) { getBehaviour().updateCloudModuleWithInstances(getModule(), subMonitor.newChild(40)); } else { subMonitor.worked(40); } // Get updated list of cloud applications from the server List<CloudApplication> applications = getBehaviour().getApplications(subMonitor.newChild(20)); // update applications and deployments from server Map<String, CloudApplication> deployedApplicationsByName = new LinkedHashMap<String, CloudApplication>(); for (CloudApplication application : applications) { deployedApplicationsByName.put(application.getName(), application); } getBehaviour().getCloudFoundryServer().updateModules(deployedApplicationsByName); List<CloudService> services = getBehaviour().getServices(subMonitor.newChild(20)); ServerEventHandler.getDefault().fireServerEvent( new CloudRefreshEvent(getBehaviour().getCloudFoundryServer(), getModule(), CloudServerEvent.EVENT_SERVER_REFRESHED, services)); subMonitor.worked(20); } };