mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 23:36:00 -04:00
Open new window for contract in popups, Improve funding button layout
This commit is contained in:
parent
513bc79d58
commit
a9a711f68b
@ -118,6 +118,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
private ChangeListener<String> tradeCurrencyCodeListener;
|
||||
private ImageView qrCodeImageView;
|
||||
private ChangeListener<Coin> balanceListener;
|
||||
private HBox fundingHBox;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -311,8 +312,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
qrCodeImageView.setVisible(true);
|
||||
balanceLabel.setVisible(true);
|
||||
balanceTextField.setVisible(true);
|
||||
fundFromSavingsWalletButton.setVisible(true);
|
||||
fundFromExternalWalletButton.setVisible(true);
|
||||
fundingHBox.setVisible(true);
|
||||
placeOfferButton.setVisible(true);
|
||||
cancelButton2.setVisible(true);
|
||||
//root.requestFocus();
|
||||
@ -406,8 +406,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
// buttons
|
||||
placeOfferButton.disableProperty().bind(model.isPlaceOfferButtonDisabled);
|
||||
cancelButton2.disableProperty().bind(model.cancelButtonDisabled);
|
||||
fundFromSavingsWalletButton.disableProperty().bind(model.dataModel.isWalletFunded);
|
||||
fundFromExternalWalletButton.disableProperty().bind(model.dataModel.isWalletFunded);
|
||||
fundingHBox.disableProperty().bind(model.dataModel.isWalletFunded);
|
||||
|
||||
// payment account
|
||||
currencyComboBox.prefWidthProperty().bind(paymentAccountsComboBox.widthProperty());
|
||||
@ -439,6 +438,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
volumeTextField.validationResultProperty().unbind();
|
||||
placeOfferButton.disableProperty().unbind();
|
||||
cancelButton2.disableProperty().unbind();
|
||||
fundingHBox.disableProperty().unbind();
|
||||
currencyComboBox.managedProperty().unbind();
|
||||
currencyComboBoxLabel.visibleProperty().unbind();
|
||||
currencyComboBoxLabel.managedProperty().unbind();
|
||||
@ -758,14 +758,17 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
balanceTextField = balanceTuple.second;
|
||||
balanceTextField.setVisible(false);
|
||||
|
||||
Tuple2<Button, Button> tuple = add2ButtonsAfterGroup(gridPane, ++gridRow, "Transfer from Bitsquare wallet", "Fund from external wallet");
|
||||
fundFromSavingsWalletButton = tuple.first;
|
||||
fundFromSavingsWalletButton.setVisible(false);
|
||||
|
||||
fundingHBox = new HBox();
|
||||
fundingHBox.setSpacing(10);
|
||||
fundFromSavingsWalletButton = new Button("Transfer funds from Bitsquare wallet");
|
||||
fundFromSavingsWalletButton.setDefaultButton(true);
|
||||
fundingHBox.setVisible(false);
|
||||
fundFromSavingsWalletButton.setDefaultButton(false);
|
||||
fundFromSavingsWalletButton.setOnAction(e -> model.useSavingsWalletForFunding());
|
||||
|
||||
fundFromExternalWalletButton = tuple.second;
|
||||
fundFromExternalWalletButton.setVisible(false);
|
||||
Label label = new Label("OR");
|
||||
label.setPadding(new Insets(5, 0, 0, 0));
|
||||
fundFromExternalWalletButton = new Button("Pay in funds from external wallet");
|
||||
fundFromExternalWalletButton.setDefaultButton(false);
|
||||
fundFromExternalWalletButton.setOnAction(e -> {
|
||||
try {
|
||||
@ -776,6 +779,12 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
"Perhaps you don't have one installed?").show();
|
||||
}
|
||||
});
|
||||
fundingHBox.getChildren().addAll(fundFromSavingsWalletButton, label, fundFromExternalWalletButton);
|
||||
GridPane.setRowIndex(fundingHBox, ++gridRow);
|
||||
GridPane.setColumnIndex(fundingHBox, 1);
|
||||
GridPane.setMargin(fundingHBox, new Insets(15, 10, 0, 0));
|
||||
gridPane.getChildren().add(fundingHBox);
|
||||
|
||||
|
||||
placeOfferButton = addButton(gridPane, ++gridRow, "");
|
||||
placeOfferButton.setVisible(false);
|
||||
|
@ -147,36 +147,29 @@ public class NotificationCenter {
|
||||
private void onTradeStateChanged(Trade trade, Trade.State tradeState) {
|
||||
Log.traceCall(tradeState.toString());
|
||||
String message = null;
|
||||
if (tradeManager.isBuyer(trade.getOffer())) {
|
||||
switch (tradeState) {
|
||||
case OFFERER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG:
|
||||
message = "Your offer has been accepted by a seller.";
|
||||
break;
|
||||
case DEPOSIT_CONFIRMED_IN_BLOCK_CHAIN:
|
||||
message = "Your trade has at least one blockchain confirmation.\n" +
|
||||
"You can start the payment now.";
|
||||
|
||||
break;
|
||||
/* case FIAT_PAYMENT_RECEIPT_MSG_RECEIVED:
|
||||
case PAYOUT_TX_COMMITTED:
|
||||
case PAYOUT_TX_SENT:*/
|
||||
case PAYOUT_BROAD_CASTED:
|
||||
message = "The trade is now completed and you can withdraw your funds.";
|
||||
break;
|
||||
}
|
||||
if (tradeState == Trade.State.PAYOUT_BROAD_CASTED) {
|
||||
message = "The trade is now completed and you can withdraw your funds.";
|
||||
} else {
|
||||
switch (tradeState) {
|
||||
case OFFERER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG:
|
||||
message = "Your offer has been accepted by a buyer.";
|
||||
break;
|
||||
case SELLER_RECEIVED_FIAT_PAYMENT_INITIATED_MSG:
|
||||
message = "The bitcoin buyer has started the payment.";
|
||||
break;
|
||||
/* case FIAT_PAYMENT_RECEIPT_MSG_SENT:
|
||||
case PAYOUT_TX_RECEIVED:
|
||||
case PAYOUT_TX_COMMITTED:*/
|
||||
case PAYOUT_BROAD_CASTED:
|
||||
message = "The trade is now completed and you can withdraw your funds.";
|
||||
if (tradeManager.isBuyer(trade.getOffer())) {
|
||||
switch (tradeState) {
|
||||
case OFFERER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG:
|
||||
message = "Your offer has been accepted by a seller.";
|
||||
break;
|
||||
case DEPOSIT_CONFIRMED_IN_BLOCK_CHAIN:
|
||||
message = "Your trade has at least one blockchain confirmation.\n" +
|
||||
"You can start the payment now.";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (tradeState) {
|
||||
case OFFERER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG:
|
||||
message = "Your offer has been accepted by a buyer.";
|
||||
break;
|
||||
case SELLER_RECEIVED_FIAT_PAYMENT_INITIATED_MSG:
|
||||
message = "The bitcoin buyer has started the payment.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ package io.bitsquare.gui.main.overlays.windows;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import io.bitsquare.arbitration.Dispute;
|
||||
import io.bitsquare.gui.main.MainView;
|
||||
import io.bitsquare.gui.main.overlays.Overlay;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
@ -30,9 +31,15 @@ import io.bitsquare.payment.PaymentMethod;
|
||||
import io.bitsquare.trade.Contract;
|
||||
import io.bitsquare.trade.offer.Offer;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.stage.Window;
|
||||
import org.bitcoinj.core.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -93,7 +100,7 @@ public class ContractWindow extends Overlay<ContractWindow> {
|
||||
List<String> acceptedCountryCodes = offer.getAcceptedCountryCodes();
|
||||
boolean showAcceptedCountryCodes = acceptedCountryCodes != null && !acceptedCountryCodes.isEmpty();
|
||||
|
||||
int rows = 16;
|
||||
int rows = 17;
|
||||
if (dispute.getDepositTxSerialized() != null)
|
||||
rows++;
|
||||
if (dispute.getPayoutTxSerialized() != null)
|
||||
@ -167,6 +174,36 @@ public class ContractWindow extends Overlay<ContractWindow> {
|
||||
if (dispute.getPayoutTxSerialized() != null)
|
||||
addLabelTxIdTextField(gridPane, ++rowIndex, "Payout transaction ID:", dispute.getPayoutTxId());
|
||||
|
||||
if (contract != null) {
|
||||
Button viewContractButton = addLabelButton(gridPane, ++rowIndex, "Contract in JSON format:", "View contract in JSON format", 0).second;
|
||||
viewContractButton.setDefaultButton(false);
|
||||
viewContractButton.setOnAction(e -> {
|
||||
TextArea textArea = new TextArea();
|
||||
textArea.setText(dispute.getContractAsJson());
|
||||
textArea.setPrefHeight(50);
|
||||
textArea.setEditable(false);
|
||||
textArea.setWrapText(true);
|
||||
textArea.setPrefSize(800, 600);
|
||||
|
||||
Scene viewContractScene = new Scene(textArea);
|
||||
Stage viewContractStage = new Stage();
|
||||
viewContractStage.setTitle("Contract for trade with ID: " + dispute.getShortTradeId());
|
||||
viewContractStage.setScene(viewContractScene);
|
||||
if (owner == null)
|
||||
owner = MainView.getRootContainer();
|
||||
Scene rootScene = owner.getScene();
|
||||
viewContractStage.initOwner(rootScene.getWindow());
|
||||
viewContractStage.initModality(Modality.NONE);
|
||||
viewContractStage.initStyle(StageStyle.UTILITY);
|
||||
viewContractStage.show();
|
||||
|
||||
Window window = rootScene.getWindow();
|
||||
double titleBarHeight = window.getHeight() - rootScene.getHeight();
|
||||
viewContractStage.setX(Math.round(window.getX() + (owner.getWidth() - viewContractStage.getWidth()) / 2) + 200);
|
||||
viewContractStage.setY(Math.round(window.getY() + titleBarHeight + (owner.getHeight() - viewContractStage.getHeight()) / 2) + 50);
|
||||
});
|
||||
}
|
||||
|
||||
Button cancelButton = addButtonAfterGroup(gridPane, ++rowIndex, "Close");
|
||||
//TODO app wide focus
|
||||
//cancelButton.requestFocus();
|
||||
|
@ -19,6 +19,7 @@ package io.bitsquare.gui.main.overlays.windows;
|
||||
|
||||
import io.bitsquare.arbitration.DisputeManager;
|
||||
import io.bitsquare.btc.FeePolicy;
|
||||
import io.bitsquare.gui.main.MainView;
|
||||
import io.bitsquare.gui.main.overlays.Overlay;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
@ -32,10 +33,15 @@ import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.stage.Window;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -116,6 +122,7 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
||||
addLabelTextField(gridPane, ++rowIndex, "Currency:", offer.getCurrencyCode());
|
||||
addLabelTextField(gridPane, ++rowIndex, "Payment method:", BSResources.get(offer.getPaymentMethod().getId()));
|
||||
|
||||
// second group
|
||||
rows = 5;
|
||||
PaymentAccountContractData buyerPaymentAccountContractData = null;
|
||||
PaymentAccountContractData sellerPaymentAccountContractData = null;
|
||||
@ -146,7 +153,8 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
||||
rows++;
|
||||
if (trade.getPayoutTx() != null)
|
||||
rows++;
|
||||
if (disputeManager.findOwnDispute(trade.getId()).isPresent())
|
||||
boolean showDisputedTx = disputeManager.findOwnDispute(trade.getId()).isPresent() && disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTxId() != null;
|
||||
if (showDisputedTx)
|
||||
rows++;
|
||||
if (trade.errorMessageProperty().get() != null)
|
||||
rows += 2;
|
||||
@ -186,14 +194,37 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
||||
addLabelTxIdTextField(gridPane, ++rowIndex, "Deposit transaction ID:", trade.getDepositTx().getHashAsString());
|
||||
if (trade.getPayoutTx() != null)
|
||||
addLabelTxIdTextField(gridPane, ++rowIndex, "Payout transaction ID:", trade.getPayoutTx().getHashAsString());
|
||||
if (disputeManager.findOwnDispute(trade.getId()).isPresent() && disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTxId() != null)
|
||||
if (showDisputedTx)
|
||||
addLabelTxIdTextField(gridPane, ++rowIndex, "Disputed payout transaction ID:", disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTxId());
|
||||
|
||||
if (contract != null) {
|
||||
TextArea textArea = addLabelTextArea(gridPane, ++rowIndex, "Contract in JSON format:", trade.getContractAsJson()).second;
|
||||
textArea.setText(trade.getContractAsJson());
|
||||
textArea.setPrefHeight(50);
|
||||
textArea.setEditable(false);
|
||||
Button viewContractButton = addLabelButton(gridPane, ++rowIndex, "Contract in JSON format:", "View contract", 0).second;
|
||||
viewContractButton.setDefaultButton(false);
|
||||
viewContractButton.setOnAction(e -> {
|
||||
TextArea textArea = new TextArea();
|
||||
textArea.setText(trade.getContractAsJson());
|
||||
textArea.setPrefHeight(50);
|
||||
textArea.setEditable(false);
|
||||
textArea.setWrapText(true);
|
||||
textArea.setPrefSize(800, 600);
|
||||
|
||||
Scene viewContractScene = new Scene(textArea);
|
||||
Stage viewContractStage = new Stage();
|
||||
viewContractStage.setTitle("Contract for trade with ID: " + trade.getShortId());
|
||||
viewContractStage.setScene(viewContractScene);
|
||||
if (owner == null)
|
||||
owner = MainView.getRootContainer();
|
||||
Scene rootScene = owner.getScene();
|
||||
viewContractStage.initOwner(rootScene.getWindow());
|
||||
viewContractStage.initModality(Modality.NONE);
|
||||
viewContractStage.initStyle(StageStyle.UTILITY);
|
||||
viewContractStage.show();
|
||||
|
||||
Window window = rootScene.getWindow();
|
||||
double titleBarHeight = window.getHeight() - rootScene.getHeight();
|
||||
viewContractStage.setX(Math.round(window.getX() + (owner.getWidth() - viewContractStage.getWidth()) / 2) + 200);
|
||||
viewContractStage.setY(Math.round(window.getY() + titleBarHeight + (owner.getHeight() - viewContractStage.getHeight()) / 2) + 50);
|
||||
});
|
||||
}
|
||||
|
||||
if (trade.errorMessageProperty().get() != null) {
|
||||
|
@ -34,9 +34,12 @@ import io.bitsquare.gui.main.portfolio.pendingtrades.steps.TradeStepView;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import org.bitcoinj.core.AddressFormatException;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
@ -117,9 +120,20 @@ public class BuyerStep5View extends TradeStepView {
|
||||
addLabelTextField(gridPane, gridRow, "Amount to withdraw:", model.getPayoutAmount(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
|
||||
withdrawAddressTextField = addLabelInputTextField(gridPane, ++gridRow, "Withdraw to address:").second;
|
||||
|
||||
Tuple2<Button, Button> tuple2 = add2ButtonsAfterGroup(gridPane, ++gridRow, "Move to Bitsquare wallet", "Withdraw to external wallet");
|
||||
useSavingsWalletButton = tuple2.first;
|
||||
withdrawToExternalWalletButton = tuple2.second;
|
||||
HBox hBox = new HBox();
|
||||
hBox.setSpacing(10);
|
||||
useSavingsWalletButton = new Button("Move funds to Bitsquare wallet");
|
||||
useSavingsWalletButton.setDefaultButton(false);
|
||||
Label label = new Label("OR");
|
||||
label.setPadding(new Insets(5, 0, 0, 0));
|
||||
withdrawToExternalWalletButton = new Button("Withdraw to external wallet");
|
||||
withdrawToExternalWalletButton.setDefaultButton(false);
|
||||
hBox.getChildren().addAll(useSavingsWalletButton, label, withdrawToExternalWalletButton);
|
||||
GridPane.setRowIndex(hBox, ++gridRow);
|
||||
GridPane.setColumnIndex(hBox, 1);
|
||||
GridPane.setMargin(hBox, new Insets(15, 10, 0, 0));
|
||||
gridPane.getChildren().add(hBox);
|
||||
|
||||
useSavingsWalletButton.setOnAction(e -> {
|
||||
model.dataModel.walletService.swapTradeToSavings(trade.getId());
|
||||
handleTradeCompleted();
|
||||
|
Loading…
x
Reference in New Issue
Block a user