@FXML private void initialize() { deleteButton.setDisable(true); reconcileButton.setDisable(true); initializeTreeTableView(); Platform.runLater(this::loadAccountTree); MessageBus.getInstance() .registerListener( this, MessageChannel.SYSTEM, MessageChannel.ACCOUNT, MessageChannel.TRANSACTION); // Register invalidation listeners to force a reload typeFilter.addListener(observable -> reload()); selectedAccountProperty.addListener( (observable, oldValue, newValue) -> { updateButtonStates(); }); modifyButton.disableProperty().bind(selectedAccountProperty.isNull()); AccountBalanceDisplayManager.getAccountBalanceDisplayModeProperty() .addListener( (observable, oldValue, newValue) -> { treeTableView.refresh(); }); }
@SuppressWarnings("unchecked") private void initializeTreeTableView() { treeTableView.setShowRoot(false); // don't show the root treeTableView.setEditable(true); // required for editable columns treeTableView.setTableMenuButtonVisible(true); // force resize policy for better default appearance treeTableView.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY); final TreeTableColumn<Account, String> nameColumn = new TreeTableColumn<>(resources.getString("Column.Account")); nameColumn.setCellValueFactory( param -> new ReadOnlyStringWrapper(param.getValue().getValue().getName())); final TreeTableColumn<Account, Integer> entriesColumn = new TreeTableColumn<>(resources.getString("Column.Entries")); entriesColumn.setCellValueFactory( param -> new SimpleIntegerProperty(param.getValue().getValue().getTransactionCount()) .asObject()); final TreeTableColumn<Account, BigDecimal> balanceColumn = new TreeTableColumn<>(resources.getString("Column.Balance")); balanceColumn.setCellValueFactory( param -> new ReadOnlyObjectWrapper<>( AccountBalanceDisplayManager.convertToSelectedBalanceMode( param.getValue().getValue().getAccountType(), param.getValue().getValue().getTreeBalance()))); balanceColumn.setCellFactory(cell -> new AccountCommodityFormatTreeTableCell()); final TreeTableColumn<Account, BigDecimal> reconciledBalanceColumn = new TreeTableColumn<>(resources.getString("Column.ReconciledBalance")); reconciledBalanceColumn.setCellValueFactory( param -> new ReadOnlyObjectWrapper<>( AccountBalanceDisplayManager.convertToSelectedBalanceMode( param.getValue().getValue().getAccountType(), param.getValue().getValue().getReconciledTreeBalance()))); reconciledBalanceColumn.setCellFactory(cell -> new AccountCommodityFormatTreeTableCell()); final TreeTableColumn<Account, String> currencyColumn = new TreeTableColumn<>(resources.getString("Column.Currency")); currencyColumn.setCellValueFactory( param -> new ReadOnlyStringWrapper(param.getValue().getValue().getCurrencyNode().getSymbol())); final TreeTableColumn<Account, String> typeColumn = new TreeTableColumn<>(resources.getString("Column.Type")); typeColumn.setCellValueFactory( param -> new ReadOnlyStringWrapper(param.getValue().getValue().getAccountType().toString())); final TreeTableColumn<Account, Integer> codeColumn = new TreeTableColumn<>(resources.getString("Column.Code")); codeColumn.setEditable(true); codeColumn.setCellValueFactory( param -> new SimpleIntegerProperty(param.getValue().getValue().getAccountCode()).asObject()); codeColumn.setCellFactory(param -> new IntegerEditingTreeTableCell()); codeColumn.setOnEditCommit( event -> updateAccountCode(event.getRowValue().getValue(), event.getNewValue())); treeTableView .getColumns() .addAll( nameColumn, codeColumn, entriesColumn, balanceColumn, reconciledBalanceColumn, currencyColumn, typeColumn); restoreColumnVisibility(); installListeners(); }
@FXML private void initialize() { final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT); if (engine != null) { accountSeparatorTextField.setText(engine.getAccountSeparator()); accountSeparatorTextField .textProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue != null && newValue.length() > 0) { engine.setAccountSeparator(newValue); } }); } else { accountSeparatorTextField.setDisable(true); } useAccountingTermsCheckBox .selectedProperty() .bindBidirectional(Options.useAccountingTermsProperty()); switch (AccountBalanceDisplayManager.getDisplayMode()) { case NONE: noAccountsRadioButton.setSelected(true); break; case REVERSE_CREDIT: creditAccountsRadioButton.setSelected(true); break; case REVERSE_INCOME_EXPENSE: incomeExpenseAccountsRadioButton.setSelected(true); break; } noAccountsRadioButton .selectedProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue) { AccountBalanceDisplayManager.setDisplayMode(AccountBalanceDisplayMode.NONE); } }); creditAccountsRadioButton .selectedProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue) { AccountBalanceDisplayManager.setDisplayMode( AccountBalanceDisplayMode.REVERSE_CREDIT); } }); incomeExpenseAccountsRadioButton .selectedProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue) { AccountBalanceDisplayManager.setDisplayMode( AccountBalanceDisplayMode.REVERSE_INCOME_EXPENSE); } }); }