use of javafx.scene.control.TableColumn in project jgnash by ccavanaugh.
the class BudgetTableController method buildAccountTypeTable.
private void buildAccountTypeTable() {
final TableColumn<AccountGroup, String> nameColumn = new TableColumn<>(resources.getString("Column.Type"));
nameColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().toString()));
accountTypeTable.getColumns().add(nameColumn);
}
use of javafx.scene.control.TableColumn in project jgnash by ccavanaugh.
the class NotificationDialog method initialize.
@FXML
private void initialize() {
final TableColumn<PendingReminder, Boolean> enabledColumn = new TableColumn<>(resources.getString("Column.Approve"));
enabledColumn.setCellValueFactory(param -> new SimpleBooleanProperty(param.getValue().isApproved()));
enabledColumn.setCellFactory(CheckBoxTableCell.forTableColumn(enabledColumn));
tableView.getColumns().add(enabledColumn);
final TableColumn<PendingReminder, LocalDate> dateColumn = new TableColumn<>(resources.getString("Column.Date"));
dateColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getCommitDate()));
dateColumn.setCellFactory(cell -> new DateTableCell());
tableView.getColumns().add(dateColumn);
final TableColumn<PendingReminder, String> descriptionColumn = new TableColumn<>(resources.getString("Column.Description"));
descriptionColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getReminder().getDescription()));
tableView.getColumns().add(descriptionColumn);
tableView.setItems(observableReminderList);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
// Toggle the selection
tableView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
newValue.setApproved(!newValue.isApproved());
tableView.refresh();
Platform.runLater(() -> tableView.getSelectionModel().clearSelection());
}
});
okButton.onActionProperty().set(event -> handleOkayAction());
cancelButton.onActionProperty().set(event -> handleCancelAction());
selectAllButton.onActionProperty().set(event -> handleSelectAllAction());
clearAllButton.onActionProperty().set(event -> handleClearAllAction());
invertButton.onActionProperty().set(event -> handleInvertSelectionAction());
snoozeComboBox.setSelectedPeriod(Options.reminderSnoozePeriodProperty().get());
// Bind options to the snooze period property
Options.reminderSnoozePeriodProperty().bind(snoozeComboBox.periodProperty());
MessageBus.getInstance().registerListener(this, MessageChannel.SYSTEM);
}
use of javafx.scene.control.TableColumn 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;
}
use of javafx.scene.control.TableColumn 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;
}
use of javafx.scene.control.TableColumn in project jgnash by ccavanaugh.
the class SecurityHistoryController method initialize.
@FXML
void initialize() {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
numberFormat.set(CommodityFormat.getShortNumberFormat(engine.getDefaultCurrency()));
selectedSecurityHistoryNode.bind(priceTableView.getSelectionModel().selectedItemProperty());
selectedSecurityNode.bind(securityComboBox.getSelectionModel().selectedItemProperty());
deletePriceButton.disableProperty().bind(Bindings.isNull(selectedSecurityHistoryNode));
selectedSecurityHistoryEvent.bind(eventTableView.getSelectionModel().selectedItemProperty());
deleteEventButton.disableProperty().bind(Bindings.isNull(selectedSecurityHistoryEvent));
// Disabled the update button if a security is not selected, or it does not have a quote source
updatePriceButton.disableProperty().bind(Bindings.or(Bindings.isNull(selectedSecurityNode), Bindings.equal(QuoteSource.NONE, quoteSource)));
// Disabled the update button if a security is not selected, or it does not have a quote source
updateEventButton.disableProperty().bind(Bindings.or(Bindings.isNull(selectedSecurityNode), Bindings.equal(QuoteSource.NONE, quoteSource)));
// Can't add if a security is not selected
addPriceButton.disableProperty().bind(Bindings.isNull(selectedSecurityNode));
// Can't add if a security is not selected and a value is not set
addEventButton.disableProperty().bind(Bindings.isNull(selectedSecurityNode).or(Bindings.isEmpty(eventValueTextField.textProperty())));
priceTableView.setTableMenuButtonVisible(false);
priceTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
final TableColumn<SecurityHistoryNode, LocalDate> priceDateColumn = new TableColumn<>(resources.getString("Column.Date"));
priceDateColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getLocalDate()));
priceDateColumn.setCellFactory(cell -> new ShortDateTableCell<>());
priceTableView.getColumns().add(priceDateColumn);
final TableColumn<SecurityHistoryNode, BigDecimal> priceCloseColumn = new TableColumn<>(resources.getString("Column.Close"));
priceCloseColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getPrice()));
priceCloseColumn.setCellFactory(cell -> new BigDecimalTableCell<>(numberFormat));
priceTableView.getColumns().add(priceCloseColumn);
final TableColumn<SecurityHistoryNode, BigDecimal> priceLowColumn = new TableColumn<>(resources.getString("Column.Low"));
priceLowColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getLow()));
priceLowColumn.setCellFactory(cell -> new BigDecimalTableCell<>(numberFormat));
priceTableView.getColumns().add(priceLowColumn);
final TableColumn<SecurityHistoryNode, BigDecimal> priceHighColumn = new TableColumn<>(resources.getString("Column.High"));
priceHighColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getHigh()));
priceHighColumn.setCellFactory(cell -> new BigDecimalTableCell<>(numberFormat));
priceTableView.getColumns().add(priceHighColumn);
final TableColumn<SecurityHistoryNode, Long> priceVolumeColumn = new TableColumn<>(resources.getString("Column.Volume"));
priceVolumeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getVolume()));
priceVolumeColumn.setCellFactory(cell -> new LongFormatTableCell());
priceTableView.getColumns().add(priceVolumeColumn);
priceTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
sortedHistoryList.comparatorProperty().bind(priceTableView.comparatorProperty());
priceTableView.setItems(sortedHistoryList);
final TableColumn<SecurityHistoryEvent, LocalDate> eventDateColumn = new TableColumn<>(resources.getString("Column.Date"));
eventDateColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDate()));
eventDateColumn.setCellFactory(cell -> new ShortDateTableCell<>());
eventTableView.getColumns().add(eventDateColumn);
final TableColumn<SecurityHistoryEvent, String> eventActionColumn = new TableColumn<>(resources.getString("Column.Event"));
eventActionColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getType().toString()));
eventTableView.getColumns().add(eventActionColumn);
final NumberFormat decimalFormat = NumberFormat.getInstance();
if (decimalFormat instanceof DecimalFormat) {
decimalFormat.setMinimumFractionDigits(MathConstants.SECURITY_PRICE_ACCURACY);
decimalFormat.setMaximumFractionDigits(MathConstants.SECURITY_PRICE_ACCURACY);
}
final TableColumn<SecurityHistoryEvent, BigDecimal> eventValueColumn = new TableColumn<>(resources.getString("Column.Value"));
eventValueColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getValue()));
eventValueColumn.setCellFactory(cell -> new BigDecimalTableCell<>(decimalFormat));
eventTableView.getColumns().add(eventValueColumn);
eventTableView.setTableMenuButtonVisible(false);
eventTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
eventTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
sortedHistoryEventList.comparatorProperty().bind(eventTableView.comparatorProperty());
eventTableView.setItems(sortedHistoryEventList);
eventValueTextField.scaleProperty().set(MathConstants.SECURITY_PRICE_ACCURACY);
chart = new SecurityNodeAreaChart();
chart.securityNodeProperty().bind(selectedSecurityNode);
chartPane.getChildren().addAll(chart);
securityComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
numberFormat.set(CommodityFormat.getShortNumberFormat(newValue.getReportedCurrencyNode()));
closeTextField.scaleProperty().set(newValue.getScale());
lowTextField.scaleProperty().set(newValue.getScale());
highTextField.scaleProperty().set(newValue.getScale());
quoteSource.set(newValue.getQuoteSource());
Platform.runLater(this::loadTables);
}
});
selectedSecurityHistoryNode.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
loadPriceForm();
} else {
clearPriceForm();
}
});
selectedSecurityHistoryEvent.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
loadEventForm();
} else {
clearEventForm();
}
});
// Install a listener to unregister from the message bus when the window closes
parent.addListener((observable, oldValue, scene) -> {
if (scene != null) {
scene.windowProperty().get().addEventHandler(WindowEvent.WINDOW_HIDING, event -> {
Logger.getLogger(SecurityHistoryController.class.getName()).info("Unregistered from the message bus");
MessageBus.getInstance().unregisterListener(SecurityHistoryController.this, MessageChannel.COMMODITY);
});
}
});
Platform.runLater(() -> MessageBus.getInstance().registerListener(SecurityHistoryController.this, MessageChannel.COMMODITY));
}
Aggregations