Search in sources :

Example 1 with WorkbenchDialog

use of com.dlsc.workbenchfx.model.WorkbenchDialog 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 2 with WorkbenchDialog

use of com.dlsc.workbenchfx.model.WorkbenchDialog in project java-jotasync by trixon.

the class MainApp method initActions.

private void initActions() {
    // DRAWER
    // history
    mHistoryAction = new Action(Dict.HISTORY.toString(), (ActionEvent event) -> {
        mWorkbench.hideNavigationDrawer();
        mWorkbench.openModule(mHistoryModule);
    });
    mHistoryAction.disabledProperty().bind(mManager.connectedProperty().not());
    // options
    mOptionsAction = new Action(Dict.OPTIONS.toString(), (ActionEvent event) -> {
        mWorkbench.hideNavigationDrawer();
        displayOptions();
    });
    // help
    mHelpAction = new Action(Dict.HELP.toString(), (ActionEvent event) -> {
        mWorkbench.hideNavigationDrawer();
        SystemHelper.desktopBrowse("https://trixon.se/projects/jotasync/documentation/");
    });
    // about rsync
    mAboutRsyncAction = new Action(String.format(Dict.ABOUT_S.toString(), "rsync"), (ActionEvent event) -> {
        mWorkbench.hideNavigationDrawer();
        try {
            String aboutRsync = mManager.getServerCommander().getAboutRsync();
            mWorkbench.showInformationDialog(String.format(Dict.ABOUT_S.toString(), "rsync"), aboutRsync, null);
        } catch (RemoteException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    mAboutRsyncAction.disabledProperty().bind(mManager.connectedProperty().not());
    // about
    mAboutAction = new Action(Dict.ABOUT.toString(), (ActionEvent event) -> {
        mWorkbench.hideNavigationDrawer();
        PomInfo pomInfo = new PomInfo(MainApp.class, "se.trixon", "jotasync");
        AboutModel aboutModel = new AboutModel(SystemHelper.getBundle(getClass(), "about"), SystemHelperFx.getResourceAsImageView(MainApp.class, "logo.png"));
        aboutModel.setAppVersion(pomInfo.getVersion());
        AboutPane aboutPane = new AboutPane(aboutModel);
        double scaledFontSize = FxHelper.getScaledFontSize();
        Label appLabel = new Label(aboutModel.getAppName());
        appLabel.setFont(new Font(scaledFontSize * 1.8));
        Label verLabel = new Label(String.format("%s %s", Dict.VERSION.toString(), aboutModel.getAppVersion()));
        verLabel.setFont(new Font(scaledFontSize * 1.2));
        Label dateLabel = new Label(aboutModel.getAppDate());
        dateLabel.setFont(new Font(scaledFontSize * 1.2));
        VBox box = new VBox(appLabel, verLabel, dateLabel);
        box.setAlignment(Pos.CENTER_LEFT);
        box.setPadding(new Insets(0, 0, 0, 22));
        BorderPane topBorderPane = new BorderPane(box);
        topBorderPane.setLeft(aboutModel.getImageView());
        topBorderPane.setPadding(new Insets(22));
        BorderPane mainBorderPane = new BorderPane(aboutPane);
        mainBorderPane.setTop(topBorderPane);
        WorkbenchDialog dialog = WorkbenchDialog.builder(Dict.ABOUT.toString(), mainBorderPane, ButtonType.CLOSE).build();
        mWorkbench.showDialog(dialog);
    });
}
Also used : Action(org.controlsfx.control.action.Action) BorderPane(javafx.scene.layout.BorderPane) PomInfo(se.trixon.almond.util.PomInfo) AboutPane(se.trixon.almond.util.fx.dialogs.about.AboutPane) Insets(javafx.geometry.Insets) ActionEvent(javafx.event.ActionEvent) Label(javafx.scene.control.Label) AboutModel(se.trixon.almond.util.fx.AboutModel) Font(javafx.scene.text.Font) WorkbenchDialog(com.dlsc.workbenchfx.model.WorkbenchDialog) RemoteException(java.rmi.RemoteException) VBox(javafx.scene.layout.VBox)

Aggregations

WorkbenchDialog (com.dlsc.workbenchfx.model.WorkbenchDialog)2 RemoteException (java.rmi.RemoteException)2 Workbench (com.dlsc.workbenchfx.Workbench)1 HashMap (java.util.HashMap)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 Platform (javafx.application.Platform)1 ActionEvent (javafx.event.ActionEvent)1 Insets (javafx.geometry.Insets)1 ButtonBar (javafx.scene.control.ButtonBar)1 ButtonType (javafx.scene.control.ButtonType)1 Label (javafx.scene.control.Label)1 BorderPane (javafx.scene.layout.BorderPane)1 VBox (javafx.scene.layout.VBox)1 Font (javafx.scene.text.Font)1 Action (org.controlsfx.control.action.Action)1 Dict (se.trixon.almond.util.Dict)1 PomInfo (se.trixon.almond.util.PomInfo)1 AboutModel (se.trixon.almond.util.fx.AboutModel)1 AboutPane (se.trixon.almond.util.fx.dialogs.about.AboutPane)1