Search in sources :

Example 21 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project Smartcity-Smarthouse by TechnionYP5777.

the class UserInfoController method setCellsFactories.

private void setCellsFactories() {
    nameColumn.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().contact.getName()));
    idColumn.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().contact.getId()));
    phoneColumn.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().contact.getPhoneNumber()));
    emailColumn.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().contact.getEmailAddress()));
    eLevelColumn.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().eLevel + ""));
    contactsTable.setEditable(true);
    phoneColumn.setCellFactory(TextFieldTableCell.forTableColumn());
    phoneColumn.setOnEditCommit(¢ -> ¢.getTableView().getItems().get(¢.getTablePosition().getRow()).contact.setPhoneNumber(¢.getNewValue()));
    emailColumn.setCellFactory(TextFieldTableCell.forTableColumn());
    emailColumn.setOnEditCommit(¢ -> ¢.getTableView().getItems().get(¢.getTablePosition().getRow()).contact.setEmailAddress(¢.getNewValue()));
    eLevelColumn.setCellFactory(ComboBoxTableCell.<ContactGUI, String>forTableColumn(FXCollections.observableArrayList(EmergencyLevel.stringValues())));
    eLevelColumn.setOnEditCommit(¢ -> getModel().getUser().setContactEmergencyLevel(¢.getTableView().getItems().get(¢.getTablePosition().getRow()).contact.getId(), ¢.getNewValue()));
}
Also used : SimpleStringProperty(javafx.beans.property.SimpleStringProperty)

Example 22 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project jgnash by ccavanaugh.

the class BudgetGoalsDialogController method initialize.

@FXML
private void initialize() {
    buttonBar.buttonOrderProperty().bind(Options.buttonOrderProperty());
    endRowSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 1));
    startRowSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 1));
    periodComboBox.getItems().addAll(Period.values());
    patternComboBox.getItems().addAll(Pattern.values());
    patternComboBox.setValue(Pattern.EveryRow);
    fillAllDecimalTextField.emptyWhenZeroProperty().set(false);
    fillPatternAmountDecimalTextField.emptyWhenZeroProperty().set(false);
    fillAllDecimalTextField.setDecimal(BigDecimal.ZERO);
    fillPatternAmountDecimalTextField.setDecimal(BigDecimal.ZERO);
    goalTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    goalTable.setEditable(true);
    final TableColumn<BudgetPeriodDescriptor, String> periodColumn = new TableColumn<>(resources.getString("Column.Period"));
    periodColumn.setEditable(false);
    periodColumn.setCellValueFactory(param -> {
        if (param != null) {
            return new SimpleStringProperty(param.getValue().getPeriodDescription());
        }
        return new SimpleStringProperty("");
    });
    periodColumn.setSortable(false);
    goalTable.getColumns().add(periodColumn);
    final TableColumn<BudgetPeriodDescriptor, BigDecimal> amountColumn = new TableColumn<>(resources.getString("Column.Amount"));
    amountColumn.setEditable(true);
    amountColumn.setSortable(false);
    amountColumn.setCellValueFactory(param -> {
        if (param != null) {
            final BudgetPeriodDescriptor descriptor = param.getValue();
            final BigDecimal goal = budgetGoal.get().getGoal(descriptor.getStartPeriod(), descriptor.getEndPeriod());
            return new SimpleObjectProperty<>(goal.setScale(accountProperty().get().getCurrencyNode().getScale(), MathConstants.roundingMode));
        }
        return new SimpleObjectProperty<>(BigDecimal.ZERO);
    });
    amountColumn.setCellFactory(cell -> new BigDecimalTableCell<>(numberFormat));
    /// fTextFieldTableCell.forTableColumn()
    amountColumn.setOnEditCommit(event -> {
        final BudgetPeriodDescriptor descriptor = event.getTableView().getItems().get(event.getTablePosition().getRow());
        budgetGoalProperty().get().setGoal(descriptor.getStartPeriod(), descriptor.getEndPeriod(), event.getNewValue());
    });
    goalTable.getColumns().add(amountColumn);
    periodComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            budgetGoalProperty().get().setBudgetPeriod(newValue);
            final List<BudgetPeriodDescriptor> descriptors = getDescriptors();
            goalTable.getItems().setAll(descriptors);
            descriptorSize.set(descriptors.size());
        }
    });
    budgetGoalProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            periodComboBox.setValue(newValue.getBudgetPeriod());
        }
    });
    // the spinner factory max values do not like being bound; Set value instead
    descriptorSize.addListener((observable, oldValue, newValue) -> {
        ((SpinnerValueFactory.IntegerSpinnerValueFactory) endRowSpinner.getValueFactory()).setMax(newValue.intValue());
        ((SpinnerValueFactory.IntegerSpinnerValueFactory) startRowSpinner.getValueFactory()).setMax(newValue.intValue());
        endRowSpinner.getValueFactory().setValue(newValue.intValue());
    });
    // account has changed; update currency related properties
    accountProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            final CurrencyNode currencyNode = newValue.getCurrencyNode();
            currencyLabel.setText(currencyNode.getSymbol());
            fillAllDecimalTextField.scaleProperty().set(currencyNode.getScale());
            fillAllDecimalTextField.minScaleProperty().set(currencyNode.getScale());
            fillPatternAmountDecimalTextField.scaleProperty().set(currencyNode.getScale());
            fillPatternAmountDecimalTextField.minScaleProperty().set(currencyNode.getScale());
            final NumberFormat decimalFormat = NumberFormat.getInstance();
            if (decimalFormat instanceof DecimalFormat) {
                decimalFormat.setMinimumFractionDigits(currencyNode.getScale());
                decimalFormat.setMaximumFractionDigits(currencyNode.getScale());
            }
            numberFormat.set(decimalFormat);
        }
    });
}
Also used : CurrencyNode(jgnash.engine.CurrencyNode) DecimalFormat(java.text.DecimalFormat) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TableColumn(javafx.scene.control.TableColumn) BigDecimal(java.math.BigDecimal) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) BudgetPeriodDescriptor(jgnash.engine.budget.BudgetPeriodDescriptor) NumberFormat(java.text.NumberFormat) FXML(javafx.fxml.FXML)

