columSituacao.setCellValueFactory(new Callback<CellDataFeatures<Tabela, Tabela>, ObservableValue<Tabela>>() {
public ObservableValue<Tabela> call(CellDataFeatures<Tabela, Tabela> p) {
return new ReadOnlyObjectWrapper<Tabela>(p.getValue());
}
});
columSituacao.setCellFactory(new Callback<TableColumn<Tabela, Tabela>, TableCell<Tabela, Tabela>>() {
public TableCell<Tabela, Tabela> call(TableColumn<Tabela, Tabela> param) {
final ProgressBar progressBar = new ProgressBar();
final HBox box = new HBox();
box.setPrefHeight(Progress.PREF_HEIGHT);
final Text text = new Text();
BorderPane border = new BorderPane();
border.setTop(text);
border.setBottom(progressBar);
BorderPane.setAlignment(text, Pos.CENTER);
box.getChildren().add(border);
return new TableCell<Tabela, Tabela>() {
@Override
protected void updateItem(Tabela item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
setGraphic(null);
} else {
if (text != null) {
text.textProperty().bind(item.etapaProperty());
}
progressBar.progressProperty().bind(item.progressProperty());
progressBar.prefWidthProperty().bind(this.widthProperty());
setGraphic(box);
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
}
}
};
}
});
tableView.getItems().addAll(lista);
tableView.getSelectionModel().selectFirst();
}