-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from DEIS-Tools/feature/preloader
Feature: add a splashscreen/preloader to indicate loading progress
- Loading branch information
Showing
6 changed files
with
272 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package dk.cs.aau.huppaal; | ||
|
||
import dk.cs.aau.huppaal.presentations.PreloaderPresentation; | ||
import javafx.application.Platform; | ||
import javafx.application.Preloader; | ||
import javafx.scene.Scene; | ||
import javafx.stage.Stage; | ||
import javafx.stage.StageStyle; | ||
|
||
public class HUPPAALPreloader extends Preloader { | ||
public enum LoadStage { | ||
LOADING_PROJECT, | ||
INITALIZE_JFX, | ||
AFTER_INIT, | ||
START_JFX, | ||
AFTER_SHOW, | ||
FINISHED | ||
} | ||
public static class Notification implements PreloaderNotification { | ||
private final LoadStage stage; | ||
public Notification(LoadStage stage) { | ||
this.stage = stage; | ||
} | ||
public LoadStage getStage() { | ||
return stage; | ||
} | ||
} | ||
private Stage stage; | ||
private PreloaderPresentation presentation; | ||
|
||
@Override | ||
public void start(Stage primaryStage) throws Exception { | ||
stage = new Stage(); | ||
presentation = new PreloaderPresentation(); | ||
presentation.getController().projectNameLabel.setText(HUPPAAL.projectDirectory.getValue()); | ||
stage.setScene(new Scene(presentation)); | ||
stage.initStyle(StageStyle.UNDECORATED); | ||
stage.show(); | ||
} | ||
|
||
@Override | ||
public void handleApplicationNotification(PreloaderNotification info) { | ||
if(info instanceof Notification notificationInfo) { | ||
switch (notificationInfo.getStage()) { | ||
case LOADING_PROJECT -> presentation.getController().statusLabel.setText("Loading Project..."); | ||
case INITALIZE_JFX -> presentation.getController().statusLabel.setText("Initializing JFX..."); | ||
case AFTER_INIT -> presentation.getController().statusLabel.setText("Finished init..."); | ||
case START_JFX -> presentation.getController().statusLabel.setText("Starting JFX..."); | ||
case AFTER_SHOW -> stage.hide(); | ||
case FINISHED -> Platform.runLater(() -> presentation.getController().statusLabel.setText("Finished")); | ||
} | ||
} | ||
super.handleApplicationNotification(info); | ||
} | ||
} |
Oops, something went wrong.