use of bisq.desktop.components.AutoTooltipButton in project bisq-desktop by bisq-network.
the class FormBuilder method addLabelComboBoxButton.
public static Tuple3<Label, ComboBox, Button> addLabelComboBoxButton(GridPane gridPane, int rowIndex, String title, String buttonTitle, double top) {
Label label = addLabel(gridPane, rowIndex, title, top);
HBox hBox = new HBox();
hBox.setSpacing(10);
Button button = new AutoTooltipButton(buttonTitle);
button.setDefaultButton(true);
ComboBox comboBox = new ComboBox();
hBox.getChildren().addAll(comboBox, button);
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, button);
}
use of bisq.desktop.components.AutoTooltipButton in project bisq-desktop by bisq-network.
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 AutoTooltipButton(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);
}
use of bisq.desktop.components.AutoTooltipButton in project bisq-desktop by bisq-network.
the class DisplayAlertMessageWindow method addContent.
// /////////////////////////////////////////////////////////////////////////////////////////
// Protected
// /////////////////////////////////////////////////////////////////////////////////////////
private void addContent() {
checkNotNull(alert, "alertMessage must not be null");
FormBuilder.addMultilineLabel(gridPane, ++rowIndex, alert.getMessage(), 10);
if (alert.isUpdateInfo()) {
headLine = Res.get("displayAlertMessageWindow.update.headline");
headLineLabel.getStyleClass().addAll("headline-label", "highlight");
String url = "https://bisq.network/downloads";
HyperlinkWithIcon hyperlinkWithIcon = FormBuilder.addLabelHyperlinkWithIcon(gridPane, ++rowIndex, Res.get("displayAlertMessageWindow.update.download"), url, url).second;
hyperlinkWithIcon.setMaxWidth(550);
} else {
headLine = Res.get("displayAlertMessageWindow.headline");
headLineLabel.getStyleClass().addAll("headline-label", "error-text");
}
closeButton = new AutoTooltipButton(Res.get("shared.close"));
closeButton.setOnAction(e -> {
hide();
closeHandlerOptional.ifPresent(Runnable::run);
});
GridPane.setRowIndex(closeButton, ++rowIndex);
GridPane.setColumnIndex(closeButton, 1);
gridPane.getChildren().add(closeButton);
GridPane.setMargin(closeButton, new Insets(10, 0, 0, 0));
}
use of bisq.desktop.components.AutoTooltipButton 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.components.AutoTooltipButton in project bisq-desktop by bisq-network.
the class SendPrivateNotificationWindow method addContent.
private void addContent() {
InputTextField keyInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("shared.unlock"), 10).second;
if (useDevPrivilegeKeys)
keyInputTextField.setText(DevEnv.DEV_PRIVILEGE_PRIV_KEY);
Tuple2<Label, TextArea> labelTextAreaTuple2 = addLabelTextArea(gridPane, ++rowIndex, Res.get("sendPrivateNotificationWindow.privateNotification"), Res.get("sendPrivateNotificationWindow.enterNotification"));
TextArea alertMessageTextArea = labelTextAreaTuple2.second;
Label first = labelTextAreaTuple2.first;
first.setMinWidth(200);
Button sendButton = new AutoTooltipButton(Res.get("sendPrivateNotificationWindow.send"));
sendButton.setOnAction(e -> {
if (alertMessageTextArea.getText().length() > 0 && keyInputTextField.getText().length() > 0) {
if (!sendPrivateNotificationHandler.handle(new PrivateNotificationPayload(alertMessageTextArea.getText()), pubKeyRing, nodeAddress, keyInputTextField.getText(), new SendMailboxMessageListener() {
@Override
public void onArrived() {
log.info("PrivateNotificationMessage arrived at peer.");
new Popup<>().feedback(Res.get("shared.messageArrived")).onClose(SendPrivateNotificationWindow.this::hide).show();
}
@Override
public void onStoredInMailbox() {
log.info("PrivateNotificationMessage was stored in mailbox.");
new Popup<>().feedback(Res.get("shared.messageStoredInMailbox")).onClose(SendPrivateNotificationWindow.this::hide).show();
}
@Override
public void onFault(String errorMessage) {
log.error("sendEncryptedMailboxMessage failed. message=" + message);
new Popup<>().feedback(Res.get("shared.messageSendingFailed", errorMessage)).onClose(SendPrivateNotificationWindow.this::hide).show();
}
}))
new Popup<>().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
}
});
closeButton = new AutoTooltipButton(Res.get("shared.close"));
closeButton.setOnAction(e -> {
hide();
closeHandlerOptional.ifPresent(Runnable::run);
});
HBox hBox = new HBox();
hBox.setSpacing(10);
GridPane.setRowIndex(hBox, ++rowIndex);
GridPane.setColumnIndex(hBox, 1);
hBox.getChildren().addAll(sendButton, closeButton);
gridPane.getChildren().add(hBox);
GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
}
Aggregations