This is the application logic for the "Splash Screen" when loading PCGEn It isn't directly the controller for the UI, but interacts the view and interacts with the controller. Once we're 100% on JavaFX can possibly be replaced with the native Preloader, but requires thought. @see pcgen.gui3.JFXPane
| 43 | * @see pcgen.gui3.JFXPanelFromResource |
| 44 | */ |
| 45 | public class PCGenPreloader implements PCGenTaskListener, Controllable<PCGenPreloaderController> |
| 46 | { |
| 47 | |
| 48 | private final FXMLLoader loader = new FXMLLoader(); |
| 49 | private Stage primaryStage; |
| 50 | |
| 51 | |
| 52 | public PCGenPreloader() |
| 53 | { |
| 54 | GuiAssertions.assertIsNotOnGUIThread(); |
| 55 | loader.setLocation(getClass().getResource("PCGenPreloader.fxml")); |
| 56 | Platform.runLater(() -> { |
| 57 | primaryStage = new Stage(); |
| 58 | final Scene scene; |
| 59 | try |
| 60 | { |
| 61 | scene = loader.load(); |
| 62 | } catch (IOException e) |
| 63 | { |
| 64 | Logging.errorPrint("failed to load preloader", e); |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | primaryStage.setScene(scene); |
| 69 | primaryStage.show(); |
| 70 | }); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @return the controller for the preloader |
| 75 | */ |
| 76 | @Override |
| 77 | public PCGenPreloaderController getController() |
| 78 | { |
| 79 | GuiAssertions.assertIsNotOnGUIThread(); |
| 80 | return GuiUtility.runOnJavaFXThreadNow(loader::getController); |
| 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public void progressChanged(final PCGenTaskEvent event) |
| 85 | { |
| 86 | ProgressContainer task = event.getSource(); |
| 87 | getController().setProgress(task.getMessage(), task.getProgress() / (double)task.getMaximum()); |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public void errorOccurred(final PCGenTaskEvent event) |
| 92 | { |
| 93 | Logging.errorPrint("ignore this for now. Eventually do something useful"); |
| 94 | throw new UnsupportedOperationException("Not supported yet."); |
| 95 | |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * indicates that preloading is done. splash screen should "go away" |
| 100 | */ |
| 101 | public void done() |
| 102 | { |
nothing calls this directly
no outgoing calls
no test coverage detected