Example 23 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty 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);
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TableColumn(javafx.scene.control.TableColumn) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) RecTransaction(jgnash.engine.RecTransaction) ChangeListener(javafx.beans.value.ChangeListener)

Example 24 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project Gargoyle by callakrsos.

the class SVNViewer method initialize.

@FXML
public void initialize() {
    tvSvnView = new SVNTreeView();
    tvSvnView.setOnAction(this::svnTreeViewOnAction);
    tvSvnView.setOnKeyPressed(this::svnTreeVoewOnKeyPressed);
    tvSvnView.load();
    anTreePane.getChildren().set(0, tvSvnView);
    AnchorPane.setLeftAnchor(tvSvnView, 0.0);
    AnchorPane.setRightAnchor(tvSvnView, 0.0);
    AnchorPane.setBottomAnchor(tvSvnView, 0.0);
    AnchorPane.setTopAnchor(tvSvnView, 0.0);
    colRevision.setCellValueFactory(v -> new SimpleObjectProperty<Long>(v.getValue().getRevision()));
    colUser.setCellValueFactory(v -> new SimpleStringProperty(v.getValue().getAuthor()));
    colComment.setCellValueFactory(v -> new SimpleStringProperty(v.getValue().getMessage()));
    colDate.setCellValueFactory(v -> new SimpleStringProperty(DateUtil.getDateString(v.getValue().getDate().getTime(), "yyyy-MM-dd")));
    javaTextAre = new JavaTextArea();
    borSource.setCenter(javaTextAre);
    lineHist = new LineChart<>(new CategoryAxis(), new CategoryAxis());
    borChart.setCenter(lineHist);
    tbRevision.getSelectionModel().setCellSelectionEnabled(true);
    tbRevision.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    //		FxClipboardUtil.installCopyPasteHandler(tbRevision);
    //		FxTableViewUtil.
    FxUtil.installClipboardKeyEvent(tbRevision);
    MenuItem menuDiff = new MenuItem("Diff");
    menuDiff.setOnAction(this::menuDiffOnAction);
    tbRevision.setContextMenu(new ContextMenu(menuDiff));
    tvSvnView.svnGraphPropertyProperty().addListener((oba, oldView, newView) -> {
        if (newView != null) {
            Tab tabSvnGraph = new Tab("SVN Graph", newView);
            if (tabPaneSVN.getTabs().size() <= TAB_INDEX_SVN_GRAPH) {
                tabPaneSVN.getTabs().add(tabSvnGraph);
            } else {
                tabPaneSVN.getTabs().add(TAB_INDEX_SVN_GRAPH, tabSvnGraph);
            }
        }
    });
    displayLatestRevision();
}
Also used : Tab(javafx.scene.control.Tab) JavaTextArea(com.kyj.fx.voeditor.visual.component.text.JavaTextArea) CategoryAxis(javafx.scene.chart.CategoryAxis) MenuItem(javafx.scene.control.MenuItem) ContextMenu(javafx.scene.control.ContextMenu) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) FXML(javafx.fxml.FXML)

Example 25 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project Gargoyle by callakrsos.

