Search in sources :

Example 1 with BudgetPeriodDescriptor

use of jgnash.engine.budget.BudgetPeriodDescriptor in project jgnash by ccavanaugh.

the class BudgetGoalsDialogController method handleFillAllAction.

@FXML
private void handleFillAllAction() {
    final BigDecimal fillAmount = fillAllDecimalTextField.getDecimal();
    for (final BudgetPeriodDescriptor descriptor : getDescriptors()) {
        budgetGoal.get().setGoal(descriptor.getStartPeriod(), descriptor.getEndPeriod(), fillAmount);
    }
    goalTable.refresh();
}
Also used : BudgetPeriodDescriptor(jgnash.engine.budget.BudgetPeriodDescriptor) BigDecimal(java.math.BigDecimal) FXML(javafx.fxml.FXML)

Example 2 with BudgetPeriodDescriptor

use of jgnash.engine.budget.BudgetPeriodDescriptor in project jgnash by ccavanaugh.

the class BudgetTableController method buildAccountPeriodResultsColumn.

private TableColumn<Account, BigDecimal> buildAccountPeriodResultsColumn(final int index) {
    final BudgetPeriodDescriptor descriptor = budgetResultsModel.getDescriptorList().get(index);
    final TableColumn<Account, BigDecimal> headerColumn = new TableColumn<>(descriptor.getPeriodDescription());
    final TableColumn<Account, BigDecimal> budgetedColumn = new TableColumn<>(resources.getString("Column.Budgeted"));
    budgetedColumn.setCellValueFactory(param -> {
        if (param.getValue() != null) {
            return new SimpleObjectProperty<>(budgetResultsModel.getResults(descriptor, param.getValue()).getBudgeted());
        }
        return new SimpleObjectProperty<>(BigDecimal.ZERO);
    });
    budgetedColumn.setCellFactory(param -> new AccountCommodityFormatTableCell());
    budgetedColumn.minWidthProperty().bind(columnWidth);
    budgetedColumn.maxWidthProperty().bind(columnWidth);
    budgetedColumn.setSortable(false);
    budgetedColumn.resizableProperty().set(false);
    headerColumn.getColumns().add(budgetedColumn);
    final TableColumn<Account, BigDecimal> actualColumn = new TableColumn<>(resources.getString("Column.Actual"));
    actualColumn.setCellValueFactory(param -> {
        if (param.getValue() != null) {
            return new SimpleObjectProperty<>(budgetResultsModel.getResults(descriptor, param.getValue()).getChange());
        }
        return new SimpleObjectProperty<>(BigDecimal.ZERO);
    });
    actualColumn.setCellFactory(param -> new AccountCommodityFormatTableCell());
    actualColumn.minWidthProperty().bind(columnWidth);
    actualColumn.maxWidthProperty().bind(columnWidth);
    actualColumn.setSortable(false);
    actualColumn.resizableProperty().set(false);
    headerColumn.getColumns().add(actualColumn);
    final TableColumn<Account, BigDecimal> remainingColumn = new TableColumn<>(resources.getString("Column.Remaining"));
    remainingColumn.setCellValueFactory(param -> {
        if (param.getValue() != null) {
            return new SimpleObjectProperty<>(budgetResultsModel.getResults(descriptor, param.getValue()).getRemaining());
        }
        return new SimpleObjectProperty<>(BigDecimal.ZERO);
    });
    remainingColumn.setCellFactory(param -> new AccountCommodityFormatTableCell());
    // the max width is not bound to allow last column to grow and fill any voids
    remainingColumn.minWidthProperty().bind(remainingColumnWidth);
    remainingColumn.maxWidthProperty().bind(remainingColumnWidth);
    remainingColumn.setSortable(false);
    remainingColumn.resizableProperty().set(false);
    headerColumn.getColumns().add(remainingColumn);
    headerColumn.resizableProperty().set(false);
    return headerColumn;
}
Also used : Account(jgnash.engine.Account) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) BudgetPeriodDescriptor(jgnash.engine.budget.BudgetPeriodDescriptor) TableColumn(javafx.scene.control.TableColumn) TreeTableColumn(javafx.scene.control.TreeTableColumn) BigDecimal(java.math.BigDecimal)

Example 3 with BudgetPeriodDescriptor

use of jgnash.engine.budget.BudgetPeriodDescriptor in project jgnash by ccavanaugh.

the class BudgetTableController method calculateMinPeriodColumnWidth.

private double calculateMinPeriodColumnWidth() {
    double max = 0;
    for (final BudgetPeriodDescriptor descriptor : budgetResultsModel.getDescriptorList()) {
        for (final Account account : expandedAccountList) {
            max = Math.max(max, calculateMinColumnWidth(descriptor, account));
        }
    }
    max = Math.max(max, JavaFXUtils.getDisplayedTextWidth(resources.getString("Column.Budgeted") + BORDER_MARGIN, null));
    max = Math.max(max, JavaFXUtils.getDisplayedTextWidth(resources.getString("Column.Actual") + BORDER_MARGIN, null));
    max = Math.max(max, JavaFXUtils.getDisplayedTextWidth(resources.getString("Column.Remaining") + BORDER_MARGIN, null));
    return Math.ceil(max);
}
Also used : Account(jgnash.engine.Account) BudgetPeriodDescriptor(jgnash.engine.budget.BudgetPeriodDescriptor)

