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.BorderPaneprivate ConfigurationWill be set asthe notifier's configuration.private UnifiedPushNotifierThe user's input as aUnifiedPushNotifier.private ResourceBundleprivate booleanTrue if the user has entered valid data and closed the dialog, false otherwise.private javafx.scene.control.TextFieldprivate static final URL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Makes the dialog disappear from the user's screen.voidconfirm()This method is called when the user clicks the "Confirm" button.@NonNull Optional<UnifiedPushNotifier> @NonNull FuzzyBooleanvoidinitialize(URL location, @NonNull ResourceBundle resources) It is required to call theprepare(page.codeberg.friedolyn.configuration.Configuration)method immediately after this method.voidOpens theUnifiedPush websitein the user's default browser.voidprepare(@NonNull Configuration configuration) Uses the givenConfigurationto insert the user's current UnifiedPush setup into the dialog.voidSends a test notification to the user's device to verify that the UnifiedPush setup made by the user works fine.private booleanvalidate()Checks that the user has entered a valid URL in thetextFieldURLfield.
-
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.nullby 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 givenConfigurationto 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:
preparein interfacePreparable<Configuration>- Overrides:
preparein classController<Configuration>- Parameters:
configuration- TheUnifiedPushNotifierinconfiguration.getNotifications()will be used to populate the dialog. TheConfigurationitself will be associated with theresulting UnifiedPushNotifieras specified in itsconstructor, i.e. must be the correct reference.- See Also:
-
openUnifiedPushWebsite
public void openUnifiedPushWebsite()Opens theUnifiedPush websitein 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 thetextFieldURLfield. If not, an error message is displayed to the user in form of analert popup.- Returns:
trueif the user has entered a valid URL,falseotherwise.
-
confirm
public void confirm()This method is called when the user clicks the "Confirm" button. Itvalidatesthe user's input and, if everything is valid, sets theresulttotrueand closes the dialog.- Specified by:
confirmin classDialogController<Configuration,UnifiedPushNotifier>
-
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,UnifiedPushNotifier> - Returns:
- The user's input as a
UnifiedPushNotifier.
-
close
public void close()Makes the dialog disappear from the user's screen.- Specified by:
closein classController<Configuration>
-