001/*
002 * Copyright 2019-2021 M. Sean Gilligan.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package app.supernaut.fx.fxml;
017
018import app.supernaut.fx.ApplicationDelegate;
019
020import javafx.stage.Stage;
021
022/**
023 * ApplicationDelegate with constructor that expects a {@link FxmlLoaderFactory}
024 */
025public class BaseFxmlAppDelegate implements ApplicationDelegate {
026    /** {@link FxmlLoaderFactory} for subclass access */
027    protected final FxmlLoaderFactory fxmlLoaderFactory;
028
029    /**
030     * Constructor that gets an {@link FxmlLoaderFactory} injected
031     *
032     * @param fxmlLoaderFactory the injected factory
033     */
034    public BaseFxmlAppDelegate(FxmlLoaderFactory fxmlLoaderFactory) {
035        this.fxmlLoaderFactory = fxmlLoaderFactory;
036    }
037
038    /**
039     * No-op start method (can be overridden)
040     * 
041     * @param primaryStage primary {@link Stage}
042     * @throws Exception An exception occurred
043     */
044    @Override
045    public void start(Stage primaryStage) throws Exception {
046    }
047
048    /**
049     * Accessor for injected {@link FxmlLoaderFactory}
050     * @return the injected factory
051     */
052    public FxmlLoaderFactory getFxmlLoaderFactory() {
053        return fxmlLoaderFactory;
054    }
055}