the class AbstractTableColumnInformationController method initialize.

@FXML
public void initialize() {
    colNumber.setCellValueFactory(new NumberingCellValueFactory<TableColumnMetaVO>(tbColumns));
    colKeyType.setCellFactory(param -> new TableCell<TableColumnMetaVO, KEY_TYPE>() {

        @Override
        protected void updateItem(KEY_TYPE item, boolean empty) {
            super.updateItem(item, empty);
            if (empty) {
                setGraphic(null);
            } else {
                ImageView image = null;
                switch(item) {
                    case PRI:
                        image = getImage(PRIMAKRY_KEY_IMAGE_NAME);
                        image.setFitWidth(getPrefWidth());
                        setGraphic(image);
                        break;
                    case MULTI:
                        image = getImage(MULTI_KEY_IMAGE_NAME);
                        image.setFitWidth(getPrefWidth());
                        setGraphic(image);
                        break;
                    case FOREIGN:
                        image = getImage(FOREIGN_KEY_IMAGE_NAME);
                        image.setFitWidth(getPrefWidth());
                        setGraphic(image);
                        break;
                    default:
                        image = new ImageView();
                }
                setGraphic(image);
            }
        }
    });
    colReference.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<TableColumnMetaVO, String>, ObservableValue<String>>() {

        @Override
        public ObservableValue<String> call(CellDataFeatures<TableColumnMetaVO, String> param) {
            TableColumnMetaVO value = param.getValue();
            SimpleStringProperty stringProperty = new SimpleStringProperty();
            if (value != null && value.getRefs() != null) {
                Optional<String> reduce = value.getRefs().stream().map(v -> v.getPkColumnName() + " ->  [ " + v.getFkTableName() + "-" + v.getFkColumnName() + " ]").reduce((str1, str2) -> str1.concat("\n").concat(str2));
                reduce.ifPresent(stringProperty::setValue);
            }
            return stringProperty;
        }
    });
    colKeyType.setCellValueFactory(new PropertyValueFactory<>("keyType"));
    colKeyType.setStyle("-fx-alignment:center");
    this.tbColumns.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    FxUtil.installClipboardKeyEvent(this.tbColumns);
}
Also used : KEY_TYPE(com.kyj.fx.voeditor.visual.component.sql.table.IKeyType.KEY_TYPE) NumberingCellValueFactory(com.kyj.fx.voeditor.visual.component.NumberingCellValueFactory) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) LoggerFactory(org.slf4j.LoggerFactory) DatabaseMetaData(java.sql.DatabaseMetaData) Function(java.util.function.Function) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) SQLException(java.sql.SQLException) TableCell(javafx.scene.control.TableCell) ResultSet(java.sql.ResultSet) Map(java.util.Map) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Logger(org.slf4j.Logger) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Set(java.util.Set) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Collectors(java.util.stream.Collectors) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) SelectionMode(javafx.scene.control.SelectionMode) TreeMap(java.util.TreeMap) ImageView(javafx.scene.image.ImageView) RowMapper(org.springframework.jdbc.core.RowMapper) Optional(java.util.Optional) ObservableValue(javafx.beans.value.ObservableValue) Collections(java.util.Collections) Image(javafx.scene.image.Image) InputStream(java.io.InputStream) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) Optional(java.util.Optional) ObservableValue(javafx.beans.value.ObservableValue) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) ImageView(javafx.scene.image.ImageView) KEY_TYPE(com.kyj.fx.voeditor.visual.component.sql.table.IKeyType.KEY_TYPE) FXML(javafx.fxml.FXML)

Aggregations

SimpleStringProperty (javafx.beans.property.SimpleStringProperty)40 StringProperty (javafx.beans.property.StringProperty)14 TableColumn (javafx.scene.control.TableColumn)12 FXML (javafx.fxml.FXML)9 BigDecimal (java.math.BigDecimal)7 Button (javafx.scene.control.Button)7 IOException (java.io.IOException)5 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)5 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)5 ObservableValue (javafx.beans.value.ObservableValue)5 MockedProperty (com.canoo.dp.impl.remoting.MockedProperty)4 Binding (com.canoo.platform.core.functional.Binding)4 List (java.util.List)4 Map (java.util.Map)4 Label (javafx.scene.control.Label)4 CellDataFeatures (javafx.scene.control.TableColumn.CellDataFeatures)4 ImageView (javafx.scene.image.ImageView)4 Test (org.testng.annotations.Test)4 ChunkWrapper (com.kyj.fx.voeditor.visual.diff.ChunkWrapper)3 CompareResult (com.kyj.fx.voeditor.visual.diff.CompareResult)3