Search in sources :

Example 1 with SimpleObjectProperty

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());
    }
}
Also used : SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Goal(fvarrui.sysadmin.challenger.Goal) Test(fvarrui.sysadmin.challenger.test.Test) ShellCommand(fvarrui.sysadmin.challenger.command.ShellCommand) Challenge(fvarrui.sysadmin.challenger.Challenge)

Example 2 with SimpleObjectProperty

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;
        }
    });
}
Also used : CellDataFeatures(javafx.scene.control.TreeTableColumn.CellDataFeatures) TreeItem(javafx.scene.control.TreeItem) ReadOnlyStringWrapper(javafx.beans.property.ReadOnlyStringWrapper) ObservableValue(javafx.beans.value.ObservableValue) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty)

Example 3 with SimpleObjectProperty

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;
}
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 4 with SimpleObjectProperty

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;
}
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 SimpleObjectProperty

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;
    });
}
Also used : LocalDateTime(java.time.LocalDateTime) DateUtils(jgnash.time.DateUtils) Label(javafx.scene.control.Label) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Transaction(jgnash.engine.Transaction) LocalDateTime(java.time.LocalDateTime) TableColumn(javafx.scene.control.TableColumn) FXML(javafx.fxml.FXML) BigDecimal(java.math.BigDecimal) TableCell(javafx.scene.control.TableCell) SelectionMode(javafx.scene.control.SelectionMode) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) LocalDate(java.time.LocalDate) AccountBalanceDisplayManager(jgnash.uifx.views.AccountBalanceDisplayManager) Account(jgnash.engine.Account) InvestmentTransaction(jgnash.engine.InvestmentTransaction) AccountType(jgnash.engine.AccountType) Callback(javafx.util.Callback) NumericFormats(jgnash.text.NumericFormats) LocalDate(java.time.LocalDate) TableCell(javafx.scene.control.TableCell) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TableColumn(javafx.scene.control.TableColumn) AccountType(jgnash.engine.AccountType) BigDecimal(java.math.BigDecimal) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction)

Aggregations

SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)28 TableColumn (javafx.scene.control.TableColumn)12 BigDecimal (java.math.BigDecimal)9 Button (javafx.scene.control.Button)8 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)6 FXML (javafx.fxml.FXML)6 LocalDate (java.time.LocalDate)5 Optional (java.util.Optional)5 Bindings (javafx.beans.binding.Bindings)5 ObjectProperty (javafx.beans.property.ObjectProperty)5 ObservableList (javafx.collections.ObservableList)5 TableCell (javafx.scene.control.TableCell)5 MappedList (org.phoenicis.javafx.collections.MappedList)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 FXCollections (javafx.collections.FXCollections)4 Scene (javafx.scene.Scene)4 TableView (javafx.scene.control.TableView)4 JavaFxSettingsManager (org.phoenicis.javafx.settings.JavaFxSettingsManager)4 Node (javafx.scene.Node)3