mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 18:33:43 +01:00
Merge pull request #1521 from ripcurlx/improve-edit-offer
Improvements for edit offer
This commit is contained in:
commit
0a6f79b50f
@ -134,6 +134,7 @@ public abstract class EditableOfferDataModel extends OfferDataModel implements B
|
||||
private boolean marketPriceAvailable;
|
||||
private int feeTxSize = 260; // size of typical tx with 1 input
|
||||
private int feeTxSizeEstimationRecursionCounter;
|
||||
protected boolean allowAmountUpdate = true;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
@ -652,7 +653,8 @@ public abstract class EditableOfferDataModel extends OfferDataModel implements B
|
||||
if (volume.get() != null &&
|
||||
price.get() != null &&
|
||||
!volume.get().isZero() &&
|
||||
!price.get().isZero()) {
|
||||
!price.get().isZero() &&
|
||||
allowAmountUpdate) {
|
||||
try {
|
||||
amount.set(formatter.reduceTo4Decimals(price.get().getAmountByVolume(volume.get())));
|
||||
calculateTotalToPay();
|
||||
|
@ -137,18 +137,18 @@ public abstract class EditableOfferView<M extends EditableOfferViewModel> extend
|
||||
private TitledGroupBg payFundsTitledGroupBg, setDepositTitledGroupBg, paymentTitledGroupBg;
|
||||
private BusyAnimation waitingForFundsBusyAnimation;
|
||||
private Button nextButton, cancelButton1, cancelButton2, placeOfferButton, priceTypeToggleButton;
|
||||
private InputTextField buyerSecurityDepositInputTextField, fixedPriceTextField, marketBasedPriceTextField,
|
||||
volumeTextField;
|
||||
protected InputTextField amountTextField, minAmountTextField;
|
||||
private InputTextField buyerSecurityDepositInputTextField, fixedPriceTextField, marketBasedPriceTextField;
|
||||
protected InputTextField amountTextField, minAmountTextField, volumeTextField;
|
||||
private TextField currencyTextField;
|
||||
private AddressTextField addressTextField;
|
||||
private BalanceTextField balanceTextField;
|
||||
private FundsTextField totalToPayTextField;
|
||||
private Label directionLabel, amountDescriptionLabel, addressLabel, balanceLabel, totalToPayLabel,
|
||||
priceCurrencyLabel, volumeCurrencyLabel, priceDescriptionLabel,
|
||||
priceCurrencyLabel, priceDescriptionLabel,
|
||||
volumeDescriptionLabel, currencyTextFieldLabel, buyerSecurityDepositLabel, currencyComboBoxLabel,
|
||||
waitingForFundsLabel, marketBasedPriceLabel, xLabel, percentagePriceDescription, resultLabel,
|
||||
buyerSecurityDepositBtcLabel, paymentAccountsLabel;
|
||||
protected Label amountBtcLabel, volumeCurrencyLabel, minAmountBtcLabel;
|
||||
private ComboBox<PaymentAccount> paymentAccountsComboBox;
|
||||
private ComboBox<TradeCurrency> currencyComboBox;
|
||||
private ImageView imageView, qrCodeImageView;
|
||||
@ -169,6 +169,7 @@ public abstract class EditableOfferView<M extends EditableOfferViewModel> extend
|
||||
private boolean clearXchangeWarningDisplayed, isActivated;
|
||||
private ChangeListener<Boolean> getShowWalletFundedNotificationListener;
|
||||
private InfoInputTextField marketBasedPriceInfoInputTextField;
|
||||
protected TitledGroupBg amountTitledGroupBg;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
@ -201,6 +202,10 @@ public abstract class EditableOfferView<M extends EditableOfferViewModel> extend
|
||||
|
||||
paymentAccountsComboBox.setConverter(GUIUtil.getPaymentAccountsComboBoxStringConverter());
|
||||
|
||||
doSetFocus();
|
||||
}
|
||||
|
||||
protected void doSetFocus() {
|
||||
GUIUtil.focusWhenAddedToScene(amountTextField);
|
||||
}
|
||||
|
||||
@ -463,7 +468,7 @@ public abstract class EditableOfferView<M extends EditableOfferViewModel> extend
|
||||
}
|
||||
}
|
||||
|
||||
private void onPaymentAccountsComboBoxSelected() {
|
||||
protected void onPaymentAccountsComboBoxSelected() {
|
||||
// Temporary deactivate handler as the payment account change can populate a new currency list and causes
|
||||
// unwanted selection events (item 0)
|
||||
currencyComboBox.setOnAction(null);
|
||||
@ -911,8 +916,8 @@ public abstract class EditableOfferView<M extends EditableOfferViewModel> extend
|
||||
}
|
||||
|
||||
private void addAmountPriceGroup() {
|
||||
TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 2, Res.get("createOffer.setAmountPrice"), Layout.GROUP_DISTANCE);
|
||||
GridPane.setColumnSpan(titledGroupBg, 3);
|
||||
amountTitledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 2, Res.get("createOffer.setAmountPrice"), Layout.GROUP_DISTANCE);
|
||||
GridPane.setColumnSpan(amountTitledGroupBg, 3);
|
||||
|
||||
imageView = new ImageView();
|
||||
imageView.setPickOnBounds(true);
|
||||
@ -1133,7 +1138,7 @@ public abstract class EditableOfferView<M extends EditableOfferViewModel> extend
|
||||
HBox amountValueCurrencyBox = amountValueCurrencyBoxTuple.first;
|
||||
amountTextField = amountValueCurrencyBoxTuple.second;
|
||||
editOfferElements.add(amountTextField);
|
||||
Label amountBtcLabel = amountValueCurrencyBoxTuple.third;
|
||||
amountBtcLabel = amountValueCurrencyBoxTuple.third;
|
||||
editOfferElements.add(amountBtcLabel);
|
||||
Tuple2<Label, VBox> amountInputBoxTuple = getTradeInputBox(amountValueCurrencyBox, model.getAmountDescription());
|
||||
amountDescriptionLabel = amountInputBoxTuple.first;
|
||||
@ -1263,7 +1268,7 @@ public abstract class EditableOfferView<M extends EditableOfferViewModel> extend
|
||||
HBox amountValueCurrencyBox = amountValueCurrencyBoxTuple.first;
|
||||
minAmountTextField = amountValueCurrencyBoxTuple.second;
|
||||
editOfferElements.add(minAmountTextField);
|
||||
Label minAmountBtcLabel = amountValueCurrencyBoxTuple.third;
|
||||
minAmountBtcLabel = amountValueCurrencyBoxTuple.third;
|
||||
editOfferElements.add(minAmountBtcLabel);
|
||||
|
||||
Tuple2<Label, VBox> amountInputBoxTuple = getTradeInputBox(amountValueCurrencyBox,
|
||||
|
@ -57,6 +57,8 @@ class EditOpenOfferDataModel extends EditableOfferDataModel {
|
||||
this.openOffer = openOffer;
|
||||
this.initialState = openOffer.getState();
|
||||
this.paymentAccount = user.getPaymentAccount(openOffer.getOffer().getMakerPaymentAccountId());
|
||||
|
||||
this.allowAmountUpdate = false;
|
||||
}
|
||||
|
||||
public void populateData() {
|
||||
|
@ -70,6 +70,16 @@ public class EditOpenOfferView extends EditableOfferView<EditOpenOfferViewModel>
|
||||
super.initialize();
|
||||
|
||||
addConfirmEditGroup();
|
||||
renameAmountGroup();
|
||||
}
|
||||
|
||||
private void renameAmountGroup() {
|
||||
amountTitledGroupBg.setText(Res.get("editOffer.setPrice"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doSetFocus() {
|
||||
// Don't focus in any field before data was set
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -78,12 +88,15 @@ public class EditOpenOfferView extends EditableOfferView<EditOpenOfferViewModel>
|
||||
|
||||
addBindings();
|
||||
|
||||
hidePaymentGroup();
|
||||
hideOptionsGroup();
|
||||
|
||||
// Lock amount field as it would require bigger changes to support increased amount values.
|
||||
amountTextField.setDisable(true);
|
||||
amountBtcLabel.setDisable(true);
|
||||
minAmountTextField.setDisable(true);
|
||||
minAmountBtcLabel.setDisable(true);
|
||||
volumeTextField.setDisable(true);
|
||||
volumeCurrencyLabel.setDisable(true);
|
||||
|
||||
// Workaround to fix margin on top of amount group
|
||||
gridPane.setPadding(new Insets(-20, 25, -1, 25));
|
||||
@ -91,20 +104,15 @@ public class EditOpenOfferView extends EditableOfferView<EditOpenOfferViewModel>
|
||||
updateMarketPriceAvailable();
|
||||
updateElementsWithDirection();
|
||||
|
||||
model.onStartEditOffer(errorMessage -> {
|
||||
log.error(errorMessage);
|
||||
new Popup<>().warning(Res.get("editOffer.failed", errorMessage))
|
||||
.onClose(() -> {
|
||||
close();
|
||||
})
|
||||
.show();
|
||||
});
|
||||
|
||||
model.isNextButtonDisabled.setValue(false);
|
||||
cancelButton.setDisable(false);
|
||||
|
||||
model.onInvalidateMarketPriceMargin();
|
||||
model.onInvalidatePrice();
|
||||
|
||||
// To force re-validation of payment account validation
|
||||
onPaymentAccountsComboBoxSelected();
|
||||
hidePaymentGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -127,8 +135,18 @@ public class EditOpenOfferView extends EditableOfferView<EditOpenOfferViewModel>
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void initWithData(OpenOffer openOffer) {
|
||||
super.initWithData(openOffer.getOffer().getDirection(), CurrencyUtil.getTradeCurrency(openOffer.getOffer().getCurrencyCode()).get());
|
||||
super.initWithData(openOffer.getOffer().getDirection(),
|
||||
CurrencyUtil.getTradeCurrency(openOffer.getOffer().getCurrencyCode()).get());
|
||||
model.initWithData(openOffer);
|
||||
|
||||
model.onStartEditOffer(errorMessage -> {
|
||||
log.error(errorMessage);
|
||||
new Popup<>().warning(Res.get("editOffer.failed", errorMessage))
|
||||
.onClose(() -> {
|
||||
close();
|
||||
})
|
||||
.show();
|
||||
});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user