Search in sources :

Example 11 with ChangeListener

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);
}
Also used : ColumnStyle(jgnash.ui.report.jasper.ColumnStyle) Arrays(java.util.Arrays) Transaction(jgnash.engine.Transaction) LocalDateTime(java.time.LocalDateTime) ResourceUtils(jgnash.util.ResourceUtils) FXCollections(javafx.collections.FXCollections) TransactionEntry(jgnash.engine.TransactionEntry) AccountComboBox(jgnash.uifx.control.AccountComboBox) BigDecimal(java.math.BigDecimal) ColumnHeaderStyle(jgnash.ui.report.jasper.ColumnHeaderStyle) Nullable(jgnash.util.Nullable) ResourceBundle(java.util.ResourceBundle) Locale(java.util.Locale) InvestmentTransaction(jgnash.engine.InvestmentTransaction) AccountType(jgnash.engine.AccountType) CurrencyNode(jgnash.engine.CurrencyNode) ReconciledState(jgnash.engine.ReconciledState) DateUtils(jgnash.time.DateUtils) JasperPrint(net.sf.jasperreports.engine.JasperPrint) TextField(javafx.scene.control.TextField) Predicate(java.util.function.Predicate) FilteredList(javafx.collections.transformation.FilteredList) CheckBox(javafx.scene.control.CheckBox) RegisterFactory(jgnash.uifx.views.register.RegisterFactory) Collectors(java.util.stream.Collectors) Preferences(java.util.prefs.Preferences) AccountGroup(jgnash.engine.AccountGroup) TransactionType(jgnash.engine.TransactionType) FXML(javafx.fxml.FXML) List(java.util.List) Row(jgnash.ui.report.Row) LocalDate(java.time.LocalDate) Account(jgnash.engine.Account) ObservableList(javafx.collections.ObservableList) AbstractReportTableModel(jgnash.ui.report.jasper.AbstractReportTableModel) ChangeListener(javafx.beans.value.ChangeListener) DatePickerEx(jgnash.uifx.control.DatePickerEx) DynamicJasperReport(jgnash.uifx.report.jasper.DynamicJasperReport) Preferences(java.util.prefs.Preferences) FXML(javafx.fxml.FXML)

Example 12 with ChangeListener

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);
}
Also used : Scene(javafx.scene.Scene) Engine(jgnash.engine.Engine) EngineFactory(jgnash.engine.EngineFactory) ResourceUtils(jgnash.util.ResourceUtils) StackPane(javafx.scene.layout.StackPane) XYChart(javafx.scene.chart.XYChart) NumberFormat(java.text.NumberFormat) BigDecimal(java.math.BigDecimal) ResourceBundle(java.util.ResourceBundle) ComboBox(javafx.scene.control.ComboBox) AccountType(jgnash.engine.AccountType) Tooltip(javafx.scene.control.Tooltip) CurrencyNode(jgnash.engine.CurrencyNode) DateUtils(jgnash.time.DateUtils) ObjectProperty(javafx.beans.property.ObjectProperty) InjectFXML(jgnash.uifx.util.InjectFXML) FXMLUtils(jgnash.uifx.util.FXMLUtils) BarChart(javafx.scene.chart.BarChart) Preferences(java.util.prefs.Preferences) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) List(java.util.List) CommodityFormat(jgnash.text.CommodityFormat) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) LocalDate(java.time.LocalDate) CustomCursor(jgnash.resource.cursor.CustomCursor) Account(jgnash.engine.Account) ReportPeriodUtils(jgnash.report.ReportPeriodUtils) ChangeListener(javafx.beans.value.ChangeListener) ReportPeriod(jgnash.report.ReportPeriod) DatePickerEx(jgnash.uifx.control.DatePickerEx) Options(jgnash.uifx.Options) Preferences(java.util.prefs.Preferences) Engine(jgnash.engine.Engine) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Example 13 with ChangeListener

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);
}
Also used : DoughnutChart(jgnash.uifx.control.DoughnutChart) Scene(javafx.scene.Scene) Engine(jgnash.engine.Engine) TextInputControl(javafx.scene.control.TextInputControl) Transaction(jgnash.engine.Transaction) EngineFactory(jgnash.engine.EngineFactory) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) VBox(javafx.scene.layout.VBox) Side(javafx.geometry.Side) AccountComboBox(jgnash.uifx.control.AccountComboBox) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) EncodeDecode(jgnash.util.EncodeDecode) BigDecimal(java.math.BigDecimal) ResourceBundle(java.util.ResourceBundle) Map(java.util.Map) Tooltip(javafx.scene.control.Tooltip) GridPane(javafx.scene.layout.GridPane) CurrencyNode(jgnash.engine.CurrencyNode) ObjectProperty(javafx.beans.property.ObjectProperty) TextField(javafx.scene.control.TextField) InjectFXML(jgnash.uifx.util.InjectFXML) TitledPane(javafx.scene.control.TitledPane) NotNull(jgnash.util.NotNull) Comparators(jgnash.engine.Comparators) Predicate(java.util.function.Predicate) Collectors(java.util.stream.Collectors) Preferences(java.util.prefs.Preferences) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) PieChart(javafx.scene.chart.PieChart) List(java.util.List) CommodityFormat(jgnash.text.CommodityFormat) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) LocalDate(java.time.LocalDate) Account(jgnash.engine.Account) ObservableList(javafx.collections.ObservableList) PayeePredicate(jgnash.util.function.PayeePredicate) ChangeListener(javafx.beans.value.ChangeListener) Collections(java.util.Collections) DatePickerEx(jgnash.uifx.control.DatePickerEx) CollectionUtils(jgnash.util.CollectionUtils) Options(jgnash.uifx.Options) Account(jgnash.engine.Account) Engine(jgnash.engine.Engine) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Example 14 with ChangeListener

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);
}
Also used : DoughnutChart(jgnash.uifx.control.DoughnutChart) Scene(javafx.scene.Scene) Engine(jgnash.engine.Engine) EngineFactory(jgnash.engine.EngineFactory) FXCollections(javafx.collections.FXCollections) StackPane(javafx.scene.layout.StackPane) ParentAccountPredicate(jgnash.util.function.ParentAccountPredicate) Side(javafx.geometry.Side) AccountComboBox(jgnash.uifx.control.AccountComboBox) NumberFormat(java.text.NumberFormat) ResourceBundle(java.util.ResourceBundle) AccountType(jgnash.engine.AccountType) Tooltip(javafx.scene.control.Tooltip) CurrencyNode(jgnash.engine.CurrencyNode) ObjectProperty(javafx.beans.property.ObjectProperty) InjectFXML(jgnash.uifx.util.InjectFXML) Preferences(java.util.prefs.Preferences) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Cursor(javafx.scene.Cursor) PieChart(javafx.scene.chart.PieChart) CommodityFormat(jgnash.text.CommodityFormat) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) LocalDate(java.time.LocalDate) CustomCursor(jgnash.resource.cursor.CustomCursor) Account(jgnash.engine.Account) ObservableList(javafx.collections.ObservableList) ChangeListener(javafx.beans.value.ChangeListener) DatePickerEx(jgnash.uifx.control.DatePickerEx) Options(jgnash.uifx.Options) Account(jgnash.engine.Account) ParentAccountPredicate(jgnash.util.function.ParentAccountPredicate) Preferences(java.util.prefs.Preferences) Engine(jgnash.engine.Engine) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Example 15 with ChangeListener

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);
}
Also used : Engine(jgnash.engine.Engine) TransactionAgePredicate(jgnash.util.function.TransactionAgePredicate) TableViewManager(jgnash.uifx.util.TableViewManager) MessageBus(jgnash.engine.message.MessageBus) BigDecimal(java.math.BigDecimal) MessageProperty(jgnash.engine.message.MessageProperty) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) ComboBox(javafx.scene.control.ComboBox) MessageChannel(jgnash.engine.message.MessageChannel) ContextMenu(javafx.scene.control.ContextMenu) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) TableView(javafx.scene.control.TableView) MemoPredicate(jgnash.util.function.MemoPredicate) MessageListener(jgnash.engine.message.MessageListener) SortedList(javafx.collections.transformation.SortedList) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) Predicate(java.util.function.Predicate) RecurringEntryDialog(jgnash.uifx.views.recurring.RecurringEntryDialog) FilteredList(javafx.collections.transformation.FilteredList) Set(java.util.Set) JavaFXUtils(jgnash.uifx.util.JavaFXUtils) TransactionType(jgnash.engine.TransactionType) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) List(java.util.List) ReconciledPredicate(jgnash.util.function.ReconciledPredicate) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) Message(jgnash.engine.message.Message) ReadOnlyObjectProperty(javafx.beans.property.ReadOnlyObjectProperty) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Transaction(jgnash.engine.Transaction) EngineFactory(jgnash.engine.EngineFactory) ResourceUtils(jgnash.util.ResourceUtils) FXCollections(javafx.collections.FXCollections) Bindings(javafx.beans.binding.Bindings) IntegerProperty(javafx.beans.property.IntegerProperty) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) ResourceBundle(java.util.ResourceBundle) AccountBalanceDisplayManager(jgnash.uifx.views.AccountBalanceDisplayManager) InvestmentTransaction(jgnash.engine.InvestmentTransaction) Callback(javafx.util.Callback) ThemeManager(jgnash.uifx.skin.ThemeManager) Tooltip(javafx.scene.control.Tooltip) ReconciledState(jgnash.engine.ReconciledState) ObjectProperty(javafx.beans.property.ObjectProperty) Label(javafx.scene.control.Label) TableRow(javafx.scene.control.TableRow) Reminder(jgnash.engine.recurring.Reminder) Menu(javafx.scene.control.Menu) TimeUnit(java.util.concurrent.TimeUnit) CommodityFormat(jgnash.text.CommodityFormat) ChronoUnit(java.time.temporal.ChronoUnit) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) StyleClass(jgnash.uifx.skin.StyleClass) Account(jgnash.engine.Account) PayeePredicate(jgnash.util.function.PayeePredicate) ChangeListener(javafx.beans.value.ChangeListener) Collections(java.util.Collections) Options(jgnash.uifx.Options) Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) FXML(javafx.fxml.FXML)

Aggregations

ChangeListener (javafx.beans.value.ChangeListener)25 ObservableValue (javafx.beans.value.ObservableValue)11 ObservableList (javafx.collections.ObservableList)11 FXCollections (javafx.collections.FXCollections)10 FXML (javafx.fxml.FXML)10 ResourceBundle (java.util.ResourceBundle)8 Platform (javafx.application.Platform)8 Stage (javafx.stage.Stage)8 List (java.util.List)7 Scene (javafx.scene.Scene)7 Account (jgnash.engine.Account)7 BigDecimal (java.math.BigDecimal)6 NumberFormat (java.text.NumberFormat)6 Objects (java.util.Objects)6 Preferences (java.util.prefs.Preferences)6 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)6 Tooltip (javafx.scene.control.Tooltip)6 ImageView (javafx.scene.image.ImageView)6 Engine (jgnash.engine.Engine)6 EngineFactory (jgnash.engine.EngineFactory)6