Class SetupUnifiedPushDialogController
java.lang.Object
page.codeberg.friedolyn.gui.controllers.Controller<Configuration>
page.codeberg.friedolyn.gui.controllers.DialogController<Configuration,UnifiedPushNotifier>
page.codeberg.friedolyn.gui.controllers.SetupUnifiedPushDialogController
- All Implemented Interfaces:
javafx.fxml.Initializable
,Preparable<Configuration>
public class SetupUnifiedPushDialogController
extends DialogController<Configuration,UnifiedPushNotifier>
A class that defines the behaviour of the setup dialog for the
UnifiedPushNotifier
that shall be used to send
push notifications to the user's device.
- 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 Configuration
Will be set asthe notifier's configuration
.private UnifiedPushNotifier
The user's input as aUnifiedPushNotifier
.private ResourceBundle
private boolean
True if the user has entered valid data and closed the dialog, false otherwise.private javafx.scene.control.TextField
private static final URL
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Makes the dialog disappear from the user's screen.void
confirm()
This method is called when the user clicks the "Confirm" button.@NonNull Optional
<UnifiedPushNotifier> @NonNull FuzzyBoolean
void
initialize
(URL location, @NonNull ResourceBundle resources) It is required to call theprepare(page.codeberg.friedolyn.configuration.Configuration)
method immediately after this method.void
Opens theUnifiedPush website
in the user's default browser.void
prepare
(@NonNull Configuration configuration) Uses the givenConfiguration
to insert the user's current UnifiedPush setup into the dialog.void
Sends a test notification to the user's device to verify that the UnifiedPush setup made by the user works fine.private boolean
validate()
Checks that the user has entered a valid URL in thetextFieldURL
field.
-
Field Details
-
UNIFIED_PUSH_WEBSITE
-
result
private boolean resultTrue if the user has entered valid data and closed the dialog, false otherwise. -
configuration
Will be set asthe notifier's configuration
. -
resourceBundle
-
notifier
The user's input as aUnifiedPushNotifier
.null
by default. -
borderPane
private javafx.scene.layout.BorderPane borderPane -
textFieldURL
private javafx.scene.control.TextField textFieldURL
-
-
Constructor Details
-
SetupUnifiedPushDialogController
public SetupUnifiedPushDialogController()
-
-
Method Details
-
initialize
It is required to call theprepare(page.codeberg.friedolyn.configuration.Configuration)
method immediately after this method.- Parameters:
location
- Seeinitialize
.resources
- Seeinitialize
.
-
prepare
Uses the givenConfiguration
to insert the user's current UnifiedPush setup into the dialog. It is required to call this method immediately afterinitialize(java.net.URL, java.util.ResourceBundle)
.- Specified by:
prepare
in interfacePreparable<Configuration>
- Overrides:
prepare
in classController<Configuration>
- Parameters:
configuration
- TheUnifiedPushNotifier
inconfiguration.getNotifications()
will be used to populate the dialog. TheConfiguration
itself will be associated with theresulting UnifiedPushNotifier
as specified in itsconstructor
, i.e. must be the correct reference.- See Also:
-
openUnifiedPushWebsite
public void openUnifiedPushWebsite()Opens theUnifiedPush website
in the user's default browser. -
testSetup
public void testSetup()Sends a test notification to the user's device to verify that the UnifiedPush setup made by the user works fine. -
validate
private boolean validate()Checks that the user has entered a valid URL in thetextFieldURL
field. If not, an error message is displayed to the user in form of analert popup
.- Returns:
true
if the user has entered a valid URL,false
otherwise.
-
confirm
public void confirm()This method is called when the user clicks the "Confirm" button. Itvalidates
the user's input and, if everything is valid, sets theresult
totrue
and closes the dialog.- Specified by:
confirm
in classDialogController<Configuration,
UnifiedPushNotifier>
-
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,
UnifiedPushNotifier> - Returns:
- The user's input as a
UnifiedPushNotifier
.
-
close
public void close()Makes the dialog disappear from the user's screen.- Specified by:
close
in classController<Configuration>
-