Search in sources :

Example 1 with MonitorManager

use of eu.ggnet.dwoss.assembly.client.support.monitor.MonitorManager in project dwoss by gg-net.

the class DwOssApplication method start.

/**
 * Starting the Deutsche Warenwirtschaft Open Source application.
 * The startup happens through the following steps:
 * <ol>
 * <li>Parameter validation via <a href="https://jcommander.org/">JCommander</a>. The required and optional parametes are defined here
 * {@link ConnectionParameter}.</li>
 * <li>Setting the LAF for Swing components via {@link LafMenuManager#loadAndSetUserLaf() }</li>
 * <li>Displaying a placeholder main pane and the blocking login screen.
 * <ul>
 * <li>The login screen has no authentification system on visibility but the user can already type in his username and password.</li>
 * <li>The guardian is set later and only then an authentification will happen, even if the user has pressed return before.</li>
 * <li>A red/green circle in the ui displays the status of the guardian (red meaning not yet set).</li>
 * </ul>
 * </li>
 * <li>Initialize the client backend, remote connections, saft core, and preparing the main view by wrapping the javafx pane in a swing frame.
 * <ul>
 * <li>{@link #initSeContainer() }</li>
 * <li>{@link #initGlobalExceptionHandling() }</li>
 * <li>{@link #initRemoteConnection(eu.ggnet.dwoss.assembly.client.support.ConnectionParameter) }</li>
 * <li>{@link #initMainPane() }</li>
 * <li>{@link #startSaftInitMainFrameAndWrapMainPane(javax.swing.JFrame, javafx.scene.layout.Pane, eu.ggnet.dwoss.assembly.client.support.ConnectionParameter)
 * }</li>
 * </ul>
 * </li>
 * <li>Activating the authentification in the login screen by calling {@link LoginScreenController#setAndActivateGuardian(eu.ggnet.saft.experimental.auth.Guardian)
 * with the remote guardian</li>
 * <li>Start the polling of server progress {@link MonitorManager#startPolling() }</li>
 * <li>Initialize the session timeout and global keys for manual logout and relocation of windows. Ctrl+Shift+L for manual logout and Ctrl+Shift+R for
 * relocation of all windows</li>
 * </ol>
 *
 * @param primaryStage primaryStage of application.
 * @throws Exception all possible exeptions.
 */
