Search in sources :

Example 36 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project bitsquare by bitsquare.

the class LockedView method setAddressColumnCellFactory.

private void setAddressColumnCellFactory() {
    addressColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    addressColumn.setCellFactory(new Callback<TableColumn<LockedListItem, LockedListItem>, TableCell<LockedListItem, LockedListItem>>() {

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

                private HyperlinkWithIcon hyperlinkWithIcon;

                @Override
                public void updateItem(final LockedListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        String address = item.getAddressString();
                        hyperlinkWithIcon = new HyperlinkWithIcon(address, AwesomeIcon.EXTERNAL_LINK);
                        hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
                        hyperlinkWithIcon.setTooltip(new Tooltip("Open external blockchain explorer for " + "address: " + address));
                        setGraphic(hyperlinkWithIcon);
                    } else {
                        setGraphic(null);
                        if (hyperlinkWithIcon != null)
                            hyperlinkWithIcon.setOnAction(null);
                    }
                }
            };
        }
    });
}
Also used : OpenOffer(io.bitsquare.trade.offer.OpenOffer) Popup(io.bitsquare.gui.main.overlays.popups.Popup) Transaction(org.bitcoinj.core.Transaction) javafx.scene.control(javafx.scene.control) Coin(org.bitcoinj.core.Coin) FXCollections(javafx.collections.FXCollections) Trade(io.bitsquare.trade.Trade) ActivatableView(io.bitsquare.gui.common.view.ActivatableView) VBox(javafx.scene.layout.VBox) BalanceListener(io.bitsquare.btc.listeners.BalanceListener) Tradable(io.bitsquare.trade.Tradable) GUIUtil(io.bitsquare.gui.util.GUIUtil) Inject(javax.inject.Inject) TradeManager(io.bitsquare.trade.TradeManager) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) WalletService(io.bitsquare.btc.WalletService) TradeDetailsWindow(io.bitsquare.gui.main.overlays.windows.TradeDetailsWindow) Callback(javafx.util.Callback) AddressEntry(io.bitsquare.btc.AddressEntry) BSFormatter(io.bitsquare.gui.util.BSFormatter) SortedList(javafx.collections.transformation.SortedList) OfferDetailsWindow(io.bitsquare.gui.main.overlays.windows.OfferDetailsWindow) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) Preferences(io.bitsquare.user.Preferences) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon) OpenOfferManager(io.bitsquare.trade.offer.OpenOfferManager) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) FxmlView(io.bitsquare.gui.common.view.FxmlView) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon)

Example 37 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project bitsquare by bitsquare.

the class ReservedView method setAddressColumnCellFactory.

private void setAddressColumnCellFactory() {
    addressColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    addressColumn.setCellFactory(new Callback<TableColumn<ReservedListItem, ReservedListItem>, TableCell<ReservedListItem, ReservedListItem>>() {

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

                private HyperlinkWithIcon hyperlinkWithIcon;

                @Override
                public void updateItem(final ReservedListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        String address = item.getAddressString();
                        hyperlinkWithIcon = new HyperlinkWithIcon(address, AwesomeIcon.EXTERNAL_LINK);
                        hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
                        hyperlinkWithIcon.setTooltip(new Tooltip("Open external blockchain explorer for " + "address: " + address));
                        setGraphic(hyperlinkWithIcon);
                    } else {
                        setGraphic(null);
                        if (hyperlinkWithIcon != null)
                            hyperlinkWithIcon.setOnAction(null);
                    }
                }
            };
        }
    });
}
Also used : OpenOffer(io.bitsquare.trade.offer.OpenOffer) Popup(io.bitsquare.gui.main.overlays.popups.Popup) Transaction(org.bitcoinj.core.Transaction) javafx.scene.control(javafx.scene.control) Coin(org.bitcoinj.core.Coin) FXCollections(javafx.collections.FXCollections) Trade(io.bitsquare.trade.Trade) ActivatableView(io.bitsquare.gui.common.view.ActivatableView) VBox(javafx.scene.layout.VBox) BalanceListener(io.bitsquare.btc.listeners.BalanceListener) Tradable(io.bitsquare.trade.Tradable) GUIUtil(io.bitsquare.gui.util.GUIUtil) Inject(javax.inject.Inject) TradeManager(io.bitsquare.trade.TradeManager) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) WalletService(io.bitsquare.btc.WalletService) TradeDetailsWindow(io.bitsquare.gui.main.overlays.windows.TradeDetailsWindow) Callback(javafx.util.Callback) AddressEntry(io.bitsquare.btc.AddressEntry) BSFormatter(io.bitsquare.gui.util.BSFormatter) SortedList(javafx.collections.transformation.SortedList) OfferDetailsWindow(io.bitsquare.gui.main.overlays.windows.OfferDetailsWindow) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) Preferences(io.bitsquare.user.Preferences) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon) OpenOfferManager(io.bitsquare.trade.offer.OpenOfferManager) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) FxmlView(io.bitsquare.gui.common.view.FxmlView) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon)

