Commit be2ece6e authored by Romain Bioteau's avatar Romain Bioteau
Browse files

fix(contract) fix contract preview


closes BS-16238
parent 6a624f36
...@@ -172,36 +172,38 @@ public class GeneratedScriptPreviewPage extends WizardPage { ...@@ -172,36 +172,38 @@ public class GeneratedScriptPreviewPage extends WizardPage {
@Override @Override
public void setVisible(final boolean visible) { public void setVisible(final boolean visible) {
super.setVisible(visible); super.setVisible(visible);
try { final BusinessObjectData data = (BusinessObjectData) selectedDataObservable.getValue();
getContainer().run(true, false, new IRunnableWithProgress() { if (data != null) {
try {
@Override getContainer().run(false, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
generateExpressionScript(monitor); @Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
generateExpressionScript(data, monitor);
}
});
document.set(generatedExpression.getContent());
if (generatedExpression.getName() != null) {
scriptNameText.setText(generatedExpression.getName());
} }
}); } catch (InvocationTargetException | InterruptedException e) {
document.set(generatedExpression.getContent()); BonitaStudioLog.error("Failed to create Operations from contract", e);
if (generatedExpression.getName() != null) { new BonitaErrorDialog(getShell(), Messages.errorTitle, Messages.contractFromDataCreationErrorMessage, e)
scriptNameText.setText(generatedExpression.getName()); .open();
} }
} catch (InvocationTargetException | InterruptedException e) {
BonitaStudioLog.error("Failed to create Operations from contract", e);
new BonitaErrorDialog(getShell(), Messages.errorTitle, Messages.contractFromDataCreationErrorMessage, e)
.open();
} }
} }
protected void generateExpressionScript(IProgressMonitor monitor) throws InvocationTargetException { protected void generateExpressionScript(BusinessObjectData data, IProgressMonitor monitor)
if (selectedDataObservable.getValue() != null) { throws InvocationTargetException {
rootContractInputGenerator = createRootContractInputGenerator(); rootContractInputGenerator = createRootContractInputGenerator();
if (!fieldToContractInputMappingsObservable.isEmpty()) { if (!fieldToContractInputMappingsObservable.isEmpty()) {
try { try {
rootContractInputGenerator.buildForInstanciation((BusinessObjectData) selectedDataObservable.getValue(), rootContractInputGenerator.buildForInstanciation(data,
monitor); monitor);
generatedExpression = rootContractInputGenerator.getInitialValueExpression(); generatedExpression = rootContractInputGenerator.getInitialValueExpression();
} catch (final OperationCreationException e) { } catch (final OperationCreationException e) {
throw new InvocationTargetException(e); throw new InvocationTargetException(e);
}
} }
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment