66 lines
2.4 KiB
Java
66 lines
2.4 KiB
Java
package envoy.client.ui.settings;
|
|
|
|
import javafx.event.EventHandler;
|
|
import javafx.scene.control.*;
|
|
import javafx.scene.input.InputEvent;
|
|
|
|
import envoy.client.util.IssueUtil;
|
|
import envoy.event.IssueProposal;
|
|
|
|
/**
|
|
* This class offers the option for users to submit a bug report. Only the title
|
|
* of a bug is needed to be sent.
|
|
*
|
|
* @author Leon Hofmeister
|
|
* @since Envoy Client v0.2-beta
|
|
*/
|
|
public final class BugReportPane extends OnlineOnlySettingsPane {
|
|
|
|
private final Label titleLabel = new Label("Suggest a title for the bug:");
|
|
private final TextField titleTextField = new TextField();
|
|
private final Label pleaseExplainLabel = new Label("Paste here the log of what went wrong and/ or explain what went wrong:");
|
|
private final TextArea errorDetailArea = new TextArea();
|
|
private final CheckBox showUsernameInBugReport = new CheckBox("Show your username in the bug report?");
|
|
private final Button submitReportButton = new Button("Submit report");
|
|
|
|
private final EventHandler<? super InputEvent> inputEventHandler = e -> submitReportButton.setDisable(titleTextField.getText().isBlank());
|
|
|
|
/**
|
|
* Creates a new {@code BugReportPane}.
|
|
*
|
|
* @since Envoy Client v0.2-beta
|
|
*/
|
|
public BugReportPane() {
|
|
super("Report a bug");
|
|
setSpacing(10);
|
|
setToolTipText("A bug can only be reported while being online");
|
|
|
|
// Displaying the label to ask for a title
|
|
titleLabel.setWrapText(true);
|
|
getChildren().add(titleLabel);
|
|
|
|
// Displaying the TextField where to enter the title of this bug
|
|
titleTextField.setOnKeyTyped(inputEventHandler);
|
|
titleTextField.setOnInputMethodTextChanged(inputEventHandler);
|
|
getChildren().add(titleTextField);
|
|
|
|
// Displaying the label to ask for clarification
|
|
pleaseExplainLabel.setWrapText(true);
|
|
getChildren().add(pleaseExplainLabel);
|
|
|
|
// Displaying the TextArea where to enter the log and/or own description
|
|
errorDetailArea.setWrapText(true);
|
|
getChildren().add(errorDetailArea);
|
|
|
|
// Displaying the consent button that your user name will be shown
|
|
showUsernameInBugReport.setSelected(true);
|
|
getChildren().add(showUsernameInBugReport);
|
|
|
|
// Displaying the submitReportButton
|
|
submitReportButton.setDisable(true);
|
|
submitReportButton.setOnAction(e -> client.send(new IssueProposal(titleTextField.getText(), IssueUtil
|
|
.sanitizeIssueDescription(errorDetailArea.getText(), showUsernameInBugReport.isSelected() ? client.getSender().getName() : null), true)));
|
|
getChildren().add(submitReportButton);
|
|
}
|
|
}
|