public void showPreview() throws XulException {
XulDialog previewDialog = (XulDialog) document.getElementById(ELEM_ID_PREVIEW_DIALOG);
StringBuilder ddlBuf = new StringBuilder();
List<UIAggregate> aggList = getEnabledAggs();
XulTextbox ddlField = (XulTextbox) document.getElementById(ELEM_ID_DDL_FIELD);
List<Output> outputs = new ArrayList<Output>();
for (UIAggregate agg : aggList) {
outputs.add(agg.getOutput());
}
if (outputs.size() > 0) {
try {
ddlBuf.append(outputService.getFullArtifact(outputs, CreateScriptGenerator.class));
} catch (OutputValidationException e) {
e.printStackTrace();
// TODO mlowery show an error dialog before returning
return;
}
ddlField.setValue(ddlBuf.toString());
} else {
ddlField.setValue(EMPTY_STRING);
}
StringBuilder dmlBuf = new StringBuilder();
XulTextbox dmlField = (XulTextbox) document.getElementById(ELEM_ID_DML_FIELD);
if (document.getElementById("dml_tabpanel") != null) {
try {
dmlBuf.append(outputService.getFullArtifact(outputs, PopulateScriptGenerator.class));
} catch (OutputValidationException e) {
e.printStackTrace();
// TODO mlowery show an error dialog before returning
return;
}
dmlField.setValue(dmlBuf.toString());
}
StringBuilder schemaBuf = new StringBuilder();
XulTextbox multiDimSchemaField = (XulTextbox) document.getElementById("multiDimSchemaField");
if (multiDimSchemaField != null) {
outputs = new ArrayList<Output>();
for (UIAggregate agg : aggList) {
outputs.add(agg.getOutput());
}
try {
schemaBuf.append(outputService.getFullArtifact(outputs, SchemaGenerator.class));
} catch (OutputValidationException e) {
e.printStackTrace();
return;
}
multiDimSchemaField.setValue(schemaBuf.toString());
}
previewDialog.show();
}