Search in sources :

Example 1 with AutoTooltipCheckBox

use of bisq.desktop.components.AutoTooltipCheckBox in project bisq-desktop by bisq-network.

the class SepaForm method addCountriesGrid.

private void addCountriesGrid(boolean isEditable, String title, List<CheckBox> checkBoxList, List<Country> dataProvider) {
    Label label = FormBuilder.addLabel(gridPane, ++gridRow, title, 0);
    label.setWrapText(true);
    label.setMaxWidth(180);
    label.setTextAlignment(TextAlignment.RIGHT);
    GridPane.setHalignment(label, HPos.RIGHT);
    GridPane.setValignment(label, VPos.TOP);
    FlowPane flowPane = new FlowPane();
    flowPane.setPadding(new Insets(10, 10, 10, 10));
    flowPane.setVgap(10);
    flowPane.setHgap(10);
    flowPane.setMinHeight(55);
    if (isEditable)
        flowPane.setId("flow-pane-checkboxes-bg");
    else
        flowPane.setId("flow-pane-checkboxes-non-editable-bg");
    dataProvider.stream().forEach(country -> {
        final String countryCode = country.code;
        CheckBox checkBox = new AutoTooltipCheckBox(countryCode);
        checkBox.setUserData(countryCode);
        checkBoxList.add(checkBox);
        checkBox.setMouseTransparent(!isEditable);
        checkBox.setMinWidth(45);
        checkBox.setMaxWidth(45);
        checkBox.setTooltip(new Tooltip(country.name));
        checkBox.setOnAction(event -> {
            if (checkBox.isSelected())
                sepaAccount.addAcceptedCountry(countryCode);
            else
                sepaAccount.removeAcceptedCountry(countryCode);
            updateAllInputsValid();
        });
        flowPane.getChildren().add(checkBox);
    });
    updateCountriesSelection(isEditable, checkBoxList);
    GridPane.setRowIndex(flowPane, gridRow);
    GridPane.setColumnIndex(flowPane, 1);
    gridPane.getChildren().add(flowPane);
}
Also used : AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) Insets(javafx.geometry.Insets) CheckBox(javafx.scene.control.CheckBox) AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label) FlowPane(javafx.scene.layout.FlowPane)

Example 2 with AutoTooltipCheckBox

use of bisq.desktop.components.AutoTooltipCheckBox in project bisq-desktop by bisq-network.

the class SepaInstantForm method addCountriesGrid.

private void addCountriesGrid(boolean isEditable, String title, List<CheckBox> checkBoxList, List<Country> dataProvider) {
    Label label = FormBuilder.addLabel(gridPane, ++gridRow, title, 0);
    label.setWrapText(true);
    label.setMaxWidth(180);
    label.setTextAlignment(TextAlignment.RIGHT);
    GridPane.setHalignment(label, HPos.RIGHT);
    GridPane.setValignment(label, VPos.TOP);
    FlowPane flowPane = new FlowPane();
    flowPane.setPadding(new Insets(10, 10, 10, 10));
    flowPane.setVgap(10);
    flowPane.setHgap(10);
    flowPane.setMinHeight(55);
    if (isEditable)
        flowPane.setId("flow-pane-checkboxes-bg");
    else
        flowPane.setId("flow-pane-checkboxes-non-editable-bg");
    dataProvider.stream().forEach(country -> {
        final String countryCode = country.code;
        CheckBox checkBox = new AutoTooltipCheckBox(countryCode);
        checkBox.setUserData(countryCode);
        checkBoxList.add(checkBox);
        checkBox.setMouseTransparent(!isEditable);
        checkBox.setMinWidth(45);
        checkBox.setMaxWidth(45);
        checkBox.setTooltip(new Tooltip(country.name));
        checkBox.setOnAction(event -> {
            if (checkBox.isSelected())
                sepaInstantAccount.addAcceptedCountry(countryCode);
            else
                sepaInstantAccount.removeAcceptedCountry(countryCode);
            updateAllInputsValid();
        });
        flowPane.getChildren().add(checkBox);
    });
    updateCountriesSelection(isEditable, checkBoxList);
    GridPane.setRowIndex(flowPane, gridRow);
    GridPane.setColumnIndex(flowPane, 1);
    gridPane.getChildren().add(flowPane);
}
Also used : AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) Insets(javafx.geometry.Insets) CheckBox(javafx.scene.control.CheckBox) AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label) FlowPane(javafx.scene.layout.FlowPane)

