Java Code Examples for javafx.scene.layout.GridPane#setRowSpan()

The following examples show how to use javafx.scene.layout.GridPane#setRowSpan() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuyerStep4View.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void onWithdrawal() {
    withdrawAddressTextField.setManaged(true);
    withdrawAddressTextField.setVisible(true);
    GridPane.setRowSpan(withdrawTitledGroupBg, 2);
    withdrawToExternalWalletButton.setDefaultButton(true);
    useSavingsWalletButton.setDefaultButton(false);
    withdrawToExternalWalletButton.getStyleClass().add("action-button");
    useSavingsWalletButton.getStyleClass().remove("action-button");

    withdrawToExternalWalletButton.setOnAction(e -> {
        if (model.dataModel.isReadyForTxBroadcast()) {
            reviewWithdrawal();
        }
    });

}
 
Example 2
Source File: ProposalDisplay.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public void applyBallotAndVoteWeight(@Nullable Ballot ballot, long merit, long stake, boolean ballotIncluded) {
    boolean ballotIsNotNull = ballot != null;
    boolean hasVoted = stake > 0;
    if (hasVoted) {
        String myVote = Res.get("dao.proposal.display.myVote.ignored");
        Vote vote = ballotIsNotNull ? ballot.getVote() : null;
        if (vote != null) {
            myVote = vote.isAccepted() ? Res.get("dao.proposal.display.myVote.accepted") :
                    Res.get("dao.proposal.display.myVote.rejected");
        }

        String voteIncluded = ballotIncluded ? "" : " - " + Res.get("dao.proposal.display.myVote.unCounted");
        String meritString = bsqFormatter.formatCoinWithCode(Coin.valueOf(merit));
        String stakeString = bsqFormatter.formatCoinWithCode(Coin.valueOf(stake));
        String weight = bsqFormatter.formatCoinWithCode(Coin.valueOf(merit + stake));
        String myVoteSummary = Res.get("dao.proposal.myVote.summary", myVote,
                weight, meritString, stakeString, voteIncluded);
        myVoteTextField.setText(myVoteSummary);

        GridPane.setRowSpan(myVoteTitledGroup, votingBoxRowSpan - 1);
    }

    boolean show = ballotIsNotNull && hasVoted;
    setMyVoteBoxVisibility(show);
}
 
Example 3
Source File: FiatAccountsView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void onSelectAccount(PaymentAccount paymentAccount) {
    removeAccountRows();
    addAccountButton.setDisable(false);
    accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 2, Res.get("shared.selectedAccount"), Layout.GROUP_DISTANCE);
    paymentMethodForm = getPaymentMethodForm(paymentAccount);
    if (paymentMethodForm != null) {
        paymentMethodForm.addFormForDisplayAccount();
        gridRow = paymentMethodForm.getGridRow();
        Tuple2<Button, Button> tuple = add2ButtonsAfterGroup(root, ++gridRow, Res.get("shared.deleteAccount"), Res.get("shared.cancel"));
        Button deleteAccountButton = tuple.first;
        deleteAccountButton.setOnAction(event -> onDeleteAccount(paymentMethodForm.getPaymentAccount()));
        Button cancelButton = tuple.second;
        cancelButton.setOnAction(event -> removeSelectAccountForm());
        GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan());
        model.onSelectAccount(paymentAccount);
    }
}
 
Example 4
Source File: AltCoinAccountsView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
protected void addNewAccount() {
    paymentAccountsListView.getSelectionModel().clearSelection();
    removeAccountRows();
    addAccountButton.setDisable(true);
    accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 1, Res.get("shared.createNewAccount"), Layout.GROUP_DISTANCE);

    if (paymentMethodForm != null) {
        FormBuilder.removeRowsFromGridPane(root, 3, paymentMethodForm.getGridRow() + 1);
        GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1);
    }
    gridRow = 2;
    paymentMethodForm = getPaymentMethodForm(PaymentMethod.BLOCK_CHAINS);
    paymentMethodForm.addFormForAddAccount();
    gridRow = paymentMethodForm.getGridRow();
    Tuple2<Button, Button> tuple2 = add2ButtonsAfterGroup(root, ++gridRow, Res.get("shared.saveNewAccount"), Res.get("shared.cancel"));
    saveNewAccountButton = tuple2.first;
    saveNewAccountButton.setOnAction(event -> onSaveNewAccount(paymentMethodForm.getPaymentAccount()));
    saveNewAccountButton.disableProperty().bind(paymentMethodForm.allInputsValidProperty().not());
    Button cancelButton = tuple2.second;
    cancelButton.setOnAction(event -> onCancelNewAccount());
    GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1);
}
 
