}
// disallow accidentally clicking submit twice
display.getSubmitJobButton().setEnabled(false);
final SimpleCallback doSubmit = new SimpleCallback() {
public void doCallback(Object source) {
JSONObject args = new JSONObject();
args.put("name", new JSONString(display.getJobName().getText()));
String priority = display.getPriorityList().getSelectedName();
args.put("priority", new JSONString(priority));
args.put("control_file", new JSONString(display.getControlFile().getText()));
args.put("control_type",
new JSONString(controlTypeSelect.getControlType()));
args.put("synch_count", synchCount);
args.put("timeout", new JSONNumber(timeoutValue));
args.put("max_runtime_hrs", new JSONNumber(maxRuntimeValue));
args.put("email_list", new JSONString(display.getEmailList().getText()));
args.put("run_verify", JSONBoolean.getInstance(
!display.getSkipVerify().getValue()));
args.put("is_template", JSONBoolean.getInstance(isTemplate));
args.put("dependencies", getSelectedDependencies());
args.put("reboot_before", new JSONString(rebootBefore.getSelectedChoice()));
args.put("reboot_after", new JSONString(rebootAfter.getSelectedChoice()));
args.put("parse_failed_repair",
JSONBoolean.getInstance(display.getParseFailedRepair().getValue()));
args.put("hostless", JSONBoolean.getInstance(display.getHostless().getValue()));
args.put("reserve_hosts", JSONBoolean.getInstance(display.getReserveHosts().getValue()));
if (staticData.getData("drone_sets_enabled").isBoolean().booleanValue()) {
args.put("drone_set", new JSONString(display.getDroneSet().getSelectedName()));
}
HostSelector.HostSelection hosts = hostSelector.getSelectedHosts();
args.put("hosts", Utils.stringsToJSON(hosts.hosts));
args.put("profiles", Utils.stringsToJSON(hosts.profiles));
args.put("meta_hosts", Utils.stringsToJSON(hosts.metaHosts));
args.put("meta_host_profiles", Utils.stringsToJSON(hosts.metaHostProfiles));
args.put("one_time_hosts",
Utils.stringsToJSON(hosts.oneTimeHosts));
rpcProxy.rpcCall("create_job", args, new JsonRpcCallback() {
@Override
public void onSuccess(JSONValue result) {
int id = (int) result.isNumber().doubleValue();
NotifyManager.getInstance().showMessage(
"Job " + Integer.toString(id) + " created");
reset();
if (listener != null) {
listener.onJobCreated(id);
}
display.getSubmitJobButton().setEnabled(true);
}
@Override
public void onError(JSONObject errorObject) {
super.onError(errorObject);
display.getSubmitJobButton().setEnabled(true);
}
});
}
};
// ensure control file is ready for submission
if (!controlReadyForSubmit) {
generateControlFile(true, doSubmit, new SimpleCallback() {
public void doCallback(Object source) {
display.getSubmitJobButton().setEnabled(true);
}
});
} else {
doSubmit.doCallback(this);
}
}