use of org.absmodels.abs.plugin.exceptions.AbsJobException in project abstools by abstools.
the class AbstractTab method updateErrors.
/**
* Don't recommend to start projects which have errors.
* TODO: manipulating the error message here does not cooperate well with isValid().
*/
protected boolean updateErrors() {
boolean res = true;
String projectName = getSelectedProjectName();
String prod = getSelectedProductName();
if (this.lastProjectName != null && this.lastProd != null && this.lastProjectName.equals(projectName) && this.lastProd.equals(prod)) {
// every time something changes in the run configuration dialog
return lastResult;
}
if (projectName != null) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
try {
AbsNature nat = UtilityFunctions.getAbsNature(project);
assert nat != null;
synchronized (nat.modelLock) {
Model model = nat.getCompleteModel();
/* E.g. errors in the project */
if (model == null)
return false;
/* Check product if any */
// work on a copy:
model = model.treeCopyNoTransform();
model.flushTreeCache();
if (prod != null) {
model.flattenForProduct(prod);
/* Type check again */
// #335, see IncrementalModelBuilder#flushAll()
model.flushCache();
}
SemanticConditionList errs = model.getErrors();
// TODO: check for warnings also
if (errs != null && errs.containsErrors()) {
createMarkers(nat, errs);
throw new AbsJobException(new TypeCheckerException(errs));
}
errs = model.typeCheck();
// TODO: check for warnings also
if (errs != null && errs.containsErrors()) {
createMarkers(nat, errs);
throw new AbsJobException(new TypeCheckerException(errs));
}
}
setErrorMessage(null);
} catch (AbsJobException e) {
setErrorMessage(e.getMessage());
res = false;
} catch (WrongProgramArgumentException e) {
setErrorMessage(e.getMessage());
res = false;
} catch (DeltaModellingException e) {
setErrorMessage(e.getMessage());
res = false;
}
getLaunchConfigurationDialog().updateMessage();
}
// cache the result
lastProd = prod;
lastProjectName = projectName;
lastResult = res;
return res;
}
use of org.absmodels.abs.plugin.exceptions.AbsJobException in project abstools by abstools.
the class JavaRunConfiguration method launch.
@Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
JavaLaunchConfig launchConfig = new JavaLaunchConfig(config);
IAction action = createNewAction(launchConfig);
IProject project = ActionUtils.getProject(config);
IFile file = null;
ActionUtils.saveDirtyEditors(project);
JavaJob job = new JavaJob(JavaJob.RUN_JOB, action, project, file);
String product = launchConfig.getProductName();
if (product != null) {
try {
Model model = JavaJob.getModelFromProject(project);
job.setProduct(model.findProduct(product));
} catch (WrongProgramArgumentException e) {
throw new CoreException(new Status(IStatus.ERROR, Constants.PLUGIN_ID, "Launch failed", e));
} catch (AbsJobException e) {
throw new CoreException(new Status(IStatus.ERROR, Constants.PLUGIN_ID, "Launch failed", e));
}
}
if (launchConfig.getTestExecution()) {
List<String> obs = launchConfig.getDebuggerObserverList();
obs.add(ABSTestObserver.class.getName());
}
modifyDebuggerArguments(launchConfig, job);
if (launchConfig.getTestExecution()) {
// execution of unit tests
Job testJob = new ABSUnitTestJavaExecutionJob(project, product, job);
testJob.schedule();
} else {
// normal execution
job.schedule();
}
}
Aggregations