Resize action column if it contains own offers

This commit is contained in:
Christoph Atteneder 2022-10-19 13:25:28 +02:00
parent 9e4b43a8a1
commit e84c94f2b7
No known key found for this signature in database
GPG Key ID: CD5DC1C529CDFD3B

View File

@ -143,6 +143,7 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> depositColumn;
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> signingStateColumn;
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> avatarColumn;
private TableColumn<OfferBookListItem, OfferBookListItem> actionColumn;
private TableView<OfferBookListItem> tableView;
private int gridRow = 0;
@ -261,8 +262,9 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
tableView.getColumns().add(depositColumn);
signingStateColumn = getSigningStateColumn();
tableView.getColumns().add(signingStateColumn);
actionColumn = getActionColumn();
tableView.getColumns().add(actionColumn);
avatarColumn = getAvatarColumn();
tableView.getColumns().add(getActionColumn());
tableView.getColumns().add(avatarColumn);
tableView.getSortOrder().add(priceColumn);
@ -438,6 +440,8 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
currencySelectionSubscriber = currencySelectionBinding.subscribe((observable, oldValue, newValue) -> {
});
updateActionColumn();
tableView.setItems(model.getOfferList());
model.getOfferList().addListener(offerListListener);
@ -1309,5 +1313,10 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
getTradeCurrencyCode()).toUpperCase());
}
private void updateActionColumn() {
boolean hasOwnOffers = model.getOfferList().stream().anyMatch(offerBookListItem -> model.isMyOffer(offerBookListItem.getOffer()));
actionColumn.setMinWidth(hasOwnOffers ? 180 : 90);
}
abstract String getTradeCurrencyCode();
}