private ILock getSaveLock() { if (saveLock == null) saveLock = Platform.getJobManager().newLock(); return saveLock; }
private ILock getLock() { if (lock == null) lock = Platform.getJobManager().newLock(); return lock; }
private void clearContextBusy(final IProgressMonitor monitor) { // Add a job change listener to the job manager that will clear the busy // when there are no more jobs related to the context running final IJobManager jobManager = Platform.getJobManager(); final IJobChangeListener listener = new JobChangeAdapter() { public void done(IJobChangeEvent event) { Job[] jobs = jobManager.find(getContext()); if (jobs.length == 0) { final IResourceDiffTree diffTree = getContext().getDiffTree(); diffTree.clearBusy(null); jobManager.removeJobChangeListener(this); } } }; jobManager.addJobChangeListener(listener); }
public void dispose() { if (mProfileRule != null) { Platform.getJobManager().endRule(mProfileRule); mProfileRule = null; } super.dispose(); }
private boolean isJobInFamilyRunning(Object family) { Job[] jobs = Platform.getJobManager().find(family); if (jobs != null && jobs.length > 0) { for (int i = 0; i < jobs.length; i++) { Job job = jobs[i]; if (job.getState() != Job.NONE) { return true; } } } return false; }
public void dispose() { if (profileRule != null) { Platform.getJobManager().endRule(profileRule); profileRule = null; } super.dispose(); }
private boolean isRefreshRunning() { return Platform.getJobManager().find(getConfiguration().getParticipant()).length > 0; }
public void checkConsistency(IProgressMonitor monitor) throws OperationCanceledException { if (!fNeedsConsistencyCheck) return; if (fUpdateJob.getState() == Job.RUNNING) { try { Platform.getJobManager().join(UpdateJob.FAMILY, monitor); } catch (OperationCanceledException e) { // Ignore and do the consistency check without // waiting for the update job. } catch (InterruptedException e) { // Ignore and do the consistency check without // waiting for the update job. } } if (!fNeedsConsistencyCheck) return; internalCheckConsistency(monitor); }
public void run() { IWorkspace workspace= ResourcesPlugin.getWorkspace(); ISchedulingRule rule= workspace.getRuleFactory().modifyRule(workspace.getRoot()); try { Platform.getJobManager().beginRule(rule, null); if (validateResources((FileSearchQuery) fPage.getInput().getQuery())) { ReplaceDialog2 dialog= new ReplaceDialog2(fSite.getShell(), fElements, fPage); dialog.open(); } } catch (OperationCanceledException e) { } finally { Platform.getJobManager().endRule(rule); } }
public void stop(BundleContext context) throws Exception { super.stop(context); ResourcesPlugin.getWorkspace().removeResourceChangeListener(J2EEComponentClasspathUpdater.getInstance()); try { org.eclipse.core.runtime.Platform.getJobManager().join( J2EEElementChangedListener.PROJECT_COMPONENT_UPDATE_JOB_FAMILY, new NullProgressMonitor() ); } catch (OperationCanceledException e) { Logger.getLogger().logError(e.getMessage()); } catch (InterruptedException e) { Logger.getLogger().logError(e.getMessage()); } }
public void initialize() { JSPIndexManager singleInstance = getInstance(); if (!singleInstance.initialized) { singleInstance.initialized = true; singleInstance.indexJobCoordinator = new IndexJobCoordinator(); singleInstance.jspResourceChangeListener = new JSPResourceChangeListener(); // added as JobChange listener so JSPIndexManager can be smarter // about when it runs Platform.getJobManager().addJobChangeListener(singleInstance.indexJobCoordinator); // add JSPIndexManager to keep JSP Index up to date // listening for IResourceChangeEvent.PRE_DELETE and // IResourceChangeEvent.POST_CHANGE ResourcesPlugin.getWorkspace().addResourceChangeListener(jspResourceChangeListener, IResourceChangeEvent.POST_CHANGE); // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5091 // makes sure IndexManager is aware of our indexes saveIndexes(); singleInstance.initializing = false; } }
Platform.getJobManager().beginRule(profileRule, null);
private void handleStopValidationButton() { IJobManager jobManager = Platform.getJobManager(); Job[] jobs = jobManager.find( ValidateWSDLJob.VALIDATE_WSDL_JOB_FAMILY ); ValidateWSDLJob existingValidateWSDLJob = null; if( jobs.length > 0 ) { for (int i=0; i<jobs.length; i++) { existingValidateWSDLJob = (ValidateWSDLJob)jobs[i]; if (existingValidateWSDLJob.getState() != Job.NONE) { existingValidateWSDLJob.cancel(); } } } clearValidationMessages(); setValidationInProgress(false); }
public IStatus connect() { /* * Cancel any jobs currently associated with this profile. Specifically, * we want to make sure any RefreshProfileJobs are cancelled to prevent * deadlock in the UI thread. */ Platform.getJobManager().cancel(this); Job connectJob = new ConnectJob(); connectJob.schedule(); try { connectJob.join(); } catch (InterruptedException e) { } return connectJob.getResult(); }
public IStatus disconnect() { /* * Cancel any jobs currently associated with this profile. Specifically, * we want to make sure any RefreshProfileJobs are cancelled to prevent * deadlock in the UI thread. */ Platform.getJobManager().cancel(this); Job disconnectJob = new DisconnectJob(); disconnectJob.schedule(); try { disconnectJob.join(); } catch (InterruptedException e) { } return disconnectJob.getResult(); }
public IStatus workOffline() { /* * Cancel any jobs currently associated with this profile. Specifically, * we want to make sure any RefreshProfileJobs are cancelled to prevent * deadlock in the UI thread. */ Platform.getJobManager().cancel(this); Job workOfflineJob = new WorkOfflineJob(); workOfflineJob.schedule(); try { workOfflineJob.join(); } catch (InterruptedException e) { } return workOfflineJob.getResult(); }
public void shutdown() { // stop listening ResourcesPlugin.getWorkspace().removeResourceChangeListener(jspResourceChangeListener); // stop any searching JSPSearchSupport.getInstance().setCanceled(true); // stop listening to jobs Platform.getJobManager().removeJobChangeListener(indexJobCoordinator); int maxwait = 5000; if (processFilesJob != null) { processFilesJob.cancel(); } // attempt to make sure this indexing job is litterally // done before continuing, since we are shutting down waitTillNotRunning(maxwait, processFilesJob); if (indexingJob != null) { indexingJob.cancel(); } waitTillNotRunning(maxwait, processFilesJob); }
IJobManager jobManager = Platform.getJobManager(); Job[] jobs = jobManager.find( ValidateWSDLJob.VALIDATE_WSDL_JOB_FAMILY ); ValidateWSDLJob existingValidateWSDLJob = null;
public IStatus validateInJob(final IValidationContext helper, final IReporter reporter) throws ValidationException { Job currentJob = Platform.getJobManager().currentJob(); ISchedulingRule rule = null; if (currentJob != null) { rule = currentJob.getRule(); } IWorkspaceRunnable validationRunnable = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { try { doValidate(helper, reporter); } catch (ValidationException e) { throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID_JSP_CORE, 0, PLUGIN_ID_JSP_CORE, e)); } } }; try { JavaCore.run(validationRunnable, rule, new NullProgressMonitor()); } catch (CoreException e) { if (e.getCause() instanceof ValidationException) { throw (ValidationException) e.getCause(); } throw new ValidationException(new LocalizedMessage(IMessage.ERROR_AND_WARNING, e.getMessage()), e); } return Status.OK_STATUS; } }
protected void doRefresh(IChangeDescription changeListener, IProgressMonitor monitor) throws CoreException { ISynchronizationContext context = ((ModelSynchronizeParticipant)getParticipant()).getContext(); try { context.getDiffTree().addDiffChangeListener((ChangeDescription)changeListener); // TODO: finer grained refresh context.refresh(mappings, monitor); // Wait for any asynchronous updating to complete try { Platform.getJobManager().join(context, monitor); } catch (InterruptedException e) { // Ignore } } finally { context.getDiffTree().removeDiffChangeListener((ChangeDescription)changeListener); } }