public FXMLLoader fxmlLoader() { final FXMLLoader loader = new FXMLLoader(StandardCharsets.UTF_8); loader.setControllerFactory(clazz -> MapStream.of(constructors) .filterKey(clazz::isAssignableFrom) .values() .findFirst() .map(Supplier::get) .map(injector::inject) .orElseThrow(() -> new SpeedmentToolException( "FXML Controller '" + clazz.getName() + "' have not been installed in " + getClass().getSimpleName() + "." ))); return loader; }
loader.setControllerFactory(clazz -> { ref.set(new NotificationController(message, icon, palette, onClose)); return ref.get();
fxmlLoader.setControllerFactory(type -> { if (type == AuxclasspathSetupController.class) { return this;
SourceEditorController sourceEditorController = new SourceEditorController(owner, mainController); loader.setControllerFactory(type -> { if (type == MainDesignerController.class) { return mainController;
/** * Load synchronously. * * @param resource * the resource * @param bundle * the bundle * @return the FXML loader * @throws IllegalStateException * the illegal state exception */ private FXMLLoader loadSynchronously(final URL resource, final Optional<ResourceBundle> bundle) throws IllegalStateException { final FXMLLoader loader = new FXMLLoader(resource, bundle.orElse(null)); loader.setControllerFactory(this::createControllerForType); try { loader.load(); } catch (final IOException | IllegalStateException e) { throw new IllegalStateException("Cannot load " + getConventionalName(), e); } return loader; }
FXMLLoader loadSynchronously(final URL resource, ResourceBundle bundle, final String conventionalName) throws IllegalStateException { final FXMLLoader loader = new FXMLLoader(resource, bundle); PresenterFactory factory = discover(); Callback<Class<?>, Object> controllerFactory = (Class<?> p) -> factory.instantiatePresenter(p, this.injectionContext); loader.setControllerFactory(controllerFactory); try { loader.load(); } catch (IOException ex) { throw new IllegalStateException("Cannot load " + conventionalName, ex); } return loader; }
private FXMLLoader createLoader(final Object controller, String fxmlName, ViewConfiguration viewConfiguration) throws FxmlLoadException { Class<?> controllerClass = controller.getClass(); String foundFxmlName = getFxmlName(controllerClass); if (fxmlName != null) { foundFxmlName = fxmlName; } if (foundFxmlName == null) { throw new FxmlLoadException("No FXML File specified!"); } FXMLLoader fxmlLoader = new FXMLLoader( controllerClass.getResource(foundFxmlName)); fxmlLoader.setBuilderFactory(viewConfiguration.getBuilderFactory()); fxmlLoader.setCharset(viewConfiguration.getCharset()); fxmlLoader.setResources(viewConfiguration.getResources()); fxmlLoader.setController(controller); fxmlLoader.setControllerFactory(c -> controller); return fxmlLoader; }
loader.setControllerFactory(controllerFactory);
private FXMLLoader createLoader(final Object controller, String fxmlName, ViewConfiguration viewConfiguration) throws FxmlLoadException { Class<?> controllerClass = controller.getClass(); String foundFxmlName = getFxmlName(controllerClass); if (fxmlName != null) { foundFxmlName = fxmlName; } if (foundFxmlName == null) { throw new FxmlLoadException("No FXML File specified!"); } FXMLLoader fxmlLoader = new FXMLLoader( controllerClass.getResource(foundFxmlName)); fxmlLoader.setBuilderFactory(viewConfiguration.getBuilderFactory()); fxmlLoader.setCharset(viewConfiguration.getCharset()); fxmlLoader.setResources(viewConfiguration.getResources()); fxmlLoader.setController(controller); fxmlLoader.setControllerFactory(new Callback<Class<?>, Object>() { @Override public Object call(Class<?> arg0) { return controller; } }); return fxmlLoader; }
protected void configureFxmlLoader(@Nonnull FXMLLoader fxmlLoader) { fxmlLoader.setBuilderFactory(new GriffonBuilderFactory(getApplication(), getMvcGroup())); fxmlLoader.setResources(getApplication().getMessageSource().asResourceBundle()); fxmlLoader.setClassLoader(getApplication().getApplicationClassLoader().get()); fxmlLoader.setControllerFactory(klass -> getMvcGroup().getView()); }
loader.setControllerFactory(new Callback<Class<?>, Object>() { @Override public Object call(final Class<?> param) {
fxmlLoader.setControllerFactory(fxmlControllerFactory);