private ResourceFactory getResourceFactory() { if (resourceFactory == null) { AddonRegistry addonRegistry = Furnace.instance(getClass().getClassLoader()).getAddonRegistry(); this.resourceFactory = addonRegistry.getServices(ResourceFactory.class).get(); } return resourceFactory; } }
private ForgeScriptEngineFactory getEngineFactory() { if (engineFactory == null) { AddonRegistry addonRegistry = Furnace.instance(getClass().getClassLoader()).getAddonRegistry(); this.engineFactory = addonRegistry.getServices(ForgeScriptEngineFactory.class).get(); } return engineFactory; }
@Override protected ProjectFactory getProjectFactory() { Furnace furnace = Furnace.instance(getClass().getClassLoader()); AddonRegistry addonRegistry = furnace.getAddonRegistry(); return addonRegistry.getServices(ProjectFactory.class).get(); }
/** * @return the possible value choices for the extends input */ protected Collection<JavaResource> getExtendsValueChoices(Project project) { AddonRegistry addonRegistry = Furnace.instance(getClass().getClassLoader()).getAddonRegistry(); ProjectOperations projectOperations = addonRegistry.getServices(ProjectOperations.class).get(); return projectOperations.getProjectClasses(project); }
/** * @return the possible value choices for the implements input */ protected Collection<JavaResource> getImplementsValueChoices(Project project) { AddonRegistry addonRegistry = Furnace.instance(getClass().getClassLoader()).getAddonRegistry(); ProjectOperations projectOperations = addonRegistry.getServices(ProjectOperations.class).get(); return projectOperations.getProjectInterfaces(project); }
ForgeScriptEngine(ForgeScriptEngineFactory factory) { this.factory = factory; AddonRegistry addonRegistry = Furnace.instance(getClass().getClassLoader()).getAddonRegistry(); this.shellFactory = addonRegistry.getServices(ShellFactory.class).get(); this.resourceFactory = addonRegistry.getServices(ResourceFactory.class).get(); }
@Override public void initializeUI(UIBuilder builder) throws Exception { Project project = getSelectedProject(builder); InputComponentFactory inputFactory = builder.getInputComponentFactory(); Furnace furnace = Furnace.instance(getClass().getClassLoader()); AddonRegistry addonRegistry = furnace.getAddonRegistry(); ConverterFactory converterFactory = addonRegistry.getServices(ConverterFactory.class).get(); ProjectOperations projectOperations = addonRegistry.getServices(ProjectOperations.class).get(); List<JavaResource> projectClasses = projectOperations.getProjectClasses(project); targetClasses = inputFactory.createSelectMany("targetClasses", String.class) .setLabel("Target Class") .setDescription("The class where the field will be created").setRequired(true) .setValueChoices( projectClasses.stream() .filter(JavaGenerateSerialVersionUIDCommand::isSerializable) .map(Objects::toString) .collect(Collectors.toList())); UIContext uiContext = builder.getUIContext(); UISelection<Object> initialSelection = uiContext.getInitialSelection(); if (initialSelection.get() instanceof JavaResource) { InputComponents.setValueFor(converterFactory, targetClasses, ((JavaResource) initialSelection.get()).getJavaType().getQualifiedName()); } useDefaultValue = inputFactory.createInput("useDefaultValue", Boolean.class) .setLabel("Generate Default Value?") .setDescription("If true, sets the serialVersionUID field to 1L"); builder.add(targetClasses).add(useDefaultValue); }