org.eclipse.core.runtime.SubMonitor Java Examples
The following examples show how to use
org.eclipse.core.runtime.SubMonitor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TraceValidateAndImportOperation.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Safely create a folder meant to receive extracted content by making sure * there is no name clash. */ private static IFolder safeCreateExtractedFolder(IFolder destinationFolder, IPath relativeContainerRelativePath, IProgressMonitor monitor) throws CoreException { SubMonitor subMonitor = SubMonitor.convert(monitor, 2); IFolder extractedFolder; String suffix = ""; //$NON-NLS-1$ int i = 2; while (true) { IPath fullPath = destinationFolder.getFullPath().append(relativeContainerRelativePath + ".extract" + suffix); //$NON-NLS-1$ IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(fullPath); if (!folder.exists()) { extractedFolder = folder; break; } suffix = "(" + i + ")"; //$NON-NLS-1$//$NON-NLS-2$ i++; } subMonitor.worked(1); TraceUtils.createFolder(extractedFolder, subMonitor.newChild(1)); return extractedFolder; }
Example #2
Source File: WebProjectUtil.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
/** * Create a file in the appropriate location for the project's {@code WEB-INF}. This * implementation respects the order and tags on the WTP virtual component model, creating the * file in the {@code <wb-resource>} with the {@code defaultRootSource} tag when present. This * method is typically used after ensuring the file does not exist with {@link * #findInWebInf(IProject, IPath)}. * * <p>See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=448544">Eclipse bug 448544</a> * for details of the {@code defaultRootSource} tag. * * @param project the hosting project * @param filePath the path of the file within the project's {@code WEB-INF} * @param contents the content for the file * @param overwrite if {@code true} then overwrite the file if it exists * @see #findInWebInf(IProject, IPath) */ public static IFile createFileInWebInf( IProject project, IPath filePath, InputStream contents, boolean overwrite, IProgressMonitor monitor) throws CoreException { IFolder webInfDir = findWebInfForNewResource(project); IFile file = webInfDir.getFile(filePath); SubMonitor progress = SubMonitor.convert(monitor, 2); if (!file.exists()) { ResourceUtils.createFolders(file.getParent(), progress.newChild(1)); file.create(contents, true, progress.newChild(1)); } else if (overwrite) { file.setContents(contents, IResource.FORCE | IResource.KEEP_HISTORY, progress.newChild(2)); } return file; }
Example #3
Source File: OtherUtil.java From codewind-eclipse with Eclipse Public License 2.0 | 6 votes |
public static void setLoglevels(String connectionName, String level, String conid, IProgressMonitor monitor) throws IOException, JSONException, TimeoutException { SubMonitor mon = SubMonitor.convert(monitor, NLS.bind(Messages.SetLogLevelTaskLabel, new String[] {connectionName, level}), 100); Process process = null; try { process = CLIUtil.runCWCTL(CLIUtil.GLOBAL_JSON_INSECURE, LOGLEVELS_CMD, new String[] {CLIUtil.CON_ID_OPTION, conid}, new String[] {level}); ProcessResult result = ProcessHelper.waitForProcess(process, 500, 300, mon); CLIUtil.checkResult(LOGLEVELS_CMD, result, true); JSONObject resultJson = new JSONObject(result.getOutput()); LogLevels logLevels = new LogLevels(resultJson); if (!logLevels.getCurrentLevel().equals(level)) { String msg = "The current log level is not what was requested, requested: " + level + ", actual: " + logLevels.getCurrentLevel(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Logger.logError(msg); throw new IOException(msg); //$NON-NLS-1$ } } finally { if (process != null && process.isAlive()) { process.destroy(); } } }
Example #4
Source File: UnifiedBuilder.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private void incrementalBuild(List<IBuildParticipant> participants, IResourceDelta delta, IProgressMonitor monitor) { try { SubMonitor sub = SubMonitor.convert(monitor, 100); ResourceCollector collector = new ResourceCollector(); delta.accept(collector); indexProjectBuildPaths(sub.newChild(25)); // Notify of the removed files removeFiles(participants, collector.removedFiles, sub.newChild(5)); // Now build the new/updated files buildFiles(participants, collector.updatedFiles, sub.newChild(70)); } catch (CoreException e) { IdeLog.logError(BuildPathCorePlugin.getDefault(), e); } }
Example #5
Source File: XtendProjectConfigurator.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { addNature(request.getProject(), XtextProjectHelper.NATURE_ID, monitor); OutputConfiguration config = new XtendOutputConfigurationProvider() .getOutputConfigurations().iterator().next(); List<MojoExecution> executions = getMojoExecutions(request, monitor); SubMonitor progress = SubMonitor.convert(monitor, executions.size()); for (MojoExecution execution : executions) { String goal = execution.getGoal(); if (goal.equals("compile")) { readCompileConfig(config, request, execution, progress.split(1)); } else if (goal.equals("testCompile")) { readTestCompileConfig(config, request, execution, progress.split(1)); } else if (goal.equals("xtend-install-debug-info")) { readDebugInfoConfig(config, request, execution, progress.split(1)); } else if (goal.equals("xtend-test-install-debug-info")) { readTestDebugInfoConfig(config, request, execution, progress.split(1)); } } writePreferences(config, request.getProject()); }
Example #6
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 6 votes |
@Override public void unconfigure(IProject project, IProgressMonitor monitor) throws CoreException { try { final SubMonitor mon = SubMonitor.convert(monitor, 4); final IProjectDescription description = project.getDescription(); final List<String> natures = new LinkedList<>(Arrays.asList(description.getNatureIds())); natures.remove(SARLEclipseConfig.XTEXT_NATURE_ID); natures.remove(SARLEclipseConfig.NATURE_ID); final String[] newNatures = natures.toArray(new String[natures.size()]); mon.worked(1); final IStatus status = ResourcesPlugin.getWorkspace().validateNatureSet(newNatures); mon.worked(1); if (status.getCode() == IStatus.OK) { description.setNatureIds(newNatures); project.setDescription(description, mon.newChild(1)); safeRefresh(project, mon.newChild(1)); } else { throw new CoreException(status); } } finally { monitor.done(); } }
Example #7
Source File: RegistryBuilderParticipant.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Builds all other registered (non-language specific) {@link IXtextBuilderParticipant}s. * * @param buildContext * the {@link IBuildContext}, must not be {@code null} * @param monitor * the {@link IProgressMonitor}, must not be {@code null} * @throws CoreException * caused by an {@link IXtextBuilderParticipant} */ protected void buildOtherParticipants(final IBuildContext buildContext, final IProgressMonitor monitor) throws CoreException { ImmutableList<IXtextBuilderParticipant> otherBuilderParticipants = getParticipants(); if (otherBuilderParticipants.isEmpty()) { return; } SubMonitor progress = SubMonitor.convert(monitor, otherBuilderParticipants.size()); progress.subTask(Messages.RegistryBuilderParticipant_InvokingBuildParticipants); for (final IXtextBuilderParticipant participant : otherBuilderParticipants) { if (progress.isCanceled()) { throw new OperationCanceledException(); } try { if (initializeParticipant(participant)) { participant.build(buildContext, progress.newChild(1)); } // CHECKSTYLE:CHECK-OFF IllegalCatchCheck we need to recover from any exception and continue the build } catch (Throwable throwable) { // CHECKSTYLE:CHECK-ON IllegalCatchCheck LOG.error("Error occurred during build of builder participant: " //$NON-NLS-1$ + participant.getClass().getName(), throwable); } } }
Example #8
Source File: RegistryUtil.java From codewind-eclipse with Eclipse Public License 2.0 | 6 votes |
public static List<RegistryInfo> listRegistrySecrets(String conid, IProgressMonitor monitor) throws IOException, JSONException, TimeoutException { SubMonitor mon = SubMonitor.convert(monitor, 100); Process process = null; try { process = CLIUtil.runCWCTL(CLIUtil.GLOBAL_JSON_INSECURE, REG_SECRET_LIST_CMD, new String[] {CLIUtil.CON_ID_OPTION, conid}); ProcessResult result = ProcessHelper.waitForProcess(process, 500, 60, mon.split(100)); CLIUtil.checkResult(REG_SECRET_LIST_CMD, result, true); JSONArray registryArray = new JSONArray(result.getOutput().trim()); List<RegistryInfo> registries = new ArrayList<RegistryInfo>(); for (int i = 0; i < registryArray.length(); i++) { registries.add(new RegistryInfo(registryArray.getJSONObject(i))); } return registries; } finally { if (process != null && process.isAlive()) { process.destroy(); } } }
Example #9
Source File: WarPublisher.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
public static IStatus[] publishWar(IProject project, IPath destination, IPath safeWorkDirectory, IProgressMonitor monitor) throws CoreException { Preconditions.checkNotNull(project, "project is null"); //$NON-NLS-1$ Preconditions.checkNotNull(destination, "destination is null"); //$NON-NLS-1$ Preconditions.checkArgument(!destination.isEmpty(), "destination is empty path"); //$NON-NLS-1$ Preconditions.checkNotNull(safeWorkDirectory, "safeWorkDirectory is null"); //$NON-NLS-1$ if (monitor.isCanceled()) { throw new OperationCanceledException(); } SubMonitor subMonitor = SubMonitor.convert(monitor, 100); subMonitor.setTaskName(Messages.getString("task.name.publish.war")); //$NON-NLS-1$ IModuleResource[] resources = flattenResources(project, safeWorkDirectory, subMonitor.newChild(10)); if (resources.length == 0) { IStatus error = StatusUtil.error(WarPublisher.class, project.getName() + " has no resources to publish"); //$NON-NLS-1$ return new IStatus[] {error}; } return PublishUtil.publishZip(resources, destination, subMonitor.newChild(90)); }
Example #10
Source File: CodewindSocket.java From codewind-eclipse with Eclipse Public License 2.0 | 6 votes |
boolean blockUntilFirstConnection(IProgressMonitor monitor) { SubMonitor mon = SubMonitor.convert(monitor, 2500); final int delay = 100; final int timeout = 2500; int waited = 0; while(!hasConnected && waited < timeout) { mon.split(100); try { Thread.sleep(delay); waited += delay; if (waited % (5 * delay) == 0) { Logger.log("Waiting for CodewindSocket initial connection"); //$NON-NLS-1$ } } catch(InterruptedException e) { Logger.logError(e); } if (mon.isCanceled()) { return false; } } Logger.log("CodewindSocket initialized in time ? " + hasConnected); //$NON-NLS-1$ return hasConnected; }
Example #11
Source File: FileEventHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private static WorkspaceEdit getRenameEdit(IJavaElement targetElement, String newName, IProgressMonitor monitor) throws CoreException { RenameSupport renameSupport = RenameSupport.create(targetElement, newName, RenameSupport.UPDATE_REFERENCES); if (renameSupport == null) { return null; } if (targetElement instanceof IPackageFragment) { ((RenamePackageProcessor) renameSupport.getJavaRenameProcessor()).setRenameSubpackages(true); } RenameRefactoring renameRefactoring = renameSupport.getRenameRefactoring(); RefactoringTickProvider rtp = renameRefactoring.getRefactoringTickProvider(); SubMonitor submonitor = SubMonitor.convert(monitor, "Creating rename changes...", rtp.getAllTicks()); CheckConditionsOperation checkConditionOperation = new CheckConditionsOperation(renameRefactoring, CheckConditionsOperation.ALL_CONDITIONS); checkConditionOperation.run(submonitor.split(rtp.getCheckAllConditionsTicks())); if (checkConditionOperation.getStatus().getSeverity() >= RefactoringStatus.FATAL) { JavaLanguageServerPlugin.logError(checkConditionOperation.getStatus().getMessageMatchingSeverity(RefactoringStatus.ERROR)); } Change change = renameRefactoring.createChange(submonitor.split(rtp.getCreateChangeTicks())); change.initializeValidationData(new NotCancelableProgressMonitor(submonitor.split(rtp.getInitializeChangeTicks()))); return ChangeUtil.convertToWorkspaceEdit(change); }
Example #12
Source File: UpdateCloudToolsEclipseProjectHandler.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IProject project = ProjectFromSelectionHelper.getFirstProject(event); if (!CloudToolsEclipseProjectUpdater.hasOldContainers(project)) { throw new ExecutionException(Messages.getString("project.appears.up.to.date")); //$NON-NLS-1$ } String jobName = Messages.getString("updating.project", project.getName()); //$NON-NLS-1$ Job updateJob = new WorkspaceJob(jobName) { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { return CloudToolsEclipseProjectUpdater.updateProject(project, SubMonitor.convert(monitor)); } }; updateJob.setRule(project.getWorkspace().getRoot()); updateJob.setUser(true); updateJob.schedule(); return null; }
Example #13
Source File: InstallUtil.java From codewind-eclipse with Eclipse Public License 2.0 | 6 votes |
public static ProcessResult startCodewind(String version, IProgressMonitor monitor) throws IOException, TimeoutException { SubMonitor mon = SubMonitor.convert(monitor, Messages.StartCodewindJobLabel, 100); Process process = null; try { CodewindManager.getManager().setInstallerStatus(InstallerStatus.STARTING); process = CLIUtil.runCWCTL(null, START_CMD, new String[] {TAG_OPTION, version}); ProcessResult result = ProcessHelper.waitForProcess(process, 500, getPrefs().getInt(CodewindCorePlugin.CW_START_TIMEOUT), mon.split(90)); return result; } finally { if (process != null && process.isAlive()) { process.destroy(); } CodewindManager.getManager().refreshInstallStatus(mon.isCanceled() ? new NullProgressMonitor() : mon.split(10)); CodewindManager.getManager().setInstallerStatus(null); } }
Example #14
Source File: InstallUtil.java From codewind-eclipse with Eclipse Public License 2.0 | 6 votes |
public static ProcessResult removeCodewind(String version, IProgressMonitor monitor) throws IOException, TimeoutException { SubMonitor mon = SubMonitor.convert(monitor, Messages.RemovingCodewindJobLabel, 100); Process process = null; try { CodewindManager.getManager().setInstallerStatus(InstallerStatus.UNINSTALLING); if (version != null) { process = CLIUtil.runCWCTL(null, REMOVE_CMD, new String[] {TAG_OPTION, version}); } else { process = CLIUtil.runCWCTL(null, REMOVE_CMD, null); } ProcessResult result = ProcessHelper.waitForProcess(process, 500, getPrefs().getInt(CodewindCorePlugin.CW_UNINSTALL_TIMEOUT), mon.split(90)); return result; } finally { if (process != null && process.isAlive()) { process.destroy(); } CodewindManager.getManager().refreshInstallStatus(mon.isCanceled() ? new NullProgressMonitor() : mon.split(10)); CodewindManager.getManager().setInstallerStatus(null); } }
Example #15
Source File: ResourceRelocationProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void executeParticipants(ResourceRelocationContext context, SubMonitor monitor) { List<? extends IResourceRelocationStrategy> strategies = strategyRegistry.getStrategies(); if (context.getChangeType() == ResourceRelocationContext.ChangeType.COPY) { context.getChangeSerializer().setUpdateRelatedFiles(false); } monitor.setWorkRemaining(strategies.size()); for (IResourceRelocationStrategy strategy : strategies) { try { monitor.split(1); strategy.applyChange(context); } catch (OperationCanceledException t) { issues.add(ERROR, "Operation was cancelled while applying resource changes", t); LOG.error(t.getMessage(), t); break; } } }
Example #16
Source File: AbstractProjectCreator.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override protected void execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { SubMonitor subMonitor = SubMonitor.convert(monitor, getCreateModelProjectMessage(), 2); try { final IProject project = createProject(subMonitor.newChild(1)); if (project == null) return; enhanceProject(project, subMonitor.newChild(1)); IFile modelFile = getModelFile(project); setResult(modelFile); } finally { subMonitor.done(); } }
Example #17
Source File: CloudToolsEclipseProjectNotifier.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Override public void earlyStartup() { workbench = PlatformUI.getWorkbench(); workspace = ResourcesPlugin.getWorkspace(); Job projectUpdater = new WorkspaceJob(Messages.getString("updating.projects.jobname")) { //$NON-NLS-1$ @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { SubMonitor progress = SubMonitor.convert(monitor, 40); progress.subTask(Messages.getString("searching.for.projects")); //$NON-NLS-1$ Collection<IProject> projects = findCandidates(progress.newChild(10)); if (projects.isEmpty()) { return Status.OK_STATUS; } projects = promptUser(projects, progress.newChild(5)); if (projects.isEmpty()) { return Status.OK_STATUS; } progress.subTask(Messages.getString("updating.projects")); //$NON-NLS-1$ return upgradeProjects(projects, progress.newChild(25)); } }; projectUpdater.setRule(workspace.getRoot()); projectUpdater.setUser(true); projectUpdater.schedule(500); }
Example #18
Source File: HybridProject.java From thym with Eclipse Public License 1.0 | 6 votes |
public void build(IProgressMonitor monitor, final String... buildOptions) throws CoreException{ ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(getProject()); try{ Job.getJobManager().beginRule(rule, monitor); SubMonitor sm = SubMonitor.convert(monitor); sm.setWorkRemaining(100); ErrorDetectingCLIResult status = getProjectCLI().build(sm.newChild(70),buildOptions).convertTo(ErrorDetectingCLIResult.class); getProject().refreshLocal(IResource.DEPTH_INFINITE, sm.newChild(30)); if(status.asStatus().getSeverity() == IStatus.ERROR){ throw new CoreException(status.asStatus()); } } finally { Job.getJobManager().endRule(rule); } }
Example #19
Source File: CloudToolsEclipseProjectNotifier.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
/** * Prompt the user to select the projects to upgrade. */ private Collection<IProject> promptUser(Collection<IProject> projects, SubMonitor progress) { Preconditions.checkArgument(!projects.isEmpty(), "no projects specified!"); // $NON-NLS-1$ //$NON-NLS-1$ progress.setBlocked(StatusUtil.info(this, Messages.getString("waiting.for.user"))); //$NON-NLS-1$ boolean[] proceed = new boolean[1]; workbench.getDisplay().syncExec(() -> { StringBuilder sb = new StringBuilder( Messages.getString("following.projects.must.be.updated")); //$NON-NLS-1$ sb.append("\n"); //$NON-NLS-1$ for (IProject project : projects) { sb.append("\n ").append(project.getName()); //$NON-NLS-1$ } sb.append("\n\n"); //$NON-NLS-1$ sb.append(Messages.getString("update.now")); //$NON-NLS-1$ proceed[0] = MessageDialog.openQuestion(getShell(), Messages.getString("cloud.tools.for.eclipse"), sb.toString()); //$NON-NLS-1$ }); progress.clearBlocked(); return proceed[0] ? projects : Collections.<IProject>emptyList(); }
Example #20
Source File: TracePackageImportOperation.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private IStatus deleteExistingTraces(IProgressMonitor progressMonitor) { for (TracePackageElement packageElement : fImportTraceElements) { TracePackageTraceElement traceElement = (TracePackageTraceElement) packageElement; if (!isFilesChecked(traceElement)) { continue; } TmfCommonProjectElement projectElement = getMatchingProjectElement(traceElement); try { if (projectElement instanceof TmfExperimentElement) { Display.getDefault().syncExec(() -> projectElement.closeEditors()); projectElement.deleteSupplementaryFolder(); projectElement.getResource().delete(true, SubMonitor.convert(progressMonitor)); } else if (projectElement instanceof TmfTraceElement) { ((TmfTraceElement) projectElement).delete(SubMonitor.convert(progressMonitor), true); } } catch (CoreException e) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.Messages.TracePackage_ErrorOperation, e); } } return Status.OK_STATUS; }
Example #21
Source File: AbstractSarlMavenTest.java From sarl with Apache License 2.0 | 6 votes |
@Override protected void createFolders(IProject project, SubMonitor subMonitor, Shell shell) throws CoreException { if (this.folders != null) { for (final String folderName : this.folders) { IPath path = Path.fromPortableString(folderName); IPath tmpPath = Path.EMPTY; for (String segment : path.segments()) { tmpPath = tmpPath.append(segment); IFolder folder = project.getFolder(tmpPath.toPortableString()); if (!folder.exists()) { folder.create(false, true, subMonitor.newChild(1)); } } } } }
Example #22
Source File: LaunchHelperTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Before public void setUp() { handler = new LaunchHelper() { @Override protected void launch(IServer server, String launchMode, SubMonitor progress) throws CoreException { // do nothing } @Override Collection<IServer> findExistingServers(IModule[] modules, boolean exact, SubMonitor progress) { if (serverToReturn != null) { return Collections.singleton(serverToReturn); } return super.findExistingServers(modules, exact, progress); } }; }
Example #23
Source File: XCodeBuild.java From thym with Eclipse Public License 1.0 | 5 votes |
@Override public void buildNow(IProgressMonitor monitor) throws CoreException { if (monitor.isCanceled()) { return; } SubMonitor sm = SubMonitor.convert(monitor, "Build project for iOS", 100); try { HybridProject hybridProject = HybridProject.getHybridProject(this.getProject()); if (hybridProject == null) { throw new CoreException(new Status(IStatus.ERROR, IOSCore.PLUGIN_ID, "Not a hybrid mobile project, can not generate files")); } String buildType = "--emulator"; if(isRelease()){ buildType = "--device"; } if (sm.isCanceled()) { return; } hybridProject.build(sm.split(90), "ios",buildType); String name = hybridProject.getAppName(); IFolder buildFolder = hybridProject.getProject().getFolder("platforms/ios/build"); IFolder artifactFolder = null; if(isRelease()){ artifactFolder = buildFolder.getFolder("device"); }else{ artifactFolder = buildFolder.getFolder("emulator"); } setBuildArtifact(new File(artifactFolder.getLocation().toFile(), name + ".app")); if (!getBuildArtifact().exists()) { throw new CoreException(new Status(IStatus.ERROR, IOSCore.PLUGIN_ID, "xcodebuild has failed: build artifact does not exist")); } } finally { sm.done(); } }
Example #24
Source File: AppEngineProjectDeployer.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** * @param optionalConfigurationFilesDirectory if not {@code null}, searches optional configuration * files (such as {@code cron.yaml}) in this directory and deploys them together */ public IStatus deploy(IPath stagingDirectory, Path credentialFile, DeployPreferences deployPreferences, IPath optionalConfigurationFilesDirectory, MessageConsoleStream stdoutOutputStream, IProgressMonitor monitor) { if (monitor.isCanceled()) { throw new OperationCanceledException(); } SubMonitor progress = SubMonitor.convert(monitor, 1); progress.setTaskName(Messages.getString("task.name.deploy.project")); //$NON-NLS-1$ try { List<File> files = computeDeployables(stagingDirectory, optionalConfigurationFilesDirectory); List<Path> deployables = new ArrayList<>(); for (File file : files) { deployables.add(file.toPath()); } DeployConfiguration configuration = DeployPreferencesConverter.toDeployConfiguration(deployPreferences, deployables); try { Deployment deployment = cloudSdkProcessWrapper.getAppEngineDeployment(credentialFile, stdoutOutputStream); deployment.deploy(configuration); } catch (AppEngineException ex) { return StatusUtil.error(this, "Error deploying project: " + ex.getMessage(), ex); } return cloudSdkProcessWrapper.getExitStatus(); } finally { progress.worked(1); } }
Example #25
Source File: JavaSearchHelper.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void search(URI uri, IProgressMonitor monitor) { int numResources = Iterables.size(resourceDescriptions.getAllResourceDescriptions()); SubMonitor subMonitor = SubMonitor.convert(monitor, numResources / 10); subMonitor.subTask("Find references in EMF resources"); try { int i = 0; for (IResourceDescription resourceDescription : resourceDescriptions.getAllResourceDescriptions()) { URI resourceURI = resourceDescription.getURI(); IResourceServiceProvider resourceServiceProvider = serviceProviderRegistry.getResourceServiceProvider(resourceURI); if(resourceServiceProvider != null) { IJavaSearchParticipation javaSearchParticipation = resourceServiceProvider .get(IJavaSearchParticipation.class); if(javaSearchParticipation == null || javaSearchParticipation.canContainJvmReferences(resourceURI)) searchIn(uri, resourceDescription); } if (++i % 10 == 0) { if (subMonitor.isCanceled()) { return; // not throwing OperationCanceledException, as the client in JDT doesn't seem to handle it properly } subMonitor.worked(1); } } for(ResourceSet resourceSet: projectToResourceSet.values()) { resourceSet.getResources().clear(); resourceSet.eAdapters().clear(); } } finally { subMonitor.done(); } }
Example #26
Source File: TsvBuilder.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 5 votes |
void checkTsv(final Collection<IFile> files, IProgressMonitor monitor) throws CoreException { final SubMonitor subMonitor = SubMonitor.convert(monitor, files.size() * 5); final ItemsXmlValidator validator = getValidator(); for (final IFile file : files) { if (subMonitor.isCanceled()) { throw new OperationCanceledException("TSV Check cancelled"); } subMonitor.subTask("Checking typesystem: " + file.getFullPath()); processResults(file, validator.analyze(file, subMonitor.newChild(4)), subMonitor.newChild(1)); } }
Example #27
Source File: EclipseExternalLibraryWorkspace.java From n4js with Eclipse Public License 1.0 | 5 votes |
private RegisterResult deregisterProjectsInternal(IProgressMonitor monitor, Set<FileURI> toBeDeleted, Set<FileURI> toBeWiped) { SubMonitor subMonitor = convert(monitor, 1); // Clean projects. Set<N4JSExternalProject> allProjectsToClean = getAllToBeCleaned(toBeDeleted); List<IProject> extPrjCleaned = new LinkedList<>(); if (!allProjectsToClean.isEmpty()) { extPrjCleaned.addAll(builder.clean(allProjectsToClean, subMonitor.split(1))); } Set<IProject> wsPrjAffected = newHashSet(); wsPrjAffected.addAll(collector.getWSProjectsDependendingOn(allProjectsToClean)); toBeWiped.addAll(toBeDeleted); wipeIndex(monitor, toBeWiped, allProjectsToClean); Set<FileURI> cleaned = Sets.newHashSet(); for (IProject cleanedExternal : extPrjCleaned) { cleaned.add(getProject(new EclipseProjectName(cleanedExternal.getName()).toN4JSProjectName()) .getSafeLocation()); } return new RegisterResult( cleaned, getURIs(wsPrjAffected.toArray(new IProject[0])), toBeWiped); }
Example #28
Source File: EclipseExternalIndexSynchronizer.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Call this method after the {@link ExternalLibraryWorkspace#updateState()} adapted the changes of the * {@code node_modules} folder. Due to this adaption, new folders are already represented as external projects and * can be build and added to the index. */ private void buildChangesIndex(IProgressMonitor monitor, Collection<LibraryChange> changeSet, RegisterResult cleanResults) { SubMonitor subMonitor = convert(monitor, 10); try { Set<FileURI> toBeUpdated = getToBeBuildProjects(changeSet); for (FileURI cleanedPrjLoc : cleanResults.externalProjectsDone) { ExternalProject project = externalLibraryWorkspace.getProject(cleanedPrjLoc); if (project != null) { toBeUpdated.add(cleanedPrjLoc); } } subMonitor.setTaskName("Building new projects..."); RegisterResult buildResult = externalLibraryWorkspace.registerProjects(subMonitor.split(9), toBeUpdated); printRegisterResults(buildResult, "built"); Set<SafeURI<?>> toBeScheduled = new HashSet<>(); toBeScheduled.addAll(cleanResults.affectedWorkspaceProjects); toBeScheduled.addAll(buildResult.affectedWorkspaceProjects); externalLibraryWorkspace.scheduleWorkspaceProjects(subMonitor.split(1), toBeScheduled); } finally { subMonitor.done(); } }
Example #29
Source File: Importer.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 5 votes |
private IProject importProject(IProgressMonitor monitor, Path path, double version) throws CoreException { final SubMonitor progress = SubMonitor.convert(monitor, 120); IProjectDescription description = ResourcesPlugin.getWorkspace().loadProjectDescription(path); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName()); project.create(description, progress.newChild(30)); fixProjectCompilerSettings(monitor, project, version); project.open(progress.newChild(30)); FixProjectsUtils.removeBuildersFromProject(progress.newChild(30), project); addHybrisNature(project, progress.newChild(30)); return project; }
Example #30
Source File: NativeBinaryExportOperation.java From thym with Eclipse Public License 1.0 | 5 votes |
@Override protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { SubMonitor sm = SubMonitor.convert(monitor); sm.setWorkRemaining(delegates.size()*10); for (AbstractNativeBinaryBuildDelegate delegate : delegates) { if(monitor.isCanceled()){ break; } delegate.setRelease(true); delegate.buildNow(sm.newChild(10)); try { File buildArtifact = delegate.getBuildArtifact(); File destinationFile = new File(destinationDir, buildArtifact.getName()); if(destinationFile.exists()){ String callback = overwriteQuery.queryOverwrite(destinationFile.toString()); if(IOverwriteQuery.NO.equals(callback)){ continue; } if(IOverwriteQuery.CANCEL.equals(callback)){ break; } } File artifact = delegate.getBuildArtifact(); if(artifact.isDirectory()){ FileUtils.copyDirectoryToDirectory(artifact, destinationDir); }else{ FileUtils.copyFileToDirectory(artifact, destinationDir); } sm.done(); } catch (IOException e) { HybridCore.log(IStatus.ERROR, "Error on NativeBinaryExportOperation", e); } } monitor.done(); }