Support multiline for alerts

This commit is contained in:
Manfred Karrer 2016-02-11 10:35:19 +01:00
parent fa0d670901
commit d6e1c0d0b3
3 changed files with 3635 additions and 13 deletions

3617
doc/modena.css Normal file

File diff suppressed because it is too large Load Diff

View File

@ -19,10 +19,13 @@ package io.bitsquare.gui.popups;
import io.bitsquare.alert.Alert; import io.bitsquare.alert.Alert;
import io.bitsquare.app.BitsquareApp; import io.bitsquare.app.BitsquareApp;
import io.bitsquare.common.util.Tuple2;
import io.bitsquare.gui.components.InputTextField; import io.bitsquare.gui.components.InputTextField;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.CheckBox; import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -30,12 +33,11 @@ import org.slf4j.LoggerFactory;
import java.util.Optional; import java.util.Optional;
import static io.bitsquare.gui.util.FormBuilder.addLabelCheckBox; import static io.bitsquare.gui.util.FormBuilder.*;
import static io.bitsquare.gui.util.FormBuilder.addLabelInputTextField;
public class SendAlertMessagePopup extends Popup { public class SendAlertMessagePopup extends Popup {
private static final Logger log = LoggerFactory.getLogger(SendAlertMessagePopup.class); private static final Logger log = LoggerFactory.getLogger(SendAlertMessagePopup.class);
private Button openTicketButton; private Button sendButton;
private SendAlertMessageHandler sendAlertMessageHandler; private SendAlertMessageHandler sendAlertMessageHandler;
private RemoveAlertMessageHandler removeAlertMessageHandler; private RemoveAlertMessageHandler removeAlertMessageHandler;
@ -91,20 +93,22 @@ public class SendAlertMessagePopup extends Popup {
private void addContent() { private void addContent() {
InputTextField keyInputTextField = addLabelInputTextField(gridPane, ++rowIndex, "Alert private key:", 10).second; InputTextField keyInputTextField = addLabelInputTextField(gridPane, ++rowIndex, "Alert private key:", 10).second;
InputTextField alertMessageInputTextField = addLabelInputTextField(gridPane, ++rowIndex, "Alert message:").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; CheckBox isUpdateCheckBox = addLabelCheckBox(gridPane, ++rowIndex, "Is update notification:", "").second;
isUpdateCheckBox.setSelected(true); isUpdateCheckBox.setSelected(true);
if (BitsquareApp.DEV_MODE) { if (BitsquareApp.DEV_MODE)
keyInputTextField.setText("2e41038992f89eef2e4634ff3586e342c68ad9a5a7ffafee866781687f77a9b1"); keyInputTextField.setText("2e41038992f89eef2e4634ff3586e342c68ad9a5a7ffafee866781687f77a9b1");
alertMessageInputTextField.setText("m1");
}
openTicketButton = new Button("Send notification"); sendButton = new Button("Send notification");
openTicketButton.setOnAction(e -> { sendButton.setOnAction(e -> {
if (alertMessageInputTextField.getText().length() > 0 && keyInputTextField.getText().length() > 0) { if (alertMessageTextArea.getText().length() > 0 && keyInputTextField.getText().length() > 0) {
if (sendAlertMessageHandler.handle( if (sendAlertMessageHandler.handle(
new Alert(alertMessageInputTextField.getText(), isUpdateCheckBox.isSelected()), new Alert(alertMessageTextArea.getText(), isUpdateCheckBox.isSelected()),
keyInputTextField.getText())) keyInputTextField.getText()))
hide(); hide();
else else
@ -132,7 +136,7 @@ public class SendAlertMessagePopup extends Popup {
hBox.setSpacing(10); hBox.setSpacing(10);
GridPane.setRowIndex(hBox, ++rowIndex); GridPane.setRowIndex(hBox, ++rowIndex);
GridPane.setColumnIndex(hBox, 1); GridPane.setColumnIndex(hBox, 1);
hBox.getChildren().addAll(openTicketButton, removeAlertMessageButton, closeButton); hBox.getChildren().addAll(sendButton, removeAlertMessageButton, closeButton);
gridPane.getChildren().add(hBox); gridPane.getChildren().add(hBox);
GridPane.setMargin(hBox, new Insets(10, 0, 0, 0)); GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
} }

View File

@ -191,6 +191,7 @@ public class FormBuilder {
public static Tuple2<Label, TextArea> addLabelTextArea(GridPane gridPane, int rowIndex, String title, String prompt, double top) { public static Tuple2<Label, TextArea> addLabelTextArea(GridPane gridPane, int rowIndex, String title, String prompt, double top) {
Label label = addLabel(gridPane, rowIndex, title, 0); Label label = addLabel(gridPane, rowIndex, title, 0);
label.setAlignment(Pos.TOP_RIGHT);
GridPane.setMargin(label, new Insets(top + 4, 0, 0, 0)); GridPane.setMargin(label, new Insets(top + 4, 0, 0, 0));
GridPane.setValignment(label, VPos.TOP); GridPane.setValignment(label, VPos.TOP);