Search in sources :

Example 1 with Alert

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

the class SendAlertMessageWindow method addContent.

private void addContent() {
    InputTextField keyInputTextField = addLabelInputTextField(gridPane, ++rowIndex, "Alert private key:", 10).second;
    Tuple2<Label, TextArea> labelTextAreaTuple2 = addLabelTextArea(gridPane, ++rowIndex, "Alert message:", "Enter message");
    TextArea alertMessageTextArea = labelTextAreaTuple2.second;
    Label first = labelTextAreaTuple2.first;
    first.setMinWidth(150);
    CheckBox isUpdateCheckBox = addLabelCheckBox(gridPane, ++rowIndex, "Is update notification:", "").second;
    isUpdateCheckBox.setSelected(true);
    InputTextField versionInputTextField = addLabelInputTextField(gridPane, ++rowIndex, "New version no.:").second;
    versionInputTextField.disableProperty().bind(isUpdateCheckBox.selectedProperty().not());
    sendButton = new Button("Send notification");
    sendButton.setOnAction(e -> {
        if (alertMessageTextArea.getText().length() > 0 && keyInputTextField.getText().length() > 0) {
            if (sendAlertMessageHandler.handle(new Alert(alertMessageTextArea.getText(), isUpdateCheckBox.isSelected(), versionInputTextField.getText()), keyInputTextField.getText()))
                hide();
            else
                new Popup().warning("The key you entered was not correct.").width(300).onClose(() -> blurAgain()).show();
        }
    });
    Button removeAlertMessageButton = new Button("Remove notification");
    removeAlertMessageButton.setOnAction(e -> {
        if (keyInputTextField.getText().length() > 0) {
            if (removeAlertMessageHandler.handle(keyInputTextField.getText()))
                hide();
            else
                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, removeAlertMessageButton, 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) Button(javafx.scene.control.Button) InputTextField(io.bitsquare.gui.components.InputTextField) CheckBox(javafx.scene.control.CheckBox) Popup(io.bitsquare.gui.main.overlays.popups.Popup) Label(javafx.scene.control.Label) Alert(io.bitsquare.alert.Alert)

Aggregations

Alert (io.bitsquare.alert.Alert)1 InputTextField (io.bitsquare.gui.components.InputTextField)1 Popup (io.bitsquare.gui.main.overlays.popups.Popup)1 Insets (javafx.geometry.Insets)1 Button (javafx.scene.control.Button)1 CheckBox (javafx.scene.control.CheckBox)1 Label (javafx.scene.control.Label)1 TextArea (javafx.scene.control.TextArea)1 HBox (javafx.scene.layout.HBox)1