// first, run OAW checks to check that the initial model instance is valid
monitor.subTask("Checking initial model instance");
CheckModelInstance check = new CheckModelInstance();
final IStatus result = check.checkModel(model, o.getProject(), new SubProgressMonitor(monitor, 30));
final QuestionDialogResult answer = new QuestionDialogResult();
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
if (!result.isOK()) {
// log the result
getDefaultPlugin().log(result);
if (couldBePhantomEdges(result)) {
// issue 132: automatically suggest the removal of phantom edges
// get user confirmation
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
answer.setResult(MessageDialog.openConfirm(null,
"Possible phantom edges",
"It appears that there may be phantom edges in your model:\n\n" +
getErrorMessage(result) +
"\n\nWould you like to automatically remove these edges?"));
}
});
if (answer.getResult()) {
// remove phantom edges
RemovePhantomEdgesAction phantom = new RemovePhantomEdgesAction();
phantom.doExecute(o, new SubProgressMonitor(monitor, 10));
// refresh project
if (o.getParent() != null) {
o.getParent().refreshLocal(IFile.DEPTH_ONE, new SubProgressMonitor(monitor, 10));
}
// and execute again
return doExecute(o, new SubProgressMonitor(monitor, 80));
}
}
// get user confirmation
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
answer.setResult(MessageDialog.openConfirm(null,
"Initial validation failed",
"An error occured when validating the initial model:\n\n" +
getErrorMessage(result) +
"\n\nWould you still like to continue with code generation?"));
}
});
if (!answer.getResult()) {
// user canceled
return Status.CANCEL_STATUS;
}
}