Example 38 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project bitsquare by bitsquare.

the class ReservedView method setDetailsColumnCellFactory.

private void setDetailsColumnCellFactory() {
    detailsColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    detailsColumn.setCellFactory(new Callback<TableColumn<ReservedListItem, ReservedListItem>, TableCell<ReservedListItem, ReservedListItem>>() {

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

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final ReservedListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        Optional<Tradable> tradableOptional = getTradable(item);
                        if (tradableOptional.isPresent()) {
                            field = new HyperlinkWithIcon("Reserved in local wallet for offer with ID: " + item.getAddressEntry().getShortOfferId(), AwesomeIcon.INFO_SIGN);
                            field.setOnAction(event -> openDetailPopup(item));
                            field.setTooltip(new Tooltip("Open popup for details"));
                            setGraphic(field);
                        } else if (item.getAddressEntry().getContext() == AddressEntry.Context.ARBITRATOR) {
                            setGraphic(new Label("Arbitrator's fee"));
                        } else {
                            setGraphic(new Label("No details available"));
                        }
                    } else {
                        setGraphic(null);
                        if (field != null)
                            field.setOnAction(null);
                    }
                }
            };
        }
    });
}
Also used : OpenOffer(io.bitsquare.trade.offer.OpenOffer) Popup(io.bitsquare.gui.main.overlays.popups.Popup) Transaction(org.bitcoinj.core.Transaction) javafx.scene.control(javafx.scene.control) Coin(org.bitcoinj.core.Coin) FXCollections(javafx.collections.FXCollections) Trade(io.bitsquare.trade.Trade) ActivatableView(io.bitsquare.gui.common.view.ActivatableView) VBox(javafx.scene.layout.VBox) BalanceListener(io.bitsquare.btc.listeners.BalanceListener) Tradable(io.bitsquare.trade.Tradable) GUIUtil(io.bitsquare.gui.util.GUIUtil) Inject(javax.inject.Inject) TradeManager(io.bitsquare.trade.TradeManager) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) WalletService(io.bitsquare.btc.WalletService) TradeDetailsWindow(io.bitsquare.gui.main.overlays.windows.TradeDetailsWindow) Callback(javafx.util.Callback) AddressEntry(io.bitsquare.btc.AddressEntry) BSFormatter(io.bitsquare.gui.util.BSFormatter) SortedList(javafx.collections.transformation.SortedList) OfferDetailsWindow(io.bitsquare.gui.main.overlays.windows.OfferDetailsWindow) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) Preferences(io.bitsquare.user.Preferences) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon) OpenOfferManager(io.bitsquare.trade.offer.OpenOfferManager) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) FxmlView(io.bitsquare.gui.common.view.FxmlView) Optional(java.util.Optional) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon)

