use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.
the class FeeOptionWindow method addContent.
private void addContent() {
Label label = addLabel(gridPane, ++rowIndex, Res.get("feeOptionWindow.info"));
GridPane.setColumnSpan(label, 2);
GridPane.setHalignment(label, HPos.LEFT);
toggleGroup = new ToggleGroup();
Tuple3<Label, RadioButton, RadioButton> tuple = addLabelRadioButtonRadioButton(gridPane, ++rowIndex, toggleGroup, Res.get("feeOptionWindow.optionsLabel"), "BTC", "BSQ");
RadioButton radioButtonBTC = tuple.second;
RadioButton radioButtonBSQ = tuple.third;
makerFeeTextField = addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("createOffer.currencyForFee"), makerFeeWithCodeProperty.get()).second;
toggleChangeListener = (observable, oldValue, newValue) -> {
final boolean isBtc = newValue == radioButtonBTC;
selectionChangedHandler.accept(isBtc);
if (!isBsqForFeeAvailable && !isBtc) {
if (missingBsq != null) {
// We don't call hide() because we want to keep the blurred bg
if (stage != null)
stage.hide();
else
log.warn("Stage is null");
cleanup();
onHidden();
// noinspection unchecked
new Popup().warning(missingBsq).actionButtonTextWithGoTo("navigation.dao.wallet.receive").onAction(() -> {
UserThread.runAfter(() -> {
hide();
navigation.navigateTo(MainView.class, DaoView.class, BsqWalletView.class, BsqReceiveView.class);
}, 100, TimeUnit.MILLISECONDS);
}).closeButtonText(Res.get("feeOptionWindow.useBTC")).onClose(() -> {
selectionChangedHandler.accept(true);
closeHandler.run();
}).show();
}
UserThread.execute(() -> {
toggleGroup.selectToggle(radioButtonBTC);
radioButtonBSQ.setDisable(true);
});
}
};
toggleGroup.selectedToggleProperty().addListener(toggleChangeListener);
toggleGroup.selectToggle(!isBsqForFeeAvailable || isCurrencyForMakerFeeBtc ? radioButtonBTC : radioButtonBSQ);
makerFeeTextField.textProperty().bind(makerFeeWithCodeProperty);
}
use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.
the class OfferDetailsWindow method addConfirmAndCancelButtons.
private void addConfirmAndCancelButtons(boolean isPlaceOffer) {
boolean isBuyOffer = offer.isBuyOffer();
boolean isBuyerRole = isPlaceOffer ? isBuyOffer : !isBuyOffer;
String placeOfferButtonText = isBuyerRole ? Res.get("offerDetailsWindow.confirm.maker", Res.get("shared.buy")) : Res.get("offerDetailsWindow.confirm.maker", Res.get("shared.sell"));
String takeOfferButtonText = isBuyerRole ? Res.get("offerDetailsWindow.confirm.taker", Res.get("shared.buy")) : Res.get("offerDetailsWindow.confirm.taker", Res.get("shared.sell"));
ImageView iconView = new ImageView();
iconView.setId(isBuyerRole ? "image-buy-white" : "image-sell-white");
Tuple3<Button, BusyAnimation, Label> placeOfferTuple = addButtonBusyAnimationLabelAfterGroup(gridPane, ++rowIndex, isPlaceOffer ? placeOfferButtonText : takeOfferButtonText);
Button button = placeOfferTuple.first;
button.setMinHeight(40);
button.setPadding(new Insets(0, 20, 0, 20));
button.setGraphic(iconView);
button.setGraphicTextGap(10);
button.setId(isBuyerRole ? "buy-button-big" : "sell-button-big");
button.setText(isPlaceOffer ? placeOfferButtonText : takeOfferButtonText);
busyAnimation = placeOfferTuple.second;
Label spinnerInfoLabel = placeOfferTuple.third;
Button cancelButton = addButton(gridPane, ++rowIndex, Res.get("shared.cancel"));
cancelButton.setDefaultButton(false);
cancelButton.setId("cancel-button");
cancelButton.setOnAction(e -> {
closeHandlerOptional.ifPresent(Runnable::run);
hide();
});
button.setOnAction(e -> {
if (user.getAcceptedArbitrators().size() > 0) {
button.setDisable(true);
cancelButton.setDisable(true);
busyAnimation.play();
if (isPlaceOffer) {
spinnerInfoLabel.setText(Res.get("createOffer.fundsBox.placeOfferSpinnerInfo"));
placeOfferHandlerOptional.get().run();
} else {
spinnerInfoLabel.setText(Res.get("takeOffer.fundsBox.takeOfferSpinnerInfo"));
takeOfferHandlerOptional.get().run();
}
} else {
new Popup<>().warning(Res.get("offerDetailsWindow.warn.noArbitrator")).show();
// noinspection unchecked
navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, ArbitratorSelectionView.class);
}
});
}
use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.
the class DisplayUpdateDownloadWindow method addContent.
// /////////////////////////////////////////////////////////////////////////////////////////
// Protected
// /////////////////////////////////////////////////////////////////////////////////////////
private void addContent() {
headLine = "Important update information!";
headLineLabel.getStyleClass().addAll("headline-label", "highlight");
checkNotNull(alert, "alertMessage must not be null");
addMultilineLabel(gridPane, ++rowIndex, alert.getMessage(), 10);
Separator separator = new Separator();
separator.setMouseTransparent(true);
separator.setOrientation(Orientation.HORIZONTAL);
separator.getStyleClass().add("separator");
GridPane.setHalignment(separator, HPos.CENTER);
GridPane.setRowIndex(separator, ++rowIndex);
GridPane.setColumnSpan(separator, 2);
GridPane.setMargin(separator, new Insets(20, 0, 20, 0));
gridPane.getChildren().add(separator);
Button downloadButton = new AutoTooltipButton(Res.get("displayUpdateDownloadWindow.button.label"));
downloadButton.setDefaultButton(true);
busyAnimation = new BusyAnimation(false);
Label statusLabel = new AutoTooltipLabel();
statusLabel.managedProperty().bind(statusLabel.visibleProperty());
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.setAlignment(Pos.CENTER_LEFT);
hBox.getChildren().addAll(downloadButton, busyAnimation, statusLabel);
GridPane.setRowIndex(hBox, ++rowIndex);
GridPane.setColumnIndex(hBox, 0);
GridPane.setColumnSpan(hBox, 2);
gridPane.getChildren().add(hBox);
Label downloadingFileLabel = addLabel(gridPane, ++rowIndex, Res.get("displayUpdateDownloadWindow.downloadingFile", ""));
GridPane.setColumnIndex(downloadingFileLabel, 0);
downloadingFileLabel.setOpacity(0.2);
progressBar = new ProgressBar(0L);
progressBar.setPrefWidth(200);
progressBar.setMaxHeight(4);
progressBar.managedProperty().bind(progressBar.visibleProperty());
progressBar.setVisible(false);
GridPane.setRowIndex(progressBar, rowIndex);
GridPane.setColumnIndex(progressBar, 1);
GridPane.setHalignment(progressBar, HPos.LEFT);
GridPane.setFillWidth(progressBar, true);
GridPane.setMargin(progressBar, new Insets(3, 0, 0, 10));
gridPane.getChildren().add(progressBar);
final String downloadedFilesLabelTitle = Res.get("displayUpdateDownloadWindow.downloadedFiles");
Label downloadedFilesLabel = addLabel(gridPane, ++rowIndex, downloadedFilesLabelTitle);
GridPane.setColumnIndex(downloadedFilesLabel, 0);
GridPane.setHalignment(downloadedFilesLabel, HPos.LEFT);
GridPane.setColumnSpan(downloadedFilesLabel, 2);
downloadedFilesLabel.setOpacity(0.2);
final String verifiedSigLabelTitle = Res.get("displayUpdateDownloadWindow.verifiedSigs");
Label verifiedSigLabel = addLabel(gridPane, ++rowIndex, verifiedSigLabelTitle);
GridPane.setColumnIndex(verifiedSigLabel, 0);
GridPane.setColumnSpan(verifiedSigLabel, 2);
GridPane.setHalignment(verifiedSigLabel, HPos.LEFT);
verifiedSigLabel.setOpacity(0.2);
Separator separator2 = new Separator();
separator2.setMouseTransparent(true);
separator2.setOrientation(Orientation.HORIZONTAL);
separator2.getStyleClass().add("separator");
GridPane.setHalignment(separator2, HPos.CENTER);
GridPane.setRowIndex(separator2, ++rowIndex);
GridPane.setColumnSpan(separator2, 2);
GridPane.setMargin(separator2, new Insets(20, 0, 20, 0));
gridPane.getChildren().add(separator2);
BisqInstaller installer = new BisqInstaller();
String downloadFailedString = Res.get("displayUpdateDownloadWindow.download.failed");
downloadButton.setOnAction(e -> {
if (installer.isSupportedOS()) {
List<String> downloadedFiles = new ArrayList<>();
List<String> verifiedSigs = new ArrayList<>();
downloadButton.setDisable(true);
progressBar.setVisible(true);
downloadedFilesLabel.setOpacity(1);
downloadingFileLabel.setOpacity(1);
busyAnimation.play();
statusLabel.setText(Res.get("displayUpdateDownloadWindow.status.downloading"));
// download installer
downloadTaskOptional = installer.download(alert.getVersion());
if (downloadTaskOptional.isPresent()) {
final DownloadTask downloadTask = downloadTaskOptional.get();
final ChangeListener<String> downloadedFilesListener = (observable, oldValue, newValue) -> {
if (!newValue.endsWith("-local")) {
downloadingFileLabel.setText(Res.get("displayUpdateDownloadWindow.downloadingFile", newValue));
downloadedFilesLabel.setText(downloadedFilesLabelTitle + " " + Joiner.on(", ").join(downloadedFiles));
downloadedFiles.add(newValue);
}
};
downloadTask.messageProperty().addListener(downloadedFilesListener);
progressBar.progressProperty().unbind();
progressBar.progressProperty().bind(downloadTask.progressProperty());
downloadTask.setOnSucceeded(workerStateEvent -> {
downloadedFilesLabel.setText(downloadedFilesLabelTitle + " " + Joiner.on(", ").join(downloadedFiles));
downloadTask.messageProperty().removeListener(downloadedFilesListener);
progressBar.setVisible(false);
downloadingFileLabel.setText("");
downloadingFileLabel.setOpacity(0.2);
statusLabel.setText(Res.get("displayUpdateDownloadWindow.status.verifying"));
List<BisqInstaller.FileDescriptor> downloadResults = downloadTask.getValue();
Optional<BisqInstaller.FileDescriptor> downloadFailed = downloadResults.stream().filter(fileDescriptor -> !BisqInstaller.DownloadStatusEnum.OK.equals(fileDescriptor.getDownloadStatus())).findFirst();
downloadedFilesLabel.getStyleClass().removeAll("error-text", "success-text");
if (downloadResults == null || downloadResults.isEmpty() || downloadFailed.isPresent()) {
showErrorMessage(downloadButton, statusLabel, downloadFailedString);
downloadedFilesLabel.getStyleClass().add("error-text");
} else {
log.debug("Download completed successfully.");
downloadedFilesLabel.getStyleClass().add("success-text");
verifyTask = installer.verify(downloadResults);
verifiedSigLabel.setOpacity(1);
final ChangeListener<String> verifiedSigLabelListener = (observable, oldValue, newValue) -> {
verifiedSigs.add(newValue);
verifiedSigLabel.setText(verifiedSigLabelTitle + " " + Joiner.on(", ").join(verifiedSigs));
};
verifyTask.messageProperty().addListener(verifiedSigLabelListener);
verifyTask.setOnSucceeded(event -> {
verifyTask.messageProperty().removeListener(verifiedSigLabelListener);
statusLabel.setText("");
stopAnimations();
List<BisqInstaller.VerifyDescriptor> verifyResults = verifyTask.getValue();
// check that there are no failed verifications
Optional<BisqInstaller.VerifyDescriptor> verifyFailed = verifyResults.stream().filter(verifyDescriptor -> !BisqInstaller.VerifyStatusEnum.OK.equals(verifyDescriptor.getVerifyStatusEnum())).findFirst();
if (verifyResults == null || verifyResults.isEmpty() || verifyFailed.isPresent()) {
showErrorMessage(downloadButton, statusLabel, Res.get("displayUpdateDownloadWindow.verify.failed"));
} else {
verifiedSigLabel.getStyleClass().add("success-text");
new Popup<>().feedback(Res.get("displayUpdateDownloadWindow.success")).actionButtonText(Res.get("displayUpdateDownloadWindow.download.openDir")).onAction(() -> {
try {
Utilities.openFile(new File(Utilities.getDownloadOfHomeDir()));
doClose();
} catch (IOException e2) {
log.error(e2.getMessage());
e2.printStackTrace();
}
}).onClose(this::doClose).show();
log.info("Download & verification succeeded.");
}
});
}
});
} else {
showErrorMessage(downloadButton, statusLabel, downloadFailedString);
}
} else {
showErrorMessage(downloadButton, statusLabel, (Res.get("displayUpdateDownloadWindow.installer.failed")));
}
});
}
use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.
the class PendingTradesView method initialize.
@Override
public void initialize() {
priceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.price")));
amountColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode())));
volumeColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.amount")));
marketColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.market")));
roleColumn.setGraphic(new AutoTooltipLabel(Res.get("portfolio.pending.role")));
dateColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.dateTime")));
tradeIdColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.tradeId")));
paymentMethodColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.paymentMethod")));
avatarColumn.setText("");
setTradeIdColumnCellFactory();
setDateColumnCellFactory();
setAmountColumnCellFactory();
setPriceColumnCellFactory();
setVolumeColumnCellFactory();
setPaymentMethodColumnCellFactory();
setMarketColumnCellFactory();
setRoleColumnCellFactory();
setAvatarColumnCellFactory();
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.openTrades"))));
tableView.setMinHeight(100);
tradeIdColumn.setComparator((o1, o2) -> o1.getTrade().getId().compareTo(o2.getTrade().getId()));
dateColumn.setComparator((o1, o2) -> o1.getTrade().getDate().compareTo(o2.getTrade().getDate()));
volumeColumn.setComparator((o1, o2) -> {
if (o1.getTrade().getTradeVolume() != null && o2.getTrade().getTradeVolume() != null)
return o1.getTrade().getTradeVolume().compareTo(o2.getTrade().getTradeVolume());
else
return 0;
});
amountColumn.setComparator((o1, o2) -> {
if (o1.getTrade().getTradeAmount() != null && o2.getTrade().getTradeAmount() != null)
return o1.getTrade().getTradeAmount().compareTo(o2.getTrade().getTradeAmount());
else
return 0;
});
priceColumn.setComparator((o1, o2) -> o1.getPrice().compareTo(o2.getPrice()));
paymentMethodColumn.setComparator((o1, o2) -> o1.getTrade().getOffer().getPaymentMethod().getId().compareTo(o2.getTrade().getOffer().getPaymentMethod().getId()));
avatarColumn.setComparator((o1, o2) -> {
if (o1.getTrade().getTradingPeerNodeAddress() != null && o2.getTrade().getTradingPeerNodeAddress() != null)
return o1.getTrade().getTradingPeerNodeAddress().getFullAddress().compareTo(o2.getTrade().getTradingPeerNodeAddress().getFullAddress());
else
return 0;
});
roleColumn.setComparator((o1, o2) -> model.getMyRole(o1).compareTo(model.getMyRole(o2)));
marketColumn.setComparator((o1, o2) -> model.getMarketLabel(o1).compareTo(model.getMarketLabel(o2)));
dateColumn.setSortType(TableColumn.SortType.DESCENDING);
tableView.getSortOrder().add(dateColumn);
// we use a hidden emergency shortcut to open support ticket
keyEventEventHandler = keyEvent -> {
if (Utilities.isAltOrCtrlPressed(KeyCode.O, keyEvent)) {
Popup popup = new Popup<>();
popup.headLine(Res.get("portfolio.pending.openSupportTicket.headline")).message(Res.get("portfolio.pending.openSupportTicket.msg")).actionButtonText(Res.get("portfolio.pending.openSupportTicket.headline")).onAction(model.dataModel::onOpenSupportTicket).closeButtonText(Res.get("shared.cancel")).onClose(popup::hide).show();
} else if (Utilities.isAltPressed(KeyCode.Y, keyEvent)) {
new Popup<>().warning(Res.get("portfolio.pending.removeFailedTrade")).onAction(model.dataModel::onMoveToFailedTrades).show();
}
};
}
use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.
the class PreferencesView method initializeDisplayCurrencies.
private void initializeDisplayCurrencies() {
TitledGroupBg titledGroupBg = addTitledGroupBg(root, ++gridRow, 3, Res.get("setting.preferences.currenciesInList"), Layout.GROUP_DISTANCE);
GridPane.setColumnSpan(titledGroupBg, 4);
// noinspection unchecked
preferredTradeCurrencyComboBox = addLabelComboBox(root, gridRow, Res.get("setting.preferences.prefCurrency"), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
preferredTradeCurrencyComboBox.setConverter(new StringConverter<TradeCurrency>() {
@Override
public String toString(TradeCurrency tradeCurrency) {
// http://boschista.deviantart.com/journal/Cool-ASCII-Symbols-214218618
return tradeCurrency.getDisplayPrefix() + tradeCurrency.getNameAndCode();
}
@Override
public TradeCurrency fromString(String s) {
return null;
}
});
Tuple2<Label, ListView> fiatTuple = addLabelListView(root, ++gridRow, Res.get("setting.preferences.displayFiat"));
GridPane.setValignment(fiatTuple.first, VPos.TOP);
// noinspection unchecked
fiatCurrenciesListView = fiatTuple.second;
fiatCurrenciesListView.setMinHeight(2 * Layout.LIST_ROW_HEIGHT + 2);
fiatCurrenciesListView.setPrefHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
Label placeholder = new AutoTooltipLabel(Res.get("setting.preferences.noFiat"));
placeholder.setWrapText(true);
fiatCurrenciesListView.setPlaceholder(placeholder);
fiatCurrenciesListView.setCellFactory(new Callback<ListView<FiatCurrency>, ListCell<FiatCurrency>>() {
@Override
public ListCell<FiatCurrency> call(ListView<FiatCurrency> list) {
return new ListCell<FiatCurrency>() {
final Label label = new AutoTooltipLabel();
final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);
final Button removeButton = new AutoTooltipButton("", icon);
final AnchorPane pane = new AnchorPane(label, removeButton);
{
label.setLayoutY(5);
removeButton.setId("icon-button");
AnchorPane.setRightAnchor(removeButton, 0d);
}
@Override
public void updateItem(final FiatCurrency item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
label.setText(item.getNameAndCode());
removeButton.setOnAction(e -> {
if (item.equals(preferences.getPreferredTradeCurrency())) {
new Popup<>().warning(Res.get("setting.preferences.cannotRemovePrefCurrency")).show();
} else {
preferences.removeFiatCurrency(item);
if (!allFiatCurrencies.contains(item))
allFiatCurrencies.add(item);
}
});
setGraphic(pane);
} else {
setGraphic(null);
removeButton.setOnAction(null);
}
}
};
}
});
Tuple2<Label, ListView> cryptoCurrenciesTuple = addLabelListView(root, gridRow, Res.get("setting.preferences.displayAltcoins"));
GridPane.setValignment(cryptoCurrenciesTuple.first, VPos.TOP);
GridPane.setMargin(cryptoCurrenciesTuple.first, new Insets(0, 0, 0, 20));
// noinspection unchecked
cryptoCurrenciesListView = cryptoCurrenciesTuple.second;
GridPane.setColumnIndex(cryptoCurrenciesTuple.first, 2);
GridPane.setColumnIndex(cryptoCurrenciesListView, 3);
cryptoCurrenciesListView.setMinHeight(2 * Layout.LIST_ROW_HEIGHT + 2);
cryptoCurrenciesListView.setPrefHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
placeholder = new AutoTooltipLabel(Res.get("setting.preferences.noAltcoins"));
placeholder.setWrapText(true);
cryptoCurrenciesListView.setPlaceholder(placeholder);
cryptoCurrenciesListView.setCellFactory(new Callback<ListView<CryptoCurrency>, ListCell<CryptoCurrency>>() {
@Override
public ListCell<CryptoCurrency> call(ListView<CryptoCurrency> list) {
return new ListCell<CryptoCurrency>() {
final Label label = new AutoTooltipLabel();
final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);
final Button removeButton = new AutoTooltipButton("", icon);
final AnchorPane pane = new AnchorPane(label, removeButton);
{
label.setLayoutY(5);
removeButton.setId("icon-button");
AnchorPane.setRightAnchor(removeButton, 0d);
}
@Override
public void updateItem(final CryptoCurrency item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
label.setText(item.getNameAndCode());
removeButton.setOnAction(e -> {
if (item.equals(preferences.getPreferredTradeCurrency())) {
new Popup<>().warning(Res.get("setting.preferences.cannotRemovePrefCurrency")).show();
} else {
preferences.removeCryptoCurrency(item);
if (!allCryptoCurrencies.contains(item))
allCryptoCurrencies.add(item);
}
});
setGraphic(pane);
} else {
setGraphic(null);
removeButton.setOnAction(null);
}
}
};
}
});
// noinspection unchecked
fiatCurrenciesComboBox = addLabelComboBox(root, ++gridRow).second;
fiatCurrenciesComboBox.setPromptText(Res.get("setting.preferences.addFiat"));
fiatCurrenciesComboBox.setConverter(new StringConverter<FiatCurrency>() {
@Override
public String toString(FiatCurrency tradeCurrency) {
return tradeCurrency.getNameAndCode();
}
@Override
public FiatCurrency fromString(String s) {
return null;
}
});
Tuple2<Label, ComboBox> labelComboBoxTuple2 = addLabelComboBox(root, gridRow);
// noinspection unchecked
cryptoCurrenciesComboBox = labelComboBoxTuple2.second;
GridPane.setColumnIndex(cryptoCurrenciesComboBox, 3);
cryptoCurrenciesComboBox.setPromptText(Res.get("setting.preferences.addAltcoin"));
cryptoCurrenciesComboBox.setConverter(new StringConverter<CryptoCurrency>() {
@Override
public String toString(CryptoCurrency tradeCurrency) {
return tradeCurrency.getNameAndCode();
}
@Override
public CryptoCurrency fromString(String s) {
return null;
}
});
}
Aggregations