本文整理汇总了Java中org.eclipse.core.runtime.jobs.Job类的典型用法代码示例。如果您正苦于以下问题:Java Job类的具体用法?Java Job怎么用?Java Job使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Job类属于org.eclipse.core.runtime.jobs包,在下文中一共展示了Job类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resfreshFileInContainer
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
/**
* @param folder
* @param filetorefresh
* @return
* @throws CoreException
* @throws InterruptedException
*/
public static IResource resfreshFileInContainer(IContainer folder, String filetorefresh)
throws CoreException, InterruptedException {
final IResource buildfile = find(folder, filetorefresh);
Job job = new WorkspaceJob("Refresh folders") {
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
if (buildfile != null && buildfile.exists()) {
try {
buildfile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException e) {
ResourceManager.logException(e);
}
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return buildfile;
}
示例2: updateBuildPolicyFileFor
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
/**
* @param file
*/
public static void updateBuildPolicyFileFor(IFile file) {
Job job = new WorkspaceJob("Updating Build Policies from " + file.getName()) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
ICompilationUnit compilationUnit = JavaCore.createCompilationUnitFrom(file);
if (compilationUnit != null) {
if (JDTManager.isGraphWalkerExecutionContextClass(compilationUnit)) {
updateBuildPolicyFileForCompilatioUnit(compilationUnit);
}
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.setRule(file.getProject());
job.schedule();
}
示例3: runContainerResolverJob
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
public static void runContainerResolverJob(IJavaProject javaProject) {
IEclipseContext context = EclipseContextFactory.getServiceContext(
FrameworkUtil.getBundle(BuildPath.class).getBundleContext());
final IEclipseContext childContext =
context.createChild(LibraryClasspathContainerResolverJob.class.getName());
childContext.set(IJavaProject.class, javaProject);
Job job =
ContextInjectionFactory.make(LibraryClasspathContainerResolverJob.class, childContext);
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
childContext.dispose();
}
});
job.schedule();
}
示例4: 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();
}
}
}
示例5: configure
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
@Override
public void configure() throws CoreException
{
IProjectDescription description = project.getDescription();
JPFManifestBuilder.addBuilderToProject(description);
project.setDescription(description, null);
JPFClasspathContainer.addToProject(JavaCore.create(project));
new Job("Check JPF Manifest")
{
@Override
protected IStatus run(IProgressMonitor monitor)
{
try
{
project.build(IncrementalProjectBuilder.FULL_BUILD, JPFManifestBuilder.BUILDER_ID, null, monitor);
}
catch( CoreException e )
{
JPFClasspathLog.logError(e);
}
return Status.OK_STATUS;
}
}.schedule();
}
示例6: generateOffline
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
public static void generateOffline(final IResource resource, IPackageFragment pkg, String classfile , BuildPolicy[] generators, int timeout, IWorkbenchWindow aww) {
Job job = new Job("GW4E Offline Generation Source Job") {
@Override
public IStatus run(IProgressMonitor monitor) {
try {
if (resource instanceof IFile) {
SubMonitor subMonitor = SubMonitor.convert(monitor, 120);
IFile file = (IFile) resource;
if (PreferenceManager.isGraphModelFile(file)) {
AbstractPostConversion converter = getOfflineConversion(file,pkg,classfile,generators,timeout);
ConversionRunnable runnable = converter.createConversionRunnable(aww);
subMonitor.subTask("Processing converter ");
SubMonitor child = subMonitor.split(1);
runnable.run(child);
}
}
} catch (Exception e) {
e.printStackTrace();
ResourceManager.logException(e);
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
}
示例7: createJob
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
/**
* @param jobname
* @param tasks
* @return
*/
public static Job createJob(String jobname, List<UITask.Task> tasks) {
Job job = new Job(jobname) {
@Override
protected IStatus run(IProgressMonitor monitor) {
SubMonitor subMonitor = SubMonitor.convert(monitor, tasks.size());
for (UITask.Task task : tasks) {
try {
subMonitor.setTaskName(task.getSummary());
workOnTask(task, subMonitor.split(1));
} catch (Exception e) {
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
};
job.setUser(true);
return job;
}
示例8: apply
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
public void apply() throws CoreException {
Job job = new WorkspaceJob("GW4E Conversion Job") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
try {
_apply(monitor);
} catch (Exception e) {
DialogManager.displayErrorMessage(MessageUtil.getString("project_conversion"), MessageUtil.getString("an_error_has_occured_while_configuring_the_project"), e);
ResourceManager.logException(e);
}
return Status.OK_STATUS;
}
};
job.setRule(testInterface.getJavaProject().getProject());
job.setUser(true);
job.schedule();
}
示例9: update
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
/**
* @param project
* @param buildPolicyFile
* @param graphFilePath
* @param updatedGenerators
* @throws IOException
* @throws CoreException
* @throws InterruptedException
*/
public static void update(IProject project, IFile buildPolicyFile, String graphFilePath,
List<String> updatedGenerators) throws IOException, CoreException, InterruptedException {
Job job = new WorkspaceJob("Updating policies") {
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
try {
_update(project, buildPolicyFile, graphFilePath, updatedGenerators, monitor);
} catch (FileNotFoundException e) {
ResourceManager.logException(e);
}
return Status.OK_STATUS;
}
};
job.setRule(buildPolicyFile.getProject());
job.setUser(true);
job.schedule();
}
示例10: executeJumpPageJob
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
private void executeJumpPageJob(String statusMessage, final Long pageNumberToJump) {
Job job = new Job(statusMessage) {
@Override
protected IStatus run(IProgressMonitor monitor) {
final StatusMessage status = dataViewerAdapter.jumpToPage(pageNumberToJump);
dataViewLoader.updateDataViewLists();
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
refreshDataViewerWindow(status);
DataViewerUtility.INSTANCE.resetSort(debugDataViewer);
debugDataViewer.redrawTableCursor();
}
});
return Status.OK_STATUS;
}
};
job.schedule();
}
示例11: appEngineWebWithNoRuntime_Java7_Web25
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
@Test
public void appEngineWebWithNoRuntime_Java7_Web25()
throws CoreException, IOException, InterruptedException, SAXException {
IFacetedProject project = projectCreator
.withFacetVersions(JavaFacet.VERSION_1_7, WebFacetUtils.WEB_25).getFacetedProject();
createAppEngineWebWithNoRuntime(project);
Job conversionJob = new AppEngineStandardProjectConvertJob(project);
conversionJob.schedule();
conversionJob.join();
assertIsOk("conversion should never fail", conversionJob.getResult());
assertFacetVersions(project, JavaFacet.VERSION_1_7, WebFacetUtils.WEB_25,
AppEngineStandardFacet.JRE7);
assertNoJava8Runtime(project);
}
示例12: appEngineWebWithNoRuntime_Java8_Web25
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
@Test
public void appEngineWebWithNoRuntime_Java8_Web25()
throws CoreException, IOException, InterruptedException, SAXException {
IFacetedProject project = projectCreator
.withFacetVersions(JavaFacet.VERSION_1_8, WebFacetUtils.WEB_25).getFacetedProject();
createAppEngineWebWithNoRuntime(project);
Job conversionJob = new AppEngineStandardProjectConvertJob(project);
conversionJob.schedule();
conversionJob.join();
assertIsOk("conversion should never fail", conversionJob.getResult());
assertFacetVersions(project, JavaFacet.VERSION_1_7, WebFacetUtils.WEB_25,
AppEngineStandardFacet.JRE7);
assertNoJava8Runtime(project);
}
示例13: testIgnoreInnerPomChanges
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
@Test
public void testIgnoreInnerPomChanges() throws Exception {
IProject project = importMavenProject("archetyped");
assertEquals("The inner pom should not have been imported", 2, WorkspaceHelper.getAllProjects().size());
IFile innerPom = project.getFile("src/main/resources/archetype-resources/pom.xml");
preferences.setUpdateBuildConfigurationStatus(FeatureStatus.automatic);
boolean[] updateTriggered = new boolean[1];
IJobChangeListener listener = new JobChangeAdapter() {
@Override
public void scheduled(IJobChangeEvent event) {
if (event.getJob().getName().contains("Update project")) {
updateTriggered[0] = true;
}
}
};
try {
Job.getJobManager().addJobChangeListener(listener);
projectsManager.fileChanged(innerPom.getRawLocationURI().toString(), CHANGE_TYPE.CHANGED);
waitForBackgroundJobs();
assertFalse("Update project should not have been triggered", updateTriggered[0]);
} finally {
Job.getJobManager().removeJobChangeListener(listener);
}
}
示例14: getDisplayImage
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
@Override
public Image getDisplayImage() {
int done = getPercentDone();
if (done > 0) {
return super.getDisplayImage();
}
if (isBlocked()) {
return JFaceResources.getImage(ProgressManager.BLOCKED_JOB_KEY);
}
int state = getJob().getState();
if (state == Job.SLEEPING) {
return JFaceResources.getImage(ProgressManager.SLEEPING_JOB_KEY);
}
if (state == Job.WAITING) {
return JFaceResources.getImage(ProgressManager.WAITING_JOB_KEY);
}
//By default return the first progress image
return super.getDisplayImage();
}
示例15: getDisplayStringWithStatus
import org.eclipse.core.runtime.jobs.Job; //导入依赖的package包/类
/**
* Get the display string based on the current status and the name of the
* job.
* @param showProgress a boolean to indicate if we should
* show progress or not.
*
* @return String
*/
private String getDisplayStringWithStatus(boolean showProgress) {
if (isCanceled()) {
return NLS.bind(ProgressMessages.JobInfo_Cancelled, (new Object[] { getJob().getName() }));
}
if (isBlocked()) {
return NLS.bind(ProgressMessages.JobInfo_Blocked, (new Object[] { getJob().getName(),
blockedStatus.getMessage() }));
}
if (getJob().getState() == Job.RUNNING) {
TaskInfo info = getTaskInfo();
if (info == null) {
return getJob().getName();
}
return info.getDisplayString(showProgress);
}
if (getJob().getState() == Job.SLEEPING) {
return NLS.bind(ProgressMessages.JobInfo_Sleeping, (new Object[] { getJob().getName() }));
}
return NLS.bind(ProgressMessages.JobInfo_Waiting, (new Object[] { getJob().getName() }));
}