Search in sources :

Example 1 with PrivateNotificationPayload

use of bisq.core.alert.PrivateNotificationPayload 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));
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) TextArea(javafx.scene.control.TextArea) FormBuilder.addLabelTextArea(bisq.desktop.util.FormBuilder.addLabelTextArea) FormBuilder.addLabelInputTextField(bisq.desktop.util.FormBuilder.addLabelInputTextField) InputTextField(bisq.desktop.components.InputTextField) Label(javafx.scene.control.Label) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) PrivateNotificationPayload(bisq.core.alert.PrivateNotificationPayload) SendMailboxMessageListener(bisq.network.p2p.SendMailboxMessageListener)

Aggregations

PrivateNotificationPayload (bisq.core.alert.PrivateNotificationPayload)1 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)1 InputTextField (bisq.desktop.components.InputTextField)1 FormBuilder.addLabelInputTextField (bisq.desktop.util.FormBuilder.addLabelInputTextField)1 FormBuilder.addLabelTextArea (bisq.desktop.util.FormBuilder.addLabelTextArea)1 SendMailboxMessageListener (bisq.network.p2p.SendMailboxMessageListener)1 Insets (javafx.geometry.Insets)1 Button (javafx.scene.control.Button)1 Label (javafx.scene.control.Label)1 TextArea (javafx.scene.control.TextArea)1 HBox (javafx.scene.layout.HBox)1