use of jgnash.uifx.control.ChoiceDialog in project jgnash by ccavanaugh.
the class DefaultCurrencyAction method showAndWait.
public static void showAndWait() {
final Task<List<CurrencyNode>> task = new Task<>() {
final ResourceBundle resources = ResourceUtils.getBundle();
private List<CurrencyNode> currencyNodeList;
@Override
protected List<CurrencyNode> call() {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
currencyNodeList = engine.getCurrencies();
return currencyNodeList;
}
@Override
protected void succeeded() {
super.succeeded();
JavaFXUtils.runLater(() -> {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
final ChoiceDialog<CurrencyNode> dialog = new ChoiceDialog<>(engine.getDefaultCurrency(), currencyNodeList);
dialog.setTitle(resources.getString("Title.SelDefCurr"));
dialog.setContentText(resources.getString("Title.SelDefCurr"));
final Optional<CurrencyNode> optional = dialog.showAndWait();
optional.ifPresent(currencyNode -> {
engine.setDefaultCurrency(currencyNode);
JavaFXUtils.runLater(() -> StaticUIMethods.displayMessage(resources.getString("Message.CurrChange") + " " + engine.getDefaultCurrency().getSymbol()));
});
});
}
};
new Thread(task).start();
}
use of jgnash.uifx.control.ChoiceDialog in project jgnash by ccavanaugh.
the class DefaultLocaleAction method showAndWait.
public static void showAndWait() {
final Task<Collection<LocaleObject>> task = new Task<>() {
final ResourceBundle resources = ResourceUtils.getBundle();
private Collection<LocaleObject> localeObjects;
@Override
protected Collection<LocaleObject> call() {
localeObjects = new ArrayList<>(LocaleObject.getLocaleObjects());
return localeObjects;
}
@Override
protected void succeeded() {
super.succeeded();
JavaFXUtils.runLater(() -> {
final ChoiceDialog<LocaleObject> dialog = new ChoiceDialog<>(new LocaleObject(Locale.getDefault()), localeObjects);
dialog.setTitle(resources.getString("Title.SelDefLocale"));
dialog.setContentText(resources.getString("Title.SelDefLocale"));
final Optional<LocaleObject> optional = dialog.showAndWait();
optional.ifPresent(localeObject -> {
ResourceUtils.setLocale(localeObject.getLocale());
JavaFXUtils.runLater(() -> StaticUIMethods.displayMessage(localeObject + "\n" + resources.getString("Message.RestartLocale")));
});
});
}
};
new Thread(task).start();
}
Aggregations