*/
public void show() {
this.workflow = this.engine.getGUI().getWorkflow();
this.script = new JythonScript(this.workflow, this.engine.getConfiguration());
MonitorConfiguration notifConfig = this.engine.getMonitor().getConfiguration();
if (notifConfig.getBrokerURL() == null) {
this.engine.getGUI().getErrorWindow().error(ErrorMessages.BROKER_URL_NOT_SET_ERROR);
return;
}
// Check if the workflow is valid before the user types in input
// values.
ArrayList<String> warnings = new ArrayList<String>();
if (!this.script.validate(warnings)) {
StringBuilder buf = new StringBuilder();
for (String warning : warnings) {
buf.append("- ");
buf.append(warning);
buf.append("\n");
}
this.engine.getGUI().getErrorWindow().warning(buf.toString());
return;
}
// Create a script here. It might throw some exception because the
// validation is not perfect.
try {
this.script.create();
} catch (GraphException e) {
this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_NOT_READY_ERROR, e);
hide();
return;
} catch (RuntimeException e) {
this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
hide();
return;
} catch (Error e) {
this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
hide();
return;
}
// Create input fields
Collection<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
for (InputNode node : inputNodes) {
String id = node.getID();
QName parameterType = node.getParameterType();
JLabel nameLabel = new JLabel(id);
JLabel typeField = new JLabel(parameterType.getLocalPart());
XBayaTextField paramField = new XBayaTextField();
Object value = node.getDefaultValue();
String valueString;
if (value == null) {
valueString = "";
} else {
if (value instanceof XmlElement) {
XmlElement valueElement = (XmlElement) value;
valueString = XMLUtil.xmlElementToString(valueElement);
} else {
// Only string comes here for now.
valueString = value.toString();
}
}
paramField.setText(valueString);
this.parameterPanel.add(nameLabel);
this.parameterPanel.add(typeField);
this.parameterPanel.add(paramField);
this.parameterTextFields.add(paramField);
}
this.parameterPanel.layout(inputNodes.size(), 3, GridPanel.WEIGHT_NONE, 2);
this.topicTextField.setText(notifConfig.getTopic());
XBayaConfiguration config = this.engine.getConfiguration();
URI gfacURL = config.getGFacURL();
this.gfacTextField.setText(StringUtil.toString(gfacURL));