Search in sources :

Example 46 with AutoTooltipLabel

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

the class LockedView method initialize.

@Override
public void initialize() {
    dateColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.dateTime")));
    detailsColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.details")));
    addressColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.address")));
    balanceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.balanceWithCur", Res.getBaseCurrencyCode())));
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    tableView.setPlaceholder(new AutoTooltipLabel(Res.get("funds.locked.noFunds")));
    setDateColumnCellFactory();
    setDetailsColumnCellFactory();
    setAddressColumnCellFactory();
    setBalanceColumnCellFactory();
    addressColumn.setComparator((o1, o2) -> o1.getAddressString().compareTo(o2.getAddressString()));
    detailsColumn.setComparator((o1, o2) -> o1.getTrade().getId().compareTo(o2.getTrade().getId()));
    balanceColumn.setComparator((o1, o2) -> o1.getBalance().compareTo(o2.getBalance()));
    dateColumn.setComparator((o1, o2) -> {
        if (getTradable(o1).isPresent() && getTradable(o2).isPresent())
            return getTradable(o2).get().getDate().compareTo(getTradable(o1).get().getDate());
        else
            return 0;
    });
    tableView.getSortOrder().add(dateColumn);
    dateColumn.setSortType(TableColumn.SortType.DESCENDING);
    balanceListener = new BalanceListener() {

        @Override
        public void onBalanceChanged(Coin balance, Transaction tx) {
            updateList();
        }
    };
    openOfferListChangeListener = c -> updateList();
    tradeListChangeListener = c -> updateList();
}
Also used : Coin(org.bitcoinj.core.Coin) BalanceListener(bisq.core.btc.listeners.BalanceListener) Transaction(org.bitcoinj.core.Transaction) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel)

Example 47 with AutoTooltipLabel

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

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);
                        AddressEntry addressEntry = item.getAddressEntry();
                        if (tradableOptional.isPresent()) {
                            field = new HyperlinkWithIcon(Res.get("funds.locked.locked", addressEntry.getShortOfferId()), AwesomeIcon.INFO_SIGN);
                            field.setOnAction(event -> openDetailPopup(item));
                            field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
                            setGraphic(field);
                        } else if (addressEntry.getContext() == AddressEntry.Context.ARBITRATOR) {
                            setGraphic(new AutoTooltipLabel(Res.get("shared.arbitratorsFee")));
                        } else {
                            setGraphic(new AutoTooltipLabel(Res.get("shared.noDetailsAvailable")));
                        }
                    } else {
                        setGraphic(null);
                        if (field != null)
                            field.setOnAction(null);
                    }
                }
            };
        }
    });
}
Also used : GUIUtil(bisq.desktop.util.GUIUtil) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) ActivatableView(bisq.desktop.common.view.ActivatableView) Transaction(org.bitcoinj.core.Transaction) OfferDetailsWindow(bisq.desktop.main.overlays.windows.OfferDetailsWindow) OpenOffer(bisq.core.offer.OpenOffer) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) Coin(org.bitcoinj.core.Coin) FXCollections(javafx.collections.FXCollections) Tradable(bisq.core.trade.Tradable) VBox(javafx.scene.layout.VBox) FxmlView(bisq.desktop.common.view.FxmlView) BSFormatter(bisq.desktop.util.BSFormatter) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) BalanceListener(bisq.core.btc.listeners.BalanceListener) TableCell(javafx.scene.control.TableCell) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Res(bisq.core.locale.Res) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) SortedList(javafx.collections.transformation.SortedList) TradeDetailsWindow(bisq.desktop.main.overlays.windows.TradeDetailsWindow) Trade(bisq.core.trade.Trade) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Collectors(java.util.stream.Collectors) OpenOfferManager(bisq.core.offer.OpenOfferManager) FXML(javafx.fxml.FXML) AddressEntry(bisq.core.btc.AddressEntry) TradeManager(bisq.core.trade.TradeManager) Preferences(bisq.core.user.Preferences) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) Optional(java.util.Optional) AddressEntry(bisq.core.btc.AddressEntry) Tooltip(javafx.scene.control.Tooltip) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon)

