下面列出了org.eclipse.core.runtime.jobs.Job#cancel ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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();
}
}
}
/**
* 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;
}
}
}
/**
* 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));
}
}
/**
* 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));
}
}
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);
}
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();
}
}
}
}
/**
* 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;
}
}
/**
* @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();
}
}
@Override
public void dispose() {
super.dispose();
// Cancel the filtering job if any
Job job = fFilteringJob;
if (job != null) {
job.cancel();
}
}
/**
* 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;
}
}
@Override
public boolean preShutdown() {
Job cliParsingJob = fCliParsingJob;
if (cliParsingJob != null) {
cliParsingJob.cancel();
}
return true;
}
@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());
}
/**
* 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
}
}
@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]);
}
}
/**
* 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;
}