Search in sources :

Example 1 with Popup

use of io.bitsquare.gui.main.overlays.popups.Popup in project bitsquare by bitsquare.

the class TraderDisputeView method getTradeIdColumn.

private TableColumn<Dispute, Dispute> getTradeIdColumn() {
    TableColumn<Dispute, Dispute> column = new TableColumn<Dispute, Dispute>("Trade ID") {

        {
            setMinWidth(110);
        }
    };
    column.setCellValueFactory((dispute) -> new ReadOnlyObjectWrapper<>(dispute.getValue()));
    column.setCellFactory(new Callback<TableColumn<Dispute, Dispute>, TableCell<Dispute, Dispute>>() {

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

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final Dispute item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        field = new HyperlinkWithIcon(item.getShortTradeId(), true);
                        Optional<Trade> tradeOptional = tradeManager.getTradeById(item.getTradeId());
                        if (tradeOptional.isPresent()) {
                            field.setMouseTransparent(false);
                            field.setTooltip(new Tooltip("Open popup for details"));
                            field.setOnAction(event -> tradeDetailsWindow.show(tradeOptional.get()));
                        } else {
                            field.setMouseTransparent(true);
                        }
                        setGraphic(field);
                    } else {
                        setGraphic(null);
                        if (field != null)
                            field.setOnAction(null);
                    }
                }
            };
        }
    });
    return column;
}
Also used : EventHandler(javafx.event.EventHandler) PubKeyRing(io.bitsquare.common.crypto.PubKeyRing) Popup(io.bitsquare.gui.main.overlays.popups.Popup) javafx.scene.layout(javafx.scene.layout) javafx.scene.control(javafx.scene.control) URL(java.net.URL) ReadOnlyBooleanProperty(javafx.beans.property.ReadOnlyBooleanProperty) DisputeManager(io.bitsquare.arbitration.DisputeManager) Trade(io.bitsquare.trade.Trade) ActivatableView(io.bitsquare.gui.common.view.ActivatableView) DisputeCommunicationMessage(io.bitsquare.arbitration.messages.DisputeCommunicationMessage) GUIUtil(io.bitsquare.gui.util.GUIUtil) KeyCombination(javafx.scene.input.KeyCombination) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) KeyRing(io.bitsquare.common.crypto.KeyRing) DisputeSummaryWindow(io.bitsquare.gui.main.overlays.windows.DisputeSummaryWindow) ParseException(java.text.ParseException) DateFormat(java.text.DateFormat) SortedList(javafx.collections.transformation.SortedList) TableGroupHeadline(io.bitsquare.gui.components.TableGroupHeadline) Contract(io.bitsquare.trade.Contract) FilteredList(javafx.collections.transformation.FilteredList) KeyEvent(javafx.scene.input.KeyEvent) Subscription(org.fxmisc.easybind.Subscription) PrivateNotificationManager(io.bitsquare.alert.PrivateNotificationManager) Attachment(io.bitsquare.arbitration.payload.Attachment) Paint(javafx.scene.paint.Paint) ByteStreams(com.google.common.io.ByteStreams) Dispute(io.bitsquare.arbitration.Dispute) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) Version(io.bitsquare.app.Version) Scene(javafx.scene.Scene) java.util(java.util) P2PService(io.bitsquare.p2p.P2PService) SimpleDateFormat(java.text.SimpleDateFormat) Connection(io.bitsquare.p2p.network.Connection) Timer(io.bitsquare.common.Timer) Inject(javax.inject.Inject) TradeManager(io.bitsquare.trade.TradeManager) Lists(com.google.common.collect.Lists) Insets(javafx.geometry.Insets) TradeDetailsWindow(io.bitsquare.gui.main.overlays.windows.TradeDetailsWindow) TextAlignment(javafx.scene.text.TextAlignment) Callback(javafx.util.Callback) Nullable(javax.annotation.Nullable) BSFormatter(io.bitsquare.gui.util.BSFormatter) KeyCode(javafx.scene.input.KeyCode) InputTextField(io.bitsquare.gui.components.InputTextField) Utilities(io.bitsquare.common.util.Utilities) ContractWindow(io.bitsquare.gui.main.overlays.windows.ContractWindow) MalformedURLException(java.net.MalformedURLException) UserThread(io.bitsquare.common.UserThread) AwesomeDude(de.jensd.fx.fontawesome.AwesomeDude) NodeAddress(io.bitsquare.p2p.NodeAddress) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) TimeUnit(java.util.concurrent.TimeUnit) FileChooser(javafx.stage.FileChooser) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon) Stage(javafx.stage.Stage) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) BusyAnimation(io.bitsquare.gui.components.BusyAnimation) SendPrivateNotificationWindow(io.bitsquare.gui.main.overlays.windows.SendPrivateNotificationWindow) FxmlView(io.bitsquare.gui.common.view.FxmlView) ChangeListener(javafx.beans.value.ChangeListener) InputStream(java.io.InputStream) Dispute(io.bitsquare.arbitration.Dispute) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon)