Example 3 with AutoTooltipCheckBox

use of bisq.desktop.components.AutoTooltipCheckBox in project bisq-desktop by bisq-network.

the class FormBuilder method addButtonCheckBox.

public static Tuple2<Button, CheckBox> addButtonCheckBox(GridPane gridPane, int rowIndex, String buttonTitle, String checkBoxTitle, double top) {
    Button button = new AutoTooltipButton(buttonTitle);
    button.setDefaultButton(true);
    CheckBox checkBox = new AutoTooltipCheckBox(checkBoxTitle);
    HBox.setMargin(checkBox, new Insets(6, 0, 0, 0));
    HBox hBox = new HBox();
    hBox.setSpacing(20);
    hBox.getChildren().addAll(button, checkBox);
    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    hBox.setPadding(new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(hBox);
    return new Tuple2<>(button, checkBox);
}
Also used : AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) Button(javafx.scene.control.Button) AutoTooltipRadioButton(bisq.desktop.components.AutoTooltipRadioButton) RadioButton(javafx.scene.control.RadioButton) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) CheckBox(javafx.scene.control.CheckBox) AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) Tuple2(bisq.common.util.Tuple2) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton)

Example 4 with AutoTooltipCheckBox

use of bisq.desktop.components.AutoTooltipCheckBox in project bisq-desktop by bisq-network.

the class WithdrawalView method setSelectColumnCellFactory.

private void setSelectColumnCellFactory() {
    selectColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    selectColumn.setCellFactory(new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>, TableCell<WithdrawalListItem, WithdrawalListItem>>() {

        @Override
        public TableCell<WithdrawalListItem, WithdrawalListItem> call(TableColumn<WithdrawalListItem, WithdrawalListItem> column) {
            return new TableCell<WithdrawalListItem, WithdrawalListItem>() {

                CheckBox checkBox = new AutoTooltipCheckBox();

                @Override
                public void updateItem(final WithdrawalListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        checkBox.setOnAction(e -> {
                            item.setSelected(checkBox.isSelected());
                            selectForWithdrawal(item);
                            // If all are selected we select useAllInputsRadioButton
                            if (observableList.size() == selectedItems.size()) {
                                inputsToggleGroup.selectToggle(useAllInputsRadioButton);
                            } else {
                                // We don't want to get deselected all when we activate the useCustomInputsRadioButton
                                // so we temporarily disable the listener
                                inputsToggleGroup.selectedToggleProperty().removeListener(inputsToggleGroupListener);
                                inputsToggleGroup.selectToggle(useCustomInputsRadioButton);
                                useAllInputs.set(false);
                                inputsToggleGroup.selectedToggleProperty().addListener(inputsToggleGroupListener);
                            }
                        });
                        setGraphic(checkBox);
                        checkBox.setSelected(item.isSelected());
                    } else {
                        checkBox.setOnAction(null);
                        setGraphic(null);
                    }
                }
            };
        }
    });
}
Also used : AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) Button(javafx.scene.control.Button) Transaction(org.bitcoinj.core.Transaction) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) Coin(org.bitcoinj.core.Coin) VBox(javafx.scene.layout.VBox) StringUtils(org.apache.commons.lang3.StringUtils) BSFormatter(bisq.desktop.util.BSFormatter) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) Res(bisq.core.locale.Res) TableView(javafx.scene.control.TableView) KeyParameter(org.spongycastle.crypto.params.KeyParameter) SortedList(javafx.collections.transformation.SortedList) AddressFormatException(org.bitcoinj.core.AddressFormatException) Popup(bisq.desktop.main.overlays.popups.Popup) AddressEntryException(bisq.core.btc.AddressEntryException) ClosedTradableManager(bisq.core.trade.closed.ClosedTradableManager) TextField(javafx.scene.control.TextField) WalletPasswordWindow(bisq.desktop.main.overlays.windows.WalletPasswordWindow) P2PService(bisq.network.p2p.P2PService) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) InsufficientFundsException(bisq.core.btc.InsufficientFundsException) Set(java.util.Set) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) BooleanProperty(javafx.beans.property.BooleanProperty) List(java.util.List) AddressEntry(bisq.core.btc.AddressEntry) WalletsSetup(bisq.core.btc.wallet.WalletsSetup) TradeManager(bisq.core.trade.TradeManager) RadioButton(javafx.scene.control.RadioButton) Preferences(bisq.core.user.Preferences) UserThread(bisq.common.UserThread) Optional(java.util.Optional) Toggle(javafx.scene.control.Toggle) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) NotNull(org.jetbrains.annotations.NotNull) Restrictions(bisq.core.btc.Restrictions) GUIUtil(bisq.desktop.util.GUIUtil) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) ActivatableView(bisq.desktop.common.view.ActivatableView) Wallet(org.bitcoinj.wallet.Wallet) FXCollections(javafx.collections.FXCollections) Tradable(bisq.core.trade.Tradable) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) HashSet(java.util.HashSet) BalanceListener(bisq.core.btc.listeners.BalanceListener) TableCell(javafx.scene.control.TableCell) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label) Trade(bisq.core.trade.Trade) FailedTradesManager(bisq.core.trade.failed.FailedTradesManager) CheckBox(javafx.scene.control.CheckBox) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) InsufficientMoneyException(org.bitcoinj.core.InsufficientMoneyException) FutureCallback(com.google.common.util.concurrent.FutureCallback) TimeUnit(java.util.concurrent.TimeUnit) ToggleGroup(javafx.scene.control.ToggleGroup) SelectionMode(javafx.scene.control.SelectionMode) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) BtcAddressValidator(bisq.desktop.util.validation.BtcAddressValidator) AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) ChangeListener(javafx.beans.value.ChangeListener) CoinUtil(bisq.core.util.CoinUtil) TableCell(javafx.scene.control.TableCell) CheckBox(javafx.scene.control.CheckBox) AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) TableColumn(javafx.scene.control.TableColumn)

