org.eclipse.core.runtime.jobs.IJobManager Java Examples
The following examples show how to use
org.eclipse.core.runtime.jobs.IJobManager.
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: TestLSPExtensions.java From corrosion with Eclipse Public License 2.0 | 6 votes |
@Test public void testBuildingMessages() { String jobType = "Building"; RLSClientImplementation clientImplementation = new RLSClientImplementation(); IJobManager jobManager = Job.getJobManager(); clientImplementation.progress(new ProgressParams(PROGRESS_ID_1, jobType)); waitUntilJobIsStarted(jobManager, jobType); Job rustJob = getRustDiagnosticsJob(jobManager, jobType); assertNotNull(rustJob); clientImplementation.progress(new ProgressParams(PROGRESS_ID_1, jobType, "rust_project", 0)); clientImplementation.progress(new ProgressParams(PROGRESS_ID_1, jobType, null, 50)); clientImplementation.progress(new ProgressParams(PROGRESS_ID_1, jobType, true)); waitUntilJobIsDone(jobManager, jobType); assertEquals(rustJob.getResult().getCode(), IStatus.OK); }
Example #2
Source File: BaseTest.java From codewind-eclipse with Eclipse Public License 2.0 | 6 votes |
public CodewindConnection getLocalConnection() throws Exception { TestUtil.print("Setting up a local connection"); // Check that Codewind is installed CodewindManager.getManager().refreshInstallStatus(new NullProgressMonitor()); if (!CodewindManager.getManager().getInstallStatus().isInstalled()) { installCodewind(); startCodewind(); } else if (!CodewindManager.getManager().getInstallStatus().isStarted()) { startCodewind(); } assertTrue("Codewind must be installed and started before the tests can be run", CodewindManager.getManager().getInstallStatus().isStarted()); // Get the local Codewind connection CodewindConnection conn = CodewindConnectionManager.getLocalConnection(); if (conn == null) { IJobManager jobManager = Job.getJobManager(); Job[] jobs = jobManager.find(CodewindConnectionManager.RESTORE_CONNECTIONS_FAMILY); for (Job job : jobs) { job.join(); } conn = CodewindConnectionManager.getLocalConnection(); } assertNotNull("The connection should not be null.", conn); return conn; }
Example #3
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (fgFirstTime) { // Join the initialize after load job. IJobManager manager= Job.getJobManager(); manager.join(JavaUI.ID_PLUGIN, monitor); } OpenTypeHistory history= OpenTypeHistory.getInstance(); if (fgFirstTime || history.isEmpty()) { if (history.needConsistencyCheck()) { monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 100); refreshSearchIndices(new SubProgressMonitor(monitor, 90)); history.checkConsistency(new SubProgressMonitor(monitor, 10)); } else { refreshSearchIndices(monitor); } monitor.done(); fgFirstTime= false; } else { history.checkConsistency(monitor); } }
Example #4
Source File: JobHelpers.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private static boolean flushProcessingQueues(IJobManager jobManager, IProgressMonitor monitor) throws InterruptedException, CoreException { boolean processed = false; for(IBackgroundProcessingQueue queue : getProcessingQueues(jobManager)) { queue.join(); if(!queue.isEmpty()) { Deque<MavenExecutionContext> context = MavenExecutionContext.suspend(); try { IStatus status = queue.run(monitor); if(!status.isOK()) { throw new CoreException(status); } processed = true; } finally { MavenExecutionContext.resume(context); } } if(queue.isEmpty()) { queue.cancel(); } } return processed; }
Example #5
Source File: XdsSourceBuilder.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
/** * Observes the state of the job and cancels the monitor on job cancelation * @param monitor */ private void cancelMonitorOnJobCancel(final IProgressMonitor monitor) { IJobManager jobMan = Job.getJobManager(); Job[] build = jobMan.find(BuilderUtils.BUILD_JOB_FAMILY); BuildJob buildJob = null; if (build.length == 1) { if (build[0] instanceof BuildJob) { buildJob = (BuildJob) build[0]; buildJob.addListener(new IJobListener() { @Override public void canceled() { monitor.setCanceled(true); } }); } } }
Example #6
Source File: IndexPlugin.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public void stop(BundleContext context) throws Exception { // grab any running indexing jobs IJobManager manager = Job.getJobManager(); Job[] jobs = manager.find(IndexRequestJob.INDEX_REQUEST_JOB_FAMILY); // ...and cancel them if (!ArrayUtil.isEmpty(jobs)) { for (Job job : jobs) { job.cancel(); } } fManager = null; plugin = null; super.stop(context); }
Example #7
Source File: TestLSPExtensions.java From corrosion with Eclipse Public License 2.0 | 5 votes |
@Test public void testIndexingMessages() { String jobType = "Indexing"; RLSClientImplementation clientImplementation = new RLSClientImplementation(); IJobManager jobManager = Job.getJobManager(); clientImplementation.progress(new ProgressParams(PROGRESS_ID_2, jobType)); waitUntilJobIsStarted(jobManager, jobType); Job rustJob = getRustDiagnosticsJob(jobManager, jobType); assertNotNull(rustJob); clientImplementation.progress(new ProgressParams(PROGRESS_ID_2, jobType, true)); waitUntilJobIsDone(jobManager, jobType); assertEquals(rustJob.getResult().getCode(), IStatus.OK); }
Example #8
Source File: TestLSPExtensions.java From corrosion with Eclipse Public License 2.0 | 5 votes |
private static void waitUntilJobIsStarted(IJobManager jobManager, String jobType) { new DisplayHelper() { @Override protected boolean condition() { return getRustDiagnosticsJob(jobManager, jobType) != null; } }.waitForCondition(Display.getCurrent(), 5000); }
Example #9
Source File: TestLSPExtensions.java From corrosion with Eclipse Public License 2.0 | 5 votes |
private static void waitUntilJobIsDone(IJobManager jobManager, String jobType) { new DisplayHelper() { @Override protected boolean condition() { return getRustDiagnosticsJob(jobManager, jobType) == null; } }.waitForCondition(Display.getCurrent(), 5000); }
Example #10
Source File: TestLSPExtensions.java From corrosion with Eclipse Public License 2.0 | 5 votes |
private static Job getRustDiagnosticsJob(IJobManager jobManager, String jobType) { for (Job job : jobManager.find(null)) { if (jobType.equals(job.getName())) { return job; } } return null; }
Example #11
Source File: ProjectUtils.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** Identify all jobs that we know of that are related to building. */ private static Collection<Job> findPendingBuildJobs(IProject... projects) { Set<Job> jobs = new HashSet<>(); IJobManager jobManager = Job.getJobManager(); Collections.addAll(jobs, jobManager.find(ResourcesPlugin.FAMILY_MANUAL_BUILD)); Collections.addAll(jobs, jobManager.find(ResourcesPlugin.FAMILY_AUTO_BUILD)); // J2EEElementChangedListener.PROJECT_COMPONENT_UPDATE_JOB_FAMILY Collections.addAll(jobs, jobManager.find("org.eclipse.jst.j2ee.refactor.component")); // ServerPlugin.SHUTDOWN_JOB_FAMILY Collections.addAll(jobs, jobManager.find("org.eclipse.wst.server.core.family")); Collections.addAll(jobs, jobManager.find("org.eclipse.wst.server.ui.family")); Collections.addAll(jobs, jobManager.find(ValidationBuilder.FAMILY_VALIDATION_JOB)); Collections.addAll(jobs, jobManager.find(DependencyGraphImpl.GRAPH_UPDATE_JOB_FAMILY)); for (IProject project : projects) { Collections.addAll(jobs, jobManager.find(project.getName() + ValidatorManager.VALIDATOR_JOB_FAMILY)); } // some jobs are not part of a family for (Job job : jobManager.find(null)) { switch (job.getClass().getName()) { case "org.eclipse.wst.jsdt.web.core.internal.project.ConvertJob": case "org.eclipse.m2e.core.ui.internal.wizards.ImportMavenProjectsJob": case "org.eclipse.m2e.core.internal.project.registry.ProjectRegistryRefreshJob": jobs.add(job); break; default: break; } } return jobs; }
Example #12
Source File: JobHelpers.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static List<IBackgroundProcessingQueue> getProcessingQueues(IJobManager jobManager) { ArrayList<IBackgroundProcessingQueue> queues = new ArrayList<>(); for(Job job : jobManager.find(null)) { if(job instanceof IBackgroundProcessingQueue) { queues.add((IBackgroundProcessingQueue) job); } } return queues; }
Example #13
Source File: JobHelpers.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static void waitForWorkspaceJobsToComplete(IProgressMonitor monitor) throws InterruptedException { IJobManager jobManager = Job.getJobManager(); jobManager.suspend(); try { Job[] jobs = jobManager.find(null); for(int i = 0; i < jobs.length; i++ ) { if(jobs[i] instanceof WorkspaceJob || jobs[i].getClass().getName().endsWith("JREUpdateJob")) { jobs[i].join(); } } } finally { jobManager.resume(); } }
Example #14
Source File: JobPool.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
private JobPool(){ IJobManager jobman = Platform.getJobManager(); changeLock = jobman.newLock(); }
Example #15
Source File: ProjectImportedHasAstManagerTestWorkbench.java From Pydev with Eclipse Public License 1.0 | 4 votes |
public void testEditWithNoNature() throws Exception { NullProgressMonitor monitor = new NullProgressMonitor(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IPath workspaceLoc = root.getRawLocation(); IProject project = root.getProject("pydev_nature_pre_configured"); if (project.exists()) { project.delete(true, monitor); } //let's create its structure IPath projectLoc = workspaceLoc.append("pydev_nature_pre_configured"); projectLoc.toFile().mkdir(); writeProjectFile(projectLoc.append(".project")); writePydevProjectFile(projectLoc.append(".pydevproject")); File srcLocFile = projectLoc.append("src").toFile(); srcLocFile.mkdir(); assertTrue(!project.exists()); project.create(monitor); project.open(monitor); project.refreshLocal(IResource.DEPTH_INFINITE, monitor); IJobManager jobManager = Job.getJobManager(); jobManager.resume(); final PythonNature nature = (PythonNature) PythonNature.addNature(project, null, null, null, null, null, null); assertTrue(nature != null); //Let's give it some time to run the jobs that restore the nature goToIdleLoopUntilCondition(new ICallback<Boolean, Object>() { @Override public Boolean call(Object arg) { if (nature != null) { if (nature.getAstManager() != null) { return true; } } return false; } }); assertTrue(nature.getAstManager() != null); PythonPathHelper pythonPathHelper = (PythonPathHelper) nature.getAstManager().getModulesManager() .getPythonPathHelper(); List<String> lst = new ArrayList<String>(); lst.add(FileUtils.getFileAbsolutePath(srcLocFile)); assertEquals(lst, pythonPathHelper.getPythonpath()); }
Example #16
Source File: OpenTraceStressTest.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Main test case to test opening and closing of traces concurrently. */ @Test public void testOpenAndCloseConcurrency() { SWTBotUtils.createProject(TRACE_PROJECT_NAME); File fTestFile = new File(CtfTmfTestTraceUtils.getTrace(CTF_TRACE).getPath()); CtfTmfTestTraceUtils.dispose(CTF_TRACE); String path = fTestFile.getAbsolutePath(); assertNotNull(fTestFile); assumeTrue(fTestFile.exists()); /* * This opening and closing of traces will trigger several threads for analysis which * will be closed concurrently. There used to be a concurrency bug (447434) which should * be fixed by now and this test should run without any exceptions. * * Since the failure depends on timing it only happened sometimes before the bug fix * using this test. */ final MultiStatus status = new MultiStatus("lttn2.kernel.ui.swtbot.tests", IStatus.OK, null, null); IJobManager mgr = Job.getJobManager(); JobChangeAdapter changeListener = new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { Job job = event.getJob(); // Check for analysis failure String jobNamePrefix = NLS.bind(Messages.TmfAbstractAnalysisModule_RunningAnalysis, ""); if ((job.getName().startsWith(jobNamePrefix)) && (job.getResult().getSeverity() == IStatus.ERROR)) { status.add(job.getResult()); } } }; mgr.addJobChangeListener(changeListener); for (int i = 0; i < 10; i++) { SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); // Wait for editor so that threads have a chance to start workbenchbot.editorByTitle(fTestFile.getName()); workbenchbot.closeAllEditors(); if (!status.isOK()) { SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, workbenchbot); fail(handleErrorStatus(status)); } } SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, workbenchbot); }
Example #17
Source File: TestedWorkspaceWithJDT.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected void removeJobListener() { IJobManager jobManager = Job.getJobManager(); jobManager.removeJobChangeListener(listener); this.updateClasspathJob = null; }
Example #18
Source File: TestedWorkspaceWithJDT.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected void addJobListener() { IJobManager jobManager = Job.getJobManager(); jobManager.addJobChangeListener(listener); }
Example #19
Source File: CloudSdkManager.java From google-cloud-eclipse with Apache License 2.0 | 3 votes |
/** * Prevents potential future SDK auto-install or auto-update functionality to allow safely using * the managed Cloud SDK for some period of time. Blocks if an install or update is in progress. * Callers must call {@code CloudSdkManager#allowModifyingSdk} eventually to lift the suspension. * Any callers that intend to use {@code CloudSdk} must always call this before staring work, even * if the Cloud SDK preferences are configured not to auto-managed the SDK. * * <p>Must not be called from the UI thread, because the method can block. * * @see CloudSdkManager#allowModifyingSdk */ public void preventModifyingSdk() throws InterruptedException { do { IJobManager jobManager = Job.getJobManager(); // The join is to improve UI reporting of blocked jobs. Most of the waiting should be here. jobManager.join(CloudSdkModifyJob.CLOUD_SDK_MODIFY_JOB_FAMILY, null /* no monitor */); } while (!modifyLock.readLock().tryLock(10, TimeUnit.MILLISECONDS)); // We have acquired the read lock; all further install/update should be blocked, while others // can still grab a read lock and use the Cloud SDK. }