Example 5
Source File: PreferencesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void updateDaoFields() {
    boolean isDaoFullNode = isDaoFullNodeToggleButton.isSelected();
    GridPane.setRowSpan(daoOptionsTitledGroupBg, isDaoFullNode ? 5 : 2);
    rpcUserTextField.setVisible(isDaoFullNode);
    rpcUserTextField.setManaged(isDaoFullNode);
    rpcPwTextField.setVisible(isDaoFullNode);
    rpcPwTextField.setManaged(isDaoFullNode);
    blockNotifyPortTextField.setVisible(isDaoFullNode);
    blockNotifyPortTextField.setManaged(isDaoFullNode);
    preferences.setDaoFullNode(isDaoFullNode);
    if (!isDaoFullNode) {
        rpcUserTextField.clear();
        rpcPwTextField.clear();
        blockNotifyPortTextField.clear();
    }

    isDaoFullNodeToggleButton.setDisable(daoOptionsSet);
    rpcUserTextField.setDisable(daoOptionsSet);
    rpcPwTextField.setDisable(daoOptionsSet);
    blockNotifyPortTextField.setDisable(daoOptionsSet);
}
 
Example 6
Source File: UiNoiseGrid.java    From EWItool with GNU General Public License v3.0 5 votes vote down vote up
UiNoiseGrid( EWI4000sPatch editPatch, MidiHandler midiHandler ) {
  
  setId( "editor-grid" );
  
  Label mainLabel = new Label( "Noise" );
  mainLabel.setId( "editor-section-label" );
  add( mainLabel, 0, 0 );
  
  timeSlider = new Slider( 0.0, 127.0, 0.0 );
  timeSlider.setOrientation( Orientation.HORIZONTAL );
  timeSlider.valueProperty().addListener( (observable, oldVal, newVal)-> {
    midiHandler.sendLiveControl( 0, 80, newVal.intValue() );
    editPatch.noiseTime = newVal.intValue();
  });
  add( timeSlider, 0, 2 );
  add( new BoundRightControlLabel( "Time", HPos.CENTER, timeSlider ), 0, 1 );
  
  breathSlider = new Slider( 0.0, 127.0, 0.0 );
  breathSlider.setOrientation( Orientation.HORIZONTAL );
  breathSlider.valueProperty().addListener( (observable, oldVal, newVal)-> {
    midiHandler.sendLiveControl( 1, 80, newVal.intValue() );
    editPatch.noiseBreath = newVal.intValue();
  });
  add( breathSlider, 0, 4 );
  add( new BoundRightControlLabel( "Breath", HPos.CENTER, breathSlider ), 0, 3 );
  
  volSlider = new Slider( 0.0, 127.0, 0.0 );
  volSlider.setOrientation( Orientation.VERTICAL );
  GridPane.setRowSpan( volSlider, 3 );
  volSlider.valueProperty().addListener( (observable, oldVal, newVal)-> {
    midiHandler.sendLiveControl( 2, 80, newVal.intValue() );
    editPatch.noiseLevel = newVal.intValue();
  });
  add( volSlider, 1, 1 );
  add( new BoundBelowControlLabel( "Vol", HPos.CENTER, volSlider ), 1, 0 );
}
 
Example 7
Source File: TradeSubView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
void addWizardsToGridPane(TradeWizardItem tradeWizardItem) {
    if (leftGridPaneRowIndex == 0)
        GridPane.setMargin(tradeWizardItem, new Insets(Layout.FIRST_ROW_DISTANCE + Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0));

    GridPane.setRowIndex(tradeWizardItem, leftGridPaneRowIndex++);
    leftGridPane.getChildren().add(tradeWizardItem);
    GridPane.setRowSpan(tradeProcessTitledGroupBg, leftGridPaneRowIndex);
    GridPane.setFillWidth(tradeWizardItem, true);
}
 
