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 record
The user's input in the contact window.static final record
The information necessary to populate the contact window.private class
Displays thecontact reply method dialog
to the user.private class
Sends the user's request to the developersvia e-mail
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.layout.BorderPane
private javafx.scene.control.CheckBox
private javafx.scene.control.CheckBox
private javafx.scene.control.CheckBox
private javafx.scene.control.ChoiceBox
private Configuration
The configuration with the user's login credentials and contact information.private ContactMethods
The user's contact information as entered in the contact window.private Friedolyn.ContactRequest
Why the user is contacting the developers.private @NonNull String
The user's message to the developers.private javafx.scene.text.Text
private javafx.scene.text.Text
private org.controlsfx.control.Rating
private ResourceBundle
private boolean
Whether the user successfully sent the message.private javafx.scene.control.TextArea
private javafx.scene.control.TextField
private javafx.scene.text.Text
private javafx.scene.layout.VBox
private javafx.scene.layout.VBox
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Exits the current window.void
confirm()
Called when the user clicks the “Send” button.private @NonNull String
@NonNull Optional
<ContactController.ContactResult> void
initialize
(URL location, ResourceBundle resourceBundle) It is required to callprepare
immediately after this method.void
prepare
(@NonNull ContactController.InitialisationParameters parameters) Sets the configuration and the contact request type for this window.private void
saveMessageToDisk
(@NonNull ByteArrayOutputStream email) Tries to store the user's e-mail as a text file in thee-mails
directory.void
setContactRequestType
(Friedolyn.ContactRequest contactRequestType) Updates thecontactRequestType
and the GUI elements accordingly.void
submit()
Sends the user's message to the developer.void
Sets thecheckBoxIncludeLogs
to the opposite of its current value.void
Sets thecheckBoxIncludeSystemInfo
to the opposite of its current value.void
Sets thecheckBoxSaveToDisk
to 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:
getResult
in 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 callprepare
immediately 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:
prepare
in interfacePreparable<ContactController.InitialisationParameters>
- Overrides:
prepare
in classController<ContactController.InitialisationParameters>
- Parameters:
parameters
- The parameters to use for this window.- Throws:
IllegalArgumentException
- If the configuration, theuser
, thepassword
or theemail
is not set in the configuration.- See Also:
-
setContactRequestType
Updates thecontactRequestType
and 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 thecheckBoxSaveToDisk
to 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 thecheckBoxIncludeLogs
to 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 thecheckBoxIncludeSystemInfo
to 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_DIALOG
to ask the user how they would like to receive a reply. Then, finally, the user's message is sent to the developers.- Specified by:
confirm
in 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#getRating
ofratingFriedolny#getMax
stars
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-mails
directory. 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-mails
directory. If the file could not be created, an error message is displayed in a popup.Does nothing if the user did not tick the
checkBoxSaveToDisk
checkbox. -
close
public void close()Exits the current window.- Specified by:
close
in classController<ContactController.InitialisationParameters>
-