Example 2 with Popup

use of io.bitsquare.gui.main.overlays.popups.Popup in project bitsquare by bitsquare.

the class MainView method createFooter.

private AnchorPane createFooter() {
    // line
    Separator separator = new Separator();
    separator.setId("footer-pane-line");
    separator.setPrefHeight(1);
    setLeftAnchor(separator, 0d);
    setRightAnchor(separator, 0d);
    setTopAnchor(separator, 0d);
    // BTC
    Label btcInfoLabel = new Label();
    btcInfoLabel.setId("footer-pane");
    btcInfoLabel.textProperty().bind(model.btcInfo);
    ProgressBar blockchainSyncIndicator = new ProgressBar(-1);
    blockchainSyncIndicator.setPrefWidth(120);
    blockchainSyncIndicator.setMaxHeight(10);
    blockchainSyncIndicator.progressProperty().bind(model.btcSyncProgress);
    model.walletServiceErrorMsg.addListener((ov, oldValue, newValue) -> {
        if (newValue != null) {
            btcInfoLabel.setId("splash-error-state-msg");
            if (btcNetworkWarnMsgPopup == null) {
                btcNetworkWarnMsgPopup = new Popup<>().warning(newValue);
                btcNetworkWarnMsgPopup.show();
            }
        } else {
            btcInfoLabel.setId("footer-pane");
            if (btcNetworkWarnMsgPopup != null)
                btcNetworkWarnMsgPopup.hide();
        }
    });
    model.btcSyncProgress.addListener((ov, oldValue, newValue) -> {
        if ((double) newValue >= 1) {
            blockchainSyncIndicator.setVisible(false);
            blockchainSyncIndicator.setManaged(false);
        }
    });
    HBox blockchainSyncBox = new HBox();
    blockchainSyncBox.setSpacing(10);
    blockchainSyncBox.setAlignment(Pos.CENTER);
    blockchainSyncBox.getChildren().addAll(btcInfoLabel, blockchainSyncIndicator);
    setLeftAnchor(blockchainSyncBox, 10d);
    setBottomAnchor(blockchainSyncBox, 7d);
    // version
    Label versionLabel = new Label();
    versionLabel.setId("footer-pane");
    versionLabel.setTextAlignment(TextAlignment.CENTER);
    versionLabel.setAlignment(Pos.BASELINE_CENTER);
    versionLabel.setText(model.version);
    root.widthProperty().addListener((ov, oldValue, newValue) -> {
        versionLabel.setLayoutX(((double) newValue - versionLabel.getWidth()) / 2);
    });
    setBottomAnchor(versionLabel, 7d);
    // P2P Network
    Label p2PNetworkLabel = new Label();
    p2PNetworkLabel.setId("footer-pane");
    setRightAnchor(p2PNetworkLabel, 33d);
    setBottomAnchor(p2PNetworkLabel, 7d);
    p2PNetworkLabel.textProperty().bind(model.p2PNetworkInfo);
    ImageView p2PNetworkIcon = new ImageView();
    setRightAnchor(p2PNetworkIcon, 10d);
    setBottomAnchor(p2PNetworkIcon, 7d);
    p2PNetworkIcon.setOpacity(0.4);
    p2PNetworkIcon.idProperty().bind(model.p2PNetworkIconId);
    p2PNetworkLabel.idProperty().bind(model.p2pNetworkLabelId);
    model.p2pNetworkWarnMsg.addListener((ov, oldValue, newValue) -> {
        if (newValue != null) {
            p2PNetworkWarnMsgPopup = new Popup<>().warning(newValue);
            p2PNetworkWarnMsgPopup.show();
        } else if (p2PNetworkWarnMsgPopup != null) {
            p2PNetworkWarnMsgPopup.hide();
        }
    });
    model.bootstrapComplete.addListener((observable, oldValue, newValue) -> {
        p2PNetworkIcon.setOpacity(1);
    });
    return new AnchorPane(separator, blockchainSyncBox, versionLabel, p2PNetworkLabel, p2PNetworkIcon) {

        {
            setId("footer-pane");
            setMinHeight(30);
            setMaxHeight(30);
        }
    };
}
Also used : Popup(io.bitsquare.gui.main.overlays.popups.Popup) ImageView(javafx.scene.image.ImageView) AnchorPane(javafx.scene.layout.AnchorPane)

