use of jgnash.engine.RecTransaction in project jgnash by ccavanaugh.
the class ReconcileDialogController method configureTableView.
private void configureTableView(final TableView<RecTransaction> tableView, final TableViewManager<RecTransaction> tableViewManager) {
tableView.setTableMenuButtonVisible(false);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
final TableColumn<RecTransaction, String> reconciledColumn = new TableColumn<>(resources.getString("Column.Clr"));
reconciledColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getReconciledState().toString()));
tableView.getColumns().add(reconciledColumn);
final TableColumn<RecTransaction, LocalDate> dateColumn = new TableColumn<>(resources.getString("Column.Date"));
dateColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDate()));
dateColumn.setCellFactory(param -> new ShortDateTableCell<>());
tableView.getColumns().add(dateColumn);
final TableColumn<RecTransaction, String> numberColumn = new TableColumn<>(resources.getString("Column.Num"));
numberColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getNumber()));
tableView.getColumns().add(numberColumn);
final TableColumn<RecTransaction, String> payeeColumn = new TableColumn<>(resources.getString("Column.Payee"));
payeeColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getPayee()));
tableView.getColumns().add(payeeColumn);
final TableColumn<RecTransaction, BigDecimal> amountColumn = new TableColumn<>(resources.getString("Column.Amount"));
amountColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(AccountBalanceDisplayManager.convertToSelectedBalanceMode(account.getAccountType(), param.getValue().getAmount(account))));
amountColumn.setCellFactory(param -> new BigDecimalTableCell<>(CommodityFormat.getShortNumberFormat(account.getCurrencyNode())));
tableView.getColumns().add(amountColumn);
// hide the horizontal scrollbar
tableView.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS);
tableViewManager.setColumnFormatFactory(param -> {
if (param == amountColumn && account != null) {
return CommodityFormat.getShortNumberFormat(account.getCurrencyNode());
}
return null;
});
final ChangeListener<Number> widthListener = new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (newValue != null && newValue.doubleValue() > 0) {
JavaFXUtils.runLater(tableViewManager::restoreLayout);
JavaFXUtils.runLater(tableViewManager::packTable);
tableView.widthProperty().removeListener(this);
}
}
};
tableView.widthProperty().addListener(widthListener);
}
use of jgnash.engine.RecTransaction in project jgnash by ccavanaugh.
the class AbstractReconcileTableModel method messagePosted.
@Override
public void messagePosted(final Message event) {
if (event.getObject(MessageProperty.ACCOUNT).equals(account)) {
rwl.writeLock().lock();
try {
final Transaction transaction = event.getObject(MessageProperty.TRANSACTION);
EventQueue.invokeLater(() -> {
switch(event.getEvent()) {
case TRANSACTION_REMOVE:
RecTransaction trans = findTransaction(transaction);
if (trans != null) {
int index = list.indexOf(trans);
list.remove(index);
fireTableRowsDeleted(index, index);
}
break;
case TRANSACTION_ADD:
if (isVisible(transaction)) {
RecTransaction newTran = new RecTransaction(transaction, transaction.getReconciled(account));
int index = Collections.binarySearch(list, newTran);
if (index < 0) {
index = -index - 1;
list.add(index, newTran);
fireTableRowsInserted(index, index);
}
}
break;
default:
break;
}
});
} finally {
rwl.writeLock().unlock();
}
}
}
use of jgnash.engine.RecTransaction in project jgnash by ccavanaugh.
the class AbstractReconcileTableModel method getReconciledTotal.
public BigDecimal getReconciledTotal() {
BigDecimal sum = BigDecimal.ZERO;
rwl.readLock().lock();
try {
for (final RecTransaction t : list) {
if (t.getReconciledState() == ReconciledState.RECONCILED) {
sum = sum.add(t.getAmount(account));
}
}
} finally {
rwl.readLock().unlock();
}
return AccountBalanceDisplayManager.convertToSelectedBalanceMode(account.getAccountType(), sum);
}
Aggregations