CellValueFactory不使用属性中的内部对象填充数据(JavaFX)

时间:2018-04-08 20:08:09

标签: javafx tableview

我在TableView列中填充Employees pojo。
雇主包含rate属性,其中包含不在tableView中填充的doubleDomainObject。 comboBox的实现我没有显示,因为它很好地与CellFactory一起工作。希望专注于CellValueFactory。

DoubleDomainObject

public class DoubleDomainObject extends DomainObject {
private SimpleObjectProperty<Double> doubleValue =new SimpleObjectProperty(this, "doubleValue", null);

public Double getDoubleValue() {return doubleValue.get(); }
public SimpleObjectProperty<Double> doubleValueProperty() {return doubleValue;}
public void setDoubleValue(Double value) {this.doubleValue.set(value);}
}

ColumnDoubleComboBox

public class ColumnDoubleComboBox extends ColumnWrapper{
  protected TableColumn<DomainObject, DoubleDomainObject> column;

  @SuppressWarnings("unchecked")
  public ColumnDoubleComboBox(Bulder builder) {
      super(builder);
      this.column =  new TableColumn<>(columnName);
      setCellValueFactory();
     setCellFactory();
    }

  public void setCellValueFactory(){
      column.setCellValueFactory(new PropertyValueFactory<>(propertyName));
    }
}

员工

public class Employees extends DomainObject {

private SimpleObjectProperty<DoubleDomainObject> rate =new 
    SimpleObjectProperty<>(this, "rate", null);


public DoubleDomainObject getRate() {
   return rate.get();
}

public SimpleObjectProperty<DoubleDomainObject> rateProperty() {
   return rate;
}

public void setRate(RatePerHour rate) {
    this.rate.set(rate);
}
}

---Сlientcode---

tableViewWrapper = AppNode.NodeBuilder.create()
        .<Employees>createTableViewWrapper()
        .setDataMapper(this.dataMapperFabric.getEmployeesDataMapper())
        .setColums(
columnFabric.createColumnDoubleComboBox(ColumnWrapper.Bulder.create()              
.setColumnName("RATE").setColumnSize(0.2).setPropertyName("rate")
                       .............................etc
        );

0 个答案:

没有答案