Example 48 with AutoTooltipLabel

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

the class OfferBookChartView method initialize.

@Override
public void initialize() {
    changeListener = c -> updateChartData();
    currencyListItemsListener = c -> {
        if (model.getSelectedCurrencyListItem().isPresent())
            currencyComboBox.getSelectionModel().select(model.getSelectedCurrencyListItem().get());
    };
    currencyComboBox = new ComboBox<>();
    currencyComboBox.setPromptText(Res.get("list.currency.select"));
    currencyComboBox.setConverter(GUIUtil.getCurrencyListItemConverter(Res.get("shared.oneOffer"), Res.get("shared.multipleOffers"), model.preferences));
    Label currencyLabel = new AutoTooltipLabel(Res.getWithCol("shared.currency"));
    HBox currencyHBox = new HBox();
    currencyHBox.setSpacing(5);
    currencyHBox.setPadding(new Insets(5, -20, -5, 20));
    currencyHBox.setAlignment(Pos.CENTER_LEFT);
    currencyHBox.getChildren().addAll(currencyLabel, currencyComboBox);
    createChart();
    Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleBuy = getOfferTable(OfferPayload.Direction.BUY);
    Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleSell = getOfferTable(OfferPayload.Direction.SELL);
    buyOfferTableView = tupleBuy.first;
    sellOfferTableView = tupleSell.first;
    leftButton = tupleBuy.third;
    rightButton = tupleSell.third;
    leftHeaderLabel = tupleBuy.forth;
    rightHeaderLabel = tupleSell.forth;
    bottomHBox = new HBox();
    // 30
    bottomHBox.setSpacing(20);
    bottomHBox.setAlignment(Pos.CENTER);
    HBox.setHgrow(tupleBuy.second, Priority.ALWAYS);
    HBox.setHgrow(tupleSell.second, Priority.ALWAYS);
    tupleBuy.second.setUserData(OfferPayload.Direction.BUY.name());
    tupleSell.second.setUserData(OfferPayload.Direction.SELL.name());
    bottomHBox.getChildren().addAll(tupleBuy.second, tupleSell.second);
    root.getChildren().addAll(currencyHBox, areaChart, bottomHBox);
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) VBox(javafx.scene.layout.VBox) TableView(javafx.scene.control.TableView)

Example 49 with AutoTooltipLabel

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

the class SpreadView method initialize.

@Override
public void initialize() {
    tableView = new TableView<>();
    GridPane.setRowIndex(tableView, gridRow);
    GridPane.setMargin(tableView, new Insets(-10, -15, -10, -15));
    GridPane.setVgrow(tableView, Priority.ALWAYS);
    GridPane.setHgrow(tableView, Priority.ALWAYS);
    root.getChildren().add(tableView);
    Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noData"));
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);
    TableColumn<SpreadItem, SpreadItem> currencyColumn = getCurrencyColumn();
    tableView.getColumns().add(currencyColumn);
    numberOfOffersColumn = getNumberOfOffersColumn();
    tableView.getColumns().add(numberOfOffersColumn);
    numberOfBuyOffersColumn = getNumberOfBuyOffersColumn();
    tableView.getColumns().add(numberOfBuyOffersColumn);
    numberOfSellOffersColumn = getNumberOfSellOffersColumn();
    tableView.getColumns().add(numberOfSellOffersColumn);
    totalAmountColumn = getTotalAmountColumn();
    tableView.getColumns().add(totalAmountColumn);
    TableColumn<SpreadItem, SpreadItem> spreadColumn = getSpreadColumn();
    tableView.getColumns().add(spreadColumn);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    currencyColumn.setComparator((o1, o2) -> CurrencyUtil.getNameByCode(o1.currencyCode).compareTo(CurrencyUtil.getNameByCode(o2.currencyCode)));
    numberOfOffersColumn.setComparator((o1, o2) -> Integer.valueOf(o1.numberOfOffers).compareTo(o2.numberOfOffers));
    numberOfBuyOffersColumn.setComparator((o1, o2) -> Integer.valueOf(o1.numberOfBuyOffers).compareTo(o2.numberOfBuyOffers));
    numberOfSellOffersColumn.setComparator((o1, o2) -> Integer.valueOf(o1.numberOfSellOffers).compareTo(o2.numberOfSellOffers));
    totalAmountColumn.setComparator((o1, o2) -> o1.totalAmount.compareTo(o2.totalAmount));
    spreadColumn.setComparator((o1, o2) -> {
        Long spreadO1 = o1.priceSpread != null ? o1.priceSpread.getValue() : 0;
        Long spreadO2 = o2.priceSpread != null ? o2.priceSpread.getValue() : 0;
        return spreadO1.compareTo(spreadO2);
    });
    numberOfOffersColumn.setSortType(TableColumn.SortType.DESCENDING);
    tableView.getSortOrder().add(numberOfOffersColumn);
    itemListChangeListener = c -> updateHeaders();
}
Also used : Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel)