@Override
public void start(Stage primaryStage) throws Exception {
    try {
        // Parameter discovery is done here, cause a error will be shown via Ui.
        ConnectionParameter cp = new ConnectionParameter();
        JCommander.newBuilder().addObject(cp).programName(DwOssMain.class.getName()).build().parse(getParameters().getRaw().toArray(new String[] {}));
        L.debug("start() parameters discovered: {}", cp);
        LafMenuManager.loadAndSetUserLaf();
        createAndShowMainPane(primaryStage);
        // Creating the Swing MainFrame as long as we are in the Swing mode.
        JFrame mainFrame = new JFrame();
        LoginScreenController firstLoginScreen = createAndShowFirstLoginScreen(primaryStage, mainFrame);
        CompletableFuture.runAsync(() -> {
            container = initSeContainer();
            instance = container.getBeanManager().createInstance();
            saft = instance.select(Saft.class).get();
            UiCore.initGlobal(saft);
        }).thenRun(() -> initGlobalExceptionHandling()).thenRun(() -> initRemoteConnection(cp)).thenApply(v -> initMainPane()).thenAcceptAsync(mainView -> startSaftInitMainFrameAndWrapMainPane(mainFrame, mainView, cp), java.awt.EventQueue::invokeLater).thenRunAsync(() -> firstLoginScreen.setAndActivateGuardian(Dl.local().lookup(Guardian.class))).thenRun(() -> initOnceViews()).thenRun(() -> instance.select(MonitorManager.class).get().startPolling()).thenRun(() -> initSessionTimeoutAndManualLogoutKeys()).thenRun(() -> initRelocationKeys()).handle((v, ex) -> {
            new DwFinalExceptionConsumer(null).accept(Optional.empty(), ex);
            return null;
        });
    } catch (ParameterException e) {
        // Sout is here correct.
        System.out.println(e.getMessage());
        System.out.println();
        e.getJCommander().usage();
        Alert a = new Alert(javafx.scene.control.Alert.AlertType.ERROR);
        a.setTitle("Fehler beim Start");
        a.setHeaderText("Fehler bei Start.");
        a.setContentText("Es ist ein Fehler beim Start aufgetreten. Bitte Console und/oder Logs prüfen.");
        a.show();
    }
}
Also used : EventHandler(javafx.event.EventHandler) Scene(javafx.scene.Scene) UserInfoException(eu.ggnet.dwoss.core.common.UserInfoException) ParameterException(com.beust.jcommander.ParameterException) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) StackPane(javafx.scene.layout.StackPane) eu.ggnet.dwoss.assembly.client.support(eu.ggnet.dwoss.assembly.client.support) JFXPanel(javafx.embed.swing.JFXPanel) DossierFilterView(eu.ggnet.dwoss.redtapext.ui.dbs.DossierFilterView) Application(javafx.application.Application) Parent(javafx.scene.Parent) RedTapeView(eu.ggnet.dwoss.redtapext.ui.cao.RedTapeView) FXMLLoader(javafx.fxml.FXMLLoader) MonitorManager(eu.ggnet.dwoss.assembly.client.support.monitor.MonitorManager) ImageIcon(javax.swing.ImageIcon) Dl(eu.ggnet.dwoss.core.widget.Dl) eu.ggnet.dwoss.assembly.client.support.exception(eu.ggnet.dwoss.assembly.client.support.exception) JFrame(javax.swing.JFrame) Instance(javax.enterprise.inject.Instance) Pane(javafx.scene.layout.Pane) Alert(javafx.scene.control.Alert) Modality(javafx.stage.Modality) Label(javafx.scene.control.Label) javafx.scene.input(javafx.scene.input) Logger(org.slf4j.Logger) SeContainerInitializer(javax.enterprise.inject.se.SeContainerInitializer) RemoteLookup(eu.ggnet.dwoss.core.widget.dl.RemoteLookup) CachedMandators(eu.ggnet.dwoss.mandator.spi.CachedMandators) eu.ggnet.dwoss.assembly.client.support.login(eu.ggnet.dwoss.assembly.client.support.login) Swing(eu.ggnet.saft.core.impl.Swing) JCommander(com.beust.jcommander.JCommander) IOException(java.io.IOException) WindowAdapter(java.awt.event.WindowAdapter) SearchCask(eu.ggnet.dwoss.search.ui.SearchCask) WindowEvent(java.awt.event.WindowEvent) StandardCharsets(java.nio.charset.StandardCharsets) EventType(javafx.event.EventType) Platform(javafx.application.Platform) Saft(eu.ggnet.saft.core.Saft) ConstraintViolationException(javax.validation.ConstraintViolationException) Stage(javafx.stage.Stage) Guardian(eu.ggnet.dwoss.core.widget.auth.Guardian) UiCore(eu.ggnet.saft.core.UiCore) SeContainer(javax.enterprise.inject.se.SeContainer) Optional(java.util.Optional) RawReportView(eu.ggnet.dwoss.report.ui.RawReportView) JFrame(javax.swing.JFrame) Guardian(eu.ggnet.dwoss.core.widget.auth.Guardian) ParameterException(com.beust.jcommander.ParameterException) Alert(javafx.scene.control.Alert)

Aggregations

JCommander (com.beust.jcommander.JCommander)1 ParameterException (com.beust.jcommander.ParameterException)1 eu.ggnet.dwoss.assembly.client.support (eu.ggnet.dwoss.assembly.client.support)1 eu.ggnet.dwoss.assembly.client.support.exception (eu.ggnet.dwoss.assembly.client.support.exception)1 eu.ggnet.dwoss.assembly.client.support.login (eu.ggnet.dwoss.assembly.client.support.login)1 MonitorManager (eu.ggnet.dwoss.assembly.client.support.monitor.MonitorManager)1 UserInfoException (eu.ggnet.dwoss.core.common.UserInfoException)1 Dl (eu.ggnet.dwoss.core.widget.Dl)1 Guardian (eu.ggnet.dwoss.core.widget.auth.Guardian)1 RemoteLookup (eu.ggnet.dwoss.core.widget.dl.RemoteLookup)1 CachedMandators (eu.ggnet.dwoss.mandator.spi.CachedMandators)1 RedTapeView (eu.ggnet.dwoss.redtapext.ui.cao.RedTapeView)1 DossierFilterView (eu.ggnet.dwoss.redtapext.ui.dbs.DossierFilterView)1 RawReportView (eu.ggnet.dwoss.report.ui.RawReportView)1 SearchCask (eu.ggnet.dwoss.search.ui.SearchCask)1 Saft (eu.ggnet.saft.core.Saft)1 UiCore (eu.ggnet.saft.core.UiCore)1 Swing (eu.ggnet.saft.core.impl.Swing)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1