Search in sources :

Example 66 with Popup

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

the class OpenOffersView method setOfferIdColumnCellFactory.

private void setOfferIdColumnCellFactory() {
    offerIdColumn.setCellValueFactory((openOfferListItem) -> new ReadOnlyObjectWrapper<>(openOfferListItem.getValue()));
    offerIdColumn.setCellFactory(new Callback<TableColumn<OpenOfferListItem, OpenOfferListItem>, TableCell<OpenOfferListItem, OpenOfferListItem>>() {

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

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final OpenOfferListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        field = new HyperlinkWithIcon(model.getTradeId(item), true);
                        field.setOnAction(event -> offerDetailsWindow.show(item.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) 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) HyperlinkWithIcon(io.bitsquare.gui.components.HyperlinkWithIcon)

Example 67 with Popup

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

the class GUIUtil method importAccounts.

public static void importAccounts(User user, String fileName, Preferences preferences, Stage stage) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(new File(preferences.getDefaultPath()));
    fileChooser.setTitle("Select path to " + fileName);
    File file = fileChooser.showOpenDialog(stage.getOwner());
    if (file != null) {
        String path = file.getAbsolutePath();
        if (Paths.get(path).getFileName().toString().equals(fileName)) {
            String directory = Paths.get(path).getParent().toString();
            preferences.setDefaultPath(directory);
            Storage<ArrayList<PaymentAccount>> paymentAccountsStorage = new Storage<>(new File(directory));
            ArrayList<PaymentAccount> persisted = paymentAccountsStorage.initAndGetPersistedWithFileName(fileName);
            if (persisted != null) {
                final StringBuilder msg = new StringBuilder();
                persisted.stream().forEach(paymentAccount -> {
                    final String id = paymentAccount.getId();
                    if (user.getPaymentAccount(id) == null) {
                        user.addPaymentAccount(paymentAccount);
                        msg.append("Trading account with id ").append(id).append("\n");
                    } else {
                        msg.append("We did not import trading account with id ").append(id).append(" because it exists already.\n");
                    }
                });
                new Popup<>().feedback("Trading account imported from path:\n" + path + "\n\nImported accounts:\n" + msg).show();
            } else {
                new Popup<>().warning("No exported trading accounts has been found at path: " + path + ".\n" + "File name is " + fileName + ".").show();
            }
        } else {
            new Popup<>().warning("The selected file is not the expected file for import. The expected file name is: " + fileName + ".").show();
        }
    }
}
Also used : Storage(io.bitsquare.storage.Storage) PaymentAccount(io.bitsquare.payment.PaymentAccount) Popup(io.bitsquare.gui.main.overlays.popups.Popup) FileChooser(javafx.stage.FileChooser) File(java.io.File)

Example 68 with Popup

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

the class GUIUtil method exportAccounts.

public static void exportAccounts(ArrayList<PaymentAccount> accounts, String fileName, Preferences preferences, Stage stage) {
    if (!accounts.isEmpty()) {
        String directory = getDirectoryFormChooser(preferences, stage);
        Storage<ArrayList<PaymentAccount>> paymentAccountsStorage = new Storage<>(new File(directory));
        paymentAccountsStorage.initAndGetPersisted(accounts, fileName);
        paymentAccountsStorage.queueUpForSave();
        new Popup<>().feedback("Trading accounts saved to path:\n" + Paths.get(directory, fileName).toAbsolutePath()).show();
    } else {
        new Popup<>().warning("You don't have trading accounts set up for exporting.").show();
    }
}
Also used : Storage(io.bitsquare.storage.Storage) Popup(io.bitsquare.gui.main.overlays.popups.Popup) File(java.io.File)

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