Example 8
Source File: AltCoinAccountsView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void onSelectAccount(PaymentAccount paymentAccount) {
    removeAccountRows();
    addAccountButton.setDisable(false);
    accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 2, Res.get("shared.selectedAccount"), Layout.GROUP_DISTANCE);
    paymentMethodForm = getPaymentMethodForm(paymentAccount);
    paymentMethodForm.addFormForDisplayAccount();
    gridRow = paymentMethodForm.getGridRow();
    Tuple2<Button, Button> tuple = add2ButtonsAfterGroup(root, ++gridRow, Res.get("shared.deleteAccount"), Res.get("shared.cancel"));
    Button deleteAccountButton = tuple.first;
    deleteAccountButton.setOnAction(event -> onDeleteAccount(paymentMethodForm.getPaymentAccount()));
    Button cancelButton = tuple.second;
    cancelButton.setOnAction(event -> removeSelectAccountForm());
    GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan());
    model.onSelectAccount(paymentAccount);
}
 
Example 9
Source File: PreferencesView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initializeSeparator() {
    final Separator separator = new Separator(Orientation.VERTICAL);
    separator.setPadding(new Insets(0, 10, 0, 10));
    GridPane.setColumnIndex(separator, 1);
    GridPane.setHalignment(separator, HPos.CENTER);
    GridPane.setRowIndex(separator, 0);
    GridPane.setRowSpan(separator, GridPane.REMAINING);
    root.getChildren().add(separator);
}
 
Example 10
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static TitledGroupBg addTitledGroupBg(GridPane gridPane,
                                             int rowIndex,
                                             int rowSpan,
                                             String title,
                                             double top) {
    TitledGroupBg titledGroupBg = new TitledGroupBg();
    titledGroupBg.setText(title);
    titledGroupBg.prefWidthProperty().bind(gridPane.widthProperty());
    GridPane.setRowIndex(titledGroupBg, rowIndex);
    GridPane.setRowSpan(titledGroupBg, rowSpan);
    GridPane.setMargin(titledGroupBg, new Insets(top + 8, -10, -12, -10));
    gridPane.getChildren().add(titledGroupBg);
    return titledGroupBg;
}
 
Example 11
Source File: SeparatorSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 350, 150);
    stage.setScene(scene);
    stage.setTitle("Separator Sample");

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(2);
    grid.setHgap(5);

    scene.setRoot(grid);
    scene.getStylesheets().add("separatorsample/controlStyle.css");

    Image cloudImage = new Image(getClass().getResourceAsStream("cloud.jpg"));
    Image sunImage = new Image(getClass().getResourceAsStream("sun.jpg"));

    caption.setFont(Font.font("Verdana", 20));

    GridPane.setConstraints(caption, 0, 0);
    GridPane.setColumnSpan(caption, 8);
    grid.getChildren().add(caption);

    final Separator sepHor = new Separator();
    sepHor.setValignment(VPos.CENTER);
    GridPane.setConstraints(sepHor, 0, 1);
    GridPane.setColumnSpan(sepHor, 7);
    grid.getChildren().add(sepHor);

    friday.setFont(Font.font("Verdana", 18));
    GridPane.setConstraints(friday, 0, 2);
    GridPane.setColumnSpan(friday, 2);
    grid.getChildren().add(friday);

    final Separator sepVert1 = new Separator();
    sepVert1.setOrientation(Orientation.VERTICAL);
    sepVert1.setValignment(VPos.CENTER);
    sepVert1.setPrefHeight(80);
    GridPane.setConstraints(sepVert1, 2, 2);
    GridPane.setRowSpan(sepVert1, 2);
    grid.getChildren().add(sepVert1);

    saturday.setFont(Font.font("Verdana", 18));
    GridPane.setConstraints(saturday, 3, 2);
    GridPane.setColumnSpan(saturday, 2);
    grid.getChildren().add(saturday);

    final Separator sepVert2 = new Separator();
    sepVert2.setOrientation(Orientation.VERTICAL);
    sepVert2.setValignment(VPos.CENTER);
    sepVert2.setPrefHeight(80);
    GridPane.setConstraints(sepVert2, 5, 2);
    GridPane.setRowSpan(sepVert2, 2);
    grid.getChildren().add(sepVert2);

    sunday.setFont(Font.font("Verdana", 18));
    GridPane.setConstraints(sunday, 6, 2);
    GridPane.setColumnSpan(sunday, 2);
    grid.getChildren().add(sunday);

    final ImageView cloud = new ImageView(cloudImage);
    GridPane.setConstraints(cloud, 0, 3);
    grid.getChildren().add(cloud);

    final Label t1 = new Label("16");
    t1.setFont(Font.font("Verdana", 20));
    GridPane.setConstraints(t1, 1, 3);
    grid.getChildren().add(t1);

    final ImageView sun1 = new ImageView(sunImage);
    GridPane.setConstraints(sun1, 3, 3);
    grid.getChildren().add(sun1);

    final Label t2 = new Label("18");
    t2.setFont(Font.font("Verdana", 20));
    GridPane.setConstraints(t2, 4, 3);
    grid.getChildren().add(t2);

    final ImageView sun2 = new ImageView(sunImage);
    GridPane.setConstraints(sun2, 6, 3);
    grid.getChildren().add(sun2);

    final Label t3 = new Label("20");
    t3.setFont(Font.font("Verdana", 20));
    GridPane.setConstraints(t3, 7, 3);
    grid.getChildren().add(t3);

    stage.show();
}
 
