Class FirstLaunchController
java.lang.Object
page.codeberg.friedolyn.gui.controllers.Controller<Void>
page.codeberg.friedolyn.gui.controllers.FirstLaunchController
- All Implemented Interfaces:
javafx.fxml.Initializable
,Preparable<Void>
Provides the logic for the
window initially shown
to the user when they
start Friedolyn for the first time. This window is used to log in to the University of Jena's Friedolin system.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.layout.BorderPane
Holds the main content of the window, i.e.private javafx.scene.control.Button
The “Cancel” button on the loading screen to abruptly abort the background operation and return to the main window.private javafx.scene.control.Button
private javafx.scene.control.CheckBox
private Configuration
private javafx.scene.control.TextField
private io.github.palexdev.materialfx.controls.MFXProgressSpinner
Indicates how much of the background operation has already been completed.private ResourceBundle
private javafx.scene.control.TextField
private javafx.scene.layout.VBox
The loading screen showing aprogress spinner
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Makes the current window or dialog disappear from the user's screen.void
initialize
(URL location, @NonNull ResourceBundle resources) void
Tries to connect to a running instance of the KeePassXC password manager and retrieve the user's Friedolin login credentials from there.void
proceed()
Handles the user's click on the“Proceed” button
and tries to log in to the University of Jena's Friedolin system with the student's credentials entered in theusername
andpassword
fields.protected void
setResourceBundle
(ResourceBundle resourceBundle) Updates theresourceBundle
of this controller if it hasn't been set yet.void
Toggles the state of the“I accept the obligation of use” checkbox
.private void
toggleLoadingSpinner
(boolean active) Shows or hides the loading screen showing aprogress spinner
.Methods inherited from class page.codeberg.friedolyn.gui.controllers.Controller
getSuccess, prepare
-
Field Details
-
resourceBundle
-
configuration
-
textFieldUser
private javafx.scene.control.TextField textFieldUser -
passwordField
private javafx.scene.control.TextField passwordField -
checkBoxObligationOfUse
private javafx.scene.control.CheckBox checkBoxObligationOfUse -
buttonProceed
private javafx.scene.control.Button buttonProceed -
borderPaneMain
private javafx.scene.layout.BorderPane borderPaneMainHolds the main content of the window, i.e. the login fields and the “Proceed” button. This is disabled while theloading screen
is shown. -
vBoxLoading
private javafx.scene.layout.VBox vBoxLoadingThe loading screen showing aprogress spinner
. -
progressSpinner
private io.github.palexdev.materialfx.controls.MFXProgressSpinner progressSpinnerIndicates how much of the background operation has already been completed. Child of theloading screen
. -
buttonCancelLogin
private javafx.scene.control.Button buttonCancelLoginThe “Cancel” button on the loading screen to abruptly abort the background operation and return to the main window. Child of theloading screen
.
-
-
Constructor Details
-
FirstLaunchController
public FirstLaunchController()
-
-
Method Details
-
setResourceBundle
Updates theresourceBundle
of this controller if it hasn't been set yet.- Parameters:
resourceBundle
- The resource bundle to set.- Throws:
IllegalStateException
- If the resource bundle has already been set.
-
initialize
-
loginWithKeePassXC
public void loginWithKeePassXC() -
proceed
public void proceed()Handles the user's click on the“Proceed” button
and tries to log in to the University of Jena's Friedolin system with the student's credentials entered in theusername
andpassword
fields.Will show an error popup if the
“I accept the obligation of use” checkbox
is not checked. All non-GUI operations are executed in a separate thread in order to not block the GUI and not incentivise the operating system (looking at you, Windows) to tell the user that we're "not responding". Instead, a loading screen with aprogress spinner
is displayed. -
toggleAcceptObligationOfUseCheckBox
public void toggleAcceptObligationOfUseCheckBox()Toggles the state of the“I accept the obligation of use” checkbox
. If it was checked, it will be unchecked and vice versa. -
toggleLoadingSpinner
private void toggleLoadingSpinner(boolean active) Shows or hides the loading screen showing aprogress spinner
. This is supposed to be used while performing heavy non-GUI operations whose response time could be significant, like making a network request or reading from a file.Did you know?
The loading screen features theprogressSpinner
whoseprogress property
can be bound to aTask's progress property
to show a percentage indicating how much of the operation has already been completed.- Parameters:
active
-true
to show the loading screen,false
to hide it.- Implementation Note:
- You might want to consider ordering the disabling/enabling statements such that disabling an element is done before enabling another one, to prevent them from being clickable both at the same time. However, this would require introducing several conditionals, which wouldn't be worth it in this case, because the enabling/disabling is almost instantaneous.
-
close
public void close()Makes the current window or dialog disappear from the user's screen.- Specified by:
close
in classController<Void>
-