use of javafx.beans.value.ChangeListener in project jgnash by ccavanaugh.
the class AccountRegisterReportController method initialize.
@FXML
private void initialize() {
final Preferences preferences = getPreferences();
showSplitsCheckBox.setSelected(preferences.getBoolean(SHOW_SPLITS, false));
showTimestampCheckBox.setSelected(preferences.getBoolean(SHOW_TIMESTAMP, false));
accountComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
refreshAccount(newValue);
handleRefresh();
});
final ChangeListener<Object> refreshListener = (observable, oldValue, newValue) -> handleRefresh();
showSplitsCheckBox.selectedProperty().addListener(refreshListener);
startDatePicker.valueProperty().addListener(refreshListener);
endDatePicker.valueProperty().addListener(refreshListener);
payeeFilterTextField.textProperty().addListener(refreshListener);
memoFilterTextField.textProperty().addListener(refreshListener);
showTimestampCheckBox.selectedProperty().addListener(refreshListener);
}
use of javafx.beans.value.ChangeListener in project jgnash by ccavanaugh.
the class IncomeExpenseBarChartDialogController method initialize.
@FXML
public void initialize() {
final Preferences preferences = Preferences.userNodeForPackage(IncomeExpenseBarChartDialogController.class).node("IncomeExpenseBarChart");
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
periodComboBox.getItems().addAll(ReportPeriod.values());
periodComboBox.setValue(ReportPeriod.values()[preferences.getInt(REPORT_PERIOD, ReportPeriod.MONTHLY.ordinal())]);
defaultCurrency = engine.getDefaultCurrency();
numberFormat = CommodityFormat.getFullNumberFormat(defaultCurrency);
barChart.getStylesheets().addAll(CHART_CSS);
barChart.getYAxis().setLabel(defaultCurrency.getSymbol());
barChart.barGapProperty().set(BAR_GAP);
barChart.setCategoryGap(PERIOD_GAP);
// Respect animation preference
barChart.animatedProperty().set(Options.animationsEnabledProperty().get());
startDatePicker.setValue(DateUtils.getFirstDayOfTheMonth(endDatePicker.getValue().minusMonths(11)));
final ChangeListener<Object> listener = (observable, oldValue, newValue) -> {
if (newValue != null) {
Platform.runLater(this::updateChart);
}
};
startDatePicker.valueProperty().addListener(listener);
endDatePicker.valueProperty().addListener(listener);
periodComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
preferences.putInt(REPORT_PERIOD, newValue.ordinal());
Platform.runLater(this::updateChart);
});
// Push the initial load to the end of the platform thread for better startup and a nicer visual effect
Platform.runLater(this::updateChart);
}
use of javafx.beans.value.ChangeListener in project jgnash by ccavanaugh.
the class IncomeExpensePayeePieChartDialogController method initialize.
@FXML
public void initialize() {
// Respect animation preference
debitPieChart.animatedProperty().set(Options.animationsEnabledProperty().get());
creditPieChart.animatedProperty().set(Options.animationsEnabledProperty().get());
creditPieChart.getStylesheets().addAll(CHART_CSS);
debitPieChart.getStylesheets().addAll(CHART_CSS);
creditPieChart.centerTitleProperty().set(resources.getString("Column.Credit"));
debitPieChart.centerTitleProperty().set(resources.getString("Column.Debit"));
accountComboBox.setPredicate(AccountComboBox.getShowAllPredicate());
if (preferences.get(LAST_ACCOUNT, null) != null) {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
final Account account = engine.getAccountByUuid(preferences.get(LAST_ACCOUNT, null));
if (account != null) {
accountComboBox.setValue(account);
}
}
startDatePicker.setValue(endDatePicker.getValue().minusYears(1));
final ChangeListener<Object> listener = (observable, oldValue, newValue) -> {
if (newValue != null) {
updateCharts();
preferences.put(LAST_ACCOUNT, accountComboBox.getValue().getUuid());
}
};
accountComboBox.valueProperty().addListener(listener);
startDatePicker.valueProperty().addListener(listener);
endDatePicker.valueProperty().addListener(listener);
creditPieChart.setLegendSide(Side.BOTTOM);
debitPieChart.setLegendSide(Side.BOTTOM);
// Load in the first aux payee text field
insertAuxPayeeTextField();
restoreFilters();
// Expand the titled pane if filters are being used
Platform.runLater(() -> {
if (getPayeeTextFields().size() > 1) {
titledPane.setExpanded(true);
}
});
// Push the initial load to the end of the platform thread for better startup and nicer visual effect
Platform.runLater(this::updateCharts);
}
use of javafx.beans.value.ChangeListener in project jgnash by ccavanaugh.
the class IncomeExpensePieChartDialogController method initialize.
@FXML
public void initialize() {
// Respect animation preference
pieChart.animatedProperty().set(Options.animationsEnabledProperty().get());
accountComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null && newValue.getParent().getAccountType() != AccountType.ROOT) {
pieChart.setCursor(CustomCursor.getZoomOutCursor());
} else {
pieChart.setCursor(Cursor.DEFAULT);
}
});
final Preferences preferences = Preferences.userNodeForPackage(IncomeExpensePieChartDialogController.class).node("IncomeExpensePieChart");
accountComboBox.setPredicate(new ParentAccountPredicate());
if (preferences.get(LAST_ACCOUNT, null) != null) {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
final Account account = engine.getAccountByUuid(preferences.get(LAST_ACCOUNT, null));
if (account != null) {
accountComboBox.setValue(account);
}
}
startDatePicker.setValue(endDatePicker.getValue().minusYears(1));
final ChangeListener<Object> listener = (observable, oldValue, newValue) -> {
if (newValue != null) {
updateChart();
preferences.put(LAST_ACCOUNT, accountComboBox.getValue().getUuid());
}
};
accountComboBox.valueProperty().addListener(listener);
startDatePicker.valueProperty().addListener(listener);
endDatePicker.valueProperty().addListener(listener);
pieChart.setLegendSide(Side.BOTTOM);
// zoom out
pieChart.setOnMouseClicked(event -> {
if (!nodeFocused && accountComboBox.getValue().getParent().getAccountType() != AccountType.ROOT) {
accountComboBox.setValue(accountComboBox.getValue().getParent());
}
});
// Push the initial load to the end of the platform thread for better startup and nicer visual effect
Platform.runLater(this::updateChart);
}
use of javafx.beans.value.ChangeListener in project jgnash by ccavanaugh.
the class RegisterTableController method initialize.
@FXML
void initialize() {
// table view displays the sorted list of data. The comparator property must be bound
tableView.setItems(sortedList);
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
// Bind the account property
getAccountPropertyWrapper().accountProperty().bind(account);
accountNameLabel.textProperty().bind(getAccountPropertyWrapper().accountNameProperty());
balanceLabel.textProperty().bind(getAccountPropertyWrapper().accountBalanceProperty());
tableView.setTableMenuButtonVisible(true);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
// hide the horizontal scrollbar and prevent ghosting
tableView.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS);
// Load the table on change and set the row factory if the account in not locked
accountProperty().addListener((observable, oldValue, newValue) -> {
loadAccount();
if (!newValue.isLocked()) {
tableView.setRowFactory(new TransactionRowFactory());
}
numberFormat = CommodityFormat.getFullNumberFormat(newValue.getCurrencyNode());
});
selectedTransaction.bind(tableView.getSelectionModel().selectedItemProperty());
// Update the selection size property when the selection list changes
tableView.getSelectionModel().getSelectedItems().addListener((ListChangeListener<Transaction>) c -> selectionSize.set(tableView.getSelectionModel().getSelectedIndices().size()));
selectionSize.addListener((observable, oldValue, newValue) -> {
if ((Integer) newValue > 1) {
final List<Transaction> transactions = new ArrayList<>(tableView.getSelectionModel().getSelectedItems());
BigDecimal total = BigDecimal.ZERO;
for (final Transaction transaction : transactions) {
if (transaction != null) {
total = total.add(transaction.getAmount(account.get()));
}
}
selectionSummaryTooltip.setText(numberFormat.format(AccountBalanceDisplayManager.convertToSelectedBalanceMode(account.get().getAccountType(), total)));
} else {
selectionSummaryTooltip.setText(null);
}
});
// For the table view to refresh itself if the mode changes
AccountBalanceDisplayManager.accountBalanceDisplayMode().addListener((observable, oldValue, newValue) -> tableView.refresh());
reconciledStateFilterComboBox.getItems().addAll(ReconciledStateEnum.values());
reconciledStateFilterComboBox.setValue(ReconciledStateEnum.ALL);
transactionAgeFilterComboBox.getItems().addAll(AgeEnum.values());
transactionAgeFilterComboBox.setValue(AgeEnum.ALL);
final ChangeListener<Object> filterChangeListener = (observable, oldValue, newValue) -> handleFilterChange();
reconciledStateFilterComboBox.valueProperty().addListener(filterChangeListener);
transactionAgeFilterComboBox.valueProperty().addListener(filterChangeListener);
// Rebuild filters when regex properties change
Options.regexForFiltersProperty().addListener(filterChangeListener);
if (memoFilterTextField != null) {
// memo filter may not have been initialized for all register types
memoFilterTextField.textProperty().addListener(filterChangeListener);
}
if (payeeFilterTextField != null) {
// payee filter may not have been initialized for all register types
payeeFilterTextField.textProperty().addListener(filterChangeListener);
}
// Repack the table if the font scale changes
ThemeManager.fontScaleProperty().addListener((observable, oldValue, newValue) -> tableViewManager.packTable());
// Listen for transaction events
MessageBus.getInstance().registerListener(messageBusHandler, MessageChannel.TRANSACTION);
}
Aggregations