Example 12
Source File: SellerStep3View.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void addContent() {

    gridPane.getColumnConstraints().get(1).setHgrow(Priority.ALWAYS);

    addTradeInfoBlock();

    TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 3,
            Res.get("portfolio.pending.step3_seller.confirmPaymentReceipt"), Layout.COMPACT_GROUP_DISTANCE);

    TextFieldWithCopyIcon field = addTopLabelTextFieldWithCopyIcon(gridPane, gridRow,
            Res.get("portfolio.pending.step3_seller.amountToReceive"),
            model.getFiatVolume(), Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE).second;
    field.setCopyWithoutCurrencyPostFix(true);

    String myPaymentDetails = "";
    String peersPaymentDetails = "";
    String myTitle = "";
    String peersTitle = "";
    boolean isBlockChain = false;
    String nameByCode = CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode());
    Contract contract = trade.getContract();
    if (contract != null) {
        PaymentAccountPayload myPaymentAccountPayload = contract.getSellerPaymentAccountPayload();
        PaymentAccountPayload peersPaymentAccountPayload = contract.getBuyerPaymentAccountPayload();
        if (myPaymentAccountPayload instanceof AssetsAccountPayload) {
            myPaymentDetails = ((AssetsAccountPayload) myPaymentAccountPayload).getAddress();
            peersPaymentDetails = ((AssetsAccountPayload) peersPaymentAccountPayload).getAddress();
            myTitle = Res.get("portfolio.pending.step3_seller.yourAddress", nameByCode);
            peersTitle = Res.get("portfolio.pending.step3_seller.buyersAddress", nameByCode);
            isBlockChain = true;
        } else {
            myPaymentDetails = myPaymentAccountPayload.getPaymentDetails();
            peersPaymentDetails = peersPaymentAccountPayload.getPaymentDetails();
            myTitle = Res.get("portfolio.pending.step3_seller.yourAccount");
            peersTitle = Res.get("portfolio.pending.step3_seller.buyersAccount");
        }
    }

    if (!isBlockChain && !trade.getOffer().getPaymentMethod().equals(PaymentMethod.F2F)) {
        addTopLabelTextFieldWithCopyIcon(
                gridPane, gridRow, 1, Res.get("shared.reasonForPayment"),
                model.dataModel.getReference(), Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE);
        GridPane.setRowSpan(titledGroupBg, 4);
    }

    TextFieldWithCopyIcon myPaymentDetailsTextField = addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow,
            0, myTitle, myPaymentDetails).second;
    myPaymentDetailsTextField.setMouseTransparent(false);
    myPaymentDetailsTextField.setTooltip(new Tooltip(myPaymentDetails));

    TextFieldWithCopyIcon peersPaymentDetailsTextField = addCompactTopLabelTextFieldWithCopyIcon(gridPane, gridRow,
            1, peersTitle, peersPaymentDetails).second;
    peersPaymentDetailsTextField.setMouseTransparent(false);
    peersPaymentDetailsTextField.setTooltip(new Tooltip(peersPaymentDetails));


    Tuple4<Button, BusyAnimation, Label, HBox> tuple = addButtonBusyAnimationLabelAfterGroup(gridPane, ++gridRow,
            Res.get("portfolio.pending.step3_seller.confirmReceipt"));

    GridPane.setColumnSpan(tuple.fourth, 2);
    confirmButton = tuple.first;
    confirmButton.setOnAction(e -> onPaymentReceived());
    busyAnimation = tuple.second;
    statusLabel = tuple.third;
}
 
