Java Code Examples for org.eclipse.core.runtime.jobs.Job#cancel()

The following examples show how to use org.eclipse.core.runtime.jobs.Job#cancel() . 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: ModelEditor.java    From tlaplus with MIT License 6 votes vote down vote up
/**
  * Stops TLC
  */
 public void stop()
 {
     if (getModel().isRunning())
     {
         Job[] runningSpecJobs = Job.getJobManager().find(getModel().getLaunchConfiguration());
         for (int i = 0; i < runningSpecJobs.length; i++)
         {
             // send cancellations to all jobs...
             runningSpecJobs[i].cancel();
         }
     } else if (getModel().isRunningRemotely()) {
     	final Job[] remoteJobs = Job.getJobManager().find(getModel());
     	for (Job remoteJob : remoteJobs) {
	remoteJob.cancel();
}
     }
 }
 
Example 2
Source File: AbstractTimeGraphView.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Method to reset the view internal data for a given trace.
 *
 * When overriding this method make sure to call the super implementation.
 *
 * @param viewTrace
 *            trace to reset the view for.
 * @since 2.0
 */
protected void resetView(ITmfTrace viewTrace) {
    if (viewTrace == null) {
        return;
    }
    synchronized (fBuildJobMap) {
        for (ITmfTrace trace : getTracesToBuild(viewTrace)) {
            Job buildJob = fBuildJobMap.remove(trace);
            if (buildJob != null) {
                buildJob.cancel();
            }
        }
    }
    synchronized (fEntryListMap) {
        fEntryListMap.remove(viewTrace);
    }
    fViewContext.remove(viewTrace);
    fFiltersMap.remove(viewTrace);
    fMarkerEventSourcesMap.remove(viewTrace);
    if (viewTrace == fTrace) {
        if (fZoomThread != null) {
            fZoomThread.cancel();
            fZoomThread = null;
        }
    }
}
 
Example 3
Source File: AbstractSegmentStoreTableViewer.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Trace selected handler
 *
 * @param signal
 *            Different opened trace (on which segment store analysis as
 *            already been performed) has been selected
 */
@TmfSignalHandler
public void traceSelected(TmfTraceSelectedSignal signal) {
    ITmfTrace trace = signal.getTrace();
    if (trace != fTrace) {
        // Cancel the filtering job from the previous trace
        Job job = fFilteringJob;
        if (job != null) {
            job.cancel();
        }
    }
    fTrace = trace;
    if (trace != null) {
        setData(getSegmentStoreProvider(trace));
    }
}
 
Example 4
Source File: AbstractSegmentStoreTableViewer.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Trace opened handler
 *
 * @param signal
 *            New trace (on which segment store analysis has not been
 *            performed) is opened
 */
@TmfSignalHandler
public void traceOpened(TmfTraceOpenedSignal signal) {
    ITmfTrace trace = signal.getTrace();
    if (trace != fTrace) {
        // Cancel the filtering job from the previous trace
        Job job = fFilteringJob;
        if (job != null) {
            job.cancel();
        }
    }
    fTrace = trace;
    if (trace != null) {
        setData(getSegmentStoreProvider(trace));
    }
}
 
Example 5
Source File: IndexPlugin.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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 6
Source File: FindBugsJob.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void cancelSimilarJobs(FindBugsJob job) {
    if (job.getResource() == null) {
        return;
    }
    Job[] jobs = Job.getJobManager().find(FindbugsPlugin.class);
    for (Job job2 : jobs) {
        if (job2 instanceof FindBugsJob
                && job.getResource().equals(((FindBugsJob) job2).getResource())) {
            if (job2.getState() != Job.RUNNING) {
                job2.cancel();
            }
        }
    }
}
 
Example 7
Source File: TmfAbstractAnalysisModule.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Cancels the analysis if it is executing
 */
@Override
public final void cancel() {
    synchronized (syncObj) {
        Job job = fJob;
        if (job != null) {
            TmfCoreTracer.traceAnalysis(getId(), getTrace(), "cancelled by application"); //$NON-NLS-1$
            job.cancel();
            fAnalysisCancelled = true;
            setAnalysisCompleted();
        }
        fStarted = false;
    }
}
 
Example 8
Source File: TmfStatisticsViewer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param isGlobal
 *            if the job to remove is global or partial
 * @param jobTrace
 *            The trace
 */
void removeFromJobs(boolean isGlobal, ITmfTrace jobTrace) {
    Map<ITmfTrace, Job> updateJobs = isGlobal ? fUpdateJobsGlobal : fUpdateJobsPartial;
    Job job = updateJobs.remove(jobTrace);
    if (job != null) {
        job.cancel();
    }
}
 
