Search in sources :

Example 6 with Tuple3

use of io.bitsquare.common.util.Tuple3 in project bitsquare by bitsquare.

the class MainView method initialize.

@Override
protected void initialize() {
    MainView.rootContainer = this.root;
    ToggleButton marketButton = new NavButton(MarketView.class, "Market");
    ToggleButton buyButton = new NavButton(BuyOfferView.class, "Buy BTC");
    ToggleButton sellButton = new NavButton(SellOfferView.class, "Sell BTC");
    ToggleButton portfolioButton = new NavButton(PortfolioView.class, "Portfolio");
    ToggleButton fundsButton = new NavButton(FundsView.class, "Funds");
    ToggleButton disputesButton = new NavButton(DisputesView.class, "Support");
    ToggleButton settingsButton = new NavButton(SettingsView.class, "Settings");
    ToggleButton accountButton = new NavButton(AccountView.class, "Account");
    Pane portfolioButtonHolder = new Pane(portfolioButton);
    Pane disputesButtonHolder = new Pane(disputesButton);
    HBox leftNavPane = new HBox(marketButton, buyButton, sellButton, portfolioButtonHolder, fundsButton, disputesButtonHolder) {

        {
            setLeftAnchor(this, 10d);
            setTopAnchor(this, 0d);
        }
    };
    Tuple3<ComboBox<PriceFeedComboBoxItem>, Label, VBox> marketPriceBox = getMarketPriceBox("Market price");
    ComboBox<PriceFeedComboBoxItem> priceComboBox = marketPriceBox.first;
    priceComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        model.setPriceFeedComboBoxItem(newValue);
    });
    ChangeListener<PriceFeedComboBoxItem> selectedPriceFeedItemListender = (observable, oldValue, newValue) -> {
        if (newValue != null)
            priceComboBox.getSelectionModel().select(newValue);
    };
    model.selectedPriceFeedComboBoxItemProperty.addListener(selectedPriceFeedItemListender);
    priceComboBox.setItems(model.priceFeedComboBoxItems);
    marketPriceBox.second.textProperty().bind(createStringBinding(() -> {
        PriceFeedService.Type type = model.typeProperty.get();
        return type != null ? "Market price (" + type.name + ")" : "";
    }, model.marketPriceCurrencyCode, model.typeProperty));
    HBox.setMargin(marketPriceBox.third, new Insets(0, 0, 0, 0));
    Tuple2<TextField, VBox> availableBalanceBox = getBalanceBox("Available balance");
    availableBalanceBox.first.textProperty().bind(model.availableBalance);
    Tuple2<TextField, VBox> reservedBalanceBox = getBalanceBox("Reserved in offers");
    reservedBalanceBox.first.textProperty().bind(model.reservedBalance);
    Tuple2<TextField, VBox> lockedBalanceBox = getBalanceBox("Locked in trades");
    lockedBalanceBox.first.textProperty().bind(model.lockedBalance);
    HBox rightNavPane = new HBox(marketPriceBox.third, availableBalanceBox.second, reservedBalanceBox.second, lockedBalanceBox.second, settingsButton, accountButton) {

        {
            setRightAnchor(this, 10d);
            setTopAnchor(this, 0d);
        }
    };
    root.widthProperty().addListener((observable, oldValue, newValue) -> {
        double w = (double) newValue;
        if (w > 0) {
            leftNavPane.setSpacing(w >= 1080 ? 10 : 5);
            rightNavPane.setSpacing(w >= 1080 ? 10 : 5);
        }
    });
    AnchorPane contentContainer = new AnchorPane() {

        {
            setId("content-pane");
            setLeftAnchor(this, 0d);
            setRightAnchor(this, 0d);
            setTopAnchor(this, 60d);
            setBottomAnchor(this, 10d);
        }
    };
    AnchorPane applicationContainer = new AnchorPane(leftNavPane, rightNavPane, contentContainer) {

        {
            setId("content-pane");
        }
    };
    BorderPane baseApplicationContainer = new BorderPane(applicationContainer) {

        {
            setId("base-content-container");
        }
    };
    baseApplicationContainer.setBottom(createFooter());
    setupNotificationIcon(portfolioButtonHolder);
    setupDisputesIcon(disputesButtonHolder);
    navigation.addListener(viewPath -> {
        if (viewPath.size() != 2 || viewPath.indexOf(MainView.class) != 0)
            return;
        Class<? extends View> viewClass = viewPath.tip();
        View view = viewLoader.load(viewClass);
        contentContainer.getChildren().setAll(view.getRoot());
        navButtons.getToggles().stream().filter(toggle -> toggle instanceof NavButton).filter(button -> viewClass == ((NavButton) button).viewClass).findFirst().orElseThrow(() -> new BitsquareException("No button matching %s found", viewClass)).setSelected(true);
    });
    VBox splashScreen = createSplashScreen();
    root.getChildren().addAll(baseApplicationContainer, splashScreen);
    model.showAppScreen.addListener((ov, oldValue, newValue) -> {
        if (newValue) {
            navigation.navigateToPreviousVisitedView();
            if (!persistedFilesCorrupted.isEmpty()) {
                if (persistedFilesCorrupted.size() > 1 || !persistedFilesCorrupted.get(0).equals("Navigation")) {
                    // show warning that some files has been corrupted
                    new Popup().warning("We detected incompatible data base files!\n\n" + "Those database file(s) are not compatible with our current code base:" + "\n" + persistedFilesCorrupted.toString() + "\n\nWe made a backup of the corrupted file(s) and applied the default values to a new " + "database version." + "\n\nThe backup is located at:\n[you local app data directory]/db/backup_of_corrupted_data.\n\n" + "Please check if you have the latest version of Bitsquare installed.\n" + "You can download it at:\nhttps://github.com/bitsquare/bitsquare/releases\n\n" + "Please restart the application.").closeButtonText("Shut down").onClose(BitsquareApp.shutDownHandler::run).show();
                } else {
                    log.debug("We detected incompatible data base file for Navigation. That is a minor issue happening with refactoring of UI classes " + "and we don't display a warning popup to the user.");
                }
            }
            transitions.fadeOutAndRemove(splashScreen, 1500, actionEvent -> disposeSplashScreen());
        }
    });
    // Delay a bit to give time for rendering the splash screen
    UserThread.execute(model::start);
}
Also used : Pos(javafx.geometry.Pos) PriceFeedService(io.bitsquare.btc.pricefeed.PriceFeedService) Popup(io.bitsquare.gui.main.overlays.popups.Popup) MarketView(io.bitsquare.gui.main.market.MarketView) javafx.scene.layout(javafx.scene.layout) javafx.scene.control(javafx.scene.control) LoggerFactory(org.slf4j.LoggerFactory) BitsquareApp(io.bitsquare.app.BitsquareApp) Tuple2(io.bitsquare.common.util.Tuple2) Transitions(io.bitsquare.gui.util.Transitions) FundsView(io.bitsquare.gui.main.funds.FundsView) GUIUtil(io.bitsquare.gui.util.GUIUtil) Inject(javax.inject.Inject) DevFlags(io.bitsquare.app.DevFlags) Insets(javafx.geometry.Insets) Navigation(io.bitsquare.gui.Navigation) SettingsView(io.bitsquare.gui.main.settings.SettingsView) TextAlignment(javafx.scene.text.TextAlignment) Named(javax.inject.Named) BSFormatter(io.bitsquare.gui.util.BSFormatter) Color(javafx.scene.paint.Color) Logger(org.slf4j.Logger) UserThread(io.bitsquare.common.UserThread) BuyOfferView(io.bitsquare.gui.main.offer.BuyOfferView) BitsquareException(io.bitsquare.BitsquareException) DropShadow(javafx.scene.effect.DropShadow) DisputesView(io.bitsquare.gui.main.disputes.DisputesView) io.bitsquare.gui.common.view(io.bitsquare.gui.common.view) PortfolioView(io.bitsquare.gui.main.portfolio.PortfolioView) List(java.util.List) Bindings.createStringBinding(javafx.beans.binding.Bindings.createStringBinding) Tuple3(io.bitsquare.common.util.Tuple3) AnchorPane(javafx.scene.layout.AnchorPane) ImageView(javafx.scene.image.ImageView) BusyAnimation(io.bitsquare.gui.components.BusyAnimation) SellOfferView(io.bitsquare.gui.main.offer.SellOfferView) ChangeListener(javafx.beans.value.ChangeListener) AccountView(io.bitsquare.gui.main.account.AccountView) Insets(javafx.geometry.Insets) BitsquareApp(io.bitsquare.app.BitsquareApp) Popup(io.bitsquare.gui.main.overlays.popups.Popup) AnchorPane(javafx.scene.layout.AnchorPane) AnchorPane(javafx.scene.layout.AnchorPane) MarketView(io.bitsquare.gui.main.market.MarketView) FundsView(io.bitsquare.gui.main.funds.FundsView) SettingsView(io.bitsquare.gui.main.settings.SettingsView) BuyOfferView(io.bitsquare.gui.main.offer.BuyOfferView) DisputesView(io.bitsquare.gui.main.disputes.DisputesView) PortfolioView(io.bitsquare.gui.main.portfolio.PortfolioView) ImageView(javafx.scene.image.ImageView) SellOfferView(io.bitsquare.gui.main.offer.SellOfferView) AccountView(io.bitsquare.gui.main.account.AccountView) BitsquareException(io.bitsquare.BitsquareException)

