use of se.trixon.jota.server.JobValidator in project java-jotasync by trixon.
the class MainFrame method requestStartJob.
public boolean requestStartJob(Job job) {
try {
JobValidator validator = mManager.getServerCommander().validate(job);
if (validator.isValid()) {
Object[] options = { Dict.RUN.toString(), Dict.DRY_RUN.toString(), Dict.CANCEL.toString() };
HtmlPanel htmlPanel = new HtmlPanel(job.getSummaryAsHtml());
SwingHelper.makeWindowResizable(htmlPanel);
int result = JOptionPane.showOptionDialog(this, htmlPanel, Dict.RUN.toString(), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[1]);
if (result > -1 && result < 2) {
boolean dryRun = result == 1;
mManager.getServerCommander().startJob(job, dryRun);
}
} else {
Message.html(this, Dict.Dialog.ERROR_VALIDATION.toString(), validator.getSummaryAsHtml());
}
} catch (RemoteException ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
}
use of se.trixon.jota.server.JobValidator in project java-jotasync by trixon.
the class JobController method run.
public void run(Job job) {
try {
JobValidator validator = mManager.getServerCommander().validate(job);
if (validator.isValid()) {
HtmlPane previewPanel = new HtmlPane(job.getSummaryAsHtml());
ButtonType runButtonType = new ButtonType(Dict.RUN.toString());
ButtonType dryRunButtonType = new ButtonType(Dict.DRY_RUN.toString(), ButtonBar.ButtonData.OK_DONE);
ButtonType cancelButtonType = new ButtonType(Dict.CANCEL.toString(), ButtonBar.ButtonData.CANCEL_CLOSE);
String title = String.format(Dict.Dialog.TITLE_PROFILE_RUN.toString(), job.getName());
WorkbenchDialog dialog = WorkbenchDialog.builder(title, previewPanel, runButtonType, dryRunButtonType, cancelButtonType).onResult(buttonType -> {
try {
if (buttonType != cancelButtonType) {
boolean dryRun = buttonType == dryRunButtonType;
mManager.getServerCommander().startJob(job, dryRun);
}
} catch (RemoteException ex) {
LOGGER.log(Level.SEVERE, null, ex);
}
}).build();
mWorkbench.showDialog(dialog);
} else {
WorkbenchDialog dialog = WorkbenchDialog.builder(Dict.Dialog.ERROR_VALIDATION.toString(), new HtmlPane(validator.getSummaryAsHtml()), WorkbenchDialog.Type.ERROR).build();
mWorkbench.showDialog(dialog);
}
} catch (RemoteException ex) {
LOGGER.log(Level.SEVERE, null, ex);
}
}
use of se.trixon.jota.server.JobValidator in project java-jotasync by trixon.
the class MainFrame method requestStartJob.
public boolean requestStartJob(Job job) {
try {
JobValidator validator = mManager.getServerCommander().validate(job);
if (validator.isValid()) {
Object[] options = { Dict.RUN.toString(), Dict.DRY_RUN.toString(), Dict.CANCEL.toString() };
HtmlPanel htmlPanel = new HtmlPanel(job.getSummaryAsHtml());
SwingHelper.makeWindowResizable(htmlPanel);
int result = JOptionPane.showOptionDialog(this, htmlPanel, Dict.RUN.toString(), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[1]);
if (result > -1 && result < 2) {
boolean dryRun = result == 1;
mManager.getServerCommander().startJob(job, dryRun);
}
} else {
Message.html(this, Dict.Dialog.ERROR_VALIDATION.toString(), validator.getSummaryAsHtml());
}
} catch (RemoteException ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
}
Aggregations