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.BorderPane
private static final @NonNull URL
Ntfy's project website: ntfy.shprivate NtfyNotifier
The user's input as aNtfyNotifier
.private @NonNull ResourceBundle
private boolean
True if the user has entered valid data and closed the dialog, false otherwise.private javafx.scene.control.TextField
private javafx.scene.control.TextField
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Makes the dialog disappear from the user's screen.void
confirm()
Called when the user clicks the “OK” button to save the entered data.@NonNull Optional
<NtfyNotifier> @NonNull FuzzyBoolean
void
initialize
(URL location, ResourceBundle resources) It is required to callprepare(page.codeberg.friedolyn.configuration.Configuration)
immediately after this method.void
Opens theNtfy website
in the user's default browser.void
prepare
(@NonNull Configuration configuration) Uses the givenConfiguration
to insert the user's current Ntfy setup into the dialog.void
Sends a test notification to the user's Ntfy setup to verify that it works.private boolean
validate()
Checks that the user has entered a validinvalid reference
host
invalid reference
topic
-
Field Details
-
NTFY_WEBSITE
-
resourceBundle
-
ntfyNotifier
The user's input as aNtfyNotifier
.null
by 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 givenConfiguration
to 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:
prepare
in interfacePreparable<Configuration>
- Overrides:
prepare
in classController<Configuration>
- Parameters:
configuration
- TheConfiguration
to use for the setup.- See Also:
-
openNtfyWebsite
public void openNtfyWebsite()Opens theNtfy website
in 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 validinvalid reference
host
invalid reference
topic
- Returns:
true
if the user has entered valid data,false
otherwise.
-
confirm
public void confirm()Called when the user clicks the “OK” button to save the entered data.Validates
the user's input and, if it is valid, sets theresult
totrue
andcloses
the dialog.- Specified by:
confirm
in classDialogController<Configuration,
NtfyNotifier>
-
getSuccess
- Overrides:
getSuccess
in classController<Configuration>
- Returns:
FuzzyBoolean.TRUE
if the user has entered valid data and closed the dialog,FuzzyBoolean.FALSE
otherwise. It is guaranteed thatFuzzyBoolean.MAYBE
is never returned.
-
getResult
- Specified by:
getResult
in 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:
close
in classController<Configuration>
-