Example 9
Source File: AbstractSegmentStoreTableViewer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void dispose() {
    super.dispose();
    // Cancel the filtering job if any
    Job job = fFilteringJob;
    if (job != null) {
        job.cancel();
    }
}
 
Example 10
Source File: AbstractSegmentStoreTableViewer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Trace closed handler
 *
 * @param signal
 *            Last opened trace was closed
 */
@TmfSignalHandler
public void traceClosed(TmfTraceClosedSignal signal) {
    ITmfTrace trace = fTrace;
    if (trace == signal.getTrace()) {
        // Cancel the filtering job
        Job job = fFilteringJob;
        if (job != null) {
            job.cancel();
        }
    }
    // Check if there is no more opened trace
    if (TmfTraceManager.getInstance().getActiveTrace() == null) {
        if (!getTableViewer().getTable().isDisposed()) {
            getTableViewer().setInput(null);
            getTableViewer().setItemCount(0);
            refresh();
        }

        ISegmentStoreProvider provider = getSegmentProvider();
        if ((provider != null)) {
            SegmentStoreProviderProgressListener listener = fListener;
            if (listener != null) {
                provider.removeListener(listener);
            }
        }
        fTrace = null;
    }
}
 
Example 11
Source File: ApplicationWorkbenchAdvisor.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean preShutdown() {
    Job cliParsingJob = fCliParsingJob;
    if (cliParsingJob != null) {
        cliParsingJob.cancel();
    }
    return true;
}
 
Example 12
Source File: JavaCompilationParticipant.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void cleanStarting(IJavaProject project) {
  // Cancel the current validation job.
  synchronized (this) {
    Job buildJob = validationJobs.get(project.getProject());
    if (buildJob != null) {
      buildJob.cancel();
    }
  }

  cleanBuildArtifacts(project.getProject());
}
 
Example 13
Source File: JobManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Stop background processing, and wait until the current job is completed before returning
 */
public void shutdown() {

	if (VERBOSE)
		Util.verbose("Shutdown"); //$NON-NLS-1$

	disable();
	discardJobs(null); // will wait until current executing job has completed
	Thread thread = this.processingThread;
	try {
		if (thread != null) { // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=31858
			synchronized (this) {
				this.processingThread = null; // mark the job manager as shutting down so that the thread will stop by itself
				notifyAll(); // ensure its awake so it can be shutdown
			}
			// in case processing thread is handling a job
			thread.join();
		}
		Job job = this.progressJob;
		if (job != null) {
			job.cancel();
			job.join();
		}
	} catch (InterruptedException e) {
		// ignore
	}
}
 
Example 14
Source File: AbstractSearchIndexResultPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void clear() {
    if (fContentProvider != null) {
        fContentProvider.clear();
        Job r = this.refreshJob;
        if (r != null) {
            r.cancel();
        }
        filterText.setText("");
        getViewer().setFilters(new ViewerFilter[0]);
    }
}
 
Example 15
Source File: TexlipseBuilder.java    From texlipse with Eclipse Public License 1.0 4 votes vote down vote up
/**
    * Build the project.
    * 
 * @see IncrementalProjectBuilder.build
 */
   @Override
protected IProject[] build(int kind, Map args,
        IProgressMonitor monitor) throws CoreException {

       final IProject project = getProject();
       final ProjectFileTracking fileTracking = new ProjectFileTracking(project);
       final OutputFileManager fileManager = new OutputFileManager(project, fileTracking);

       Object rebuild = TexlipseProperties.getSessionProperty(project,
               TexlipseProperties.FORCED_REBUILD);

       // Wait for all scheduled parser jobs, since they could change relevant
       // session properties
       for (Job parser : Job.getJobManager().find(TexDocumentModel.PARSER_FAMILY)) {
           int state = parser.getState();
           if (state == Job.WAITING || state == Job.SLEEPING) {
               // If waiting, run immediately
               parser.cancel();
               parser.schedule();
           }
           try {
               parser.join();
           } catch (InterruptedException e) {
           }
       }

       if (rebuild == null && fileManager.isUpToDate()) {
           return null;
       }

       BuilderRegistry.clearConsole();

       Object s = TexlipseProperties.getProjectProperty(project,
               TexlipseProperties.PARTIAL_BUILD_PROPERTY);
	if (s != null) {
		partialBuild(project, fileManager, monitor);
	} else {
		buildFile(project, null, fileManager, monitor);
	}

	TexlipseProperties.setSessionProperty(project,
	        TexlipseProperties.FORCED_REBUILD, null);

	return null;
}