Example 5 with AutoTooltipCheckBox

use of bisq.desktop.components.AutoTooltipCheckBox in project bisq-desktop by bisq-network.

the class ArbitratorSelectionView method addArbitratorsGroup.

private void addArbitratorsGroup() {
    TableGroupHeadline tableGroupHeadline = new TableGroupHeadline(Res.get("account.arbitratorSelection.whichDoYouAccept"));
    GridPane.setRowIndex(tableGroupHeadline, ++gridRow);
    GridPane.setColumnSpan(tableGroupHeadline, 2);
    GridPane.setMargin(tableGroupHeadline, new Insets(40, -10, -10, -10));
    root.getChildren().add(tableGroupHeadline);
    tableView = new TableView<>();
    GridPane.setRowIndex(tableView, gridRow);
    GridPane.setColumnSpan(tableView, 2);
    GridPane.setMargin(tableView, new Insets(60, -10, 5, -10));
    root.getChildren().add(tableView);
    autoSelectAllMatchingCheckBox = addCheckBox(root, ++gridRow, Res.get("account.arbitratorSelection.autoSelect"));
    GridPane.setColumnSpan(autoSelectAllMatchingCheckBox, 2);
    GridPane.setHalignment(autoSelectAllMatchingCheckBox, HPos.LEFT);
    GridPane.setColumnIndex(autoSelectAllMatchingCheckBox, 0);
    GridPane.setMargin(autoSelectAllMatchingCheckBox, new Insets(0, -10, 0, -10));
    autoSelectAllMatchingCheckBox.setOnAction(event -> model.setAutoSelectArbitrators(autoSelectAllMatchingCheckBox.isSelected()));
    TableColumn<ArbitratorListItem, String> dateColumn = new AutoTooltipTableColumn<>(Res.get("account.arbitratorSelection.regDate"));
    dateColumn.setSortable(false);
    dateColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getRegistrationDate()));
    dateColumn.setMinWidth(140);
    dateColumn.setMaxWidth(140);
    TableColumn<ArbitratorListItem, String> nameColumn = new AutoTooltipTableColumn<>(Res.get("shared.onionAddress"));
    nameColumn.setSortable(false);
    nameColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getAddressString()));
    nameColumn.setMinWidth(90);
    TableColumn<ArbitratorListItem, String> languagesColumn = new AutoTooltipTableColumn<>(Res.get("account.arbitratorSelection.languages"));
    languagesColumn.setSortable(false);
    languagesColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getLanguageCodes()));
    languagesColumn.setMinWidth(130);
    TableColumn<ArbitratorListItem, ArbitratorListItem> selectionColumn = new AutoTooltipTableColumn<ArbitratorListItem, ArbitratorListItem>(Res.get("shared.accept")) {

        {
            setMinWidth(60);
            setMaxWidth(60);
            setSortable(false);
        }
    };
    selectionColumn.setCellValueFactory((arbitrator) -> new ReadOnlyObjectWrapper<>(arbitrator.getValue()));
    selectionColumn.setCellFactory(new Callback<TableColumn<ArbitratorListItem, ArbitratorListItem>, TableCell<ArbitratorListItem, ArbitratorListItem>>() {

        @Override
        public TableCell<ArbitratorListItem, ArbitratorListItem> call(TableColumn<ArbitratorListItem, ArbitratorListItem> column) {
            return new TableCell<ArbitratorListItem, ArbitratorListItem>() {

                private final CheckBox checkBox = new AutoTooltipCheckBox();

                private TableRow tableRow;

                private BooleanProperty selectedProperty;

                private void updateDisableState(final ArbitratorListItem item) {
                    boolean selected = model.isAcceptedArbitrator(item.arbitrator);
                    item.setIsSelected(selected);
                    boolean hasMatchingLanguage = model.hasMatchingLanguage(item.arbitrator);
                    if (!hasMatchingLanguage) {
                        model.onRemoveArbitrator(item.arbitrator);
                        if (selected)
                            item.setIsSelected(false);
                    }
                    boolean isMyOwnRegisteredArbitrator = model.isMyOwnRegisteredArbitrator(item.arbitrator);
                    checkBox.setDisable(!hasMatchingLanguage || isMyOwnRegisteredArbitrator);
                    tableRow = getTableRow();
                    if (tableRow != null) {
                        tableRow.setOpacity(hasMatchingLanguage && !isMyOwnRegisteredArbitrator ? 1 : 0.4);
                        if (isMyOwnRegisteredArbitrator) {
                            String text = Res.get("account.arbitratorSelection.cannotSelectHimself");
                            tableRow.setTooltip(new Tooltip(text));
                            tableRow.setOnMouseClicked(e -> new Popup<>().warning(text).show());
                        } else if (!hasMatchingLanguage) {
                            tableRow.setTooltip(new Tooltip(Res.get("account.arbitratorSelection.noMatchingLang")));
                            tableRow.setOnMouseClicked(e -> new Popup<>().warning(Res.get("account.arbitratorSelection.noLang")).show());
                        } else {
                            tableRow.setOnMouseClicked(null);
                            tableRow.setTooltip(null);
                        }
                    }
                }

                @Override
                public void updateItem(final ArbitratorListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        selectedProperty = item.isSelectedProperty();
                        languageCodesListChangeListener = c -> updateDisableState(item);
                        model.languageCodes.addListener(languageCodesListChangeListener);
                        isSelectedChangeListener = (observable, oldValue, newValue) -> checkBox.setSelected(newValue);
                        selectedProperty.addListener(isSelectedChangeListener);
                        checkBox.setSelected(model.isAcceptedArbitrator(item.arbitrator));
                        checkBox.setOnAction(e -> {
                            if (checkBox.isSelected()) {
                                onAddArbitrator(item);
                            } else if (model.isDeselectAllowed(item)) {
                                onRemoveArbitrator(item);
                            } else {
                                new Popup<>().warning(Res.get("account.arbitratorSelection.minOne")).show();
                                checkBox.setSelected(true);
                            }
                            item.setIsSelected(checkBox.isSelected());
                        });
                        updateDisableState(item);
                        setGraphic(checkBox);
                    } else {
                        model.languageCodes.removeListener(languageCodesListChangeListener);
                        if (selectedProperty != null)
                            selectedProperty.removeListener(isSelectedChangeListener);
                        setGraphic(null);
                        if (checkBox != null)
                            checkBox.setOnAction(null);
                        if (tableRow != null)
                            tableRow.setOnMouseClicked(null);
                    }
                }
            };
        }
    });
    // noinspection unchecked
    tableView.getColumns().addAll(dateColumn, nameColumn, languagesColumn, selectionColumn);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
}
Also used : AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) TableGroupHeadline(bisq.desktop.components.TableGroupHeadline) Button(javafx.scene.control.Button) HPos(javafx.geometry.HPos) ListView(javafx.scene.control.ListView) ListCell(javafx.scene.control.ListCell) Layout(bisq.desktop.util.Layout) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) Tuple2(bisq.common.util.Tuple2) TableCell(javafx.scene.control.TableCell) FormBuilder.addLabelComboBox(bisq.desktop.util.FormBuilder.addLabelComboBox) Insets(javafx.geometry.Insets) ComboBox(javafx.scene.control.ComboBox) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) VPos(javafx.geometry.VPos) Res(bisq.core.locale.Res) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) GridPane(javafx.scene.layout.GridPane) FormBuilder.addLabelListView(bisq.desktop.util.FormBuilder.addLabelListView) Popup(bisq.desktop.main.overlays.popups.Popup) Label(javafx.scene.control.Label) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) TableRow(javafx.scene.control.TableRow) FormBuilder.addTitledGroupBg(bisq.desktop.util.FormBuilder.addTitledGroupBg) CheckBox(javafx.scene.control.CheckBox) StringConverter(javafx.util.StringConverter) FormBuilder.addCheckBox(bisq.desktop.util.FormBuilder.addCheckBox) BooleanProperty(javafx.beans.property.BooleanProperty) ImageUtil(bisq.desktop.util.ImageUtil) AnchorPane(javafx.scene.layout.AnchorPane) ImageView(javafx.scene.image.ImageView) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) LanguageUtil(bisq.core.locale.LanguageUtil) UserThread(bisq.common.UserThread) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) ChangeListener(javafx.beans.value.ChangeListener) TableGroupHeadline(bisq.desktop.components.TableGroupHeadline) Insets(javafx.geometry.Insets) BooleanProperty(javafx.beans.property.BooleanProperty) Tooltip(javafx.scene.control.Tooltip) TableColumn(javafx.scene.control.TableColumn) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) TableCell(javafx.scene.control.TableCell) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) CheckBox(javafx.scene.control.CheckBox) FormBuilder.addCheckBox(bisq.desktop.util.FormBuilder.addCheckBox) AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) TableRow(javafx.scene.control.TableRow) Popup(bisq.desktop.main.overlays.popups.Popup)

Aggregations

AutoTooltipCheckBox (bisq.desktop.components.AutoTooltipCheckBox)10 CheckBox (javafx.scene.control.CheckBox)10 Insets (javafx.geometry.Insets)9 Label (javafx.scene.control.Label)8 Tooltip (javafx.scene.control.Tooltip)5 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)4 FlowPane (javafx.scene.layout.FlowPane)4 Tuple2 (bisq.common.util.Tuple2)3 Button (javafx.scene.control.Button)3 UserThread (bisq.common.UserThread)2 Res (bisq.core.locale.Res)2 FxmlView (bisq.desktop.common.view.FxmlView)2 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)2 Popup (bisq.desktop.main.overlays.popups.Popup)2 BooleanProperty (javafx.beans.property.BooleanProperty)2 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)2 ChangeListener (javafx.beans.value.ChangeListener)2 TableCell (javafx.scene.control.TableCell)2 TableColumn (javafx.scene.control.TableColumn)2 TableView (javafx.scene.control.TableView)2