use of javafx.beans.property.ReadOnlyObjectWrapper in project bitsquare by bitsquare.
the class LockedView method setAddressColumnCellFactory.
private void setAddressColumnCellFactory() {
addressColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
addressColumn.setCellFactory(new Callback<TableColumn<LockedListItem, LockedListItem>, TableCell<LockedListItem, LockedListItem>>() {
@Override
public TableCell<LockedListItem, LockedListItem> call(TableColumn<LockedListItem, LockedListItem> column) {
return new TableCell<LockedListItem, LockedListItem>() {
private HyperlinkWithIcon hyperlinkWithIcon;
@Override
public void updateItem(final LockedListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
String address = item.getAddressString();
hyperlinkWithIcon = new HyperlinkWithIcon(address, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip("Open external blockchain explorer for " + "address: " + address));
setGraphic(hyperlinkWithIcon);
} else {
setGraphic(null);
if (hyperlinkWithIcon != null)
hyperlinkWithIcon.setOnAction(null);
}
}
};
}
});
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project bitsquare by bitsquare.
the class ReservedView method setAddressColumnCellFactory.
private void setAddressColumnCellFactory() {
addressColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
addressColumn.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 hyperlinkWithIcon;
@Override
public void updateItem(final ReservedListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
String address = item.getAddressString();
hyperlinkWithIcon = new HyperlinkWithIcon(address, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip("Open external blockchain explorer for " + "address: " + address));
setGraphic(hyperlinkWithIcon);
} else {
setGraphic(null);
if (hyperlinkWithIcon != null)
hyperlinkWithIcon.setOnAction(null);
}
}
};
}
});
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project bitsquare by bitsquare.
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("Reserved in local wallet for offer with ID: " + item.getAddressEntry().getShortOfferId(), AwesomeIcon.INFO_SIGN);
field.setOnAction(event -> openDetailPopup(item));
field.setTooltip(new Tooltip("Open popup for details"));
setGraphic(field);
} else if (item.getAddressEntry().getContext() == AddressEntry.Context.ARBITRATOR) {
setGraphic(new Label("Arbitrator's fee"));
} else {
setGraphic(new Label("No details available"));
}
} else {
setGraphic(null);
if (field != null)
field.setOnAction(null);
}
}
};
}
});
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project bitsquare by bitsquare.
the class OfferBookView method getActionColumn.
private TableColumn<OfferBookListItem, OfferBookListItem> getActionColumn() {
TableColumn<OfferBookListItem, OfferBookListItem> column = new TableColumn<OfferBookListItem, OfferBookListItem>("I want to:") {
{
setMinWidth(80);
setSortable(false);
}
};
column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
column.setCellFactory(new Callback<TableColumn<OfferBookListItem, OfferBookListItem>, TableCell<OfferBookListItem, OfferBookListItem>>() {
@Override
public TableCell<OfferBookListItem, OfferBookListItem> call(TableColumn<OfferBookListItem, OfferBookListItem> column) {
return new TableCell<OfferBookListItem, OfferBookListItem>() {
final ImageView iconView = new ImageView();
final Button button = new Button();
boolean isTradable, isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion, isIgnored, isOfferBanned, isNodeBanned;
{
button.setGraphic(iconView);
button.setMinWidth(130);
button.setMaxWidth(130);
button.setGraphicTextGap(10);
}
@Override
public void updateItem(final OfferBookListItem newItem, boolean empty) {
super.updateItem(newItem, empty);
TableRow tableRow = getTableRow();
if (newItem != null && !empty) {
final Offer offer = newItem.getOffer();
boolean myOffer = model.isMyOffer(offer);
if (tableRow != null) {
isPaymentAccountValidForOffer = model.isAnyPaymentAccountValidForOffer(offer);
hasMatchingArbitrator = model.hasMatchingArbitrator(offer);
hasSameProtocolVersion = model.hasSameProtocolVersion(offer);
isIgnored = model.isIgnored(offer);
isOfferBanned = model.isOfferBanned(offer);
isNodeBanned = model.isNodeBanned(offer);
isTradable = isPaymentAccountValidForOffer && hasMatchingArbitrator && hasSameProtocolVersion && !isIgnored && !isOfferBanned && !isNodeBanned;
tableRow.setOpacity(isTradable || myOffer ? 1 : 0.4);
if (isTradable) {
// set first row button as default
button.setDefaultButton(getIndex() == 0);
tableRow.setOnMousePressed(null);
} else {
button.setDefaultButton(false);
tableRow.setOnMousePressed(e -> {
if (!(e.getTarget() instanceof ImageView || e.getTarget() instanceof Canvas))
onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion, isIgnored, isOfferBanned, isNodeBanned);
});
//TODO
//tableRow.setTooltip(new Tooltip(""));
}
}
String title;
if (myOffer) {
iconView.setId("image-remove");
title = "Remove";
button.setId("cancel-button");
// does not take the font colors sometimes from the style
button.setStyle("-fx-text-fill: #444;");
button.setOnAction(e -> onRemoveOpenOffer(offer));
} else {
boolean isSellOffer = offer.getDirection() == Offer.Direction.SELL;
iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
button.setId(isSellOffer ? "buy-button" : "sell-button");
// does not take the font colors sometimes from the style
button.setStyle("-fx-text-fill: white;");
title = model.getDirectionLabel(offer);
button.setTooltip(new Tooltip("Take offer for " + model.getDirectionLabelTooltip(offer)));
button.setOnAction(e -> onTakeOffer(offer));
}
if (!myOffer && !isTradable)
button.setOnAction(e -> onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion, isIgnored, isOfferBanned, isNodeBanned));
button.setText(title);
setGraphic(button);
} else {
setGraphic(null);
if (button != null)
button.setOnAction(null);
if (tableRow != null) {
tableRow.setOpacity(1);
tableRow.setOnMousePressed(null);
}
}
}
};
}
});
return column;
}
use of javafx.beans.property.ReadOnlyObjectWrapper in project bitsquare by bitsquare.
the class OfferBookView method getPaymentMethodColumn.
private TableColumn<OfferBookListItem, OfferBookListItem> getPaymentMethodColumn() {
TableColumn<OfferBookListItem, OfferBookListItem> column = new TableColumn<OfferBookListItem, OfferBookListItem>("Payment method") {
{
setMinWidth(125);
}
};
column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
column.setCellFactory(new Callback<TableColumn<OfferBookListItem, OfferBookListItem>, TableCell<OfferBookListItem, OfferBookListItem>>() {
@Override
public TableCell<OfferBookListItem, OfferBookListItem> call(TableColumn<OfferBookListItem, OfferBookListItem> column) {
return new TableCell<OfferBookListItem, OfferBookListItem>() {
private HyperlinkWithIcon field;
@Override
public void updateItem(final OfferBookListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
field = new HyperlinkWithIcon(model.getPaymentMethod(item), true);
field.setOnAction(event -> offerDetailsWindow.show(item.getOffer()));
field.setTooltip(new Tooltip(model.getPaymentMethodToolTip(item)));
setGraphic(field);
} else {
setGraphic(null);
if (field != null)
field.setOnAction(null);
}
}
};
}
});
return column;
}
Aggregations