本文整理匯總了Java中org.eclipse.core.runtime.jobs.Job.create方法的典型用法代碼示例。如果您正苦於以下問題:Java Job.create方法的具體用法?Java Job.create怎麽用?Java Job.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.runtime.jobs.Job
的用法示例。
在下文中一共展示了Job.create方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: tryValidateManifest
import org.eclipse.core.runtime.jobs.Job; //導入方法依賴的package包/類
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();
}
}
}
示例2: executeRunnable
import org.eclipse.core.runtime.jobs.Job; //導入方法依賴的package包/類
private static void executeRunnable(String title, long delay, TimeUnit unit, ScheduledRunnable scheduled) {
Job job = Job.create(title, monitor -> {
scheduled.run();
return Status.OK_STATUS;
});
job.schedule(unit.toMillis(delay));
}
示例3: init
import org.eclipse.core.runtime.jobs.Job; //導入方法依賴的package包/類
@Inject @Optional
private void init(@UIEventTopic(TermSuiteEvents.EDITOR_INITIATED) Object part, MPart mPart) {
if(this == part) {
ETerminology terminology = (ETerminology)context.get(TermSuiteUI.INPUT_OBJECT);
terminology.eAdapters().add(new EContentAdapter() {
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
if(notification.getFeature().equals(TermsuiteuiPackage.eINSTANCE.getETerminology_Name())) {
mPart.setLabel(toPartLabel(terminology));
} else {
// set dirty
// dirty.setDirty(true);
}
}
});
final IndexedCorpus indexedCorpus = eTerminologyService.readTerminology(terminology);
context.set(IndexedCorpus.class, indexedCorpus);
context.set(Terminology.class, indexedCorpus.getTerminology());
final TerminologyService terminologyService = eTerminologyService.getTerminologyService(terminology);
context.set(TerminologyService.class, terminologyService);
Job job = Job.create("Open terminology", monitor -> {
sync.asyncExec(() -> viewer.setInput(terminologyService));
return Status.OK_STATUS;
});
job.schedule();
}
}
示例4: getPrepareCorpusJob
import org.eclipse.core.runtime.jobs.Job; //導入方法依賴的package包/類
@Override
public Job getPrepareCorpusJob(EPipeline pipeline, ESingleLanguageCorpus corpus) {
String jobName = String.format("Preprocessing corpus %s - %s (%d documents)",
corpus.getCorpus().getName(),
corpus.getLanguage().getName(),
context.get(CorpusService.class).getDocuments(corpus).size());
Job job = Job.create(jobName, monitor -> {
final int totalWork = 1000;
CorpusService corpusService = context.get(CorpusService.class);
final SubMonitor subMonitor = SubMonitor.convert(monitor, totalWork);
try {
IndexedCorpus preparedCorpus = TermSuite.preprocessor()
.setTagger(context.get(TaggerService.class).getTermSuiteTagger(pipeline))
.setTaggerPath(context.get(TaggerService.class).getTaggerPath(pipeline))
.setResourceOptions(resourceService.getResourceConfig(corpus.getLanguage()))
.setListener(new WorkbenchPipelineListener(subMonitor, sync, totalWork))
.toIndexedCorpus(
corpusService.asTxtCorpus(corpus),
MAX_SIZE);
// save preprocessed corpus to cache
Path cachePath = getCachePath(corpus, pipeline.getTaggerConfigName(), pipeline.getMaxNumTermsMemory());
IndexedCorpusIO.toJson(preparedCorpus, cachePath);
eventBroker.post(TermSuiteEvents.CORPUS_PREPROCESSED, preparedCorpus);
return Status.OK_STATUS;
} catch(Exception e) {
if(e.getCause() != null && e.getCause() instanceof OperationCanceledException)
return Status.CANCEL_STATUS;
else if(e.getCause() != null && e.getCause().getCause() != null && e.getCause().getCause() instanceof OperationCanceledException)
return Status.CANCEL_STATUS;
else
return new Status(Status.ERROR, TermSuiteUI.PLUGIN_ID, e.getMessage(), e);
} finally {
subMonitor.done();
}
});
job.setRule(Jobs.MUTEX_RULE);
job.setPriority(Job.BUILD);
return job;
}
示例5: execute
import org.eclipse.core.runtime.jobs.Job; //導入方法依賴的package包/類
@Execute
public void execute(
@Optional @Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
@Optional TerminologyService terminologyService,
@Optional ETerminologyService eTerminologyService,
ILoggerProvider loggerProvider,
UISynchronize sync,
@Optional ETerminology terminology,
IEventBroker broker,
@Optional IndexedCorpus indexedCorpus
) throws IOException {
FilterTerminologyDialog filterDialog = new FilterTerminologyDialog(shell);
if(filterDialog.open() == Dialog.OK){
Job job = Job.create("Filtering terminology " + TerminologyPart.toPartLabel(terminology), (monitor) -> {
new TerminologyFilterer(filterDialog.getFilterOptions()).filter(indexedCorpus);
});
job.addJobChangeListener(new JobChangeAdapter(){
@Override
public void done(IJobChangeEvent event) {
if(event.getResult().getSeverity() == Status.OK) {
try {
eTerminologyService.saveTerminologyJson(terminology, indexedCorpus, true, true);
broker.post(TermSuiteEvents.TERMINOLOGY_MODIFIED, terminology);
eTerminologyService.invalidateCaches(terminology);
} catch (IOException e) {
String message = "Failed to save terminology " + TerminologyPart.toPartLabel(terminology);
loggerProvider.getClassLogger(getClass()).error(e, message);
sync.asyncExec(() -> MessageDialog.openError(shell, "Error saving terminology: " + e.getMessage(), message));
}
}
super.done(event);
event.getJob().removeJobChangeListener(this);
}
});
job.schedule();
}
}