@Override public Builder<?> getBuilder(Class<?> type) { Builder<?> builder = null; if (deligator != null) { Builder<?> userBuilder = deligator.getBuilder(type); if (userBuilder != null) { return userBuilder; } } if (type == Button.class) { builder = new GargoyleButtonBuilder(); } else if (type == TableView.class) { builder = new GargoyleTableViewBuilder(); } return builder; }
@Override public Builder<?> getBuilder(Class<?> type) { if(type == ImageGrid.class) { return new ImageGridBuilder(imageViewFactory, fileUtils); } return new JavaFXBuilderFactory().getBuilder(type); }
@Override public Builder<?> getBuilder(Class<?> type) { Builder<?> builder = null; if (type == Button.class) { builder = new GargoyleButtonBuilder(); } return builder; }
@Override public Builder<?> getBuilder(Class<?> type) { if(packages.stream().anyMatch(p -> type.getPackage().getName().indexOf(p) == 0)) { try { Object bean = applicationContext.getBean(type); return () -> bean; } catch(NoSuchBeanDefinitionException ex) { return null; } } return null; }
@Override public Builder<?> getBuilder(Class<?> type) { Builder<?> builder = builders.computeIfAbsent(type, t -> { Map<String, ?> beansOfType = beanFactory.getBeansOfType(type, true, false); if (beansOfType.isEmpty()) { return NULL_BUILDER; } return () -> beanFactory.getBean(type); }); return builder == NULL_BUILDER ? null : builder; }
/** * Default constructor. */ CdiFXMLLoader() { super(); // Uses the currently loaded CDI implementation to look up controller classes // that have been specified via "fx:controller='...'" in our FXML files. this.setControllerFactory((aClass) -> CDI.current().select(aClass)); // Initializes the default JavaFX builder factory to be used for non CDI-aware beans. this.defaultBuilderFactory = new JavaFXBuilderFactory(); this.setBuilderFactory((aClass) -> { // Uses the default builder factory to retrieve builders where applicable. final Builder<?> defaultBuilder = defaultBuilderFactory.getBuilder(aClass); if (defaultBuilder != null) { return defaultBuilder; } // Make sure that we use a "null" builder for components that are 'blacklisted'. final String packageName = aClass.getPackage().getName(); for (final String blacklisted : CDI_BLACKLIST) { if (packageName.startsWith(blacklisted)) { return null; } } return new CdiFXMLComponentBuilder(aClass); }); }