use of javafx.beans.property.ReadOnlyObjectWrapper in project bisq-desktop by bisq-network.
the class OpenOffersView method setRemoveColumnCellFactory.
private void setRemoveColumnCellFactory() {
removeItemColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
removeItemColumn.setCellFactory(new Callback<TableColumn<OpenOfferListItem, OpenOfferListItem>, TableCell<OpenOfferListItem, OpenOfferListItem>>() {
@Override
public TableCell<OpenOfferListItem, OpenOfferListItem> call(TableColumn<OpenOfferListItem, OpenOfferListItem> column) {
return new TableCell<OpenOfferListItem, OpenOfferListItem>() {
final ImageView iconView = new ImageView();
Button button;
@Override
public void updateItem(final OpenOfferListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
if (button == null) {
button = new AutoTooltipButton(Res.get("shared.remove"));
button.setMinWidth(70);
iconView.setId("image-remove");
button.setGraphic(iconView);
setGraphic(button);
}
button.setOnAction(event -> onRemoveOpenOffer(item.getOpenOffer()));
} else {
setGraphic(null);
if (button != null) {
button.setOnAction(null);
button = null;
}
}
}
};
}
});
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project bisq-desktop by bisq-network.
the class PendingTradesView method setTradeIdColumnCellFactory.
// /////////////////////////////////////////////////////////////////////////////////////////
// CellFactories
// /////////////////////////////////////////////////////////////////////////////////////////
private void setTradeIdColumnCellFactory() {
tradeIdColumn.setCellValueFactory((pendingTradesListItem) -> new ReadOnlyObjectWrapper<>(pendingTradesListItem.getValue()));
tradeIdColumn.setCellFactory(new Callback<TableColumn<PendingTradesListItem, PendingTradesListItem>, TableCell<PendingTradesListItem, PendingTradesListItem>>() {
@Override
public TableCell<PendingTradesListItem, PendingTradesListItem> call(TableColumn<PendingTradesListItem, PendingTradesListItem> column) {
return new TableCell<PendingTradesListItem, PendingTradesListItem>() {
private HyperlinkWithIcon field;
@Override
public void updateItem(final PendingTradesListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
field = new HyperlinkWithIcon(item.getTrade().getShortId());
field.setOnAction(event -> tradeDetailsWindow.show(item.getTrade()));
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
setGraphic(field);
} else {
setGraphic(null);
if (field != null)
field.setOnAction(null);
}
}
};
}
});
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project VocabHunter by VocabHunter.
the class FilterGridController method extractValue.
private ObservableValue<GridCell> extractValue(final CellDataFeatures<GridLine, GridCell> features, final int index) {
List<GridCell> cells = features.getValue().getCells();
GridCell cell = getCell(cells, index);
return cellCache.computeIfAbsent(cell, ReadOnlyObjectWrapper::new);
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project jvarkit by lindenb.
the class VcfStage method buildGenotypeTableRow.
/**
* build Genotype table
*/
private TableView<Genotype> buildGenotypeTableRow(final VCFHeader header) {
final TableView<Genotype> table = new TableView<Genotype>();
/* sample */
table.getColumns().add(makeColumn("Sample", G -> G.getSampleName()));
for (final VCFFormatHeaderLine h : header.getFormatHeaderLines()) {
final TableColumn<Genotype, String> newcol = new TableColumn<>(h.getID());
newcol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Genotype, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<Genotype, String> param) {
final String delim;
Object o;
if (param.getTableColumn().getText().equals(VCFConstants.GENOTYPE_KEY)) {
delim = param.getValue().isPhased() ? "|" : "/";
o = param.getValue().getAlleles().stream().map(A -> allele2stringConverter.apply(A)).collect(Collectors.toList());
} else {
delim = ",";
o = param.getValue().getAnyAttribute(param.getTableColumn().getText());
}
if (o == null) {
return new ReadOnlyObjectWrapper<String>(null);
}
if (o instanceof List) {
List<?> L = (List<?>) o;
o = L.stream().map(S -> String.valueOf(S)).collect(Collectors.joining(delim)).toString();
}
return new ReadOnlyObjectWrapper<String>(String.valueOf(o));
}
});
table.getColumns().add(newcol);
}
/* type */
table.getColumns().add(makeColumn("Type", G -> G.getType().name()));
table.setPlaceholder(new Label("No Genotype."));
return table;
}
Aggregations