Example 50 with AutoTooltipLabel

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

the class SpreadView method updateHeaders.

private void updateHeaders() {
    int numberOfOffers = sortedList.stream().mapToInt(item -> item.numberOfOffers).sum();
    int numberOfBuyOffers = sortedList.stream().mapToInt(item -> item.numberOfBuyOffers).sum();
    int numberOfSellOffers = sortedList.stream().mapToInt(item -> item.numberOfSellOffers).sum();
    String total = formatter.formatCoin(Coin.valueOf(sortedList.stream().mapToLong(item -> item.totalAmount.value).sum()));
    numberOfOffersColumn.setGraphic(new AutoTooltipLabel(Res.get("market.spread.numberOfOffersColumn", numberOfOffers)));
    numberOfBuyOffersColumn.setGraphic(new AutoTooltipLabel(Res.get("market.spread.numberOfBuyOffersColumn", numberOfBuyOffers)));
    numberOfSellOffersColumn.setGraphic(new AutoTooltipLabel((Res.get("market.spread.numberOfSellOffersColumn", numberOfSellOffers))));
    totalAmountColumn.setGraphic(new AutoTooltipLabel(Res.get("market.spread.totalAmountColumn", total)));
}
Also used : GUIUtil(bisq.desktop.util.GUIUtil) Label(javafx.scene.control.Label) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) Coin(org.bitcoinj.core.Coin) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FxmlView(bisq.desktop.common.view.FxmlView) BSFormatter(bisq.desktop.util.BSFormatter) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) Priority(javafx.scene.layout.Priority) TableCell(javafx.scene.control.TableCell) Insets(javafx.geometry.Insets) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Res(bisq.core.locale.Res) CurrencyUtil(bisq.core.locale.CurrencyUtil) ColoredDecimalPlacesWithZerosText(bisq.desktop.components.ColoredDecimalPlacesWithZerosText) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) GridPane(javafx.scene.layout.GridPane) SortedList(javafx.collections.transformation.SortedList) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel)

Aggregations

AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)90 Label (javafx.scene.control.Label)55 Insets (javafx.geometry.Insets)45 HBox (javafx.scene.layout.HBox)29 TableCell (javafx.scene.control.TableCell)27 TableColumn (javafx.scene.control.TableColumn)27 VBox (javafx.scene.layout.VBox)23 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)22 Button (javafx.scene.control.Button)22 ImageView (javafx.scene.image.ImageView)19 Res (bisq.core.locale.Res)18 InputTextField (bisq.desktop.components.InputTextField)18 Popup (bisq.desktop.main.overlays.popups.Popup)17 FxmlView (bisq.desktop.common.view.FxmlView)16 Callback (javafx.util.Callback)16 Inject (javax.inject.Inject)16 Coin (org.bitcoinj.core.Coin)16 Tooltip (javafx.scene.control.Tooltip)15 TableView (javafx.scene.control.TableView)14 BSFormatter (bisq.desktop.util.BSFormatter)13