use of javafx.beans.property.SimpleObjectProperty in project Challenger4SysAdmins by fvarrui.
the class RootController method onSeleccionadoChanged.
/**
* Listener para ser notificado de cambios y bindear el modelo.
* @param o valor observable
* @param ov viejo goal
* @param nv goal nuevo
* @throws IOException si no puede cargar la vista
*/
private void onSeleccionadoChanged(ObservableValue<? extends Object> o, Object ov, Object nv) {
centerPane.setCenter(emptyView);
// desbindea del panel el elemento anterior
if (ov instanceof Challenge) {
challengeController.challengeProperty().unbind();
} else if (ov instanceof Goal) {
goalController.goalProperty().unbind();
} else if (ov instanceof Test) {
testController.testProperty().unbind();
} else if (ov instanceof ShellCommand) {
comandController.shellCommandProperty().unbind();
}
// bindea el elemento al panel adecuado y lo muestra
if (nv instanceof Challenge) {
Challenge challenge = (Challenge) nv;
challengeController.challengeProperty().bind(new SimpleObjectProperty<>(challenge));
centerPane.setCenter(challengeController.getView());
} else if (nv instanceof Goal) {
Goal goal = (Goal) nv;
goalController.goalProperty().bind(new SimpleObjectProperty<Goal>(goal));
centerPane.setCenter(goalController.getView());
} else if (nv instanceof Test) {
Test test = (Test) nv;
testController.testProperty().bind(new SimpleObjectProperty<>(test));
centerPane.setCenter(testController.getView());
} else if (nv instanceof ShellCommand) {
ShellCommand comand = (ShellCommand) nv;
comandController.shellCommandProperty().bind(new SimpleObjectProperty<>(comand));
centerPane.setCenter(comandController.getView());
}
}
use of javafx.beans.property.SimpleObjectProperty in project dwoss by gg-net.
the class TreeTableController method initialize.
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TreeItem<DataWrapper> root = new TreeItem<>(new DataWrapper() {
@Override
public String getName() {
return "Root";
}
});
view.setRoot(root);
root.setExpanded(true);
view.setShowRoot(false);
root.getChildren().addAll(getTradeNames());
overview.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<DataWrapper, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<DataWrapper, String> param) {
return new ReadOnlyStringWrapper(param.getValue().getValue().getName());
}
});
amount.setCellValueFactory(new Callback<CellDataFeatures<DataWrapper, Integer>, ObservableValue<Integer>>() {
@Override
public ObservableValue<Integer> call(CellDataFeatures<DataWrapper, Integer> param) {
DataWrapper dw = param.getValue().getValue();
SimpleObjectProperty<Integer> result;
if (dw instanceof ProductGroupWrapper) {
result = new SimpleObjectProperty<>(amountOfCategoryProducts(((ProductGroupWrapper) dw).getTradeName(), ((ProductGroupWrapper) dw).getProductGroup()));
return result;
}
if (dw instanceof CategoryProductWrapper) {
result = new SimpleObjectProperty<>(amountOfProducts(((CategoryProductWrapper) dw).getCategoryProductId()));
return result;
}
if (dw instanceof ProductWrapper) {
result = new SimpleObjectProperty<>(amountOfUnitCollections(((ProductWrapper) dw).getProductId()));
return result;
}
if (dw instanceof UnitCollectionWrapper) {
result = new SimpleObjectProperty<>(amountOfUnits(((UnitCollectionWrapper) dw).getUnitCollectionId()));
return result;
}
result = new SimpleObjectProperty<>(0);
return result;
}
});
}
use of javafx.beans.property.SimpleObjectProperty 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);
// determine if the column is to be highlighted if the period is not yearly
final Boolean highlight = (descriptor.isBetween(LocalDate.now()) ? Boolean.TRUE : Boolean.FALSE) && budget.get().getBudgetPeriod() != Period.YEARLY;
final TableColumn<Account, BigDecimal> headerColumn = new TableColumn<>(descriptor.getPeriodDescription());
final TableColumn<Account, BigDecimal> budgetedColumn = new TableColumn<>(resources.getString("Column.Budgeted"));
budgetedColumn.getProperties().put(NOW, highlight);
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());
lockColumnBehavior(budgetedColumn, columnWidth);
headerColumn.getColumns().add(budgetedColumn);
final TableColumn<Account, BigDecimal> actualColumn = new TableColumn<>(resources.getString("Column.Actual"));
actualColumn.getProperties().put(NOW, highlight);
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());
lockColumnBehavior(actualColumn, columnWidth);
headerColumn.getColumns().add(actualColumn);
final TableColumn<Account, BigDecimal> remainingColumn = new TableColumn<>(resources.getString("Column.Remaining"));
remainingColumn.getProperties().put(NOW, highlight);
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());
lockColumnBehavior(remainingColumn, remainingColumnWidth);
headerColumn.getColumns().add(remainingColumn);
headerColumn.resizableProperty().set(false);
return headerColumn;
}
use of javafx.beans.property.SimpleObjectProperty 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);
// determine if the column is to be highlighted if the period is not yearly
final Boolean highlight = (descriptor.isBetween(LocalDate.now()) ? Boolean.TRUE : Boolean.FALSE) && budget.get().getBudgetPeriod() != Period.YEARLY;
final TableColumn<AccountGroup, BigDecimal> headerColumn = new TableColumn<>(descriptor.getPeriodDescription());
final TableColumn<AccountGroup, BigDecimal> budgetedColumn = new TableColumn<>(resources.getString("Column.Budgeted"));
budgetedColumn.getProperties().put(NOW, highlight);
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());
lockColumnBehavior(budgetedColumn, columnWidth);
headerColumn.getColumns().add(budgetedColumn);
final TableColumn<AccountGroup, BigDecimal> actualColumn = new TableColumn<>(resources.getString("Column.Actual"));
actualColumn.getProperties().put(NOW, highlight);
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());
lockColumnBehavior(actualColumn, columnWidth);
headerColumn.getColumns().add(actualColumn);
final TableColumn<AccountGroup, BigDecimal> remainingColumn = new TableColumn<>(resources.getString("Column.Remaining"));
remainingColumn.getProperties().put(NOW, highlight);
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
lockColumnBehavior(remainingColumn, remainingColumnWidth);
headerColumn.getColumns().add(remainingColumn);
return headerColumn;
}
use of javafx.beans.property.SimpleObjectProperty in project jgnash by ccavanaugh.
the class BasicRegisterTableController method buildTable.
@Override
protected void buildTable() {
final String[] columnNames = RegisterFactory.getColumnNames(accountProperty().get().getAccountType());
final TableColumn<Transaction, LocalDate> dateColumn = new TableColumn<>(columnNames[0]);
dateColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getLocalDate()));
dateColumn.setCellFactory(cell -> new TransactionDateTableCell());
tableView.getColumns().add(dateColumn);
final TableColumn<Transaction, LocalDateTime> dateTimeColumn = new TableColumn<>(columnNames[1]);
dateTimeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getTimestamp()));
dateTimeColumn.setCellFactory(cell -> new TransactionDateTimeTableCell());
tableView.getColumns().add(dateTimeColumn);
final TableColumn<Transaction, String> numberColumn = new TableColumn<>(columnNames[2]);
numberColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getNumber()));
numberColumn.setCellFactory(cell -> new TransactionStringTableCell());
tableView.getColumns().add(numberColumn);
final TableColumn<Transaction, String> payeeColumn = new TableColumn<>(columnNames[3]);
payeeColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getPayee()));
payeeColumn.setCellFactory(cell -> new TransactionStringTableCell());
tableView.getColumns().add(payeeColumn);
final TableColumn<Transaction, String> memoColumn = new TableColumn<>(columnNames[4]);
memoColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getMemo()));
memoColumn.setCellFactory(cell -> new TransactionStringTableCell());
tableView.getColumns().add(memoColumn);
final TableColumn<Transaction, String> accountColumn = new TableColumn<>(columnNames[5]);
accountColumn.setCellValueFactory(param -> new AccountNameWrapper(param.getValue()));
accountColumn.setCellFactory(cell -> new TransactionStringTableCell());
tableView.getColumns().add(accountColumn);
final TableColumn<Transaction, String> reconciledColumn = new TableColumn<>(columnNames[6]);
reconciledColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getReconciled(account.get()).toString()));
reconciledColumn.setCellFactory(cell -> new TransactionStringTableCell());
tableView.getColumns().add(reconciledColumn);
final Callback<TableColumn<Transaction, BigDecimal>, TableCell<Transaction, BigDecimal>> shortDecimalCellFactory = cell -> new TransactionCommodityFormatTableCell(NumericFormats.getShortCommodityFormat(account.get().getCurrencyNode()));
final TableColumn<Transaction, BigDecimal> increaseColumn = new TableColumn<>(columnNames[7]);
increaseColumn.setCellValueFactory(param -> new IncreaseAmountProperty(param.getValue().getAmount(accountProperty().getValue())));
increaseColumn.setCellFactory(shortDecimalCellFactory);
tableView.getColumns().add(increaseColumn);
final TableColumn<Transaction, BigDecimal> decreaseColumn = new TableColumn<>(columnNames[8]);
decreaseColumn.setCellValueFactory(param -> new DecreaseAmountProperty(param.getValue().getAmount(accountProperty().getValue())));
decreaseColumn.setCellFactory(shortDecimalCellFactory);
tableView.getColumns().add(decreaseColumn);
final TableColumn<Transaction, BigDecimal> balanceColumn = new TableColumn<>(columnNames[9]);
balanceColumn.setCellValueFactory(param -> {
final AccountType accountType = accountProperty().getValue().getAccountType();
return new SimpleObjectProperty<>(AccountBalanceDisplayManager.convertToSelectedBalanceMode(accountType, getBalanceAt(param.getValue())));
});
balanceColumn.setCellFactory(cell -> new TransactionCommodityFormatTableCell(NumericFormats.getFullCommodityFormat(account.get().getCurrencyNode())));
// do not allow a sort on the balance
balanceColumn.setSortable(false);
tableView.getColumns().add(balanceColumn);
tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
tableViewManager.setColumnFormatFactory(param -> {
if (param == balanceColumn) {
return NumericFormats.getFullCommodityFormat(accountProperty().getValue().getCurrencyNode());
} else if (param == increaseColumn || param == decreaseColumn) {
return NumericFormats.getShortCommodityFormat(accountProperty().getValue().getCurrencyNode());
} else if (param == dateColumn) {
return DateUtils.getShortDateFormatter().toFormat();
} else if (param == dateTimeColumn) {
return DateUtils.getShortDateTimeFormatter().toFormat();
}
return null;
});
}
Aggregations