use of com.owlplug.auth.ui.AccountCellFactory in project OwlPlug by DropSnorz.
the class MainController method initialize.
/**
* FXML initialize method.
*/
@FXML
public void initialize() {
viewRegistry.preload();
this.tabPaneHeader.getSelectionModel().selectedIndexProperty().addListener((options, oldValue, newValue) -> {
tabPaneContent.getSelectionModel().select(newValue.intValue());
leftDrawer.close();
// store tab.
if (newValue.intValue() == 2) {
storeController.requestLayout();
}
});
accountComboBox.getSelectionModel().selectedItemProperty().addListener((options, oldValue, newValue) -> {
if (newValue instanceof AccountMenuItem) {
accountController.show();
// Delay comboBox selector change
Platform.runLater(() -> accountComboBox.setValue(oldValue));
}
if (newValue instanceof UserAccount) {
UserAccount userAccount = (UserAccount) newValue;
this.getPreferences().putLong(ApplicationDefaults.SELECTED_ACCOUNT_KEY, userAccount.getId());
}
accountComboBox.hide();
});
accountComboBox.setButtonCell(new AccountCellFactory(imageCache, Pos.CENTER_RIGHT).call(null));
accountComboBox.setCellFactory(new AccountCellFactory(authenticationService, imageCache, true));
JFXComboBoxListViewSkin<AccountItem> accountCBSkin = new JFXComboBoxListViewSkin<AccountItem>(accountComboBox);
accountCBSkin.setHideOnClick(false);
accountComboBox.setSkin(accountCBSkin);
refreshAccounts();
downloadUpdateButton.setOnAction(e -> {
PlatformUtils.openDefaultBrowser(this.getApplicationDefaults().getUpdateDownloadUrl());
});
updatePane.setVisible(false);
Task<Boolean> retrieveUpdateStatusTask = new Task<Boolean>() {
@Override
protected Boolean call() throws Exception {
return updateService.isUpToDate();
}
};
retrieveUpdateStatusTask.setOnSucceeded(e -> {
if (!retrieveUpdateStatusTask.getValue()) {
updatePane.setVisible(true);
}
});
new Thread(retrieveUpdateStatusTask).start();
}
Aggregations