Example 7 with Tuple3

use of io.bitsquare.common.util.Tuple3 in project bitsquare by bitsquare.

the class MainView method getMarketPriceBox.

private Tuple3<ComboBox<PriceFeedComboBoxItem>, Label, VBox> getMarketPriceBox(String text) {
    ComboBox<PriceFeedComboBoxItem> priceComboBox = new ComboBox<>();
    priceComboBox.setVisibleRowCount(20);
    priceComboBox.setMaxWidth(220);
    priceComboBox.setMinWidth(220);
    priceComboBox.setFocusTraversable(false);
    priceComboBox.setId("price-feed-combo");
    priceComboBox.setCellFactory(p -> getPriceFeedComboBoxListCell());
    ListCell<PriceFeedComboBoxItem> buttonCell = getPriceFeedComboBoxListCell();
    buttonCell.setId("price-feed-combo");
    priceComboBox.setButtonCell(buttonCell);
    Label label = new Label(text);
    label.setId("nav-balance-label");
    label.setPadding(new Insets(0, 0, 0, 2));
    final ImageView btcAverageIcon = new ImageView();
    btcAverageIcon.setId("btcaverage");
    final Button btcAverageIconButton = new Button("", btcAverageIcon);
    btcAverageIconButton.setPadding(new Insets(-1, 0, -1, 0));
    btcAverageIconButton.setFocusTraversable(false);
    btcAverageIconButton.setStyle("-fx-background-color: transparent;");
    HBox.setMargin(btcAverageIconButton, new Insets(0, 5, 0, 0));
    btcAverageIconButton.setOnAction(e -> GUIUtil.openWebPage("https://bitcoinaverage.com"));
    btcAverageIconButton.setVisible(model.isFiatCurrencyPriceFeedSelected.get());
    btcAverageIconButton.setManaged(model.isFiatCurrencyPriceFeedSelected.get());
    btcAverageIconButton.visibleProperty().bind(model.isFiatCurrencyPriceFeedSelected);
    btcAverageIconButton.managedProperty().bind(model.isFiatCurrencyPriceFeedSelected);
    btcAverageIconButton.setOnMouseEntered(e -> {
        btcAverageIconButton.setTooltip(new Tooltip("Market price is provided by https://bitcoinaverage.com\n" + "Last update: " + formatter.formatTime(model.priceFeedService.getLastRequestTimeStampBtcAverage())));
    });
    final ImageView poloniexIcon = new ImageView();
    poloniexIcon.setId("poloniex");
    final Button poloniexIconButton = new Button("", poloniexIcon);
    poloniexIconButton.setPadding(new Insets(-3, 0, -3, 0));
    poloniexIconButton.setFocusTraversable(false);
    poloniexIconButton.setStyle("-fx-background-color: transparent;");
    HBox.setMargin(poloniexIconButton, new Insets(1, 3, 0, 0));
    poloniexIconButton.setOnAction(e -> GUIUtil.openWebPage("https://poloniex.com"));
    poloniexIconButton.setVisible(model.isCryptoCurrencyPriceFeedSelected.get());
    poloniexIconButton.setManaged(model.isCryptoCurrencyPriceFeedSelected.get());
    poloniexIconButton.visibleProperty().bind(model.isCryptoCurrencyPriceFeedSelected);
    poloniexIconButton.managedProperty().bind(model.isCryptoCurrencyPriceFeedSelected);
    poloniexIconButton.setOnMouseEntered(e -> {
        poloniexIconButton.setTooltip(new Tooltip("Market price is provided by https://poloniex.com.\n" + "If the altcoin is not available at Poloniex we use https://coinmarketcap.com\n" + "Last update: " + formatter.formatTime(model.priceFeedService.getLastRequestTimeStampPoloniex())));
    });
    Pane spacer = new Pane();
    HBox.setHgrow(spacer, Priority.ALWAYS);
    HBox hBox2 = new HBox();
    hBox2.getChildren().setAll(label, spacer, btcAverageIconButton, poloniexIconButton);
    VBox vBox = new VBox();
    vBox.setSpacing(3);
    vBox.setPadding(new Insets(11, 0, 0, 0));
    vBox.getChildren().addAll(priceComboBox, hBox2);
    return new Tuple3<>(priceComboBox, label, vBox);
}
Also used : Insets(javafx.geometry.Insets) AnchorPane(javafx.scene.layout.AnchorPane) Tuple3(io.bitsquare.common.util.Tuple3) ImageView(javafx.scene.image.ImageView)