Example 13
Source File: BsqTxView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void initialize() {
    gridRow = bsqBalanceUtil.addGroup(root, gridRow);

    tableView = new TableView<>();
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    addDateColumn();
    addTxIdColumn();
    addInformationColumn();
    addAmountColumn();
    addConfidenceColumn();
    addTxTypeColumn();

    chainSyncIndicator = new JFXProgressBar();
    chainSyncIndicator.setPrefWidth(120);
    if (DevEnv.isDaoActivated())
        chainSyncIndicator.setProgress(-1);
    else
        chainSyncIndicator.setProgress(0);
    chainSyncIndicator.setPadding(new Insets(-6, 0, -10, 5));

    chainHeightLabel = FormBuilder.addLabel(root, ++gridRow, "");
    chainHeightLabel.setId("num-offers");
    chainHeightLabel.setPadding(new Insets(-5, 0, -10, 5));

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(chainHeightLabel, chainSyncIndicator);

    VBox vBox = new VBox();
    vBox.setSpacing(10);
    GridPane.setVgrow(vBox, Priority.ALWAYS);
    GridPane.setRowIndex(vBox, ++gridRow);
    GridPane.setColumnSpan(vBox, 3);
    GridPane.setRowSpan(vBox, 2);
    GridPane.setMargin(vBox, new Insets(40, -10, 5, -10));
    vBox.getChildren().addAll(tableView, hBox);
    VBox.setVgrow(tableView, Priority.ALWAYS);
    root.getChildren().add(vBox);

    walletChainHeightListener = (observable, oldValue, newValue) -> {
        walletChainHeight = bsqWalletService.getBestChainHeight();
        onUpdateAnyChainHeight();
    };
}
 
Example 14
Source File: DepositView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void initialize() {

    paymentLabelString = Res.get("funds.deposit.fundBisqWallet");
    addressColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.address")));
    balanceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.balanceWithCur", Res.getBaseCurrencyCode())));
    confirmationsColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.confirmations")));
    usageColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.usage")));

    // trigger creation of at least 1 savings address
    walletService.getFreshAddressEntry();

    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    tableView.setPlaceholder(new AutoTooltipLabel(Res.get("funds.deposit.noAddresses")));
    tableViewSelectionListener = (observableValue, oldValue, newValue) -> {
        if (newValue != null) {
            fillForm(newValue.getAddressString());
            GUIUtil.requestFocus(amountTextField);
        }
    };

    setAddressColumnCellFactory();
    setBalanceColumnCellFactory();
    setUsageColumnCellFactory();
    setConfidenceColumnCellFactory();

    addressColumn.setComparator(Comparator.comparing(DepositListItem::getAddressString));
    balanceColumn.setComparator(Comparator.comparing(DepositListItem::getBalanceAsCoin));
    confirmationsColumn.setComparator(Comparator.comparingDouble(o -> o.getTxConfidenceIndicator().getProgress()));
    usageColumn.setComparator(Comparator.comparingInt(DepositListItem::getNumTxOutputs));
    tableView.getSortOrder().add(usageColumn);
    tableView.setItems(sortedList);

    titledGroupBg = addTitledGroupBg(gridPane, gridRow, 4, Res.get("funds.deposit.fundWallet"));
    titledGroupBg.getStyleClass().add("last");

    qrCodeImageView = new ImageView();
    qrCodeImageView.getStyleClass().add("qr-code");
    Tooltip.install(qrCodeImageView, new Tooltip(Res.get("shared.openLargeQRWindow")));
    qrCodeImageView.setOnMouseClicked(e -> GUIUtil.showFeeInfoBeforeExecute(
            () -> UserThread.runAfter(
                    () -> new QRCodeWindow(getBitcoinURI()).show(),
                    200, TimeUnit.MILLISECONDS)));
    GridPane.setRowIndex(qrCodeImageView, gridRow);
    GridPane.setRowSpan(qrCodeImageView, 4);
    GridPane.setColumnIndex(qrCodeImageView, 1);
    GridPane.setMargin(qrCodeImageView, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 10));
    gridPane.getChildren().add(qrCodeImageView);

    addressTextField = addAddressTextField(gridPane, ++gridRow, Res.get("shared.address"), Layout.FIRST_ROW_DISTANCE);
    addressTextField.setPaymentLabel(paymentLabelString);


    amountTextField = addInputTextField(gridPane, ++gridRow, Res.get("funds.deposit.amount"));
    amountTextField.setMaxWidth(380);
    if (DevEnv.isDevMode())
        amountTextField.setText("10");

    titledGroupBg.setVisible(false);
    titledGroupBg.setManaged(false);
    qrCodeImageView.setVisible(false);
    qrCodeImageView.setManaged(false);
    addressTextField.setVisible(false);
    addressTextField.setManaged(false);
    amountTextField.setManaged(false);

    generateNewAddressButton = addButton(gridPane, ++gridRow, Res.get("funds.deposit.generateAddress"), -20);
    GridPane.setColumnIndex(generateNewAddressButton, 0);
    GridPane.setHalignment(generateNewAddressButton, HPos.LEFT);

    generateNewAddressButton.setOnAction(event -> {
        boolean hasUnUsedAddress = observableList.stream().anyMatch(e -> e.getNumTxOutputs() == 0);
        if (hasUnUsedAddress) {
            new Popup().warning(Res.get("funds.deposit.selectUnused")).show();
        } else {
            AddressEntry newSavingsAddressEntry = walletService.getFreshAddressEntry();
            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();
        }
    };

    GUIUtil.focusWhenAddedToScene(amountTextField);
}
 
