Search in sources :

Example 1 with JobValidator

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;
}
Also used : HtmlPanel(se.trixon.almond.util.swing.dialogs.HtmlPanel) JobValidator(se.trixon.jota.server.JobValidator) RemoteException(java.rmi.RemoteException)

Example 2 with JobValidator

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);
    }
}
Also used : ButtonBar(javafx.scene.control.ButtonBar) ServerEventListener(se.trixon.jota.shared.ServerEventListener) ServerEvent(se.trixon.jota.shared.ServerEvent) ButtonType(javafx.scene.control.ButtonType) ProcessEvent(se.trixon.jota.shared.ProcessEvent) Task(se.trixon.jota.shared.task.Task) HashMap(java.util.HashMap) Logger(java.util.logging.Logger) RemoteException(java.rmi.RemoteException) Level(java.util.logging.Level) Job(se.trixon.jota.shared.job.Job) Platform(javafx.application.Platform) Dict(se.trixon.almond.util.Dict) WorkbenchDialog(com.dlsc.workbenchfx.model.WorkbenchDialog) Manager(se.trixon.jota.client.Manager) JobValidator(se.trixon.jota.server.JobValidator) Workbench(com.dlsc.workbenchfx.Workbench) JobValidator(se.trixon.jota.server.JobValidator) WorkbenchDialog(com.dlsc.workbenchfx.model.WorkbenchDialog) RemoteException(java.rmi.RemoteException) ButtonType(javafx.scene.control.ButtonType)

Example 3 with JobValidator

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;
}
Also used : HtmlPanel(se.trixon.almond.util.swing.dialogs.HtmlPanel) JobValidator(se.trixon.jota.server.JobValidator) RemoteException(java.rmi.RemoteException)

Aggregations

RemoteException (java.rmi.RemoteException)3 JobValidator (se.trixon.jota.server.JobValidator)3 HtmlPanel (se.trixon.almond.util.swing.dialogs.HtmlPanel)2 Workbench (com.dlsc.workbenchfx.Workbench)1 WorkbenchDialog (com.dlsc.workbenchfx.model.WorkbenchDialog)1 HashMap (java.util.HashMap)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 Platform (javafx.application.Platform)1 ButtonBar (javafx.scene.control.ButtonBar)1 ButtonType (javafx.scene.control.ButtonType)1 Dict (se.trixon.almond.util.Dict)1 Manager (se.trixon.jota.client.Manager)1 ProcessEvent (se.trixon.jota.shared.ProcessEvent)1 ServerEvent (se.trixon.jota.shared.ServerEvent)1 ServerEventListener (se.trixon.jota.shared.ServerEventListener)1 Job (se.trixon.jota.shared.job.Job)1 Task (se.trixon.jota.shared.task.Task)1