Search in sources :

Example 1 with PrivateNotification

use of io.bitsquare.alert.PrivateNotification in project bitsquare by bitsquare.

the class SendPrivateNotificationWindow method addContent.

private void addContent() {
    InputTextField keyInputTextField = addLabelInputTextField(gridPane, ++rowIndex, "Key for private notification:", 10).second;
    Tuple2<Label, TextArea> labelTextAreaTuple2 = addLabelTextArea(gridPane, ++rowIndex, "Private notification:", "Enter notification");
    TextArea alertMessageTextArea = labelTextAreaTuple2.second;
    Label first = labelTextAreaTuple2.first;
    first.setMinWidth(200);
    sendButton = new Button("Send private notification");
    sendButton.setOnAction(e -> {
        if (alertMessageTextArea.getText().length() > 0 && keyInputTextField.getText().length() > 0) {
            if (!sendPrivateNotificationHandler.handle(new PrivateNotification(alertMessageTextArea.getText()), pubKeyRing, nodeAddress, keyInputTextField.getText(), new SendMailboxMessageListener() {

                @Override
                public void onArrived() {
                    log.trace("PrivateNotificationMessage arrived at peer.");
                    new Popup<>().feedback("Message arrived.").onClose(SendPrivateNotificationWindow.this::hide).show();
                }

                @Override
                public void onStoredInMailbox() {
                    log.trace("PrivateNotificationMessage was stored in mailbox.");
                    new Popup<>().feedback("Message stored in mailbox.").onClose(SendPrivateNotificationWindow.this::hide).show();
                }

                @Override
                public void onFault(String errorMessage) {
                    new Popup<>().feedback("Message sending failed. error=" + errorMessage).onClose(SendPrivateNotificationWindow.this::hide).show();
                }
            }))
                new Popup().warning("The key you entered was not correct.").width(300).onClose(() -> blurAgain()).show();
        }
    });
    closeButton = new Button("Close");
    closeButton.setOnAction(e -> {
        hide();
        closeHandlerOptional.ifPresent(closeHandler -> closeHandler.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(io.bitsquare.gui.util.FormBuilder.addLabelTextArea) Button(javafx.scene.control.Button) FormBuilder.addLabelInputTextField(io.bitsquare.gui.util.FormBuilder.addLabelInputTextField) InputTextField(io.bitsquare.gui.components.InputTextField) Popup(io.bitsquare.gui.main.overlays.popups.Popup) Label(javafx.scene.control.Label) PrivateNotification(io.bitsquare.alert.PrivateNotification) SendMailboxMessageListener(io.bitsquare.p2p.messaging.SendMailboxMessageListener)

Aggregations

PrivateNotification (io.bitsquare.alert.PrivateNotification)1 InputTextField (io.bitsquare.gui.components.InputTextField)1 Popup (io.bitsquare.gui.main.overlays.popups.Popup)1 FormBuilder.addLabelInputTextField (io.bitsquare.gui.util.FormBuilder.addLabelInputTextField)1 FormBuilder.addLabelTextArea (io.bitsquare.gui.util.FormBuilder.addLabelTextArea)1 SendMailboxMessageListener (io.bitsquare.p2p.messaging.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