Example 15
Source File: InfoDisplay.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public InfoDisplay() {
    icon.setId("non-clickable-icon");
    icon.visibleProperty().bind(visibleProperty());

    GridPane.setValignment(icon, VPos.TOP);
    GridPane.setMargin(icon, new Insets(-2, 0, 0, 0));
    GridPane.setRowSpan(icon, 2);

    label = new AutoTooltipLabel();
    label.textProperty().bind(text);
    label.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    // width is set a frame later so we hide it first
    label.setVisible(false);

    link = new Hyperlink(Res.get("shared.readMore"));
    link.setPadding(new Insets(0, 0, 0, -2));

    // We need that to know if we have a wrapping or not.
    // Did not find a way to get that from the API.
    Label testLabel = new AutoTooltipLabel();
    testLabel.textProperty().bind(text);

    textFlow = new TextFlow();
    textFlow.visibleProperty().bind(visibleProperty());
    textFlow.getChildren().addAll(testLabel);

    testLabel.widthProperty().addListener((ov, o, n) -> {
        useReadMore = (double) n > textFlow.getWidth();
        link.setText(Res.get(useReadMore ? "shared.readMore" : "shared.openHelp"));
        UserThread.execute(() -> textFlow.getChildren().setAll(label, link));
    });

    // update the width when the window gets resized
    ChangeListener<Number> listener = (ov2, oldValue2, windowWidth) -> {
        if (label.prefWidthProperty().isBound())
            label.prefWidthProperty().unbind();
        label.setPrefWidth((double) windowWidth - localToScene(0, 0).getX() - 35);
    };


    // when clicking "Read more..." we expand and change the link to the Help
    link.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            if (useReadMore) {

                label.setWrapText(true);
                link.setText(Res.get("shared.openHelp"));
                getScene().getWindow().widthProperty().removeListener(listener);
                if (label.prefWidthProperty().isBound())
                    label.prefWidthProperty().unbind();
                label.prefWidthProperty().bind(textFlow.widthProperty());
                link.setVisited(false);
                // focus border is a bit confusing here so we remove it
                link.getStyleClass().add("hide-focus");
                link.setOnAction(onAction.get());
                getParent().layout();
            } else {
                onAction.get().handle(actionEvent);
            }
        }
    });

    sceneProperty().addListener((ov, oldValue, newValue) -> {
        if (oldValue == null && newValue != null && newValue.getWindow() != null) {
            newValue.getWindow().widthProperty().addListener(listener);
            // localToScene does deliver 0 instead of the correct x position when scene property gets set,
            // so we delay for 1 render cycle
            UserThread.execute(() -> {
                label.setVisible(true);
                label.prefWidthProperty().unbind();
                label.setPrefWidth(newValue.getWindow().getWidth() - localToScene(0, 0).getX() - 35);
            });
        }
    });
}