use of org.eclipse.core.runtime.jobs.Job in project xtext-xtend by eclipse.
the class OverrideIndicatorModelListener method asyncUpdateAnnotationModel.
private void asyncUpdateAnnotationModel() {
if (currentJob != null) {
currentJob.cancel();
}
currentJob = new Job(JOB_NAME) {
@Override
public IStatus run(IProgressMonitor monitor) {
try {
return updateAnnotationModel(monitor);
} catch (OperationCanceledException e) {
return Status.CANCEL_STATUS;
} catch (Exception e) {
LOG.error("Error updating override indicator", e);
return Status.OK_STATUS;
}
}
};
currentJob.setRule(SCHEDULING_RULE);
currentJob.setPriority(Job.DECORATE);
currentJob.setSystem(true);
currentJob.schedule();
}
use of org.eclipse.core.runtime.jobs.Job in project xtext-xtend by eclipse.
the class ResourceStorageTest method doWorkInJob.
protected void doWorkInJob(final Procedure0 work) {
try {
final ArrayList<Throwable> throwables = CollectionLiterals.<Throwable>newArrayList();
StringConcatenation _builder = new StringConcatenation();
String _name = this.getClass().getName();
_builder.append(_name);
_builder.append(".TestJob");
final Procedure1<Job> _function = (Job it) -> {
it.setRule(SchedulingRuleFactory.INSTANCE.newSequence());
};
final Job testShouldLoadFromStorageJob = ObjectExtensions.<Job>operator_doubleArrow(new Job(_builder.toString()) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
IStatus _xblockexpression = null;
{
try {
work.apply();
} catch (final Throwable _t) {
if (_t instanceof Throwable) {
final Throwable t = (Throwable) _t;
throwables.add(t);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
_xblockexpression = Status.OK_STATUS;
}
return _xblockexpression;
}
}, _function);
testShouldLoadFromStorageJob.schedule();
testShouldLoadFromStorageJob.join();
final Throwable t = IterableExtensions.<Throwable>head(throwables);
if ((t != null)) {
Throwables.propagate(t);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class BuildDockerImageLaunchConfigurationDelegate method launch.
@Override
public void launch(final ILaunchConfiguration configuration, final String mode, final ILaunch launch, final IProgressMonitor monitor) throws CoreException {
final String sourcePathLocation = configuration.getAttribute(SOURCE_PATH_LOCATION, (String) null);
final boolean sourcePathWorkspaceRelativeLocation = configuration.getAttribute(SOURCE_PATH_WORKSPACE_RELATIVE_LOCATION, false);
final IPath sourcePath = BuildDockerImageUtils.getPath(sourcePathLocation, sourcePathWorkspaceRelativeLocation);
final String connectionName = configuration.getAttribute(DOCKER_CONNECTION, (String) null);
final String repoName = configuration.getAttribute(REPO_NAME, (String) null);
final IDockerConnection connection = DockerConnectionManager.getInstance().getConnectionByName(connectionName);
final Map<String, Object> buildOptions = new HashMap<>();
buildOptions.put(QUIET_BUILD, configuration.getAttribute(QUIET_BUILD, false));
buildOptions.put(NO_CACHE, configuration.getAttribute(NO_CACHE, false));
buildOptions.put(RM_INTERMEDIATE_CONTAINERS, configuration.getAttribute(RM_INTERMEDIATE_CONTAINERS, true));
buildOptions.put(FORCE_RM_INTERMEDIATE_CONTAINERS, configuration.getAttribute(FORCE_RM_INTERMEDIATE_CONTAINERS, false));
if (connection != null && sourcePath != null) {
final Job buildImageJob = new BuildDockerImageJob(connection, sourcePath, repoName, buildOptions);
buildImageJob.schedule();
} else {
final ILaunchGroup launchGroup = DebugUITools.getLaunchGroup(configuration, // $NON-NLS-1$
"run");
// prompt the user with the launch configuration editor
Display.getDefault().syncExec(() -> DebugUITools.openLaunchConfigurationDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), configuration, launchGroup.getIdentifier(), null));
}
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class DockerComposeUpLaunchConfigurationDelegate method launch.
@Override
public void launch(final ILaunchConfiguration configuration, final String mode, final ILaunch launch, final IProgressMonitor monitor) throws CoreException {
final String sourcePathLocation = configuration.getAttribute(WORKING_DIR, (String) null);
final boolean sourcePathWorkspaceRelativeLocation = configuration.getAttribute(WORKING_DIR_WORKSPACE_RELATIVE_LOCATION, false);
final IPath sourcePath = BuildDockerImageUtils.getPath(sourcePathLocation, sourcePathWorkspaceRelativeLocation);
final String connectionName = configuration.getAttribute(DOCKER_CONNECTION, (String) null);
final IDockerConnection connection = DockerConnectionManager.getInstance().getConnectionByName(connectionName);
if (connection != null && sourcePath != null) {
final Job dockerComposeUpJob = new DockerComposeUpJob(connection, sourcePath.toOSString(), configuration);
dockerComposeUpJob.schedule();
} else {
final ILaunchGroup launchGroup = DebugUITools.getLaunchGroup(configuration, // $NON-NLS-1$
"run");
// prompt the user with the launch configuration editor
Display.getDefault().syncExec(() -> DebugUITools.openLaunchConfigurationDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), configuration, launchGroup.getIdentifier(), null));
}
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class AbstractTest method buildProject.
protected void buildProject(IProject proj) throws CoreException {
IWorkspace wsp = ResourcesPlugin.getWorkspace();
final IProject curProject = proj;
ISchedulingRule rule = wsp.getRuleFactory().buildRule();
Job buildJob = new // $NON-NLS-1$
Job(// $NON-NLS-1$
"project build job") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
curProject.build(IncrementalProjectBuilder.FULL_BUILD, null);
} catch (CoreException e) {
fail(e.getStatus().getMessage());
} catch (OperationCanceledException e) {
fail(NLS.bind(Messages.getString("AbstractTest.Build_cancelled"), curProject.getName(), // $NON-NLS-1$
e.getMessage()));
}
return Status.OK_STATUS;
}
};
buildJob.setRule(rule);
buildJob.schedule();
try {
buildJob.join();
} catch (InterruptedException e) {
fail(NLS.bind(Messages.getString("AbstractTest.Build_interrupted"), curProject.getName(), // $NON-NLS-1$
e.getMessage()));
}
IStatus status = buildJob.getResult();
if (status.getCode() != IStatus.OK) {
fail(NLS.bind(Messages.getString("AbstractTest.Build_failed"), curProject.getName(), // $NON-NLS-1$
status.getMessage()));
}
IWorkspaceRunnable runnable = monitor -> curProject.refreshLocal(IResource.DEPTH_INFINITE, null);
wsp.run(runnable, wsp.getRoot(), IWorkspace.AVOID_UPDATE, null);
}
Aggregations