mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 22:45:21 +01:00
Refactor auto-closing of sell BTC offer view
This commit is contained in:
parent
d2baabc180
commit
ee30cd9739
2 changed files with 13 additions and 8 deletions
|
@ -168,7 +168,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
||||||
private ChangeListener<String> tradeCurrencyCodeListener, errorMessageListener,
|
private ChangeListener<String> tradeCurrencyCodeListener, errorMessageListener,
|
||||||
marketPriceMarginListener, volumeListener, buyerSecurityDepositInBTCListener;
|
marketPriceMarginListener, volumeListener, buyerSecurityDepositInBTCListener;
|
||||||
private ChangeListener<Number> marketPriceAvailableListener;
|
private ChangeListener<Number> marketPriceAvailableListener;
|
||||||
private Navigation.Listener navigationWithCloseListener;
|
private Navigation.Listener closeViewListener;
|
||||||
private EventHandler<ActionEvent> currencyComboBoxSelectionHandler, paymentAccountsComboBoxSelectionHandler;
|
private EventHandler<ActionEvent> currencyComboBoxSelectionHandler, paymentAccountsComboBoxSelectionHandler;
|
||||||
private OfferView.CloseHandler closeHandler;
|
private OfferView.CloseHandler closeHandler;
|
||||||
|
|
||||||
|
@ -914,10 +914,8 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
navigationWithCloseListener = (path, data) -> {
|
closeViewListener = (path, data) -> {
|
||||||
log.warn("*** target path={}, data={}, dir={}", path, data, model.getDataModel().getDirection());
|
if (OfferViewUtil.isCloseView((String) data)) {
|
||||||
if ("closeOfferView".equals(data)) {
|
|
||||||
log.warn("*** WILL CLOSE");
|
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -978,7 +976,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
||||||
paymentAccountsComboBox.setOnAction(paymentAccountsComboBoxSelectionHandler);
|
paymentAccountsComboBox.setOnAction(paymentAccountsComboBoxSelectionHandler);
|
||||||
currencyComboBox.setOnAction(currencyComboBoxSelectionHandler);
|
currencyComboBox.setOnAction(currencyComboBoxSelectionHandler);
|
||||||
|
|
||||||
navigation.addListener(navigationWithCloseListener);
|
navigation.addListener(closeViewListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeListeners() {
|
private void removeListeners() {
|
||||||
|
@ -1015,7 +1013,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
||||||
paymentAccountsComboBox.setOnAction(null);
|
paymentAccountsComboBox.setOnAction(null);
|
||||||
currencyComboBox.setOnAction(null);
|
currencyComboBox.setOnAction(null);
|
||||||
|
|
||||||
navigation.removeListener(navigationWithCloseListener);
|
navigation.removeListener(closeViewListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,9 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
// Shared utils for Views
|
// Shared utils for Views
|
||||||
public class OfferViewUtil {
|
public class OfferViewUtil {
|
||||||
|
|
||||||
|
public static final String CLOSE_VIEW = "closeView";
|
||||||
|
|
||||||
public static Label createPopOverLabel(String text) {
|
public static Label createPopOverLabel(String text) {
|
||||||
final Label label = new Label(text);
|
final Label label = new Label(text);
|
||||||
label.setPrefWidth(300);
|
label.setPrefWidth(300);
|
||||||
|
@ -101,7 +104,7 @@ public class OfferViewUtil {
|
||||||
preferences.setSellScreenCurrencyCode("BSQ");
|
preferences.setSellScreenCurrencyCode("BSQ");
|
||||||
navigation.navigateToWithData(
|
navigation.navigateToWithData(
|
||||||
// FIXME: replace "closeOfferView" with a more unique object?
|
// FIXME: replace "closeOfferView" with a more unique object?
|
||||||
directionClosure.getDirection() == OfferPayload.Direction.SELL ? "closeOfferView" : null,
|
directionClosure.getDirection() == OfferPayload.Direction.SELL ? CLOSE_VIEW : null,
|
||||||
MainView.class, SellOfferView.class, OfferBookView.class);
|
MainView.class, SellOfferView.class, OfferBookView.class);
|
||||||
}).show());
|
}).show());
|
||||||
|
|
||||||
|
@ -112,4 +115,8 @@ public class OfferViewUtil {
|
||||||
|
|
||||||
return new Tuple2<>(buyBsqButton, buyBsqButtonVBox);
|
return new Tuple2<>(buyBsqButton, buyBsqButtonVBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isCloseView(String data) {
|
||||||
|
return CLOSE_VIEW.equals(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue