Search in sources :

Example 1 with QRCodeWindow

use of io.bitsquare.gui.main.overlays.windows.QRCodeWindow in project bitsquare by bitsquare.

the class TakeOfferView method addFundingGroup.

private void addFundingGroup() {
    // don't increase gridRow as we removed button when this gets visible
    payFundsPane = addTitledGroupBg(gridPane, gridRow, 3, BSResources.get("takeOffer.fundsBox.title"), Layout.GROUP_DISTANCE);
    GridPane.setColumnSpan(payFundsPane, 3);
    payFundsPane.setVisible(false);
    totalToPayLabel = new Label(BSResources.get("takeOffer.fundsBox.totalsNeeded"));
    totalToPayLabel.setVisible(false);
    totalToPayInfoIconLabel = new Label();
    totalToPayInfoIconLabel.setVisible(false);
    HBox totalToPayBox = new HBox();
    totalToPayBox.setSpacing(4);
    totalToPayBox.setAlignment(Pos.CENTER_RIGHT);
    totalToPayBox.getChildren().addAll(totalToPayLabel, totalToPayInfoIconLabel);
    GridPane.setMargin(totalToPayBox, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
    GridPane.setRowIndex(totalToPayBox, gridRow);
    gridPane.getChildren().add(totalToPayBox);
    totalToPayTextField = new TextFieldWithCopyIcon();
    totalToPayTextField.setFocusTraversable(false);
    totalToPayTextField.setVisible(false);
    totalToPayTextField.setPromptText(BSResources.get("createOffer.fundsBox.totalsNeeded.prompt"));
    totalToPayTextField.setCopyWithoutCurrencyPostFix(true);
    GridPane.setRowIndex(totalToPayTextField, gridRow);
    GridPane.setColumnIndex(totalToPayTextField, 1);
    GridPane.setMargin(totalToPayTextField, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
    gridPane.getChildren().add(totalToPayTextField);
    qrCodeImageView = new ImageView();
    qrCodeImageView.setVisible(false);
    qrCodeImageView.setStyle("-fx-cursor: hand;");
    Tooltip.install(qrCodeImageView, new Tooltip("Open large QR-Code window"));
    qrCodeImageView.setOnMouseClicked(e -> GUIUtil.showFeeInfoBeforeExecute(() -> UserThread.runAfter(() -> new QRCodeWindow(getBitcoinURI()).show(), 200, TimeUnit.MILLISECONDS)));
    GridPane.setRowIndex(qrCodeImageView, gridRow);
    GridPane.setColumnIndex(qrCodeImageView, 2);
    GridPane.setRowSpan(qrCodeImageView, 3);
    GridPane.setMargin(qrCodeImageView, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE - 9, 0, 0, 5));
    gridPane.getChildren().add(qrCodeImageView);
    Tuple2<Label, AddressTextField> addressTuple = addLabelAddressTextField(gridPane, ++gridRow, BSResources.get("takeOffer.fundsBox.address"));
    addressLabel = addressTuple.first;
    addressLabel.setVisible(false);
    addressTextField = addressTuple.second;
    addressTextField.setVisible(false);
    Tuple2<Label, BalanceTextField> balanceTuple = addLabelBalanceTextField(gridPane, ++gridRow, BSResources.get("takeOffer.fundsBox.balance"));
    balanceLabel = balanceTuple.first;
    balanceLabel.setVisible(false);
    balanceTextField = balanceTuple.second;
    balanceTextField.setVisible(false);
    fundingHBox = new HBox();
    fundingHBox.setVisible(false);
    fundingHBox.setManaged(false);
    fundingHBox.setSpacing(10);
    fundFromSavingsWalletButton = new Button("Transfer funds from Bitsquare wallet");
    fundFromSavingsWalletButton.setDefaultButton(true);
    fundFromSavingsWalletButton.setDefaultButton(false);
    fundFromSavingsWalletButton.setOnAction(e -> model.fundFromSavingsWallet());
    Label label = new Label("OR");
    label.setPadding(new Insets(5, 0, 0, 0));
    fundFromExternalWalletButton = new Button("Open your external wallet for funding");
    fundFromExternalWalletButton.setDefaultButton(false);
    fundFromExternalWalletButton.setOnAction(e -> GUIUtil.showFeeInfoBeforeExecute(this::openWallet));
    waitingForFundsBusyAnimation = new BusyAnimation(false);
    waitingForFundsLabel = new Label();
    waitingForFundsLabel.setPadding(new Insets(5, 0, 0, 0));
    fundingHBox.getChildren().addAll(fundFromSavingsWalletButton, label, fundFromExternalWalletButton, waitingForFundsBusyAnimation, waitingForFundsLabel);
    GridPane.setRowIndex(fundingHBox, ++gridRow);
    GridPane.setColumnIndex(fundingHBox, 1);
    GridPane.setMargin(fundingHBox, new Insets(15, 10, 0, 0));
    gridPane.getChildren().add(fundingHBox);
    takeOfferButton = addButtonAfterGroup(gridPane, gridRow, "");
    takeOfferButton.setVisible(false);
    takeOfferButton.setManaged(false);
    takeOfferButton.setMinHeight(40);
    takeOfferButton.setPadding(new Insets(0, 20, 0, 20));
    takeOfferButton.setOnAction(e -> onTakeOffer());
    cancelButton2 = addButton(gridPane, ++gridRow, BSResources.get("shared.cancel"));
    cancelButton2.setOnAction(e -> {
        if (model.dataModel.isWalletFunded.get()) {
            new Popup().warning("You have already funded that offer.\n" + "If you cancel now, your funds will be moved to your local Bitsquare wallet and are available " + "for withdrawal in the \"Funds/Available for withdrawal\" screen.\n" + "Are you sure you want to cancel?").closeButtonText("No").actionButtonText("Yes, cancel").onAction(() -> {
                model.dataModel.swapTradeToSavings();
                close();
            }).show();
        } else {
            close();
            model.dataModel.swapTradeToSavings();
        }
    });
    cancelButton2.setDefaultButton(false);
    cancelButton2.setVisible(false);
}
Also used : QRCodeWindow(io.bitsquare.gui.main.overlays.windows.QRCodeWindow) Popup(io.bitsquare.gui.main.overlays.popups.Popup) ImageView(javafx.scene.image.ImageView)

Example 2 with QRCodeWindow

use of io.bitsquare.gui.main.overlays.windows.QRCodeWindow in project bitsquare by bitsquare.

the class CreateOfferView method addFundingGroup.

private void addFundingGroup() {
    // don't increase gridRow as we removed button when this gets visible
    payFundsPane = addTitledGroupBg(gridPane, gridRow, 3, BSResources.get("createOffer.fundsBox.title"), Layout.GROUP_DISTANCE);
    GridPane.setColumnSpan(payFundsPane, 3);
    payFundsPane.setVisible(false);
    totalToPayLabel = new Label(BSResources.get("createOffer.fundsBox.totalsNeeded"));
    totalToPayLabel.setVisible(false);
    totalToPayInfoIconLabel = new Label();
    totalToPayInfoIconLabel.setVisible(false);
    HBox totalToPayBox = new HBox();
    totalToPayBox.setSpacing(4);
    totalToPayBox.setAlignment(Pos.CENTER_RIGHT);
    totalToPayBox.getChildren().addAll(totalToPayLabel, totalToPayInfoIconLabel);
    GridPane.setMargin(totalToPayBox, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
    GridPane.setRowIndex(totalToPayBox, gridRow);
    gridPane.getChildren().add(totalToPayBox);
    totalToPayTextField = new TextFieldWithCopyIcon();
    totalToPayTextField.setCopyWithoutCurrencyPostFix(true);
    totalToPayTextField.setFocusTraversable(false);
    totalToPayTextField.setVisible(false);
    GridPane.setRowIndex(totalToPayTextField, gridRow);
    GridPane.setColumnIndex(totalToPayTextField, 1);
    GridPane.setMargin(totalToPayTextField, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
    gridPane.getChildren().add(totalToPayTextField);
    qrCodeImageView = new ImageView();
    qrCodeImageView.setVisible(false);
    qrCodeImageView.setStyle("-fx-cursor: hand;");
    Tooltip.install(qrCodeImageView, new Tooltip("Open large QR-Code window"));
    qrCodeImageView.setOnMouseClicked(e -> GUIUtil.showFeeInfoBeforeExecute(() -> UserThread.runAfter(() -> new QRCodeWindow(getBitcoinURI()).show(), 200, TimeUnit.MILLISECONDS)));
    GridPane.setRowIndex(qrCodeImageView, gridRow);
    GridPane.setColumnIndex(qrCodeImageView, 2);
    GridPane.setRowSpan(qrCodeImageView, 3);
    GridPane.setMargin(qrCodeImageView, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE - 9, 0, 0, 5));
    gridPane.getChildren().add(qrCodeImageView);
    Tuple2<Label, AddressTextField> addressTuple = addLabelAddressTextField(gridPane, ++gridRow, BSResources.get("createOffer.fundsBox.address"));
    addressLabel = addressTuple.first;
    addressLabel.setVisible(false);
    addressTextField = addressTuple.second;
    addressTextField.setVisible(false);
    Tuple2<Label, BalanceTextField> balanceTuple = addLabelBalanceTextField(gridPane, ++gridRow, BSResources.get("createOffer.fundsBox.balance"));
    balanceLabel = balanceTuple.first;
    balanceLabel.setVisible(false);
    balanceTextField = balanceTuple.second;
    balanceTextField.setVisible(false);
    fundingHBox = new HBox();
    fundingHBox.setVisible(false);
    fundingHBox.setManaged(false);
    fundingHBox.setSpacing(10);
    fundFromSavingsWalletButton = new Button("Transfer funds from Bitsquare wallet");
    fundFromSavingsWalletButton.setDefaultButton(true);
    fundFromSavingsWalletButton.setDefaultButton(false);
    fundFromSavingsWalletButton.setOnAction(e -> model.fundFromSavingsWallet());
    Label label = new Label("OR");
    label.setPadding(new Insets(5, 0, 0, 0));
    fundFromExternalWalletButton = new Button("Open your external wallet for funding");
    fundFromExternalWalletButton.setDefaultButton(false);
    fundFromExternalWalletButton.setOnAction(e -> GUIUtil.showFeeInfoBeforeExecute(this::openWallet));
    waitingForFundsBusyAnimation = new BusyAnimation();
    waitingForFundsLabel = new Label();
    waitingForFundsLabel.setPadding(new Insets(5, 0, 0, 0));
    fundingHBox.getChildren().addAll(fundFromSavingsWalletButton, label, fundFromExternalWalletButton, waitingForFundsBusyAnimation, waitingForFundsLabel);
    GridPane.setRowIndex(fundingHBox, ++gridRow);
    GridPane.setColumnIndex(fundingHBox, 1);
    GridPane.setMargin(fundingHBox, new Insets(15, 10, 0, 0));
    gridPane.getChildren().add(fundingHBox);
    placeOfferButton = addButtonAfterGroup(gridPane, gridRow, "");
    placeOfferButton.setOnAction(e -> onPlaceOffer());
    placeOfferButton.setMinHeight(40);
    placeOfferButton.setPadding(new Insets(0, 20, 0, 20));
    cancelButton2 = addButton(gridPane, ++gridRow, BSResources.get("shared.cancel"));
    cancelButton2.setOnAction(e -> {
        if (model.dataModel.isWalletFunded.get()) {
            new Popup().warning("You have already funded that offer.\n" + "If you cancel now, your funds will be moved to your local Bitsquare wallet and are available " + "for withdrawal in the \"Funds/Available for withdrawal\" screen.\n" + "Are you sure you want to cancel?").closeButtonText("No").actionButtonText("Yes, cancel").onAction(() -> {
                close();
                model.dataModel.swapTradeToSavings();
            }).show();
        } else {
            close();
            model.dataModel.swapTradeToSavings();
        }
    });
    cancelButton2.setDefaultButton(false);
    cancelButton2.setVisible(false);
}
Also used : QRCodeWindow(io.bitsquare.gui.main.overlays.windows.QRCodeWindow) Popup(io.bitsquare.gui.main.overlays.popups.Popup) ImageView(javafx.scene.image.ImageView)

Example 3 with QRCodeWindow

use of io.bitsquare.gui.main.overlays.windows.QRCodeWindow in project bitsquare by bitsquare.

the class DepositView method initialize.

@Override
public void initialize() {
    // trigger creation of at least 1 savings address
    walletService.getOrCreateAddressEntry(AddressEntry.Context.AVAILABLE);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    tableView.setPlaceholder(new Label("No deposit addresses have been generated yet"));
    tableViewSelectionListener = (observableValue, oldValue, newValue) -> {
        if (newValue != null)
            fillForm(newValue.getAddressString());
    };
    setSelectColumnCellFactory();
    setAddressColumnCellFactory();
    setBalanceColumnCellFactory();
    setUsageColumnCellFactory();
    setConfidenceColumnCellFactory();
    addressColumn.setComparator((o1, o2) -> o1.getAddressString().compareTo(o2.getAddressString()));
    balanceColumn.setComparator((o1, o2) -> o1.getBalanceAsCoin().compareTo(o2.getBalanceAsCoin()));
    confidenceColumn.setComparator((o1, o2) -> Double.valueOf(o1.getTxConfidenceIndicator().getProgress()).compareTo(o2.getTxConfidenceIndicator().getProgress()));
    usageColumn.setComparator((a, b) -> (a.getNumTxOutputs() < b.getNumTxOutputs()) ? -1 : ((a.getNumTxOutputs() == b.getNumTxOutputs()) ? 0 : 1));
    tableView.getSortOrder().add(usageColumn);
    tableView.setItems(sortedList);
    titledGroupBg = addTitledGroupBg(gridPane, gridRow, 3, "Fund your wallet");
    qrCodeLabel = addLabel(gridPane, gridRow, "", 0);
    //GridPane.setMargin(qrCodeLabel, new Insets(Layout.FIRST_ROW_DISTANCE - 9, 0, 0, 5));
    qrCodeImageView = new ImageView();
    qrCodeImageView.setStyle("-fx-cursor: hand;");
    Tooltip.install(qrCodeImageView, new Tooltip("Open large QR-Code window"));
    qrCodeImageView.setOnMouseClicked(e -> GUIUtil.showFeeInfoBeforeExecute(() -> UserThread.runAfter(() -> new QRCodeWindow(getBitcoinURI()).show(), 200, TimeUnit.MILLISECONDS)));
    GridPane.setRowIndex(qrCodeImageView, gridRow);
    GridPane.setColumnIndex(qrCodeImageView, 1);
    GridPane.setMargin(qrCodeImageView, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 0));
    gridPane.getChildren().add(qrCodeImageView);
    Tuple2<Label, AddressTextField> addressTuple = addLabelAddressTextField(gridPane, ++gridRow, "Address:");
    addressLabel = addressTuple.first;
    //GridPane.setValignment(addressLabel, VPos.TOP);
    //GridPane.setMargin(addressLabel, new Insets(3, 0, 0, 0));
    addressTextField = addressTuple.second;
    addressTextField.setPaymentLabel(paymentLabelString);
    Tuple2<Label, InputTextField> amountTuple = addLabelInputTextField(gridPane, ++gridRow, "Amount in BTC (optional):");
    amountLabel = amountTuple.first;
    amountTextField = amountTuple.second;
    if (DevFlags.DEV_MODE)
        amountTextField.setText("10");
    titledGroupBg.setVisible(false);
    titledGroupBg.setManaged(false);
    qrCodeLabel.setVisible(false);
    qrCodeLabel.setManaged(false);
    qrCodeImageView.setVisible(false);
    qrCodeImageView.setManaged(false);
    addressLabel.setVisible(false);
    addressLabel.setManaged(false);
    addressTextField.setVisible(false);
    addressTextField.setManaged(false);
    amountLabel.setVisible(false);
    amountTextField.setManaged(false);
    generateNewAddressButton = addButton(gridPane, ++gridRow, "Generate new address", -20);
    GridPane.setColumnIndex(generateNewAddressButton, 0);
    GridPane.setHalignment(generateNewAddressButton, HPos.LEFT);
    generateNewAddressButton.setOnAction(event -> {
        boolean hasUnUsedAddress = observableList.stream().filter(e -> e.getNumTxOutputs() == 0).findAny().isPresent();
        if (hasUnUsedAddress) {
            new Popup().warning("Please select an unused address from the table above rather than generating a new one.").show();
        } else {
            AddressEntry newSavingsAddressEntry = walletService.getOrCreateUnusedAddressEntry(AddressEntry.Context.AVAILABLE);
            updateList();
            observableList.stream().filter(depositListItem -> depositListItem.getAddressString().equals(newSavingsAddressEntry.getAddressString())).findAny().ifPresent(depositListItem -> tableView.getSelectionModel().select(depositListItem));
        }
    });
    balanceListener = new BalanceListener() {

        @Override
        public void onBalanceChanged(Coin balance, Transaction tx) {
            updateList();
        }
    };
}
Also used : Insets(javafx.geometry.Insets) BalanceListener(io.bitsquare.btc.listeners.BalanceListener) AddressEntry(io.bitsquare.btc.AddressEntry) AddressTextField(io.bitsquare.gui.components.AddressTextField) InputTextField(io.bitsquare.gui.components.InputTextField) QRCodeWindow(io.bitsquare.gui.main.overlays.windows.QRCodeWindow) Coin(org.bitcoinj.core.Coin) Transaction(org.bitcoinj.core.Transaction) Popup(io.bitsquare.gui.main.overlays.popups.Popup) ImageView(javafx.scene.image.ImageView)

Aggregations

Popup (io.bitsquare.gui.main.overlays.popups.Popup)3 QRCodeWindow (io.bitsquare.gui.main.overlays.windows.QRCodeWindow)3 ImageView (javafx.scene.image.ImageView)3 AddressEntry (io.bitsquare.btc.AddressEntry)1 BalanceListener (io.bitsquare.btc.listeners.BalanceListener)1 AddressTextField (io.bitsquare.gui.components.AddressTextField)1 InputTextField (io.bitsquare.gui.components.InputTextField)1 Insets (javafx.geometry.Insets)1 Coin (org.bitcoinj.core.Coin)1 Transaction (org.bitcoinj.core.Transaction)1