Unify tab handling

This commit is contained in:
Christoph Atteneder 2022-04-21 10:11:20 +02:00
parent 89926d1efb
commit 3ce374e7bb
No known key found for this signature in database
GPG key ID: CD5DC1C529CDFD3B
3 changed files with 10 additions and 6 deletions

View file

@ -250,32 +250,32 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
}
if (viewClass == BtcOfferBookView.class) {
btcOfferBookView = (BtcOfferBookView) viewLoader.load(BtcOfferBookView.class);
btcOfferBookTab.setContent(btcOfferBookView.getRoot());
btcOfferBookView.setOfferActionHandler(offerActionHandler);
btcOfferBookView.setDirection(direction);
tabPane.getSelectionModel().select(btcOfferBookTab);
btcOfferBookView.onTabSelected(true);
tabPane.getSelectionModel().select(btcOfferBookTab);
btcOfferBookTab.setContent(btcOfferBookView.getRoot());
} else if (viewClass == BsqOfferBookView.class) {
bsqOfferBookView = (BsqOfferBookView) viewLoader.load(BsqOfferBookView.class);
bsqOfferBookView.setOfferActionHandler(offerActionHandler);
bsqOfferBookView.setDirection(direction);
bsqOfferBookView.onTabSelected(true);
tabPane.getSelectionModel().select(bsqOfferBookTab);
bsqOfferBookTab.setContent(bsqOfferBookView.getRoot());
bsqOfferBookView.onTabSelected(true);
} else if (viewClass == TopAltcoinOfferBookView.class) {
topAltcoinOfferBookView = (TopAltcoinOfferBookView) viewLoader.load(TopAltcoinOfferBookView.class);
topAltcoinOfferBookView.setOfferActionHandler(offerActionHandler);
topAltcoinOfferBookView.setDirection(direction);
topAltcoinOfferBookView.onTabSelected(true);
tabPane.getSelectionModel().select(topAltcoinOfferBookTab);
topAltcoinOfferBookTab.setContent(topAltcoinOfferBookView.getRoot());
topAltcoinOfferBookView.onTabSelected(true);
} else if (viewClass == OtherOfferBookView.class) {
otherOfferBookView = (OtherOfferBookView) viewLoader.load(OtherOfferBookView.class);
otherOfferBookView.setOfferActionHandler(offerActionHandler);
otherOfferBookView.setDirection(direction);
otherOfferBookView.onTabSelected(true);
tabPane.getSelectionModel().select(otherOfferBookTab);
otherOfferBookTab.setContent(otherOfferBookView.getRoot());
otherOfferBookView.onTabSelected(true);
}
}
}

View file

@ -601,11 +601,15 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
}
public void onTabSelected(boolean isSelected) {
if (model.isTabSelected == isSelected) {
return;
}
model.onTabSelected(isSelected);
if (isSelected) {
updateCurrencyComboBoxFromModel();
root.requestFocus();
updateCreateOfferButton();
}
updateCreateOfferButton();
}

View file

@ -136,7 +136,7 @@ abstract class OfferBookViewModel extends ActivatableViewModel {
PaymentMethod selectedPaymentMethod = getShowAllEntryForPaymentMethod();
private boolean isTabSelected;
boolean isTabSelected;
final BooleanProperty showAllTradeCurrenciesProperty = new SimpleBooleanProperty(true);
final BooleanProperty disableMatchToggle = new SimpleBooleanProperty();
final IntegerProperty maxPlacesForAmount = new SimpleIntegerProperty();