Automatically select the newly added account

This commit is contained in:
yushijinhun 2018-07-21 12:34:12 +08:00
parent cb6d8a88f1
commit ae64097edf
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4

View File

@ -146,6 +146,7 @@ public class AddAccountPane extends StackPane {
Task.ofResult("create_account", () -> factory.create(new Selector(), username, password, additionalData)) Task.ofResult("create_account", () -> factory.create(new Selector(), username, password, additionalData))
.finalized(Schedulers.javafx(), variables -> { .finalized(Schedulers.javafx(), variables -> {
Account account = variables.get("create_account"); Account account = variables.get("create_account");
int oldIndex = Accounts.getAccounts().indexOf(account); int oldIndex = Accounts.getAccounts().indexOf(account);
if (oldIndex == -1) { if (oldIndex == -1) {
@ -156,6 +157,10 @@ public class AddAccountPane extends StackPane {
Accounts.getAccounts().remove(oldIndex); Accounts.getAccounts().remove(oldIndex);
Accounts.getAccounts().add(oldIndex, account); Accounts.getAccounts().add(oldIndex, account);
} }
// select the new account
Accounts.setSelectedAccount(account);
acceptPane.hideSpinner(); acceptPane.hideSpinner();
fireEvent(new DialogCloseEvent()); fireEvent(new DialogCloseEvent());
}, exception -> { }, exception -> {