use of jgnash.util.LocaleObject in project jgnash by ccavanaugh.
the class DefaultLocaleAction method showAndWait.
public static void showAndWait() {
final Task<LocaleObject[]> task = new Task<LocaleObject[]>() {
final ResourceBundle resources = ResourceUtils.getBundle();
private LocaleObject[] localeObjects;
@Override
protected LocaleObject[] call() throws Exception {
localeObjects = LocaleObject.getLocaleObjects();
return localeObjects;
}
@Override
protected void succeeded() {
super.succeeded();
Platform.runLater(() -> {
final ChoiceDialog<LocaleObject> dialog = new ChoiceDialog<>(new LocaleObject(Locale.getDefault()), localeObjects);
dialog.setTitle(resources.getString("Title.SelDefLocale"));
dialog.getDialogPane().getStylesheets().addAll(MainView.DEFAULT_CSS);
dialog.getDialogPane().getScene().getRoot().styleProperty().bind(ThemeManager.styleProperty());
dialog.getDialogPane().getStyleClass().addAll("form", "dialog");
dialog.setHeaderText(resources.getString("Title.SelDefLocale"));
final Optional<LocaleObject> optional = dialog.showAndWait();
optional.ifPresent(localeObject -> {
ResourceUtils.setLocale(localeObject.getLocale());
StaticUIMethods.displayMessage(localeObject + "\n" + resources.getString("Message.RestartLocale"));
});
});
}
};
new Thread(task).start();
}
Aggregations