Class SetupNtfyDialogController
java.lang.Object
page.codeberg.friedolyn.gui.controllers.Controller<Configuration>
page.codeberg.friedolyn.gui.controllers.DialogController<Configuration,NtfyNotifier>
page.codeberg.friedolyn.gui.controllers.SetupNtfyDialogController
- All Implemented Interfaces:
javafx.fxml.Initializable,Preparable<Configuration>
Defines the behaviour of the
GUI.Window.SETUP_NTFY_DIALOG dialog, which asks the user to configure a
NtfyNotifier for sending notifications via the Ntfy service.
- Call the
prepare(page.codeberg.friedolyn.configuration.Configuration)method beforeinitialize(java.net.URL, java.util.ResourceBundle). - Use
getSuccess()to determine whether the user has entered valid data. - Get the user's input via
getResult().
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.layout.BorderPaneprivate static final @NonNull URLNtfy's project website: ntfy.shprivate NtfyNotifierThe user's input as aNtfyNotifier.private @NonNull ResourceBundleprivate booleanTrue if the user has entered valid data and closed the dialog, false otherwise.private javafx.scene.control.TextFieldprivate javafx.scene.control.TextField -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Makes the dialog disappear from the user's screen.voidconfirm()Called when the user clicks the “OK” button to save the entered data.@NonNull Optional<NtfyNotifier> @NonNull FuzzyBooleanvoidinitialize(URL location, ResourceBundle resources) It is required to callprepare(page.codeberg.friedolyn.configuration.Configuration)immediately after this method.voidOpens theNtfy websitein the user's default browser.voidprepare(@NonNull Configuration configuration) Uses the givenConfigurationto insert the user's current Ntfy setup into the dialog.voidSends a test notification to the user's Ntfy setup to verify that it works.private booleanvalidate()Checks that the user has entered a validandinvalid reference
hostinvalid reference
topic
-
Field Details
-
NTFY_WEBSITE
-
resourceBundle
-
ntfyNotifier
The user's input as aNtfyNotifier.nullby default. -
result
private boolean resultTrue if the user has entered valid data and closed the dialog, false otherwise. -
borderPane
private javafx.scene.layout.BorderPane borderPane -
textFieldHost
private javafx.scene.control.TextField textFieldHost -
textFieldTopic
private javafx.scene.control.TextField textFieldTopic
-
-
Constructor Details
-
SetupNtfyDialogController
public SetupNtfyDialogController()
-
-
Method Details
-
initialize
It is required to callprepare(page.codeberg.friedolyn.configuration.Configuration)immediately after this method.- Parameters:
location- SeeInitializable.initialize(java.net.URL, java.util.ResourceBundle).resources- SeeInitializable.initialize(java.net.URL, java.util.ResourceBundle).
-
prepare
Uses the givenConfigurationto insert the user's current Ntfy setup into the dialog. It is required to call this method beforeinitialize(java.net.URL, java.util.ResourceBundle).- Specified by:
preparein interfacePreparable<Configuration>- Overrides:
preparein classController<Configuration>- Parameters:
configuration- TheConfigurationto use for the setup.- See Also:
-
openNtfyWebsite
public void openNtfyWebsite()Opens theNtfy websitein the user's default browser. -
testSetup
public void testSetup()Sends a test notification to the user's Ntfy setup to verify that it works. -
validate
private boolean validate()Checks that the user has entered a validandinvalid reference
hostinvalid reference
topic- Returns:
trueif the user has entered valid data,falseotherwise.
-
confirm
public void confirm()Called when the user clicks the “OK” button to save the entered data.Validatesthe user's input and, if it is valid, sets theresulttotrueandclosesthe dialog.- Specified by:
confirmin classDialogController<Configuration,NtfyNotifier>
-
getSuccess
- Overrides:
getSuccessin classController<Configuration>- Returns:
FuzzyBoolean.TRUEif the user has entered valid data and closed the dialog,FuzzyBoolean.FALSEotherwise. It is guaranteed thatFuzzyBoolean.MAYBEis never returned.
-
getResult
- Specified by:
getResultin classDialogController<Configuration,NtfyNotifier> - Returns:
- The result of the dialog. May contain nonsensical data if the dialog has not been closed yet.
-
close
public void close()Makes the dialog disappear from the user's screen.- Specified by:
closein classController<Configuration>
-