mvvmfx/src/main/java/de/saxsys/mvvmfx/internal/viewloader/FxmlViewLoader.java
private  <ViewType extends View<? extends ViewModelType>, ViewModelType extends ViewModel> ViewTuple<ViewType, ViewModelType> loadFxmlViewTuple(
			final Class<?> resourceLoader, final String resource, ResourceBundle resourceBundle, final ViewType codeBehind, final Object root,
			ViewModelType viewModel, Context parentContext, Collection<Scope> providedScopes,
			List<BuilderFactory> builderFactories) {
        try {

            // FIXME Woanders hin?
            ContextImpl context = ViewLoaderScopeUtils.prepareContext(parentContext, providedScopes);
            //////////////////////////////////////////////////////////////////////

            // for the SceneLifecycle we need to know when the view is put into the scene
            BooleanProperty viewInSceneProperty = new SimpleBooleanProperty();

            final FXMLLoader loader = createFxmlLoader(resourceLoader, resource, resourceBundle, codeBehind, root, viewModel, context, viewInSceneProperty, builderFactories);

            loader.load();

            final ViewType loadedController = loader.getController();
            final Parent loadedRoot = loader.getRoot();

            viewInSceneProperty.bind(loadedRoot.sceneProperty().isNotNull());

            if (loadedController == null) {
                throw new IOException("Could not load the controller for the View " + resource
                        + " maybe your missed the fx:controller in your fxml?");
            }

            // the actually used ViewModel instance. We need this so we can
            // return it in the ViewTuple
            ViewModelType actualViewModel;

            // FIXME CONTEXT

            // if no existing viewModel was provided...
            if (viewModel == null) {
                // ... we try to find the created ViewModel from the codeBehind.
                // this is only possible when the codeBehind has a field for the
                // VM and the VM was injected
                actualViewModel = ViewLoaderReflectionUtils.getExistingViewModel(loadedController);

                // otherwise we create a new ViewModel. This is needed because
                // the ViewTuple has to contain a VM even if
                // the codeBehind doesn't need one
                if (actualViewModel == null) {
                    actualViewModel = ViewLoaderReflectionUtils.createViewModel(loadedController);

                    // it is possible that no viewModel could be created (f.e.
                    // when no generic VM type was specified)
                    // otherwise we need to initialize the created ViewModel
                    // instance.
                    if (actualViewModel != null) {
                        ViewLoaderReflectionUtils.initializeViewModel(actualViewModel);
                    }
                }
            } else {
                actualViewModel = viewModel;
            }
            if (actualViewModel != null) {
                // TODO: Create Testcase for this corner case:
                // If this view is the root view (the one that is loaded with
                // the FluentViewLoader)
                // but in the view there is no injection of the ViewModel
                // only in this case the scope has to be injected here,
                // If the viewModel was already injected in the View, it has
                // it's scopes already injected
                // ViewLoaderReflectionUtils.createAndInjectScopes(actualViewModel,
                // context);
            }

            return new ViewTuple<>(loadedController, loadedRoot, actualViewModel);

        } catch (final IOException ex) {
            throw new RuntimeException(ex);
        }
    }
private  <ViewType extends View<? extends ViewModelType>, ViewModelType extends ViewModel> ViewTuple<ViewType, ViewModelType> loadFxmlViewTuple(
			final Class<?> resourceLoader, final String resource, ResourceBundle resourceBundle, final ViewType codeBehind, final Object root,
			ViewModelType viewModel, Context parentContext, Collection<Scope> providedScopes,
			List<BuilderFactory> builderFactories) {
        try {

            // FIXME Woanders hin?
            ContextImpl context = ViewLoaderScopeUtils.prepareContext(parentContext, providedScopes);
            //////////////////////////////////////////////////////////////////////

            // for the SceneLifecycle we need to know when the view is put into the scene
            BooleanProperty viewInSceneProperty = new SimpleBooleanProperty();

            final FXMLLoader loader = createFxmlLoader(resourceLoader, resource, resourceBundle, codeBehind, root, viewModel, context, viewInSceneProperty, builderFactories);

            loader.load();

            final ViewType loadedController = loader.getController();
            final Parent loadedRoot = loader.getRoot();

            viewInSceneProperty.bind(loadedRoot.sceneProperty().isNotNull());

            if (loadedController == null) {
                throw new IOException("Could not load the controller for the View " + resource
                        + " maybe your missed the fx:controller in your fxml?");
            }

            // the actually used ViewModel instance. We need this so we can
            // return it in the ViewTuple
            ViewModelType actualViewModel;

            // FIXME CONTEXT

            // if no existing viewModel was provided...
            if (viewModel == null) {
                // ... we try to find the created ViewModel from the codeBehind.
                // this is only possible when the codeBehind has a field for the
                // VM and the VM was injected
                actualViewModel = ViewLoaderReflectionUtils.getExistingViewModel(loadedController);

                // otherwise we create a new ViewModel. This is needed because
                // the ViewTuple has to contain a VM even if
                // the codeBehind doesn't need one
                if (actualViewModel == null) {
                    actualViewModel = ViewLoaderReflectionUtils.createViewModel(loadedController);

                    // it is possible that no viewModel could be created (f.e.
                    // when no generic VM type was specified)
                    // otherwise we need to initialize the created ViewModel
                    // instance.
                    if (actualViewModel != null) {
                        ViewLoaderReflectionUtils.initializeViewModel(actualViewModel);
                    }
                }
            } else {
                actualViewModel = viewModel;
            }
            if (actualViewModel != null) {
                // TODO: Create Testcase for this corner case:
                // If this view is the root view (the one that is loaded with
                // the FluentViewLoader)
                // but in the view there is no injection of the ViewModel
                // only in this case the scope has to be injected here,
                // If the viewModel was already injected in the View, it has
                // it's scopes already injected
                // ViewLoaderReflectionUtils.createAndInjectScopes(actualViewModel,
                // context);
            }

            return new ViewTuple<>(loadedController, loadedRoot, actualViewModel);

        } catch (final IOException ex) {
            throw new RuntimeException(ex);
        }
    }
