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);
}
}
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);
});
}
Aggregations