Example 4 with BudgetPeriodDescriptor

use of jgnash.engine.budget.BudgetPeriodDescriptor in project jgnash by ccavanaugh.

the class BudgetTableController method buildAccountPeriodSummaryColumn.

private TableColumn<AccountGroup, BigDecimal> buildAccountPeriodSummaryColumn(final int index) {
    final BudgetPeriodDescriptor descriptor = budgetResultsModel.getDescriptorList().get(index);
    final TableColumn<AccountGroup, BigDecimal> headerColumn = new TableColumn<>(descriptor.getPeriodDescription());
    final TableColumn<AccountGroup, BigDecimal> budgetedColumn = new TableColumn<>(resources.getString("Column.Budgeted"));
    budgetedColumn.setCellValueFactory(param -> {
        if (param.getValue() != null) {
            return new SimpleObjectProperty<>(budgetResultsModel.getResults(descriptor, param.getValue()).getBudgeted());
        }
        return new SimpleObjectProperty<>(BigDecimal.ZERO);
    });
    budgetedColumn.setCellFactory(param -> new AccountGroupTableCell());
    budgetedColumn.minWidthProperty().bind(columnWidth);
    budgetedColumn.maxWidthProperty().bind(columnWidth);
    budgetedColumn.setSortable(false);
    budgetedColumn.resizableProperty().set(false);
    headerColumn.getColumns().add(budgetedColumn);
    final TableColumn<AccountGroup, BigDecimal> actualColumn = new TableColumn<>(resources.getString("Column.Actual"));
    actualColumn.setCellValueFactory(param -> {
        if (param.getValue() != null) {
            return new SimpleObjectProperty<>(budgetResultsModel.getResults(descriptor, param.getValue()).getChange());
        }
        return new SimpleObjectProperty<>(BigDecimal.ZERO);
    });
    actualColumn.setCellFactory(param -> new AccountGroupTableCell());
    actualColumn.minWidthProperty().bind(columnWidth);
    actualColumn.maxWidthProperty().bind(columnWidth);
    actualColumn.setSortable(false);
    actualColumn.resizableProperty().set(false);
    headerColumn.getColumns().add(actualColumn);
    final TableColumn<AccountGroup, BigDecimal> remainingColumn = new TableColumn<>(resources.getString("Column.Remaining"));
    remainingColumn.setCellValueFactory(param -> {
        if (param.getValue() != null) {
            return new SimpleObjectProperty<>(budgetResultsModel.getResults(descriptor, param.getValue()).getRemaining());
        }
        return new SimpleObjectProperty<>(BigDecimal.ZERO);
    });
    remainingColumn.setCellFactory(param -> new AccountGroupTableCell());
    // the max width is not bound to allow last column to grow and fill any voids
    remainingColumn.minWidthProperty().bind(remainingColumnWidth);
    remainingColumn.maxWidthProperty().bind(remainingColumnWidth);
    remainingColumn.setSortable(false);
    remainingColumn.resizableProperty().set(false);
    headerColumn.getColumns().add(remainingColumn);
    return headerColumn;
}
Also used : SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) AccountGroup(jgnash.engine.AccountGroup) BudgetPeriodDescriptor(jgnash.engine.budget.BudgetPeriodDescriptor) TableColumn(javafx.scene.control.TableColumn) TreeTableColumn(javafx.scene.control.TreeTableColumn) BigDecimal(java.math.BigDecimal)

Example 5 with BudgetPeriodDescriptor

use of jgnash.engine.budget.BudgetPeriodDescriptor in project jgnash by ccavanaugh.

the class BudgetTableController method calculateMinSummaryWidthColumnWidth.

private double calculateMinSummaryWidthColumnWidth() {
    double max = 0;
    for (final BudgetPeriodDescriptor descriptor : budgetResultsModel.getDescriptorList()) {
        max = Math.max(max, calculateMinColumnWidth(descriptor));
    }
    for (final Account account : expandedAccountList) {
        max = Math.max(max, calculateMinColumnWidth(account));
    }
    max = Math.max(max, JavaFXUtils.getDisplayedTextWidth(resources.getString("Column.Budgeted") + BORDER_MARGIN, null));
    max = Math.max(max, JavaFXUtils.getDisplayedTextWidth(resources.getString("Column.Actual") + BORDER_MARGIN, null));
    max = Math.max(max, JavaFXUtils.getDisplayedTextWidth(resources.getString("Column.Remaining") + BORDER_MARGIN, null));
    return Math.ceil(max);
}
Also used : Account(jgnash.engine.Account) BudgetPeriodDescriptor(jgnash.engine.budget.BudgetPeriodDescriptor)

Aggregations

BudgetPeriodDescriptor (jgnash.engine.budget.BudgetPeriodDescriptor)9 BigDecimal (java.math.BigDecimal)5 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)3 TableColumn (javafx.scene.control.TableColumn)3 Account (jgnash.engine.Account)3 FXML (javafx.fxml.FXML)2 TreeTableColumn (javafx.scene.control.TreeTableColumn)2 DecimalFormat (java.text.DecimalFormat)1 NumberFormat (java.text.NumberFormat)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)1 SpinnerValueFactory (javafx.scene.control.SpinnerValueFactory)1 AccountGroup (jgnash.engine.AccountGroup)1 CurrencyNode (jgnash.engine.CurrencyNode)1