Search in sources :

Example 11 with Callback

use of javafx.util.Callback in project bitsquare by bitsquare.

the class PendingTradesView method setTradeIdColumnCellFactory.

///////////////////////////////////////////////////////////////////////////////////////////
// CellFactories
///////////////////////////////////////////////////////////////////////////////////////////
private void setTradeIdColumnCellFactory() {
    idColumn.setCellValueFactory((pendingTradesListItem) -> new ReadOnlyObjectWrapper<>(pendingTradesListItem.getValue()));
    idColumn.setCellFactory(new Callback<TableColumn<PendingTradesListItem, PendingTradesListItem>, TableCell<PendingTradesListItem, PendingTradesListItem>>() {

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

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final PendingTradesListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        field = new HyperlinkWithIcon(item.getTrade().getShortId(), true);
                        field.setOnAction(event -> tradeDetailsWindow.show(item.getTrade()));
                        field.setTooltip(new Tooltip("Open popup for details"));
                        setGraphic(field);
                    } else {
                        setGraphic(null);
                        if (field != null)
                            field.setOnAction(null);
                    }
                }
            };
        }
    });
}
Also used : EventHandler(javafx.event.EventHandler) Scene(javafx.scene.Scene) Popup(io.bitsquare.gui.main.overlays.popups.Popup) javafx.scene.control(javafx.scene.control) PeerInfoIcon(io.bitsquare.gui.components.PeerInfoIcon) VBox(javafx.scene.layout.VBox) KeyCombination(javafx.scene.input.KeyCombination) Inject(javax.inject.Inject) Insets(javafx.geometry.Insets) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) TradeDetailsWindow(io.bitsquare.gui.main.overlays.windows.TradeDetailsWindow) Callback(javafx.util.Callback) BSFormatter(io.bitsquare.gui.util.BSFormatter) SortedList(javafx.collections.transformation.SortedList) KeyCode(javafx.scene.input.KeyCode) UserThread(io.bitsquare.common.UserThread) Node(javafx.scene.Node) KeyEvent(javafx.scene.input.KeyEvent) Subscription(org.fxmisc.easybind.Subscription) ActivatableViewAndModel(io.bitsquare.gui.common.view.ActivatableViewAndModel) PrivateNotificationManager(io.bitsquare.alert.PrivateNotificationManager) FXML(javafx.fxml.FXML) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) Priority(javafx.scene.layout.Priority) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon) EasyBind(org.fxmisc.easybind.EasyBind) FxmlView(io.bitsquare.gui.common.view.FxmlView) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon)

Example 12 with Callback

use of javafx.util.Callback in project bitsquare by bitsquare.

the class FailedTradesView method setTradeIdColumnCellFactory.

private void setTradeIdColumnCellFactory() {
    tradeIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
    tradeIdColumn.setCellFactory(new Callback<TableColumn<FailedTradesListItem, FailedTradesListItem>, TableCell<FailedTradesListItem, FailedTradesListItem>>() {

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

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final FailedTradesListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        field = new HyperlinkWithIcon(model.getTradeId(item), true);
                        field.setOnAction(event -> tradeDetailsWindow.show(item.getTrade()));
                        field.setTooltip(new Tooltip("Open popup for details"));
                        setGraphic(field);
                    } else {
                        setGraphic(null);
                        if (field != null)
                            field.setOnAction(null);
                    }
                }
            };
        }
    });
}
Also used : FXML(javafx.fxml.FXML) Inject(javax.inject.Inject) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) javafx.scene.control(javafx.scene.control) TradeDetailsWindow(io.bitsquare.gui.main.overlays.windows.TradeDetailsWindow) ActivatableViewAndModel(io.bitsquare.gui.common.view.ActivatableViewAndModel) FxmlView(io.bitsquare.gui.common.view.FxmlView) VBox(javafx.scene.layout.VBox) Callback(javafx.util.Callback) SortedList(javafx.collections.transformation.SortedList) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon)

Example 13 with Callback

use of javafx.util.Callback in project bitsquare by bitsquare.

the class OpenOffersView method setRemoveColumnCellFactory.

