1 /* 2 * ************************************************************************************************************************************************************* 3 * 4 * SteelBlue: DCI User Interfaces 5 * http://tidalwave.it/projects/steelblue 6 * 7 * Copyright (C) 2015 - 2025 by Tidalwave s.a.s. (http://tidalwave.it) 8 * 9 * ************************************************************************************************************************************************************* 10 * 11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 12 * You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 17 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 18 * 19 * ************************************************************************************************************************************************************* 20 * 21 * git clone https://bitbucket.org/tidalwave/steelblue-src 22 * git clone https://github.com/tidalwave-it/steelblue-src 23 * 24 * ************************************************************************************************************************************************************* 25 */ 26 package it.tidalwave.ui.example.presentation.javafx; 27 28 import jakarta.annotation.Nonnull; 29 import javafx.util.Duration; 30 import org.springframework.context.ApplicationContext; 31 import org.springframework.context.annotation.ComponentScan; 32 import org.springframework.context.annotation.Configuration; 33 import org.springframework.context.annotation.EnableAspectJAutoProxy; 34 import org.springframework.context.annotation.aspectj.EnableSpringConfigured; 35 import it.tidalwave.ui.javafx.JavaFXSpringAnnotationApplication; 36 import it.tidalwave.ui.javafx.JavaFXSpringApplication; 37 import it.tidalwave.ui.example.presentation.MainPanelPresentationControl; 38 39 /*************************************************************************************************************************************************************** 40 * 41 * The main class extends {@link JavaFXSpringApplication} and invokes a starting method on a controller that boots the application. 42 * 43 * @author Fabrizio Giudici 44 * 45 **************************************************************************************************************************************************************/ 46 // START SNIPPET: annotations 47 @Configuration 48 @EnableSpringConfigured 49 @EnableAspectJAutoProxy 50 @ComponentScan(basePackages = "it.tidalwave") 51 // @EnableMessageBus 52 public class Main extends JavaFXSpringAnnotationApplication 53 // END SNIPPET: annotations 54 { 55 /*********************************************************************************************************************************************************** 56 * JavaFX and Spring are automatically booted with an implicit configuration: 57 * <ul> 58 * <li>The FXML resource for the main UI is loaded from the same package as this class, and the name's {@code Application.fxml}</li> 59 * <li>A splash screen is created from a FXML resource in the same package as this class and name {@code Splash.fxml}, It is rendered on the screen while 60 * the system is initialised in background.</li> 61 * </ul> 62 **********************************************************************************************************************************************************/ 63 // START SNIPPET: main 64 public static void main (@Nonnull final String [] args) 65 { 66 launch(Main.class, 67 params().withArgs(args) 68 .withApplicationName("SteelBlueExample") 69 .withLogFolderPropertyName("it.tidalwave.ui.example.logFolder") // referenced in the logger configuration 70 // .withProperty(K_FULL_SCREEN, true) 71 // .withProperty(K_FULL_SCREEN_LOCKED, true) 72 // .withProperty(K_MAXIMIZED, true) 73 .withProperty(K_MIN_SPLASH_DURATION, Duration.seconds(3)) 74 .withProperty(K_INITIAL_SIZE, 0.8)); // initial windows size (in percentage) 75 } 76 // END SNIPPET: main 77 78 /*********************************************************************************************************************************************************** 79 * This method retrieves a reference to the main controller and boots it. 80 **********************************************************************************************************************************************************/ 81 // START SNIPPET: onStageCreated 82 @Override 83 protected void onStageCreated (@Nonnull final ApplicationContext applicationContext) 84 { 85 // Because of STB-78, it's advisable not to user @PostConstruct to initialise controllers. 86 applicationContext.getBean(MainPanelPresentationControl.class).populate(); 87 88 // If one likes pubsub, an alternate approach is to fire an event to notify initialization. 89 // See also EnableMessageBus to simplify implementation. 90 // applicationContext.getBean(MessageBus.class).publish(new PowerOnEvent()); 91 } 92 // END SNIPPET: onStageCreated 93 }