Example 8 with Tuple3

use of io.bitsquare.common.util.Tuple3 in project bitsquare by bitsquare.

the class FormBuilder method addLabelTextFieldButton.

public static Tuple3<Label, TextField, Button> addLabelTextFieldButton(GridPane gridPane, int rowIndex, String title, String buttonTitle, double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);
    TextField textField = new TextField();
    textField.setEditable(false);
    textField.setMouseTransparent(true);
    textField.setFocusTraversable(false);
    Button button = new Button(buttonTitle);
    button.setDefaultButton(true);
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(textField, button);
    HBox.setHgrow(textField, Priority.ALWAYS);
    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    GridPane.setMargin(hBox, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(hBox);
    return new Tuple3<>(label, textField, button);
}
Also used : Insets(javafx.geometry.Insets) Tuple3(io.bitsquare.common.util.Tuple3)

Example 9 with Tuple3

use of io.bitsquare.common.util.Tuple3 in project bitsquare by bitsquare.

the class FormBuilder method addLabelComboBoxLabel.

public static Tuple3<Label, ComboBox, TextField> addLabelComboBoxLabel(GridPane gridPane, int rowIndex, String title, String textFieldText, double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    ComboBox comboBox = new ComboBox();
    TextField textField = new TextField(textFieldText);
    textField.setEditable(false);
    textField.setMouseTransparent(true);
    textField.setFocusTraversable(false);
    hBox.getChildren().addAll(comboBox, textField);
    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    GridPane.setMargin(hBox, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(hBox);
    return new Tuple3<>(label, comboBox, textField);
}
Also used : Insets(javafx.geometry.Insets) Tuple3(io.bitsquare.common.util.Tuple3)

Example 10 with Tuple3

use of io.bitsquare.common.util.Tuple3 in project bitsquare by bitsquare.

the class FormBuilder method add3Buttons.

public static Tuple3<Button, Button, Button> add3Buttons(GridPane gridPane, int rowIndex, String title1, String title2, String title3, double top) {
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    Button button1 = new Button(title1);
    button1.setDefaultButton(true);
    Button button2 = new Button(title2);
    Button button3 = new Button(title3);
    hBox.getChildren().addAll(button1, button2, button3);
    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    GridPane.setMargin(hBox, new Insets(top, 10, 0, 0));
    gridPane.getChildren().add(hBox);
    return new Tuple3<>(button1, button2, button3);
}
Also used : Insets(javafx.geometry.Insets) Tuple3(io.bitsquare.common.util.Tuple3)

Aggregations

Tuple3 (io.bitsquare.common.util.Tuple3)10 Insets (javafx.geometry.Insets)8 ImageView (javafx.scene.image.ImageView)4 AnchorPane (javafx.scene.layout.AnchorPane)4 UserThread (io.bitsquare.common.UserThread)3 Tuple2 (io.bitsquare.common.util.Tuple2)3 Popup (io.bitsquare.gui.main.overlays.popups.Popup)3 BSFormatter (io.bitsquare.gui.util.BSFormatter)3 ChangeListener (javafx.beans.value.ChangeListener)3 Inject (javax.inject.Inject)3 ActivatableViewAndModel (io.bitsquare.gui.common.view.ActivatableViewAndModel)2 FxmlView (io.bitsquare.gui.common.view.FxmlView)2 TitledGroupBg (io.bitsquare.gui.components.TitledGroupBg)2 FormBuilder (io.bitsquare.gui.util.FormBuilder)2 ImageUtil (io.bitsquare.gui.util.ImageUtil)2 Layout (io.bitsquare.gui.util.Layout)2 io.bitsquare.gui.util.validation (io.bitsquare.gui.util.validation)2 PaymentAccount (io.bitsquare.payment.PaymentAccount)2 PaymentAccountFactory (io.bitsquare.payment.PaymentAccountFactory)2 PaymentMethod (io.bitsquare.payment.PaymentMethod)2