use of javafx.scene.control.TableColumn in project bisq-desktop by bisq-network.
the class TraderDisputeView method getStateColumn.
private TableColumn<Dispute, Dispute> getStateColumn() {
TableColumn<Dispute, Dispute> column = new AutoTooltipTableColumn<Dispute, Dispute>(Res.get("support.state")) {
{
setMinWidth(50);
}
};
column.setCellValueFactory((dispute) -> new ReadOnlyObjectWrapper<>(dispute.getValue()));
column.setCellFactory(new Callback<TableColumn<Dispute, Dispute>, TableCell<Dispute, Dispute>>() {
@Override
public TableCell<Dispute, Dispute> call(TableColumn<Dispute, Dispute> column) {
return new TableCell<Dispute, Dispute>() {
public ReadOnlyBooleanProperty closedProperty;
public ChangeListener<Boolean> listener;
@Override
public void updateItem(final Dispute item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
listener = (observable, oldValue, newValue) -> {
setText(newValue ? Res.get("support.closed") : Res.get("support.open"));
getTableRow().setOpacity(newValue ? 0.4 : 1);
};
closedProperty = item.isClosedProperty();
closedProperty.addListener(listener);
boolean isClosed = item.isClosed();
setText(isClosed ? Res.get("support.closed") : Res.get("support.open"));
getTableRow().setOpacity(isClosed ? 0.4 : 1);
} else {
if (closedProperty != null) {
closedProperty.removeListener(listener);
closedProperty = null;
}
setText("");
}
}
};
}
});
return column;
}
use of javafx.scene.control.TableColumn in project bisq-desktop by bisq-network.
the class DepositView method setSelectColumnCellFactory.
private void setSelectColumnCellFactory() {
selectColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
selectColumn.setCellFactory(new Callback<TableColumn<DepositListItem, DepositListItem>, TableCell<DepositListItem, DepositListItem>>() {
@Override
public TableCell<DepositListItem, DepositListItem> call(TableColumn<DepositListItem, DepositListItem> column) {
return new TableCell<DepositListItem, DepositListItem>() {
Button button;
@Override
public void updateItem(final DepositListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
if (button == null) {
button = new AutoTooltipButton(Res.get("shared.select"));
setGraphic(button);
}
button.setOnAction(e -> tableView.getSelectionModel().select(item));
} else {
setGraphic(null);
if (button != null) {
button.setOnAction(null);
button = null;
}
}
}
};
}
});
}
use of javafx.scene.control.TableColumn in project bisq-desktop by bisq-network.
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(Res.get("tooltip.openBlockchainForAddress", address)));
setGraphic(hyperlinkWithIcon);
} else {
setGraphic(null);
if (hyperlinkWithIcon != null)
hyperlinkWithIcon.setOnAction(null);
}
}
};
}
});
}
use of javafx.scene.control.TableColumn in project bisq-desktop by bisq-network.
the class LockedView method setDetailsColumnCellFactory.
private void setDetailsColumnCellFactory() {
detailsColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
detailsColumn.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 field;
@Override
public void updateItem(final LockedListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
Optional<Tradable> tradableOptional = getTradable(item);
AddressEntry addressEntry = item.getAddressEntry();
if (tradableOptional.isPresent()) {
field = new HyperlinkWithIcon(Res.get("funds.locked.locked", addressEntry.getShortOfferId()), AwesomeIcon.INFO_SIGN);
field.setOnAction(event -> openDetailPopup(item));
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
setGraphic(field);
} else if (addressEntry.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.scene.control.TableColumn in project bisq-desktop by bisq-network.
the class TradesChartsView method createTable.
// /////////////////////////////////////////////////////////////////////////////////////////
// Table
// /////////////////////////////////////////////////////////////////////////////////////////
private void createTable() {
tableView = new TableView<>();
tableView.setMinHeight(140);
tableView.setPrefHeight(140);
VBox.setVgrow(tableView, Priority.ALWAYS);
// date
TableColumn<TradeStatistics2, TradeStatistics2> dateColumn = new AutoTooltipTableColumn<TradeStatistics2, TradeStatistics2>(Res.get("shared.dateTime")) {
{
setMinWidth(240);
setMaxWidth(240);
}
};
dateColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
dateColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(formatter.formatDateTime(item.getTradeDate()));
else
setText("");
}
};
}
});
dateColumn.setComparator((o1, o2) -> o1.getTradeDate().compareTo(o2.getTradeDate()));
tableView.getColumns().add(dateColumn);
// market
marketColumn = new AutoTooltipTableColumn<TradeStatistics2, TradeStatistics2>(Res.get("shared.market")) {
{
setMinWidth(130);
setMaxWidth(130);
}
};
marketColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
marketColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(formatter.getCurrencyPair(item.getCurrencyCode()));
else
setText("");
}
};
}
});
marketColumn.setComparator((o1, o2) -> o1.getTradeDate().compareTo(o2.getTradeDate()));
tableView.getColumns().add(marketColumn);
// price
priceColumn = new TableColumn<>();
priceColumn.getStyleClass().add("number-column");
priceColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
priceColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(formatter.formatPrice(item.getTradePrice()));
else
setText("");
}
};
}
});
priceColumn.setComparator((o1, o2) -> o1.getTradePrice().compareTo(o2.getTradePrice()));
tableView.getColumns().add(priceColumn);
// amount
TableColumn<TradeStatistics2, TradeStatistics2> amountColumn = new AutoTooltipTableColumn<>(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode()));
amountColumn.getStyleClass().add("number-column");
amountColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
amountColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setGraphic(new ColoredDecimalPlacesWithZerosText(formatter.formatCoin(item.getTradeAmount(), 4), GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
else
setText("");
}
};
}
});
amountColumn.setComparator((o1, o2) -> o1.getTradeAmount().compareTo(o2.getTradeAmount()));
tableView.getColumns().add(amountColumn);
// volume
volumeColumn = new TableColumn<>();
volumeColumn.getStyleClass().add("number-column");
volumeColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
volumeColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(model.showAllTradeCurrenciesProperty.get() ? formatter.formatVolumeWithCode(item.getTradeVolume()) : formatter.formatVolume(item.getTradeVolume()));
else
setText("");
}
};
}
});
volumeColumn.setComparator((o1, o2) -> {
final Volume tradeVolume1 = o1.getTradeVolume();
final Volume tradeVolume2 = o2.getTradeVolume();
return tradeVolume1 != null && tradeVolume2 != null ? tradeVolume1.compareTo(tradeVolume2) : 0;
});
tableView.getColumns().add(volumeColumn);
// paymentMethod
TableColumn<TradeStatistics2, TradeStatistics2> paymentMethodColumn = new AutoTooltipTableColumn<>(Res.get("shared.paymentMethod"));
paymentMethodColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
paymentMethodColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(getPaymentMethodLabel(item));
else
setText("");
}
};
}
});
paymentMethodColumn.setComparator((o1, o2) -> getPaymentMethodLabel(o1).compareTo(getPaymentMethodLabel(o2)));
tableView.getColumns().add(paymentMethodColumn);
// direction
TableColumn<TradeStatistics2, TradeStatistics2> directionColumn = new AutoTooltipTableColumn<>(Res.get("shared.offerType"));
directionColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
directionColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(getDirectionLabel(item));
else
setText("");
}
};
}
});
directionColumn.setComparator((o1, o2) -> getDirectionLabel(o1).compareTo(getDirectionLabel(o2)));
tableView.getColumns().add(directionColumn);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noData"));
placeholder.setWrapText(true);
tableView.setPlaceholder(placeholder);
dateColumn.setSortType(TableColumn.SortType.DESCENDING);
tableView.getSortOrder().add(dateColumn);
}
Aggregations