Example 39 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project bitsquare by bitsquare.

the class OfferBookView method getActionColumn.

private TableColumn<OfferBookListItem, OfferBookListItem> getActionColumn() {
    TableColumn<OfferBookListItem, OfferBookListItem> column = new TableColumn<OfferBookListItem, OfferBookListItem>("I want to:") {

        {
            setMinWidth(80);
            setSortable(false);
        }
    };
    column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    column.setCellFactory(new Callback<TableColumn<OfferBookListItem, OfferBookListItem>, TableCell<OfferBookListItem, OfferBookListItem>>() {

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

                final ImageView iconView = new ImageView();

                final Button button = new Button();

                boolean isTradable, isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion, isIgnored, isOfferBanned, isNodeBanned;

                {
                    button.setGraphic(iconView);
                    button.setMinWidth(130);
                    button.setMaxWidth(130);
                    button.setGraphicTextGap(10);
                }

                @Override
                public void updateItem(final OfferBookListItem newItem, boolean empty) {
                    super.updateItem(newItem, empty);
                    TableRow tableRow = getTableRow();
                    if (newItem != null && !empty) {
                        final Offer offer = newItem.getOffer();
                        boolean myOffer = model.isMyOffer(offer);
                        if (tableRow != null) {
                            isPaymentAccountValidForOffer = model.isAnyPaymentAccountValidForOffer(offer);
                            hasMatchingArbitrator = model.hasMatchingArbitrator(offer);
                            hasSameProtocolVersion = model.hasSameProtocolVersion(offer);
                            isIgnored = model.isIgnored(offer);
                            isOfferBanned = model.isOfferBanned(offer);
                            isNodeBanned = model.isNodeBanned(offer);
                            isTradable = isPaymentAccountValidForOffer && hasMatchingArbitrator && hasSameProtocolVersion && !isIgnored && !isOfferBanned && !isNodeBanned;
                            tableRow.setOpacity(isTradable || myOffer ? 1 : 0.4);
                            if (isTradable) {
                                // set first row button as default
                                button.setDefaultButton(getIndex() == 0);
                                tableRow.setOnMousePressed(null);
                            } else {
                                button.setDefaultButton(false);
                                tableRow.setOnMousePressed(e -> {
                                    if (!(e.getTarget() instanceof ImageView || e.getTarget() instanceof Canvas))
                                        onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion, isIgnored, isOfferBanned, isNodeBanned);
                                });
                            //TODO
                            //tableRow.setTooltip(new Tooltip(""));
                            }
                        }
                        String title;
                        if (myOffer) {
                            iconView.setId("image-remove");
                            title = "Remove";
                            button.setId("cancel-button");
                            // does not take the font colors sometimes from the style
                            button.setStyle("-fx-text-fill: #444;");
                            button.setOnAction(e -> onRemoveOpenOffer(offer));
                        } else {
                            boolean isSellOffer = offer.getDirection() == Offer.Direction.SELL;
                            iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
                            button.setId(isSellOffer ? "buy-button" : "sell-button");
                            // does not take the font colors sometimes from the style
                            button.setStyle("-fx-text-fill: white;");
                            title = model.getDirectionLabel(offer);
                            button.setTooltip(new Tooltip("Take offer for " + model.getDirectionLabelTooltip(offer)));
                            button.setOnAction(e -> onTakeOffer(offer));
                        }
                        if (!myOffer && !isTradable)
                            button.setOnAction(e -> onShowInfo(isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion, isIgnored, isOfferBanned, isNodeBanned));
                        button.setText(title);
                        setGraphic(button);
                    } else {
                        setGraphic(null);
                        if (button != null)
                            button.setOnAction(null);
                        if (tableRow != null) {
                            tableRow.setOpacity(1);
                            tableRow.setOnMousePressed(null);
                        }
                    }
                }
            };
        }
    });
    return column;
}
Also used : PaymentMethod(io.bitsquare.payment.PaymentMethod) HPos(javafx.geometry.HPos) Popup(io.bitsquare.gui.main.overlays.popups.Popup) MainView(io.bitsquare.gui.main.MainView) AccountSettingsView(io.bitsquare.gui.main.account.settings.AccountSettingsView) FiatCurrency(io.bitsquare.locale.FiatCurrency) javafx.scene.control(javafx.scene.control) PeerInfoIcon(io.bitsquare.gui.components.PeerInfoIcon) TradeCurrency(io.bitsquare.locale.TradeCurrency) FundsView(io.bitsquare.gui.main.funds.FundsView) ArbitratorSelectionView(io.bitsquare.gui.main.account.content.arbitratorselection.ArbitratorSelectionView) GUIUtil(io.bitsquare.gui.util.GUIUtil) Inject(javax.inject.Inject) OfferView(io.bitsquare.gui.main.offer.OfferView) Insets(javafx.geometry.Insets) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Navigation(io.bitsquare.gui.Navigation) Layout(io.bitsquare.gui.util.Layout) VPos(javafx.geometry.VPos) MonadicBinding(org.fxmisc.easybind.monadic.MonadicBinding) FeePolicy(io.bitsquare.btc.FeePolicy) Callback(javafx.util.Callback) GridPane(javafx.scene.layout.GridPane) BSFormatter(io.bitsquare.gui.util.BSFormatter) WithdrawalView(io.bitsquare.gui.main.funds.withdrawal.WithdrawalView) Node(javafx.scene.Node) Canvas(javafx.scene.canvas.Canvas) Fiat(org.bitcoinj.utils.Fiat) OfferDetailsWindow(io.bitsquare.gui.main.overlays.windows.OfferDetailsWindow) StringConverter(javafx.util.StringConverter) Subscription(org.fxmisc.easybind.Subscription) ActivatableViewAndModel(io.bitsquare.gui.common.view.ActivatableViewAndModel) PrivateNotificationManager(io.bitsquare.alert.PrivateNotificationManager) Priority(javafx.scene.layout.Priority) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon) Offer(io.bitsquare.trade.offer.Offer) FormBuilder(io.bitsquare.gui.util.FormBuilder) FiatAccountsView(io.bitsquare.gui.main.account.content.fiataccounts.FiatAccountsView) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) ObservableValue(javafx.beans.value.ObservableValue) FxmlView(io.bitsquare.gui.common.view.FxmlView) ChangeListener(javafx.beans.value.ChangeListener) BSResources(io.bitsquare.locale.BSResources) TitledGroupBg(io.bitsquare.gui.components.TitledGroupBg) AccountView(io.bitsquare.gui.main.account.AccountView) Canvas(javafx.scene.canvas.Canvas) Offer(io.bitsquare.trade.offer.Offer) ImageView(javafx.scene.image.ImageView)