private void setRemoveColumnCellFactory() {
    removeItemColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
    removeItemColumn.setCellFactory(new Callback<TableColumn<OpenOfferListItem, OpenOfferListItem>, TableCell<OpenOfferListItem, OpenOfferListItem>>() {

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

                final ImageView iconView = new ImageView();

                final Button button = new Button();

                {
                    iconView.setId("image-remove");
                    button.setText("Remove");
                    button.setGraphic(iconView);
                    button.setMinWidth(70);
                }

                @Override
                public void updateItem(final OpenOfferListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null) {
                        button.setOnAction(event -> onRemoveOpenOffer(item.getOpenOffer()));
                        setGraphic(button);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
}
Also used : OpenOffer(io.bitsquare.trade.offer.OpenOffer) WithdrawalView(io.bitsquare.gui.main.funds.withdrawal.WithdrawalView) Popup(io.bitsquare.gui.main.overlays.popups.Popup) MainView(io.bitsquare.gui.main.MainView) javafx.scene.control(javafx.scene.control) Fiat(org.bitcoinj.utils.Fiat) OfferDetailsWindow(io.bitsquare.gui.main.overlays.windows.OfferDetailsWindow) ActivatableViewAndModel(io.bitsquare.gui.common.view.ActivatableViewAndModel) VBox(javafx.scene.layout.VBox) FundsView(io.bitsquare.gui.main.funds.FundsView) FXML(javafx.fxml.FXML) Inject(javax.inject.Inject) Preferences(io.bitsquare.user.Preferences) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) Navigation(io.bitsquare.gui.Navigation) ImageView(javafx.scene.image.ImageView) FeePolicy(io.bitsquare.btc.FeePolicy) FxmlView(io.bitsquare.gui.common.view.FxmlView) Callback(javafx.util.Callback) SortedList(javafx.collections.transformation.SortedList) ImageView(javafx.scene.image.ImageView)

Example 14 with Callback

use of javafx.util.Callback in project bitsquare by bitsquare.

the class ClosedTradesView method setTradeIdColumnCellFactory.

private void setTradeIdColumnCellFactory() {
    tradeIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
    tradeIdColumn.setCellFactory(new Callback<TableColumn<ClosedTradableListItem, ClosedTradableListItem>, TableCell<ClosedTradableListItem, ClosedTradableListItem>>() {

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

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final ClosedTradableListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        field = new HyperlinkWithIcon(model.getTradeId(item), true);
                        field.setOnAction(event -> {
                            Tradable tradable = item.getTradable();
                            if (tradable instanceof Trade)
                                tradeDetailsWindow.show((Trade) tradable);
                            else if (tradable instanceof OpenOffer)
                                offerDetailsWindow.show(tradable.getOffer());
                        });
                        field.setTooltip(new Tooltip("Open popup for details"));
                        setGraphic(field);
                    } else {
                        setGraphic(null);
                        if (field != null)
                            field.setOnAction(null);
                    }
                }
            };
        }
    });
}
Also used : OpenOffer(io.bitsquare.trade.offer.OpenOffer) javafx.scene.control(javafx.scene.control) PeerInfoIcon(io.bitsquare.gui.components.PeerInfoIcon) Coin(org.bitcoinj.core.Coin) Trade(io.bitsquare.trade.Trade) CSVEntryConverter(com.googlecode.jcsv.writer.CSVEntryConverter) VBox(javafx.scene.layout.VBox) Tradable(io.bitsquare.trade.Tradable) GUIUtil(io.bitsquare.gui.util.GUIUtil) Inject(javax.inject.Inject) Insets(javafx.geometry.Insets) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) TradeDetailsWindow(io.bitsquare.gui.main.overlays.windows.TradeDetailsWindow) Callback(javafx.util.Callback) BSFormatter(io.bitsquare.gui.util.BSFormatter) SortedList(javafx.collections.transformation.SortedList) Node(javafx.scene.Node) NodeAddress(io.bitsquare.p2p.NodeAddress) Fiat(org.bitcoinj.utils.Fiat) OfferDetailsWindow(io.bitsquare.gui.main.overlays.windows.OfferDetailsWindow) ActivatableViewAndModel(io.bitsquare.gui.common.view.ActivatableViewAndModel) PrivateNotificationManager(io.bitsquare.alert.PrivateNotificationManager) FXML(javafx.fxml.FXML) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon) Stage(javafx.stage.Stage) ObservableList(javafx.collections.ObservableList) FxmlView(io.bitsquare.gui.common.view.FxmlView) Tradable(io.bitsquare.trade.Tradable) OpenOffer(io.bitsquare.trade.offer.OpenOffer) Trade(io.bitsquare.trade.Trade) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon)

Example 15 with Callback

use of javafx.util.Callback in project bitsquare by bitsquare.

the class TransactionsView method setTransactionColumnCellFactory.