private < ViewType extends View < ? extends ViewModelType > , ViewModelType extends ViewModel > ViewTuple < ViewType , ViewModelType > loadFxmlViewTuple ( final Class < ? > resourceLoader , final String resource , ResourceBundle resourceBundle , final ViewType codeBehind , final Object root , ViewModelType viewModel , Context parentContext , Collection < Scope > providedScopes , List < BuilderFactory > builderFactories ) { try { // FIXME Woanders hin? ContextImpl context = ViewLoaderScopeUtils . prepareContext ( parentContext , providedScopes ) ; ////////////////////////////////////////////////////////////////////// // for the SceneLifecycle we need to know when the view is put into the scene BooleanProperty viewInSceneProperty = new SimpleBooleanProperty ( ) ; final FXMLLoader loader = createFxmlLoader ( resourceLoader , resource , resourceBundle , codeBehind , root , viewModel , context , viewInSceneProperty , builderFactories ) ; loader . load ( ) ; final ViewType loadedController = loader . getController ( ) ; final Parent loadedRoot = loader . getRoot ( ) ; viewInSceneProperty . bind ( loadedRoot . sceneProperty ( ) . isNotNull ( ) ) ; if ( loadedController == null ) { throw new IOException ( "Could not load the controller for the View " + resource + " maybe your missed the fx:controller in your fxml?" ) ; } // the actually used ViewModel instance. We need this so we can // return it in the ViewTuple ViewModelType actualViewModel ; // FIXME CONTEXT // if no existing viewModel was provided... if ( viewModel == null ) { // ... we try to find the created ViewModel from the codeBehind. // this is only possible when the codeBehind has a field for the // VM and the VM was injected actualViewModel = ViewLoaderReflectionUtils . getExistingViewModel ( loadedController ) ; // otherwise we create a new ViewModel. This is needed because // the ViewTuple has to contain a VM even if // the codeBehind doesn't need one if ( actualViewModel == null ) { actualViewModel = ViewLoaderReflectionUtils . createViewModel ( loadedController ) ; // it is possible that no viewModel could be created (f.e. // when no generic VM type was specified) // otherwise we need to initialize the created ViewModel // instance. if ( actualViewModel != null ) { ViewLoaderReflectionUtils . initializeViewModel ( actualViewModel ) ; } } } else { actualViewModel = viewModel ; } if ( actualViewModel != null ) { // TODO: Create Testcase for this corner case: // If this view is the root view (the one that is loaded with // the FluentViewLoader) // but in the view there is no injection of the ViewModel // only in this case the scope has to be injected here, // If the viewModel was already injected in the View, it has // it's scopes already injected // ViewLoaderReflectionUtils.createAndInjectScopes(actualViewModel, // context); } return new ViewTuple <> ( loadedController , loadedRoot , actualViewModel ) ; } catch ( final IOException ex ) { throw new RuntimeException ( ex ) ; } }
Load the viewTuple by the path of the fxml file.

@param resourceLoader
class used to load resource. When null {@link FxmlViewLoader} is used
@param resource
the string path to the fxml file that is loaded.
@param resourceBundle
the resourceBundle that is passed to the
{@link javafx.fxml.FXMLLoader}.
@param codeBehind
the controller instance that is passed to the
{@link javafx.fxml.FXMLLoader}
@param root
the root object that is passed to the
{@link javafx.fxml.FXMLLoader}
@param viewModel
the viewModel instance that is used when loading the
viewTuple.
@param <ViewType>
the generic type of the view.
@param <ViewModelType>
the generic type of the viewModel.
@param builderFactories a list of custom builder factories. may be <code>null</code>
@return the loaded ViewTuple.
Load the viewTuple by the path of the fxml file .