Example 3 with Popup

use of io.bitsquare.gui.main.overlays.popups.Popup in project bitsquare by bitsquare.

the class BackupView method activate.

@Override
protected void activate() {
    selectBackupDir.setOnAction(e -> {
        DirectoryChooser directoryChooser = new DirectoryChooser();
        directoryChooser.setInitialDirectory(new File(preferences.getDefaultPath()));
        directoryChooser.setTitle("Select backup location");
        File dir = directoryChooser.showDialog(stage);
        if (dir != null) {
            String backupDirectory = dir.getAbsolutePath();
            preferences.setDefaultPath(backupDirectory);
            backUpLocationTextField.setText(backupDirectory);
            preferences.setBackupDirectory(backupDirectory);
            backupNow.setDisable(false);
            backupNow.setDefaultButton(true);
            selectBackupDir.setDefaultButton(false);
        }
    });
    openDataDir.setOnAction(e -> {
        try {
            Utilities.openDirectory(dataDir);
        } catch (IOException e1) {
            log.error(e1.getMessage());
            new Popup().warning("Cannot open directory.\nError =" + e1.getMessage()).show();
        }
    });
    backupNow.setOnAction(e -> {
        String backupDirectory = preferences.getBackupDirectory();
        if (backupDirectory.length() > 0) {
            try {
                String dateString = new SimpleDateFormat("YYYY-MM-dd-HHmmss").format(new Date());
                String destination = Paths.get(backupDirectory, "bitsquare_backup_" + dateString).toString();
                FileUtils.copyDirectory(dataDir, new File(destination));
                new Popup().feedback("Backup successfully saved at:\n" + destination).show();
            } catch (IOException e1) {
                e1.printStackTrace();
                log.error(e1.getMessage());
                new Popup().error("Backup could not be saved.\nError message: " + e1.getMessage()).show();
            }
        }
    });
}
Also used : Popup(io.bitsquare.gui.main.overlays.popups.Popup) IOException(java.io.IOException) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) DirectoryChooser(javafx.stage.DirectoryChooser) Date(java.util.Date)

Example 4 with Popup

use of io.bitsquare.gui.main.overlays.popups.Popup 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 5 with Popup

use of io.bitsquare.gui.main.overlays.popups.Popup in project bitsquare by bitsquare.

the class PreferencesView method initializeOtherOptions.

