Class ContactController
java.lang.Object
page.codeberg.friedolyn.gui.controllers.Controller<ContactController.InitialisationParameters>
page.codeberg.friedolyn.gui.controllers.DialogController<ContactController.InitialisationParameters,ContactController.ContactResult>
page.codeberg.friedolyn.gui.controllers.ContactController
- All Implemented Interfaces:
javafx.fxml.Initializable,Preparable<ContactController.InitialisationParameters>
public class ContactController
extends DialogController<ContactController.InitialisationParameters,ContactController.ContactResult>
Defines the behaviour of the
GUI.Window.CONTACT window, which allows the user to send a message to the
developers.
-
It is required to call
prepare(InitialisationParameters)beforeinitialize(URL, ResourceBundle). -
Use
Controller.getSuccess()to check if the user successfully sent the message. (If so, the dialog has been closed.) -
Use
getResult()to get the message sent by the user, after the dialog has been closed.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe user's input in the contact window.static final recordThe information necessary to populate the contact window.private classDisplays thecontact reply method dialogto the user.private classSends the user's request to the developersvia e-mail. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.layout.BorderPaneprivate javafx.scene.control.CheckBoxprivate javafx.scene.control.CheckBoxprivate javafx.scene.control.CheckBoxprivate javafx.scene.control.ChoiceBoxprivate ConfigurationThe configuration with the user's login credentials and contact information.private ContactMethodsThe user's contact information as entered in the contact window.private Friedolyn.ContactRequestWhy the user is contacting the developers.private @NonNull StringThe user's message to the developers.private javafx.scene.text.Textprivate javafx.scene.text.Textprivate org.controlsfx.control.Ratingprivate ResourceBundleprivate booleanWhether the user successfully sent the message.private javafx.scene.control.TextAreaprivate javafx.scene.control.TextFieldprivate javafx.scene.text.Textprivate javafx.scene.layout.VBoxprivate javafx.scene.layout.VBox -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Exits the current window.voidconfirm()Called when the user clicks the “Send” button.private @NonNull String@NonNull Optional<ContactController.ContactResult> voidinitialize(URL location, ResourceBundle resourceBundle) It is required to callprepareimmediately after this method.voidprepare(@NonNull ContactController.InitialisationParameters parameters) Sets the configuration and the contact request type for this window.private voidsaveMessageToDisk(@NonNull ByteArrayOutputStream email) Tries to store the user's e-mail as a text file in thee-mailsdirectory.voidsetContactRequestType(Friedolyn.ContactRequest contactRequestType) Updates thecontactRequestTypeand the GUI elements accordingly.voidsubmit()Sends the user's message to the developer.voidSets thecheckBoxIncludeLogsto the opposite of its current value.voidSets thecheckBoxIncludeSystemInfoto the opposite of its current value.voidSets thecheckBoxSaveToDiskto the opposite of its current value.Methods inherited from class page.codeberg.friedolyn.gui.controllers.Controller
getSuccess
-
Field Details
-
resourceBundle
-
result
private boolean resultWhether the user successfully sent the message. -
contactMethods
The user's contact information as entered in the contact window. -
email
The user's message to the developers. Empty by default. -
contactRequestType
Why the user is contacting the developers. Default isFriedolyn.ContactRequest.SUPPORT. -
configuration
The configuration with the user's login credentials and contact information. -
borderPaneContact
private javafx.scene.layout.BorderPane borderPaneContact -
choiceBoxRequestType
private javafx.scene.control.ChoiceBox choiceBoxRequestType -
textSender
private javafx.scene.text.Text textSender -
textFieldSubject
private javafx.scene.control.TextField textFieldSubject -
textAreaMessage
private javafx.scene.control.TextArea textAreaMessage -
vBoxOptions
private javafx.scene.layout.VBox vBoxOptions -
vBoxDebugOptions
private javafx.scene.layout.VBox vBoxDebugOptions -
checkBoxSaveToDisk
private javafx.scene.control.CheckBox checkBoxSaveToDisk -
checkBoxIncludeLogs
private javafx.scene.control.CheckBox checkBoxIncludeLogs -
checkBoxIncludeSystemInfo
private javafx.scene.control.CheckBox checkBoxIncludeSystemInfo -
labelIncludeLogs
private javafx.scene.text.Text labelIncludeLogs -
labelIncludeSystemInfo
private javafx.scene.text.Text labelIncludeSystemInfo -
ratingFriedolyn
private org.controlsfx.control.Rating ratingFriedolyn
-
-
Constructor Details
-
ContactController
public ContactController()
-
-
Method Details
-
getResult
- Specified by:
getResultin classDialogController<ContactController.InitialisationParameters,ContactController.ContactResult> - Returns:
- The user's message to the developers, if it has been sent successfully. Otherwise, an empty
Optional.
-
initialize
It is required to callprepareimmediately after this method.- Parameters:
location- SeeInitializable.initialize(URL, ResourceBundle).resourceBundle- SeeInitializable.initialize(URL, ResourceBundle).
-
prepare
public void prepare(@NonNull @NonNull ContactController.InitialisationParameters parameters) throws IllegalArgumentException Sets the configuration and the contact request type for this window. Must be called beforeinitialize(URL, ResourceBundle).- Specified by:
preparein interfacePreparable<ContactController.InitialisationParameters>- Overrides:
preparein classController<ContactController.InitialisationParameters>- Parameters:
parameters- The parameters to use for this window.- Throws:
IllegalArgumentException- If the configuration, theuser, thepasswordor theemailis not set in the configuration.- See Also:
-
setContactRequestType
Updates thecontactRequestTypeand the GUI elements accordingly. May be called from the method that opened this window.- Parameters:
contactRequestType- The new contact request type.
-
toggleSaveToDisk
public void toggleSaveToDisk()Sets thecheckBoxSaveToDiskto the opposite of its current value. This is called when the user toggles the setting to store the e-mail locally as a text file on their computer. -
toggleIncludeLogs
public void toggleIncludeLogs()Sets thecheckBoxIncludeLogsto the opposite of its current value. This is called when the user toggles the setting to include the entire Java application's debug logs in the e-mail. -
toggleIncludeSystemInfo
public void toggleIncludeSystemInfo()Sets thecheckBoxIncludeSystemInfoto the opposite of its current value. This is called when the user toggles the setting to include the system information in the e-mail (for debugging purposes). -
confirm
public void confirm()Called when the user clicks the “Send” button. Validates that the user's message is not empty and then opens aGUI.Window.CONTACT_REPLY_METHOD_DIALOGto ask the user how they would like to receive a reply. Then, finally, the user's message is sent to the developers.- Specified by:
confirmin classDialogController<ContactController.InitialisationParameters,ContactController.ContactResult>
-
constructEmailText
- Returns:
- The user's message to the developers with additional metadata:
From:Configuration.getClearname()(Configuration.getUser())
Request type:contactRequestType
Subject:textFieldSubject
Friedolyn rating:ratingFriedolyn#getRatingofratingFriedolny#getMaxstars
textAreaMessage
-
submit
public void submit()Sends the user's message to the developer. Before that, the user's contact information is validated and added to the message. If the user's contact information is invalid, an error message is displayed in a popup.If the user wants to, the message is saved to disk in the
e-mailsdirectory. If the message could not be saved to disk, an error message is displayed in a popup.In all cases, the user's message is encrypted using the developer's OpenPGP public key. If the message could not be encrypted, an error message is displayed in a popup.
-
saveMessageToDisk
Tries to store the user's e-mail as a text file in thee-mailsdirectory. If the file could not be created, an error message is displayed in a popup.Does nothing if the user did not tick the
checkBoxSaveToDiskcheckbox. -
close
public void close()Exits the current window.- Specified by:
closein classController<ContactController.InitialisationParameters>
-