Search in sources :

Example 11 with Trade

use of io.bitsquare.trade.Trade in project bitsquare by bitsquare.

the class LockedView method setDetailsColumnCellFactory.

private void setDetailsColumnCellFactory() {
    detailsColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
    detailsColumn.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 field;

                @Override
                public void updateItem(final LockedListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        Optional<Tradable> tradableOptional = getTradable(item);
                        if (tradableOptional.isPresent()) {
                            field = new HyperlinkWithIcon("Locked in MultiSig for trade 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 12 with Trade

use of io.bitsquare.trade.Trade in project bitsquare by bitsquare.

the class PendingTradesDataModel method doOpenDispute.

private void doOpenDispute(boolean isSupportTicket, Transaction depositTx) {
    Log.traceCall("depositTx=" + depositTx);
    byte[] depositTxSerialized = null;
    byte[] payoutTxSerialized = null;
    String depositTxHashAsString = null;
    String payoutTxHashAsString = null;
    if (depositTx != null) {
        depositTxSerialized = depositTx.bitcoinSerialize();
        depositTxHashAsString = depositTx.getHashAsString();
    } else {
        log.warn("depositTx is null");
    }
    Trade trade = getTrade();
    if (trade != null) {
        Transaction payoutTx = trade.getPayoutTx();
        if (payoutTx != null) {
            payoutTxSerialized = payoutTx.bitcoinSerialize();
            payoutTxHashAsString = payoutTx.getHashAsString();
        } else {
            log.debug("payoutTx is null at doOpenDispute");
        }
        final Arbitrator acceptedArbitratorByAddress = user.getAcceptedArbitratorByAddress(trade.getArbitratorNodeAddress());
        checkNotNull(acceptedArbitratorByAddress, "acceptedArbitratorByAddress must no tbe null");
        Dispute dispute = new Dispute(disputeManager.getDisputeStorage(), trade.getId(), // traderId
        keyRing.getPubKeyRing().hashCode(), trade.getOffer().getDirection() == Offer.Direction.BUY ? isOfferer : !isOfferer, isOfferer, keyRing.getPubKeyRing(), trade.getDate(), trade.getContract(), trade.getContractHash(), depositTxSerialized, payoutTxSerialized, depositTxHashAsString, payoutTxHashAsString, trade.getContractAsJson(), trade.getOffererContractSignature(), trade.getTakerContractSignature(), acceptedArbitratorByAddress.getPubKeyRing(), isSupportTicket);
        trade.setDisputeState(Trade.DisputeState.DISPUTE_REQUESTED);
        if (p2PService.isBootstrapped()) {
            sendOpenNewDisputeMessage(dispute, false);
        } else {
            new Popup().information("You need to wait until you are fully connected to the network.\n" + "That might take up to about 2 minutes at startup.").show();
        }
    } else {
        log.warn("trade is null at doOpenDispute");
    }
}
Also used : Trade(io.bitsquare.trade.Trade) BuyerTrade(io.bitsquare.trade.BuyerTrade) SellerTrade(io.bitsquare.trade.SellerTrade) Transaction(org.bitcoinj.core.Transaction) Popup(io.bitsquare.gui.main.overlays.popups.Popup) Dispute(io.bitsquare.arbitration.Dispute) Arbitrator(io.bitsquare.arbitration.Arbitrator)

Example 13 with Trade

use of io.bitsquare.trade.Trade in project bitsquare by bitsquare.

the class ClosedTradesView method setAvatarColumnCellFactory.

private TableColumn<ClosedTradableListItem, ClosedTradableListItem> setAvatarColumnCellFactory() {
    avatarColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    avatarColumn.setCellFactory(new Callback<TableColumn<ClosedTradableListItem, ClosedTradableListItem>, TableCell<ClosedTradableListItem, ClosedTradableListItem>>() {

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

                @Override
                public void updateItem(final ClosedTradableListItem newItem, boolean empty) {
                    super.updateItem(newItem, empty);
                    if (newItem != null && !empty && newItem.getTradable() instanceof Trade) {
                        int numPastTrades = model.getNumPastTrades(newItem.getTradable());
                        Trade trade = (Trade) newItem.getTradable();
                        String hostName = trade.getTradingPeerNodeAddress() != null ? trade.getTradingPeerNodeAddress().hostName : "";
                        Node identIcon = new PeerInfoIcon(hostName, "Trading peers onion address: " + hostName, numPastTrades, privateNotificationManager, newItem.getTradable().getOffer());
                        setPadding(new Insets(-2, 0, -2, 0));
                        if (identIcon != null)
                            setGraphic(identIcon);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    return avatarColumn;
}
Also used : Insets(javafx.geometry.Insets) Node(javafx.scene.Node) PeerInfoIcon(io.bitsquare.gui.components.PeerInfoIcon) Trade(io.bitsquare.trade.Trade)

Example 14 with Trade

use of io.bitsquare.trade.Trade in project bitsquare by bitsquare.

the class PendingTradesDataModel method doSelectItem.

private void doSelectItem(PendingTradesListItem item) {
    if (item != null) {
        Trade trade = item.getTrade();
        isOfferer = tradeManager.isMyOffer(trade.getOffer());
        if (trade.getDepositTx() != null)
            txId.set(trade.getDepositTx().getHashAsString());
        else
            txId.set("");
        notificationCenter.setSelectedTradeId(trade.getId());
    } else {
        notificationCenter.setSelectedTradeId(null);
    }
    selectedItemProperty.set(item);
}
Also used : Trade(io.bitsquare.trade.Trade) BuyerTrade(io.bitsquare.trade.BuyerTrade) SellerTrade(io.bitsquare.trade.SellerTrade)

Aggregations

Trade (io.bitsquare.trade.Trade)14 TradeManager (io.bitsquare.trade.TradeManager)7 Popup (io.bitsquare.gui.main.overlays.popups.Popup)6 ObservableList (javafx.collections.ObservableList)6 BSFormatter (io.bitsquare.gui.util.BSFormatter)5 GUIUtil (io.bitsquare.gui.util.GUIUtil)5 Tradable (io.bitsquare.trade.Tradable)5 Preferences (io.bitsquare.user.Preferences)5 ListChangeListener (javafx.collections.ListChangeListener)5 Coin (org.bitcoinj.core.Coin)5 Dispute (io.bitsquare.arbitration.Dispute)4 UserThread (io.bitsquare.common.UserThread)4 FxmlView (io.bitsquare.gui.common.view.FxmlView)4 HyperlinkWithIcon (io.bitsquare.gui.components.HyperlinkWithIcon)4 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)4 SortedList (javafx.collections.transformation.SortedList)4 javafx.scene.control (javafx.scene.control)4 Callback (javafx.util.Callback)4 Inject (javax.inject.Inject)4 Transaction (org.bitcoinj.core.Transaction)4