Method that is called by the JavaFX runtime @param primaryStage The initial Stage object
(final Stage primaryStage)
| 67 | * @param primaryStage The initial Stage object |
| 68 | */ |
| 69 | @Override |
| 70 | public void start(final Stage primaryStage) { |
| 71 | Platform.setImplicitExit(false); |
| 72 | final SettingsController settingsController; |
| 73 | |
| 74 | try { |
| 75 | settingsController = new SettingsController(SharedVariables.PROPERTIES_FILE_LOCATION, SharedVariables.PROPERTIES_RESOURCE_LOCATION); |
| 76 | } catch (final IOException ex) { |
| 77 | logger.fatal("Unable to initialize the SettingsController", ex); |
| 78 | FxUtils.showErrorAlert("Exception occurred", ex.toString(), getClass().getResourceAsStream(SharedVariables.ICON_URL)); |
| 79 | Platform.exit(); |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | final Properties properties = settingsController.getProperties(); |
| 84 | final String languageTag = properties.getProperty("locale", DEFAULT_LOCALE); |
| 85 | |
| 86 | ThemeController.setTheme(properties.getProperty("theme", "light")); |
| 87 | |
| 88 | final Locale locale = Locale.forLanguageTag(languageTag); |
| 89 | final ResourceBundle translationBundle = ResourceBundle.getBundle("translations.OpalApplication", locale); |
| 90 | |
| 91 | final FXMLLoader loader = new FXMLLoader(getClass().getResource("/windows/MainWindow.fxml"), translationBundle); |
| 92 | Parent root; |
| 93 | try { |
| 94 | root = loader.load(); |
| 95 | } catch (final IOException ex) { |
| 96 | logger.fatal("Unable to load FXML for MainWindow", ex); |
| 97 | Platform.exit(); |
| 98 | return; |
| 99 | } |
| 100 | |
| 101 | logger.info("Creating the MainWindowController"); |
| 102 | |
| 103 | final MainWindowController mainWindowController = loader.getController(); |
| 104 | final UpdateController updateController = new UpdateController(properties.getProperty("updateApi", "https://codedead.com/Software/Opal/version.json"), SharedVariables.CURRENT_VERSION); |
| 105 | mainWindowController.setControllers(settingsController, updateController); |
| 106 | |
| 107 | final Scene scene = new Scene(root); |
| 108 | |
| 109 | primaryStage.setTitle(translationBundle.getString("MainWindowTitle")); |
| 110 | primaryStage.getIcons().add(new Image(Objects.requireNonNull(getClass().getResourceAsStream(SharedVariables.ICON_URL)))); |
| 111 | primaryStage.setScene(scene); |
| 112 | primaryStage.setOnCloseRequest(_ -> System.exit(0)); |
| 113 | |
| 114 | logger.info("Showing the MainWindow"); |
| 115 | primaryStage.show(); |
| 116 | } |
| 117 | } |
no test coverage detected