use of org.eclipse.core.runtime.jobs.IJobChangeListener in project tmdm-studio-se by Talend.
the class MDMValidationRunner method validate.
public static IModelValidateResult validate(List<IRepositoryViewObject> viewObjs, IValidationPreference validationPref, boolean forbidShowResultDialog) {
MDMValidationRunner runner = new MDMValidationRunner(viewObjs, validationPref, forbidShowResultDialog);
IJobChangeListener listener = new JobChangeAdapter() {
@Override
public void aboutToRun(IJobChangeEvent event) {
running = true;
}
@Override
public void done(IJobChangeEvent event) {
running = false;
}
};
runner.addJobChangeListener(listener);
runner.schedule();
try {
runner.join();
} catch (InterruptedException e) {
log.error(e.getMessage(), e);
}
return runner.validateResult;
}
use of org.eclipse.core.runtime.jobs.IJobChangeListener in project eclipse.jdt.ls by eclipse.
the class MavenBuildSupportTest method testIgnoreInnerPomChanges.
@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);
}
}
use of org.eclipse.core.runtime.jobs.IJobChangeListener in project jbosstools-openshift by jbosstools.
the class ImportApplicationWizard method createImportJob.
private void createImportJob(boolean reuseGitRepository) {
if (reuseGitRepository) {
this.importJob = new ImportJob(model.getGitUrl(), model.getGitRef(), model.getRepoPath(), model.isCheckoutBranchReusedRepo());
} else {
this.importJob = new ImportJob(model.getGitUrl(), model.getGitRef(), model.getRepoPath());
}
String gitContextDir = model.getGitContextDir();
if (StringUtils.isNotEmpty(gitContextDir)) {
importJob.setFilters(Collections.singleton(gitContextDir));
}
importJob.setUser(true);
importJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
boolean success = JobUtils.isOk(importJob.getResult());
if (success) {
saveRepoPath();
}
UsageStats.getInstance().importV3Application(model.getConnection().getHost(), success);
}
});
for (IJobChangeListener importJobChangeListener : importJobChangeListenersList) {
importJob.addJobChangeListener(importJobChangeListener);
}
}
use of org.eclipse.core.runtime.jobs.IJobChangeListener in project polymap4-core by Polymap4.
the class OperationSupport method execute2.
/**
*@see #execute(IUndoableOperation, boolean, boolean, IJobChangeListener...)
*/
public void execute2(final IUndoableOperation op, boolean async, boolean progress, Consumer<IJobChangeEvent>... doneHandlers) {
IJobChangeListener[] listeners = new IJobChangeListener[doneHandlers.length];
for (int i = 0; i < doneHandlers.length; i++) {
Consumer<IJobChangeEvent> handler = doneHandlers[i];
listeners[i] = new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent ev) {
handler.accept(ev);
}
};
}
execute(op, async, progress, listeners);
}
use of org.eclipse.core.runtime.jobs.IJobChangeListener in project polymap4-core by Polymap4.
the class OperationSupport method execute.
/**
* Executes the given operation inside an {@link UIJob job}.
*
* @param op
* @param async Indicates that the calling thread should not block execution and
* return imediatelly.
* @param progress Indicates the the operation is executed inside a progress
* dialog. Make sure that the operation does not open dialogs as they might get covered up
* by the progress dialog.
* @throws ExecutionException
*/
public void execute(final IUndoableOperation op, boolean async, boolean progress, IJobChangeListener... listeners) {
OperationJob job = new OperationJob(op) {
protected void run() throws Exception {
// try to preset task name without beginTask()
monitor.setTaskName(op.getLabel());
OperationExecutor executor = OperationExecutor.newInstance(op);
IUndoableOperation executorOp = executor.operation();
executorOp.addContext(context);
history.execute(executorOp, monitor, executor.newOperationInfo(-1));
}
};
for (IJobChangeListener l : listeners) {
job.addJobChangeListenerWithContext(l);
}
// check nested
UIJob parent = UIJob.ofThread();
if (parent != null && parent instanceof OperationJob) {
log.info("Nested operation: " + op);
run(job, async, progress);
// IUndoableOperation parentOp = ((OperationJob)parent).op;
//
// SubProgressMonitor subMonitor = new SubProgressMonitor(
// UIJob.monitorForThread(), IProgressMonitor.UNKNOWN, parentOp.getLabel() );
//
// OperationExecutor executor = OperationExecutor.newInstance( op );
// IUndoableOperation executorOp = executor.getOperation();
// executorOp.addContext( context );
//
// history.execute( executorOp, subMonitor, executor.getInfo() );
} else // start job
{
run(job, async, progress);
}
}
Aggregations