private void setTransactionColumnCellFactory() {
    transactionColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    transactionColumn.setCellFactory(new Callback<TableColumn<TransactionsListItem, TransactionsListItem>, TableCell<TransactionsListItem, TransactionsListItem>>() {

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

                private HyperlinkWithIcon hyperlinkWithIcon;

                @Override
                public void updateItem(final TransactionsListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        String transactionId = item.getTxId();
                        hyperlinkWithIcon = new HyperlinkWithIcon(transactionId, AwesomeIcon.EXTERNAL_LINK);
                        hyperlinkWithIcon.setOnAction(event -> openTxInBlockExplorer(item));
                        hyperlinkWithIcon.setTooltip(new Tooltip("Open external blockchain explorer for " + "transaction: " + transactionId));
                        setGraphic(hyperlinkWithIcon);
                    } else {
                        setGraphic(null);
                        if (hyperlinkWithIcon != null)
                            hyperlinkWithIcon.setOnAction(null);
                    }
                }
            };
        }
    });
}
Also used : EventHandler(javafx.event.EventHandler) OpenOffer(io.bitsquare.trade.offer.OpenOffer) Scene(javafx.scene.Scene) Popup(io.bitsquare.gui.main.overlays.popups.Popup) java.util(java.util) javafx.scene.control(javafx.scene.control) AddressWithIconAndDirection(io.bitsquare.gui.components.AddressWithIconAndDirection) FXCollections(javafx.collections.FXCollections) DisputeManager(io.bitsquare.arbitration.DisputeManager) Trade(io.bitsquare.trade.Trade) CSVEntryConverter(com.googlecode.jcsv.writer.CSVEntryConverter) Tuple2(io.bitsquare.common.util.Tuple2) ActivatableView(io.bitsquare.gui.common.view.ActivatableView) VBox(javafx.scene.layout.VBox) Tradable(io.bitsquare.trade.Tradable) GUIUtil(io.bitsquare.gui.util.GUIUtil) KeyCombination(javafx.scene.input.KeyCombination) Inject(javax.inject.Inject) TradeManager(io.bitsquare.trade.TradeManager) FailedTradesManager(io.bitsquare.trade.failed.FailedTradesManager) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) WalletService(io.bitsquare.btc.WalletService) TradeDetailsWindow(io.bitsquare.gui.main.overlays.windows.TradeDetailsWindow) FeePolicy(io.bitsquare.btc.FeePolicy) Callback(javafx.util.Callback) Nullable(javax.annotation.Nullable) DateFormat(java.text.DateFormat) BSFormatter(io.bitsquare.gui.util.BSFormatter) SortedList(javafx.collections.transformation.SortedList) KeyCode(javafx.scene.input.KeyCode) Utilities(io.bitsquare.common.util.Utilities) OfferDetailsWindow(io.bitsquare.gui.main.overlays.windows.OfferDetailsWindow) ClosedTradableManager(io.bitsquare.trade.closed.ClosedTradableManager) KeyEvent(javafx.scene.input.KeyEvent) Collectors(java.util.stream.Collectors) org.bitcoinj.core(org.bitcoinj.core) FXML(javafx.fxml.FXML) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) Preferences(io.bitsquare.user.Preferences) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon) Script(org.bitcoinj.script.Script) Stream(java.util.stream.Stream) Stage(javafx.stage.Stage) Tuple4(io.bitsquare.common.util.Tuple4) OpenOfferManager(io.bitsquare.trade.offer.OpenOfferManager) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) FxmlView(io.bitsquare.gui.common.view.FxmlView) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon)

Aggregations

Callback (javafx.util.Callback)43 Inject (javax.inject.Inject)27 FxmlView (io.bitsquare.gui.common.view.FxmlView)26 javafx.scene.control (javafx.scene.control)25 Popup (io.bitsquare.gui.main.overlays.popups.Popup)24 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)23 ObservableList (javafx.collections.ObservableList)22 FXML (javafx.fxml.FXML)22 VBox (javafx.scene.layout.VBox)21 HyperlinkWithIcon (io.bitsquare.gui.components.HyperlinkWithIcon)20 BSFormatter (io.bitsquare.gui.util.BSFormatter)20 SortedList (javafx.collections.transformation.SortedList)19 ImageView (javafx.scene.image.ImageView)18 ChangeListener (javafx.beans.value.ChangeListener)17 GUIUtil (io.bitsquare.gui.util.GUIUtil)16 FXCollections (javafx.collections.FXCollections)16 Insets (javafx.geometry.Insets)15 AwesomeIcon (de.jensd.fx.fontawesome.AwesomeIcon)13 UserThread (io.bitsquare.common.UserThread)13 ActivatableView (io.bitsquare.gui.common.view.ActivatableView)13