private void tryValidateManifest(final IResourceDelta delta) { final String fullPath = delta.getFullPath().toString(); final URI folderUri = URI.createPlatformResourceURI(fullPath, true); final IN4JSProject project = core.findProject(folderUri).orNull(); if (null != project && project.exists()) { final URI manifestLocation = project.getManifestLocation().orNull(); if (null != manifestLocation) { final IFile manifest = delta.getResource().getProject().getFile(N4MF_MANIFEST); final ResourceSet resourceSet = core.createResourceSet(Optional.of(project)); final Resource resource = resourceSet.getResource(manifestLocation, true); final Job job = Job.create("", monitor -> { validatorExtension.updateValidationMarkers(manifest, resource, ALL, monitor); return OK_STATUS; }); job.setPriority(INTERACTIVE); job.schedule(); } } }
@Override public void configure() throws CoreException { IProjectDescription description = project.getDescription(); JPFManifestBuilder.addBuilderToProject(description); project.setDescription(description, null); JPFClasspathContainer.addToProject(JavaCore.create(project)); new Job("Check JPF Manifest") { @Override protected IStatus run(IProgressMonitor monitor) { try { project.build(IncrementalProjectBuilder.FULL_BUILD, JPFManifestBuilder.BUILDER_ID, null, monitor); } catch( CoreException e ) { JPFClasspathLog.logError(e); } return Status.OK_STATUS; } }.schedule(); }
public static void generateOffline(final IResource resource, IPackageFragment pkg, String classfile , BuildPolicy[] generators, int timeout, IWorkbenchWindow aww) { Job job = new Job("GW4E Offline Generation Source Job") { @Override public IStatus run(IProgressMonitor monitor) { try { if (resource instanceof IFile) { SubMonitor subMonitor = SubMonitor.convert(monitor, 120); IFile file = (IFile) resource; if (PreferenceManager.isGraphModelFile(file)) { AbstractPostConversion converter = getOfflineConversion(file,pkg,classfile,generators,timeout); ConversionRunnable runnable = converter.createConversionRunnable(aww); subMonitor.subTask("Processing converter "); SubMonitor child = subMonitor.split(1); runnable.run(child); } } } catch (Exception e) { e.printStackTrace(); ResourceManager.logException(e); } return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); }
/** * @param folder * @param filetorefresh * @return * @throws CoreException * @throws InterruptedException */ public static IResource resfreshFileInContainer(IContainer folder, String filetorefresh) throws CoreException, InterruptedException { final IResource buildfile = find(folder, filetorefresh); Job job = new WorkspaceJob("Refresh folders") { public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { if (buildfile != null && buildfile.exists()) { try { buildfile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); } catch (CoreException e) { ResourceManager.logException(e); } } return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); return buildfile; }
/** * @param file */ public static void updateBuildPolicyFileFor(IFile file) { Job job = new WorkspaceJob("Updating Build Policies from " + file.getName()) { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { ICompilationUnit compilationUnit = JavaCore.createCompilationUnitFrom(file); if (compilationUnit != null) { if (JDTManager.isGraphWalkerExecutionContextClass(compilationUnit)) { updateBuildPolicyFileForCompilatioUnit(compilationUnit); } } return Status.OK_STATUS; } }; job.setUser(true); job.setRule(file.getProject()); job.schedule(); }
/** * @param jobname * @param tasks * @return */ public static Job createJob(String jobname, List<UITask.Task> tasks) { Job job = new Job(jobname) { @Override protected IStatus run(IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor, tasks.size()); for (UITask.Task task : tasks) { try { subMonitor.setTaskName(task.getSummary()); workOnTask(task, subMonitor.split(1)); } catch (Exception e) { return Status.CANCEL_STATUS; } } return Status.OK_STATUS; } }; job.setUser(true); return job; }
public void apply() throws CoreException { Job job = new WorkspaceJob("GW4E Conversion Job") { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { try { _apply(monitor); } catch (Exception e) { DialogManager.displayErrorMessage(MessageUtil.getString("project_conversion"), MessageUtil.getString("an_error_has_occured_while_configuring_the_project"), e); ResourceManager.logException(e); } return Status.OK_STATUS; } }; job.setRule(testInterface.getJavaProject().getProject()); job.setUser(true); job.schedule(); }
/** * @param project * @param buildPolicyFile * @param graphFilePath * @param updatedGenerators * @throws IOException * @throws CoreException * @throws InterruptedException */ public static void update(IProject project, IFile buildPolicyFile, String graphFilePath, List<String> updatedGenerators) throws IOException, CoreException, InterruptedException { Job job = new WorkspaceJob("Updating policies") { public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { try { _update(project, buildPolicyFile, graphFilePath, updatedGenerators, monitor); } catch (FileNotFoundException e) { ResourceManager.logException(e); } return Status.OK_STATUS; } }; job.setRule(buildPolicyFile.getProject()); job.setUser(true); job.schedule(); }
private void executeJumpPageJob(String statusMessage, final Long pageNumberToJump) { Job job = new Job(statusMessage) { @Override protected IStatus run(IProgressMonitor monitor) { final StatusMessage status = dataViewerAdapter.jumpToPage(pageNumberToJump); dataViewLoader.updateDataViewLists(); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { refreshDataViewerWindow(status); DataViewerUtility.INSTANCE.resetSort(debugDataViewer); debugDataViewer.redrawTableCursor(); } }); return Status.OK_STATUS; } }; job.schedule(); }
@Test public void appEngineWebWithNoRuntime_Java7_Web25() throws CoreException, IOException, InterruptedException, SAXException { IFacetedProject project = projectCreator .withFacetVersions(JavaFacet.VERSION_1_7, WebFacetUtils.WEB_25).getFacetedProject(); createAppEngineWebWithNoRuntime(project); Job conversionJob = new AppEngineStandardProjectConvertJob(project); conversionJob.schedule(); conversionJob.join(); assertIsOk("conversion should never fail", conversionJob.getResult()); assertFacetVersions(project, JavaFacet.VERSION_1_7, WebFacetUtils.WEB_25, AppEngineStandardFacet.JRE7); assertNoJava8Runtime(project); }
@Test public void appEngineWebWithNoRuntime_Java8_Web25() throws CoreException, IOException, InterruptedException, SAXException { IFacetedProject project = projectCreator .withFacetVersions(JavaFacet.VERSION_1_8, WebFacetUtils.WEB_25).getFacetedProject(); createAppEngineWebWithNoRuntime(project); Job conversionJob = new AppEngineStandardProjectConvertJob(project); conversionJob.schedule(); conversionJob.join(); assertIsOk("conversion should never fail", conversionJob.getResult()); assertFacetVersions(project, JavaFacet.VERSION_1_7, WebFacetUtils.WEB_25, AppEngineStandardFacet.JRE7); assertNoJava8Runtime(project); }
@Test public void testIgnoreInnerPomChanges() throws Exception { IProject project = importMavenProject("archetyped"); assertEquals("The inner pom should not have been imported", 2, WorkspaceHelper.getAllProjects().size()); IFile innerPom = project.getFile("src/main/resources/archetype-resources/pom.xml"); preferences.setUpdateBuildConfigurationStatus(FeatureStatus.automatic); boolean[] updateTriggered = new boolean[1]; IJobChangeListener listener = new JobChangeAdapter() { @Override public void scheduled(IJobChangeEvent event) { if (event.getJob().getName().contains("Update project")) { updateTriggered[0] = true; } } }; try { Job.getJobManager().addJobChangeListener(listener); projectsManager.fileChanged(innerPom.getRawLocationURI().toString(), CHANGE_TYPE.CHANGED); waitForBackgroundJobs(); assertFalse("Update project should not have been triggered", updateTriggered[0]); } finally { Job.getJobManager().removeJobChangeListener(listener); } }
@Override public Image getDisplayImage() { int done = getPercentDone(); if (done > 0) { return super.getDisplayImage(); } if (isBlocked()) { return JFaceResources.getImage(ProgressManager.BLOCKED_JOB_KEY); } int state = getJob().getState(); if (state == Job.SLEEPING) { return JFaceResources.getImage(ProgressManager.SLEEPING_JOB_KEY); } if (state == Job.WAITING) { return JFaceResources.getImage(ProgressManager.WAITING_JOB_KEY); } //By default return the first progress image return super.getDisplayImage(); }
/** * Get the display string based on the current status and the name of the * job. * @param showProgress a boolean to indicate if we should * show progress or not. * * @return String */ private String getDisplayStringWithStatus(boolean showProgress) { if (isCanceled()) { return NLS.bind(ProgressMessages.JobInfo_Cancelled, (new Object[] { getJob().getName() })); } if (isBlocked()) { return NLS.bind(ProgressMessages.JobInfo_Blocked, (new Object[] { getJob().getName(), blockedStatus.getMessage() })); } if (getJob().getState() == Job.RUNNING) { TaskInfo info = getTaskInfo(); if (info == null) { return getJob().getName(); } return info.getDisplayString(showProgress); } if (getJob().getState() == Job.SLEEPING) { return NLS.bind(ProgressMessages.JobInfo_Sleeping, (new Object[] { getJob().getName() })); } return NLS.bind(ProgressMessages.JobInfo_Waiting, (new Object[] { getJob().getName() })); }
/** * Refreshes the local data for this TFS Repository. This will NOT contact * the server. * * @param async * <code>true</code> to refresh asynchronously, <code>false</code> * otherwise */ public void refreshLocal(final boolean async) { if (!async) { refreshLocal(new NullProgressMonitor()); } else { final String messageFormat = Messages.getString("TFSRepository.ProgressTextFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, workspace.getServerName()); final Job refreshJob = new Job(message) { @Override protected IStatus run(final IProgressMonitor monitor) { refreshLocal(monitor); return Status.OK_STATUS; } }; refreshJob.schedule(); } }
public static void runContainerResolverJob(IJavaProject javaProject) { IEclipseContext context = EclipseContextFactory.getServiceContext( FrameworkUtil.getBundle(BuildPath.class).getBundleContext()); final IEclipseContext childContext = context.createChild(LibraryClasspathContainerResolverJob.class.getName()); childContext.set(IJavaProject.class, javaProject); Job job = ContextInjectionFactory.make(LibraryClasspathContainerResolverJob.class, childContext); job.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { childContext.dispose(); } }); job.schedule(); }
private void convertGpeProject(URL zipFile) throws CoreException, IOException, InterruptedException { List<IProject> projects = ProjectUtils.importProjects(zipFile, false /* checkBuildErrors */, null); assertEquals(1, projects.size()); project = projects.get(0); IFacetedProject facetedProject = ProjectFacetsManager.create(project, true /* convert to faceted project if necessary */, null /* no monitor here */); Job conversionJob = new AppEngineStandardProjectConvertJob(facetedProject); conversionJob.schedule(); conversionJob.join(); assertTrue("conversion should not have failed", conversionJob.getResult().isOK()); // ensure facet versions haven't been downgraded assertEquals(JavaFacet.VERSION_1_7, facetedProject.getProjectFacetVersion(JavaFacet.FACET)); assertEquals(WebFacetUtils.WEB_25, facetedProject.getProjectFacetVersion(WebFacetUtils.WEB_FACET)); assertEquals(AppEngineStandardFacet.JRE7, facetedProject.getProjectFacetVersion(AppEngineStandardFacet.FACET)); }
@Override public CompletableFuture<List<? extends Location>> definition(TextDocumentPositionParams position) { logInfo(">> document/definition"); NavigateToDefinitionHandler handler = new NavigateToDefinitionHandler(this.preferenceManager); return computeAsync((cc) -> { IProgressMonitor monitor = toMonitor(cc); try { Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor); } catch (OperationCanceledException ignorable) { // No need to pollute logs when query is cancelled } catch (InterruptedException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } return handler.definition(position, toMonitor(cc)); }); }
static void suspendJob(Job job, long scheduleDelay) { if (!isConvertJob.apply(job)) { return; } synchronized (suspendedJobs) { if (!suspended.get()) { return; } } // cancel() must be done outside of our synchronization barrier as may trigger events // (and even scheduling other jobs) if (job.cancel()) { // Cancel should always succeed since the job is not running yet synchronized (suspendedJobs) { // check in case the situation has changed during the cancellation if (suspended.get()) { suspendedJobs.add(new SuspendedJob(job, scheduleDelay)); } else { // we've since been resumed, so reschedule this job right away job.schedule(scheduleDelay); } } } else { logger.log(Level.SEVERE, "job already running: " + job); } }
@Override public Object execute(ExecutionEvent event) { Job job = new Job("[y] Clean and Build") { @Override protected IStatus run(IProgressMonitor monitor) { IProject platform = ResourcesPlugin.getWorkspace().getRoot().getProject(PLATFORM_NAME); try { BuildUtils.refreshAndBuild(monitor, CFG_NAME, platform); monitor.done(); return Status.OK_STATUS; } catch (Exception e) { Activator.logError("Failed to synchronize with the platform, see workspace logs for more details", e); throw new IllegalStateException("Failed to synchronize with the platform", e); } } }; job.setUser(true); job.schedule(); return null; }
@Test public void appEngineWebWithJava8Runtime_Java8() throws CoreException, IOException, InterruptedException, SAXException { IFacetedProject project = projectCreator.withFacetVersions(JavaFacet.VERSION_1_8).getFacetedProject(); createAppEngineWebWithJava8Runtime(project); Job conversionJob = new AppEngineStandardProjectConvertJob(project); conversionJob.schedule(); conversionJob.join(); assertIsOk("conversion should never fail", conversionJob.getResult()); assertFacetVersions(project, JavaFacet.VERSION_1_8, WebFacetUtils.WEB_31, AppEngineStandardFacetChangeListener.APP_ENGINE_STANDARD_JRE8); assertJava8Runtime(project); }
@Override public CompletableFuture<List<? extends CodeLens>> codeLens(CodeLensParams params) { logInfo(">> document/codeLens"); CodeLensHandler handler = new CodeLensHandler(preferenceManager); return computeAsync((cc) -> { IProgressMonitor monitor = toMonitor(cc); try { Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor); } catch (OperationCanceledException ignorable) { // No need to pollute logs when query is cancelled } catch (InterruptedException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } return handler.getCodeLensSymbols(params.getTextDocument().getUri(), monitor); }); }
@Override public boolean performFinish() { final Configuration configuration = new Configuration(); configuration.setValue(TRACE_FILE, optionsPage.getTraceFile()); final Job job = new Job("Pipeling analysis with variable utilisation") { @Override protected IStatus run(IProgressMonitor monitor) { try { new InternalVariablePipeliningAnalysisCli().start(configuration, monitor); EclipseUtils.refreshWorkspace(monitor); } catch (TurnusException e) { Logger.error(e.getMessage()); } return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); return true; }
/** * Return the listeners for the job. * * @param job * @return Collection of IJobBusyListener */ @SuppressWarnings("unchecked") private Collection<IJobBusyListener> busyListenersForJob(Job job) { if (job.isSystem()) { return Collections.EMPTY_LIST; } synchronized (familyListeners) { if (familyListeners.isEmpty()) { return Collections.EMPTY_LIST; } Iterator<Object> families = familyListeners.keySet().iterator(); Collection<IJobBusyListener> returnValue = new HashSet<>(); while (families.hasNext()) { Object next = families.next(); if (job.belongsTo(next)) { Collection<IJobBusyListener> currentListeners = familyListeners .get(next); returnValue.addAll(currentListeners); } } return returnValue; } }
/** * Modifies the set of project facets in the configured project by performing the series of * configured facets actions. * * @param monitor a progress monitor, or null if progress reporting and cancellation are not desired * @throws CoreException if anything goes wrong while applying facet actions */ public void install(IProgressMonitor monitor) throws CoreException { SubMonitor subMonitor = SubMonitor.convert(monitor, 100); // Workaround deadlock bug described in Eclipse bug (https://bugs.eclipse.org/511793). // There are graph update jobs triggered by the completion of the CreateProjectOperation // above (from resource notifications) and from other resource changes from modifying the // project facets. So we force the dependency graph to defer updates try { IDependencyGraph.INSTANCE.preUpdate(); try { Job.getJobManager().join(DependencyGraphImpl.GRAPH_UPDATE_JOB_FAMILY, subMonitor.newChild(10)); } catch (OperationCanceledException | InterruptedException ex) { logger.log(Level.WARNING, "Exception waiting for WTP Graph Update job", ex); } facetedProject.modify(facetInstallSet, subMonitor.newChild(90)); } finally { IDependencyGraph.INSTANCE.postUpdate(); } }
@Test public void appEngineWebWithJava8Runtime_Java7_Web31() throws CoreException, IOException, InterruptedException, SAXException { IFacetedProject project = projectCreator .withFacetVersions(JavaFacet.VERSION_1_7, WebFacetUtils.WEB_31).getFacetedProject(); createAppEngineWebWithJava8Runtime(project); Job conversionJob = new AppEngineStandardProjectConvertJob(project); conversionJob.schedule(); conversionJob.join(); assertIsOk("conversion should never fail", conversionJob.getResult()); assertFacetVersions(project, JavaFacet.VERSION_1_8, WebFacetUtils.WEB_31, AppEngineStandardFacetChangeListener.APP_ENGINE_STANDARD_JRE8); assertJava8Runtime(project); }
/** * Update the receiver in the progress manager. If all of the jobs are * finished and the receiver is not being kept then remove it. */ private void updateInProgressManager() { Iterator<JobInfo> infoIterator = infos.iterator(); while (infoIterator.hasNext()) { JobInfo next = infoIterator.next(); if (!(next.getJob().getState() == Job.NONE)) { progressManager.refreshGroup(this); return; } } if (finishedJobs.isKept(this)) progressManager.refreshGroup(this); else progressManager.removeGroup(this); }
@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); }
@Override public boolean performFinish() { final Configuration configuration = new Configuration(); configuration.setValue(TRACE_FILE, optionsPage.getTraceFile()); configuration.setValue(ACTION_WEIGHTS, optionsPage.getWeightsFile()); final Job job = new Job("Algorithmic bottleneck analysis") { @Override protected IStatus run(IProgressMonitor monitor) { try { new AlgorithmicPartialCriticalPathAnalysisCli().start(configuration, monitor); EclipseUtils.refreshWorkspace(monitor); } catch (Exception e) { Logger.error(e.getMessage()); } return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); return true; }
public static void requestDump(final ICoverageLaunch launch) { new Job(UIMessages.DumpExecutionData_task) { @Override protected IStatus run(IProgressMonitor monitor) { try { final boolean reset = EclEmmaUIPlugin.getInstance() .getPreferenceStore() .getBoolean(UIPreferences.PREF_RESET_ON_DUMP); launch.requestDump(reset); } catch (CoreException e) { return EclEmmaStatus.DUMP_REQUEST_ERROR.getStatus(e); } return Status.OK_STATUS; } }.schedule(); }
@Override public void handleEvent(final Event event) { final TableViewer tableViewer = gui.getResultsTable().getTableViewer(); if (tableViewer != null && !tableViewer.getTable().isDisposed() && tableViewer.getStructuredSelection() != null) { final Earthquake selectedItem = (Earthquake) tableViewer.getStructuredSelection().getFirstElement(); if (selectedItem != null) { final String guid = selectedItem.getGuid(); final MapCanvas mapCanvas = gui.getMapCanvas(); final MapCache cache = mapCanvas.getCache(); if (mapCanvas.getDownloadMapJob() == null || mapCanvas.getDownloadMapJob().getState() == Job.NONE) { if (cache.contains(guid) && cache.get(guid).getEtag() != null) { mapCanvas.setDownloadMapJob(new DownloadMapJob(gui, selectedItem, cache.get(guid).getEtag())); } else { mapCanvas.setDownloadMapJob(new DownloadMapJob(gui, selectedItem)); } } mapCanvas.getDownloadMapJob().schedule(); } } }
/** * Schedules a task for background parsing that will be started after a delay. */ public void parse(final String contents, final eu.hyvar.feature.mapping.resource.hymapping.IHymappingTextResource resource, final eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingEditor editor, long delay) { if (resource == null) { return; } if (contents == null) { return; } // this synchronization is needed to avoid the creation of multiple tasks. without // the synchronization this could easily happen, when this method is accessed by // multiple threads. the creation of multiple tasks would imply that multiple // background parsing threads for one editor are created, which is not desired. synchronized (lock) { if (job == null || job.getState() != Job.RUNNING) { // schedule new task job = new ParsingJob(); job.resource = resource; job.editor = editor; job.newContents = contents; job.schedule(); } else { job.newContents = contents; } } }
@Test public void testDidOpenNotOnClasspath() throws Exception { importProjects("eclipse/hello"); IProject project = WorkspaceHelper.getProject("hello"); URI uri = project.getFile("nopackage/Test2.java").getRawLocationURI(); ICompilationUnit cu = JDTUtils.resolveCompilationUnit(uri); String source = FileUtils.readFileToString(FileUtils.toFile(uri.toURL())); openDocument(cu, source, 1); Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor); assertEquals(project, cu.getJavaProject().getProject()); assertEquals(source, cu.getSource()); List<PublishDiagnosticsParams> diagnosticReports = getClientRequests("publishDiagnostics"); assertEquals(1, diagnosticReports.size()); PublishDiagnosticsParams diagParam = diagnosticReports.get(0); assertEquals(1, diagParam.getDiagnostics().size()); closeDocument(cu); Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor); diagnosticReports = getClientRequests("publishDiagnostics"); assertEquals(2, diagnosticReports.size()); diagParam = diagnosticReports.get(1); assertEquals(0, diagParam.getDiagnostics().size()); }
@Test public void appEngineWebWithNoRuntime_Java7_Web31() throws CoreException, IOException, InterruptedException, SAXException { IFacetedProject project = projectCreator .withFacetVersions(JavaFacet.VERSION_1_7, WebFacetUtils.WEB_31).getFacetedProject(); createAppEngineWebWithNoRuntime(project); Job conversionJob = new AppEngineStandardProjectConvertJob(project); conversionJob.schedule(); conversionJob.join(); assertIsOk("conversion should never fail", conversionJob.getResult()); assertFacetVersions(project, JavaFacet.VERSION_1_7, WebFacetUtils.WEB_25, AppEngineStandardFacet.JRE7); assertNoJava8Runtime(project); }
@Test public void appEngineWebWithNoRuntime_Java8_Web31() throws CoreException, IOException, InterruptedException, SAXException { IFacetedProject project = projectCreator .withFacetVersions(JavaFacet.VERSION_1_8, WebFacetUtils.WEB_31).getFacetedProject(); createAppEngineWebWithNoRuntime(project); Job conversionJob = new AppEngineStandardProjectConvertJob(project); conversionJob.schedule(); conversionJob.join(); assertIsOk("conversion should never fail", conversionJob.getResult()); assertFacetVersions(project, JavaFacet.VERSION_1_7, WebFacetUtils.WEB_25, AppEngineStandardFacet.JRE7); assertNoJava8Runtime(project); }
@Override public CompletableFuture<CodeLens> resolveCodeLens(CodeLens unresolved) { logInfo(">> codeLens/resolve"); CodeLensHandler handler = new CodeLensHandler(preferenceManager); return computeAsync((cc) -> { IProgressMonitor monitor = toMonitor(cc); try { Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor); } catch (OperationCanceledException ignorable) { // No need to pollute logs when query is cancelled } catch (InterruptedException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } return handler.resolve(unresolved, monitor); }); }
private final void refreshBackground(final IResource[] resources) { new Job(Messages.getString("SynchronizeSubscriber.ExaminingSynchronizationState")) //$NON-NLS-1$ { @Override protected IStatus run(final IProgressMonitor monitor) { try { refresh(resources, IResource.DEPTH_INFINITE, monitor); return Status.OK_STATUS; } catch (final CoreException e) { log.warn(Messages.getString("SynchronizeSubscriber.CouldNotRefreshSynchronizationState"), e); //$NON-NLS-1$ return new Status( IStatus.ERROR, TFSEclipseClientPlugin.PLUGIN_ID, 0, e.getLocalizedMessage(), null); } } }.schedule(); }
@Override public void run() { final TFSRepository repository = this.repository; final String messageFormat = Messages.getString("RefreshRepositoryPendingChangesAction.RefreshingPendingChangesJobFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, this.repository.getWorkspace().getName()); final Job refreshJob = new Job(message) { @Override protected IStatus run(final IProgressMonitor monitor) { repository.getPendingChangeCache().refresh(); CodeMarkerDispatch.dispatch(CODEMARKER_PENDING_CHANGES_VIEW_REFRESHED); return Status.OK_STATUS; } }; refreshJob.schedule(); }
private static void enableMavenNature(IProject newProject, IProgressMonitor monitor) throws CoreException { SubMonitor subMonitor = SubMonitor.convert(monitor, 30); // Workaround deadlock bug described in Eclipse bug (https://bugs.eclipse.org/511793). try { IDependencyGraph.INSTANCE.preUpdate(); try { Job.getJobManager().join(DependencyGraphImpl.GRAPH_UPDATE_JOB_FAMILY, subMonitor.newChild(8)); } catch (OperationCanceledException | InterruptedException ex) { logger.log(Level.WARNING, "Exception waiting for WTP Graph Update job", ex); } ResolverConfiguration resolverConfiguration = new ResolverConfiguration(); MavenPlugin.getProjectConfigurationManager().enableMavenNature(newProject, resolverConfiguration, subMonitor.newChild(20)); } finally { IDependencyGraph.INSTANCE.postUpdate(); } // M2E will cleverly set "target/<artifact ID>-<version>/WEB-INF/classes" as a new Java output // folder; delete the default old folder. newProject.getFolder("build").delete(true /* force */, subMonitor.newChild(2)); }
public void updateResults() { if (selectedBuildDefinition == null) { return; } String message; if (selectedBuildDefinition.getName() != null && !selectedBuildDefinition.getName().equals("*")) //$NON-NLS-1$ { final String messageFormat = Messages.getString("QueueEditorPage.QuerySpecificBuildQueueTextFormat"); //$NON-NLS-1$ message = MessageFormat.format(messageFormat, selectedBuildDefinition.getName()); } else { message = Messages.getString("QueueEditorPage.QueryAllBuildQueueText"); //$NON-NLS-1$ } final Job populateJob = new Job(message) { @Override protected IStatus run(final IProgressMonitor monitor) { query(selectedBuildDefinition, selectedQueueStatus, selectedBuildController, selectedUser, false); CodeMarkerDispatch.dispatch(QueueEditorPage.CODEMARKER_TABLE_UPDATED); return Status.OK_STATUS; } }; populateJob.setUser(false); populateJob.setPriority(Job.SHORT); populateJob.schedule(); }