private void initializeOtherOptions() {
    TitledGroupBg titledGroupBg = addTitledGroupBg(root, ++gridRow, 5, "General preferences", Layout.GROUP_DISTANCE);
    GridPane.setColumnSpan(titledGroupBg, 4);
    // userLanguageComboBox = addLabelComboBox(root, gridRow, "Language:", Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
    // btcDenominationComboBox = addLabelComboBox(root, ++gridRow, "Bitcoin denomination:").second;
    blockChainExplorerComboBox = addLabelComboBox(root, gridRow, "Bitcoin block explorer:", Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
    deviationInputTextField = addLabelInputTextField(root, ++gridRow, "Max. deviation from market price:").second;
    autoSelectArbitratorsCheckBox = addLabelCheckBox(root, ++gridRow, "Auto select arbitrators:", "").second;
    deviationListener = (observable, oldValue, newValue) -> {
        try {
            double value = formatter.parsePercentStringToDouble(newValue);
            if (value <= 0.3) {
                preferences.setMaxPriceDistanceInPercent(value);
            } else {
                new Popup().warning("Values higher than 30 % are not allowed.").show();
                UserThread.runAfter(() -> deviationInputTextField.setText(formatter.formatPercentagePrice(preferences.getMaxPriceDistanceInPercent())), 100, TimeUnit.MILLISECONDS);
            }
        } catch (NumberFormatException t) {
            log.error("Exception at parseDouble deviation: " + t.toString());
            UserThread.runAfter(() -> deviationInputTextField.setText(formatter.formatPercentagePrice(preferences.getMaxPriceDistanceInPercent())), 100, TimeUnit.MILLISECONDS);
        }
    };
    deviationFocusedListener = (observable1, oldValue1, newValue1) -> {
        if (oldValue1 && !newValue1)
            UserThread.runAfter(() -> deviationInputTextField.setText(formatter.formatPercentagePrice(preferences.getMaxPriceDistanceInPercent())), 100, TimeUnit.MILLISECONDS);
    };
    transactionFeeInputTextField = addLabelInputTextField(root, ++gridRow, "Withdrawal transaction fee (satoshi/byte):").second;
    transactionFeeFocusedListener = (o, oldValue, newValue) -> {
        if (oldValue && !newValue) {
            try {
                int val = Integer.parseInt(transactionFeeInputTextField.getText());
                preferences.setNonTradeTxFeePerKB(val * 1000);
            } catch (NumberFormatException t) {
                new Popup().warning("Please enter integer numbers only.").show();
                transactionFeeInputTextField.setText(getNonTradeTxFeePerKB());
            } catch (Throwable t) {
                new Popup().warning("Your input was not accepted.\n" + t.getMessage()).show();
                transactionFeeInputTextField.setText(getNonTradeTxFeePerKB());
            }
        }
    };
    ignoreTradersListInputTextField = addLabelInputTextField(root, ++gridRow, "Ignore traders with onion address (comma sep.):").second;
    ignoreTradersListListener = (observable, oldValue, newValue) -> preferences.setIgnoreTradersList(Arrays.asList(newValue.replace(" ", "").replace(":9999", "").replace(".onion", "").split(",")));
}
Also used : Popup(io.bitsquare.gui.main.overlays.popups.Popup) TitledGroupBg(io.bitsquare.gui.components.TitledGroupBg)

Aggregations

Popup (io.bitsquare.gui.main.overlays.popups.Popup)68 BSFormatter (io.bitsquare.gui.util.BSFormatter)19 UserThread (io.bitsquare.common.UserThread)15 Inject (javax.inject.Inject)15 FxmlView (io.bitsquare.gui.common.view.FxmlView)14 Insets (javafx.geometry.Insets)14 javafx.scene.control (javafx.scene.control)14 ImageView (javafx.scene.image.ImageView)14 GUIUtil (io.bitsquare.gui.util.GUIUtil)13 Preferences (io.bitsquare.user.Preferences)13 Callback (javafx.util.Callback)13 TradeManager (io.bitsquare.trade.TradeManager)12 TimeUnit (java.util.concurrent.TimeUnit)12 ObservableList (javafx.collections.ObservableList)12 InputTextField (io.bitsquare.gui.components.InputTextField)11 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)11 ChangeListener (javafx.beans.value.ChangeListener)11 SortedList (javafx.collections.transformation.SortedList)11 Coin (org.bitcoinj.core.Coin)11 HyperlinkWithIcon (io.bitsquare.gui.components.HyperlinkWithIcon)10