Example 40 with ReadOnlyObjectWrapper

use of javafx.beans.property.ReadOnlyObjectWrapper in project bitsquare by bitsquare.

the class OfferBookView method getPaymentMethodColumn.

private TableColumn<OfferBookListItem, OfferBookListItem> getPaymentMethodColumn() {
    TableColumn<OfferBookListItem, OfferBookListItem> column = new TableColumn<OfferBookListItem, OfferBookListItem>("Payment method") {

        {
            setMinWidth(125);
        }
    };
    column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    column.setCellFactory(new Callback<TableColumn<OfferBookListItem, OfferBookListItem>, TableCell<OfferBookListItem, OfferBookListItem>>() {

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

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final OfferBookListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        field = new HyperlinkWithIcon(model.getPaymentMethod(item), true);
                        field.setOnAction(event -> offerDetailsWindow.show(item.getOffer()));
                        field.setTooltip(new Tooltip(model.getPaymentMethodToolTip(item)));
                        setGraphic(field);
                    } else {
                        setGraphic(null);
                        if (field != null)
                            field.setOnAction(null);
                    }
                }
            };
        }
    });
    return column;
}
Also used : PaymentMethod(io.bitsquare.payment.PaymentMethod) HPos(javafx.geometry.HPos) Popup(io.bitsquare.gui.main.overlays.popups.Popup) MainView(io.bitsquare.gui.main.MainView) AccountSettingsView(io.bitsquare.gui.main.account.settings.AccountSettingsView) FiatCurrency(io.bitsquare.locale.FiatCurrency) javafx.scene.control(javafx.scene.control) PeerInfoIcon(io.bitsquare.gui.components.PeerInfoIcon) TradeCurrency(io.bitsquare.locale.TradeCurrency) FundsView(io.bitsquare.gui.main.funds.FundsView) ArbitratorSelectionView(io.bitsquare.gui.main.account.content.arbitratorselection.ArbitratorSelectionView) GUIUtil(io.bitsquare.gui.util.GUIUtil) Inject(javax.inject.Inject) OfferView(io.bitsquare.gui.main.offer.OfferView) Insets(javafx.geometry.Insets) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Navigation(io.bitsquare.gui.Navigation) Layout(io.bitsquare.gui.util.Layout) VPos(javafx.geometry.VPos) MonadicBinding(org.fxmisc.easybind.monadic.MonadicBinding) FeePolicy(io.bitsquare.btc.FeePolicy) Callback(javafx.util.Callback) GridPane(javafx.scene.layout.GridPane) BSFormatter(io.bitsquare.gui.util.BSFormatter) WithdrawalView(io.bitsquare.gui.main.funds.withdrawal.WithdrawalView) Node(javafx.scene.Node) Canvas(javafx.scene.canvas.Canvas) Fiat(org.bitcoinj.utils.Fiat) OfferDetailsWindow(io.bitsquare.gui.main.overlays.windows.OfferDetailsWindow) StringConverter(javafx.util.StringConverter) Subscription(org.fxmisc.easybind.Subscription) ActivatableViewAndModel(io.bitsquare.gui.common.view.ActivatableViewAndModel) PrivateNotificationManager(io.bitsquare.alert.PrivateNotificationManager) Priority(javafx.scene.layout.Priority) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon) Offer(io.bitsquare.trade.offer.Offer) FormBuilder(io.bitsquare.gui.util.FormBuilder) FiatAccountsView(io.bitsquare.gui.main.account.content.fiataccounts.FiatAccountsView) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) ObservableValue(javafx.beans.value.ObservableValue) FxmlView(io.bitsquare.gui.common.view.FxmlView) ChangeListener(javafx.beans.value.ChangeListener) BSResources(io.bitsquare.locale.BSResources) TitledGroupBg(io.bitsquare.gui.components.TitledGroupBg) AccountView(io.bitsquare.gui.main.account.AccountView) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon)

Aggregations

ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)59 Callback (javafx.util.Callback)52 Inject (javax.inject.Inject)49 SortedList (javafx.collections.transformation.SortedList)44 VBox (javafx.scene.layout.VBox)39 ObservableList (javafx.collections.ObservableList)37 FXML (javafx.fxml.FXML)34 TableColumn (javafx.scene.control.TableColumn)34 TableView (javafx.scene.control.TableView)34 Res (bisq.core.locale.Res)30 FxmlView (bisq.desktop.common.view.FxmlView)30 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)30 AwesomeIcon (de.jensd.fx.fontawesome.AwesomeIcon)30 TableCell (javafx.scene.control.TableCell)30 Tooltip (javafx.scene.control.Tooltip)30 HyperlinkWithIcon (bisq.desktop.components.HyperlinkWithIcon)29 ListChangeListener (javafx.collections.ListChangeListener)25 Insets (javafx.geometry.Insets)25 Coin (org.bitcoinj.core.Coin)24 GUIUtil (bisq.desktop.util.GUIUtil)23