Search in sources :

Example 1 with TextInputDialog

use of jgnash.uifx.control.TextInputDialog in project jgnash by ccavanaugh.

the class BudgetManagerDialogController method handleRenameAction.

@FXML
private void handleRenameAction() {
    for (final Budget budget : budgetListView.getSelectionModel().getSelectedItems()) {
        final TextInputDialog textInputDialog = new TextInputDialog(budget.getName());
        textInputDialog.setTitle(resources.getString("Title.RenameBudget"));
        textInputDialog.setContentText(resources.getString("Label.RenameBudget"));
        final Optional<String> optional = textInputDialog.showAndWait();
        optional.ifPresent(s -> {
            if (!s.isEmpty()) {
                final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
                Objects.requireNonNull(engine);
                budget.setName(s);
                engine.updateBudget(budget);
            }
        });
    }
}
Also used : Budget(jgnash.engine.budget.Budget) Engine(jgnash.engine.Engine) TextInputDialog(jgnash.uifx.control.TextInputDialog) FXML(javafx.fxml.FXML)

Aggregations

FXML (javafx.fxml.FXML)1 Engine (jgnash.engine.Engine)1 Budget (jgnash.engine.budget.Budget)1 TextInputDialog (jgnash.uifx.control.TextInputDialog)1