use of javafx.beans.property.ReadOnlyObjectWrapper in project bisq-desktop by bisq-network.
the class BsqTxView method addTxIdColumn.
private void addTxIdColumn() {
TableColumn<BsqTxListItem, BsqTxListItem> column = new AutoTooltipTableColumn<>(Res.get("shared.txId"));
column.setCellValueFactory(item -> new ReadOnlyObjectWrapper<>(item.getValue()));
column.setMinWidth(60);
column.setCellFactory(new Callback<TableColumn<BsqTxListItem, BsqTxListItem>, TableCell<BsqTxListItem, BsqTxListItem>>() {
@Override
public TableCell<BsqTxListItem, BsqTxListItem> call(TableColumn<BsqTxListItem, BsqTxListItem> column) {
return new TableCell<BsqTxListItem, BsqTxListItem>() {
private HyperlinkWithIcon hyperlinkWithIcon;
@Override
public void updateItem(final BsqTxListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
String transactionId = item.getTxId();
hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon.setOnAction(event -> openTxInBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", transactionId)));
setGraphic(hyperlinkWithIcon);
} else {
setGraphic(null);
if (hyperlinkWithIcon != null)
hyperlinkWithIcon.setOnAction(null);
}
}
};
}
});
tableView.getColumns().add(column);
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project bisq-desktop by bisq-network.
the class BsqTxView method addInformationColumn.
private void addInformationColumn() {
TableColumn<BsqTxListItem, BsqTxListItem> column = new AutoTooltipTableColumn<>(Res.get("shared.information"));
column.setCellValueFactory(item -> new ReadOnlyObjectWrapper<>(item.getValue()));
column.setMinWidth(160);
column.setCellFactory(new Callback<TableColumn<BsqTxListItem, BsqTxListItem>, TableCell<BsqTxListItem, BsqTxListItem>>() {
@Override
public TableCell<BsqTxListItem, BsqTxListItem> call(TableColumn<BsqTxListItem, BsqTxListItem> column) {
return new TableCell<BsqTxListItem, BsqTxListItem>() {
private AddressWithIconAndDirection field;
@Override
public void updateItem(final BsqTxListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
TxType txType = item.getTxType();
String labelString = Res.get("dao.tx.type.enum." + txType.name());
Label label;
if (item.getConfirmations() > 0 && txType.ordinal() > TxType.INVALID.ordinal()) {
if (item.isBurnedBsqTx() || item.getAmount().isZero()) {
if (field != null)
field.setOnAction(null);
if (txType == TxType.TRANSFER_BSQ) {
if (item.getAmount().isZero())
labelString = Res.get("funds.tx.direction.self");
}
label = new AutoTooltipLabel(labelString);
setGraphic(label);
} else {
// Received
String addressString = item.getAddress();
field = new AddressWithIconAndDirection(item.getDirection(), addressString, AwesomeIcon.EXTERNAL_LINK, item.isReceived());
field.setOnAction(event -> openAddressInBlockExplorer(item));
field.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForAddress", addressString)));
setGraphic(field);
}
} else {
label = new AutoTooltipLabel(labelString);
setGraphic(label);
}
} else {
setGraphic(null);
if (field != null)
field.setOnAction(null);
}
}
};
}
});
tableView.getColumns().add(column);
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project bisq-desktop by bisq-network.
the class ReservedView method setDetailsColumnCellFactory.
private void setDetailsColumnCellFactory() {
detailsColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
detailsColumn.setCellFactory(new Callback<TableColumn<ReservedListItem, ReservedListItem>, TableCell<ReservedListItem, ReservedListItem>>() {
@Override
public TableCell<ReservedListItem, ReservedListItem> call(TableColumn<ReservedListItem, ReservedListItem> column) {
return new TableCell<ReservedListItem, ReservedListItem>() {
private HyperlinkWithIcon field;
@Override
public void updateItem(final ReservedListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
Optional<Tradable> tradableOptional = getTradable(item);
if (tradableOptional.isPresent()) {
field = new HyperlinkWithIcon(Res.get("funds.reserved.reserved", item.getAddressEntry().getShortOfferId()), AwesomeIcon.INFO_SIGN);
field.setOnAction(event -> openDetailPopup(item));
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
setGraphic(field);
} else if (item.getAddressEntry().getContext() == AddressEntry.Context.ARBITRATOR) {
setGraphic(new AutoTooltipLabel(Res.get("shared.arbitratorsFee")));
} else {
setGraphic(new AutoTooltipLabel(Res.get("shared.noDetailsAvailable")));
}
} else {
setGraphic(null);
if (field != null)
field.setOnAction(null);
}
}
};
}
});
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project bisq-desktop by bisq-network.
the class ArbitratorSelectionView method addArbitratorsGroup.
private void addArbitratorsGroup() {
TableGroupHeadline tableGroupHeadline = new TableGroupHeadline(Res.get("account.arbitratorSelection.whichDoYouAccept"));
GridPane.setRowIndex(tableGroupHeadline, ++gridRow);
GridPane.setColumnSpan(tableGroupHeadline, 2);
GridPane.setMargin(tableGroupHeadline, new Insets(40, -10, -10, -10));
root.getChildren().add(tableGroupHeadline);
tableView = new TableView<>();
GridPane.setRowIndex(tableView, gridRow);
GridPane.setColumnSpan(tableView, 2);
GridPane.setMargin(tableView, new Insets(60, -10, 5, -10));
root.getChildren().add(tableView);
autoSelectAllMatchingCheckBox = addCheckBox(root, ++gridRow, Res.get("account.arbitratorSelection.autoSelect"));
GridPane.setColumnSpan(autoSelectAllMatchingCheckBox, 2);
GridPane.setHalignment(autoSelectAllMatchingCheckBox, HPos.LEFT);
GridPane.setColumnIndex(autoSelectAllMatchingCheckBox, 0);
GridPane.setMargin(autoSelectAllMatchingCheckBox, new Insets(0, -10, 0, -10));
autoSelectAllMatchingCheckBox.setOnAction(event -> model.setAutoSelectArbitrators(autoSelectAllMatchingCheckBox.isSelected()));
TableColumn<ArbitratorListItem, String> dateColumn = new AutoTooltipTableColumn<>(Res.get("account.arbitratorSelection.regDate"));
dateColumn.setSortable(false);
dateColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getRegistrationDate()));
dateColumn.setMinWidth(140);
dateColumn.setMaxWidth(140);
TableColumn<ArbitratorListItem, String> nameColumn = new AutoTooltipTableColumn<>(Res.get("shared.onionAddress"));
nameColumn.setSortable(false);
nameColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getAddressString()));
nameColumn.setMinWidth(90);
TableColumn<ArbitratorListItem, String> languagesColumn = new AutoTooltipTableColumn<>(Res.get("account.arbitratorSelection.languages"));
languagesColumn.setSortable(false);
languagesColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getLanguageCodes()));
languagesColumn.setMinWidth(130);
TableColumn<ArbitratorListItem, ArbitratorListItem> selectionColumn = new AutoTooltipTableColumn<ArbitratorListItem, ArbitratorListItem>(Res.get("shared.accept")) {
{
setMinWidth(60);
setMaxWidth(60);
setSortable(false);
}
};
selectionColumn.setCellValueFactory((arbitrator) -> new ReadOnlyObjectWrapper<>(arbitrator.getValue()));
selectionColumn.setCellFactory(new Callback<TableColumn<ArbitratorListItem, ArbitratorListItem>, TableCell<ArbitratorListItem, ArbitratorListItem>>() {
@Override
public TableCell<ArbitratorListItem, ArbitratorListItem> call(TableColumn<ArbitratorListItem, ArbitratorListItem> column) {
return new TableCell<ArbitratorListItem, ArbitratorListItem>() {
private final CheckBox checkBox = new AutoTooltipCheckBox();
private TableRow tableRow;
private BooleanProperty selectedProperty;
private void updateDisableState(final ArbitratorListItem item) {
boolean selected = model.isAcceptedArbitrator(item.arbitrator);
item.setIsSelected(selected);
boolean hasMatchingLanguage = model.hasMatchingLanguage(item.arbitrator);
if (!hasMatchingLanguage) {
model.onRemoveArbitrator(item.arbitrator);
if (selected)
item.setIsSelected(false);
}
boolean isMyOwnRegisteredArbitrator = model.isMyOwnRegisteredArbitrator(item.arbitrator);
checkBox.setDisable(!hasMatchingLanguage || isMyOwnRegisteredArbitrator);
tableRow = getTableRow();
if (tableRow != null) {
tableRow.setOpacity(hasMatchingLanguage && !isMyOwnRegisteredArbitrator ? 1 : 0.4);
if (isMyOwnRegisteredArbitrator) {
String text = Res.get("account.arbitratorSelection.cannotSelectHimself");
tableRow.setTooltip(new Tooltip(text));
tableRow.setOnMouseClicked(e -> new Popup<>().warning(text).show());
} else if (!hasMatchingLanguage) {
tableRow.setTooltip(new Tooltip(Res.get("account.arbitratorSelection.noMatchingLang")));
tableRow.setOnMouseClicked(e -> new Popup<>().warning(Res.get("account.arbitratorSelection.noLang")).show());
} else {
tableRow.setOnMouseClicked(null);
tableRow.setTooltip(null);
}
}
}
@Override
public void updateItem(final ArbitratorListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
selectedProperty = item.isSelectedProperty();
languageCodesListChangeListener = c -> updateDisableState(item);
model.languageCodes.addListener(languageCodesListChangeListener);
isSelectedChangeListener = (observable, oldValue, newValue) -> checkBox.setSelected(newValue);
selectedProperty.addListener(isSelectedChangeListener);
checkBox.setSelected(model.isAcceptedArbitrator(item.arbitrator));
checkBox.setOnAction(e -> {
if (checkBox.isSelected()) {
onAddArbitrator(item);
} else if (model.isDeselectAllowed(item)) {
onRemoveArbitrator(item);
} else {
new Popup<>().warning(Res.get("account.arbitratorSelection.minOne")).show();
checkBox.setSelected(true);
}
item.setIsSelected(checkBox.isSelected());
});
updateDisableState(item);
setGraphic(checkBox);
} else {
model.languageCodes.removeListener(languageCodesListChangeListener);
if (selectedProperty != null)
selectedProperty.removeListener(isSelectedChangeListener);
setGraphic(null);
if (checkBox != null)
checkBox.setOnAction(null);
if (tableRow != null)
tableRow.setOnMouseClicked(null);
}
}
};
}
});
// noinspection unchecked
tableView.getColumns().addAll(dateColumn, nameColumn, languagesColumn, selectionColumn);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project bisq-desktop by bisq-network.
the class ClosedTradesView method setTradeIdColumnCellFactory.
private void setTradeIdColumnCellFactory() {
tradeIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
tradeIdColumn.setCellFactory(new Callback<TableColumn<ClosedTradableListItem, ClosedTradableListItem>, TableCell<ClosedTradableListItem, ClosedTradableListItem>>() {
@Override
public TableCell<ClosedTradableListItem, ClosedTradableListItem> call(TableColumn<ClosedTradableListItem, ClosedTradableListItem> column) {
return new TableCell<ClosedTradableListItem, ClosedTradableListItem>() {
private HyperlinkWithIcon field;
@Override
public void updateItem(final ClosedTradableListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
field = new HyperlinkWithIcon(model.getTradeId(item));
field.setOnAction(event -> {
Tradable tradable = item.getTradable();
if (tradable instanceof Trade)
tradeDetailsWindow.show((Trade) tradable);
else if (tradable instanceof OpenOffer)
offerDetailsWindow.show(tradable.getOffer());
});
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
setGraphic(field);
} else {
setGraphic(null);
if (field != null)
field.setOnAction(null);
}
}
};
}
});
}
Aggregations