org.jboss.forge.addon.ui.context.UIBuilder Java Examples
The following examples show how to use
org.jboss.forge.addon.ui.context.UIBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NewIntegrationTestBuildCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(final UIBuilder builder) throws Exception { super.initializeUI(builder); buildName.setDefaultValue(new Callable<String>() { @Override public String call() throws Exception { Model mavenModel = getMavenModel(builder); if (mavenModel != null) { return mavenModel.getArtifactId() + "-int-test"; } return null; } }); builder.add(buildName); builder.add(mavenCommand); builder.add(image); builder.add(gitUri); }
Example #2
Source File: CamelAddRouteXmlCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { Map<Object, Object> attributeMap = builder.getUIContext().getAttributeMap(); attributeMap.remove("navigationResult"); Project project = getSelectedProject(builder.getUIContext()); String currentFile = getSelectedFile(builder.getUIContext()); // include custom components discoverCustomCamelComponentsOnClasspathAndAddToCatalog(camelCatalog, project); // we only want components that is able to consume because this is to add a new route configureComponentName(project, componentName, true, false); configureXml(project, xml, currentFile); builder.add(xml).add(id).add(componentName); }
Example #3
Source File: CamelEditComponentCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { final Project project = getSelectedProject(builder); Map<Object, Object> attributeMap = builder.getUIContext().getAttributeMap(); attributeMap.remove("navigationResult"); // include custom components discoverCustomCamelComponentsOnClasspathAndAddToCatalog(camelCatalog, project); // find all components in project (and filter out components without options) Iterable<ComponentDto> it = CamelCommandsHelper.createComponentDtoValues(project, getCamelCatalog(), null, false, false, false, true).call(); componentName.setValueChoices(it); builder.add(componentName); }
Example #4
Source File: CamelNewRouteBuilderCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { Project project = getSelectedProject(builder.getUIContext()); JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); targetPackage.setCompleter(new PackageNameCompleter(facet)); targetPackage.addValidator(new PackageNameValidator()); targetPackage.getFacet(HintsFacet.class).setInputType(InputType.JAVA_PACKAGE_PICKER); // if there is only one package then use that as default Set<String> packages = new RouteBuilderCompleter(facet).getPackages(); if (packages.size() == 1) { targetPackage.setDefaultValue(first(packages)); } name.addValidator(new ClassNameValidator(false)); name.getFacet(HintsFacet.class).setInputType(InputType.JAVA_CLASS_PICKER); builder.add(targetPackage).add(name); }
Example #5
Source File: ReplicationControllerDelete.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { super.initializeUI(builder); // populate autocompletion options replicationControllerId.setCompleter(new UICompleter<String>() { @Override public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) { List<String> list = new ArrayList<String>(); ReplicationControllerList replicationControllers = getKubernetes().replicationControllers().inNamespace(getNamespace()).list(); if (replicationControllers != null) { List<ReplicationController> items = replicationControllers.getItems(); if (items != null) { for (ReplicationController item : items) { String id = KubernetesHelper.getName(item); list.add(id); } } } Collections.sort(list); return list; } }); builder.add(replicationControllerId); }
Example #6
Source File: CamelAddNodeXmlCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { UIContext context = builder.getUIContext(); Map<Object, Object> attributeMap = context.getAttributeMap(); attributeMap.remove("navigationResult"); Project project = getSelectedProject(context); String currentFile = getSelectedFile(context); String selected = configureXml(project, xml, currentFile); parents = configureXmlNodes(context, project, selected, xml, parent); nameFilter.setValueChoices(CamelCommandsHelper.createEipLabelValues(project, getCamelCatalog())); nameFilter.setDefaultValue("<all>"); name.setValueChoices(CamelCommandsHelper.createAllEipDtoValues(project, getCamelCatalog(), nameFilter)); // include converter from string->dto name.setValueConverter(text -> createEipDto(getCamelCatalog(), text)); builder.add(xml).add(parent).add(nameFilter).add(name); }
Example #7
Source File: CamelNewComponentCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { Project project = getSelectedProject(builder.getUIContext()); final JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); // filter the list of components based on consumer and producer only configureComponentName(project, componentName, false, false); targetPackage.setCompleter(new PackageNameCompleter(facet)); targetPackage.addValidator(new PackageNameValidator()); targetPackage.getFacet(HintsFacet.class).setInputType(InputType.JAVA_PACKAGE_PICKER); // if there is only one package then use that as default Set<String> packages = new RouteBuilderCompleter(facet).getPackages(); if (packages.size() == 1) { targetPackage.setDefaultValue(first(packages)); } className.addValidator(new ClassNameValidator(false)); className.getFacet(HintsFacet.class).setInputType(InputType.JAVA_CLASS_PICKER); builder.add(componentName).add(instanceName).add(targetPackage).add(className); }
Example #8
Source File: CamelProjectAddComponentStep.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { final Project project = getSelectedProject(builder); Iterable<ComponentDto> it = CamelCommandsHelper.createAllComponentDtoValues(project, getCamelCatalog(), filter, true).call(); // flattern the choices to a map so the UI is more responsive, as we can do a direct lookup // in the map from the value converter final Map<String, ComponentDto> components = new LinkedHashMap<>(); for (ComponentDto dto : it) { components.put(dto.getScheme(), dto); } componentName.setValueChoices(components.values()); // include converter from string->dto componentName.setValueConverter(components::get); builder.add(componentName); }
Example #9
Source File: ServiceDelete.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { super.initializeUI(builder); // populate autocompletion options serviceId.setCompleter(new UICompleter<String>() { @Override public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) { List<String> list = new ArrayList<String>(); ServiceList services = getKubernetes().services().inNamespace(getNamespace()).list(); if (services != null) { List<Service> items = services.getItems(); if (items != null) { for (Service item : items) { String id = KubernetesHelper.getName(item); list.add(id); } } } Collections.sort(list); return list; } }); builder.add(serviceId); }
Example #10
Source File: CamelAddEndpointXmlCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { UIContext context = builder.getUIContext(); Map<Object, Object> attributeMap = context.getAttributeMap(); attributeMap.remove("navigationResult"); Project project = getSelectedProject(context); String currentFile = getSelectedFile(context); // include custom components discoverCustomCamelComponentsOnClasspathAndAddToCatalog(camelCatalog, project); configureComponentName(project, componentName, false, false); String selected = configureXml(project, xml, currentFile); nodes = configureXmlNodes(context, project, selected, xml, node); builder.add(xml).add(node).add(componentName); }
Example #11
Source File: CamelNewCamelContextXmlCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { Project project = getSelectedProject(builder.getUIContext()); boolean blueprint = CamelCommandsHelper.isBlueprintProject(project); boolean spring = CamelCommandsHelper.isSpringProject(project); directory.getFacet(HintsFacet.class).setInputType(InputType.DIRECTORY_PICKER); if (blueprint) { directory.setDefaultValue("OSGI-INF/blueprint"); } else if (spring) { directory.setDefaultValue("META-INF/spring"); } XmlFileCompleter xmlFileCompleter = createXmlFileCompleter(builder.getUIContext(), null); Set<String> directories = xmlFileCompleter.getDirectories(); if (directories.size() == 1) { directory.setDefaultValue(first(directories)); } if (!directories.isEmpty()) { directory.setCompleter(new StringCompleter(directories)); } name.addValidator(new ResourceNameValidator("xml")); name.getFacet(HintsFacet.class).setInputType(InputType.FILE_PICKER); builder.add(directory).add(name); }
Example #12
Source File: GetPropertiesCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { /* className.setCompleter(new UICompleter<String>() { @Override public Iterable<String> getCompletionProposals(UIContext uiContext, InputComponent<?, String> inputComponent, String s) { Project project = getSelectedProject(uiContext); ClassScanner local = ClassScanner.newInstance(project); SortedSet<String> answer = local.findClassNames("", 0); local.dispose(); return answer; } }); */ inputComponents = CommandHelpers.addInputComponents(builder, classNames); }
Example #13
Source File: ScaffoldableEntitySelectionWizard.java From angularjs-addon with Eclipse Public License 1.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { UIContext uiContext = builder.getUIContext(); Project project = getSelectedProject(uiContext); JPAFacet<?> persistenceFacet = project.getFacet(JPAFacet.class); List<JavaClassSource> allEntities = persistenceFacet.getAllEntities(); List<JavaClassSource> supportedEntities = new ArrayList<>(); for (JavaClassSource entity : allEntities) { for (Member<?> member : entity.getMembers()) { // FORGE-823 Only add entities with @Id as valid entities for REST resource generation. // Composite keys are not yet supported. if (member.hasAnnotation(Id.class)) { supportedEntities.add(entity); } } } targets.setValueChoices(supportedEntities); targets.setItemLabelConverter(JavaClassSource::getQualifiedName); builder.add(targets).add(generateRestResources); }
Example #14
Source File: NewIntegrationTestClassCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(final UIBuilder builder) throws Exception { super.initializeUI(builder); Project project = getCurrentSelectedProject(builder.getUIContext()); if (project.hasFacet(JavaSourceFacet.class)) { JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); targetPackage.setCompleter(new TestPackageNameCompleter(facet)); } targetPackage.addValidator(new PackageNameValidator()); targetPackage.setDefaultValue("io.fabric8.itests"); className.addValidator(new ClassNameValidator(false)); className.setDefaultValue(new Callable<String>() { @Override public String call() throws Exception { return "IntegrationTestKT"; } }); builder.add(targetPackage).add(className).add(profile).add(integrationTestWildcard).add(itestPlugin); }
Example #15
Source File: DetectFractionsCommand.java From thorntail-addon with Eclipse Public License 1.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { InputComponentFactory factory = builder.getInputComponentFactory(); Project project = getSelectedProject(builder); inputDir = factory.createInput("inputDir", DirectoryResource.class).setLabel("Input Directory") .setDescription("Directory containing the compiled project sources").setRequired(true) .setDefaultValue(getTargetDirectory(project)); build = factory.createInput("build", Boolean.class).setLabel("Build Project?") .setDescription("Build project before attempting to auto-detect"); depend = factory.createInput("depend", Boolean.class) .setLabel("Add Missing Fractions as Project Dependencies?") .setDescription("Add missing fractions as project dependencies"); builder.add(inputDir).add(build).add(depend); }
Example #16
Source File: NewBuildCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(final UIBuilder builder) throws Exception { super.initializeUI(builder); buildName.setDefaultValue(new Callable<String>() { @Override public String call() throws Exception { Model mavenModel = getMavenModel(builder); if (mavenModel != null) { return mavenModel.getArtifactId(); } return null; } }); builder.add(buildName); builder.add(imageName); builder.add(gitUri); builder.add(outputImage); builder.add(webHookSecret); }
Example #17
Source File: CreateTestClassCommand.java From thorntail-addon with Eclipse Public License 1.0 | 5 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { InputComponentFactory inputFactory = builder.getInputComponentFactory(); targetPackage = inputFactory.createInput("targetPackage", String.class) .setLabel("Package Name") .setRequired(true) .setDescription("The package name where this type will be created"); targetPackage.getFacet(HintsFacet.class).setInputType(InputType.JAVA_PACKAGE_PICKER); targetPackage.setValueConverter(new PackageRootConverter(getProjectFactory(), builder)); targetPackage.setDefaultValue(calculateDefaultPackage(builder.getUIContext())); named = inputFactory.createInput("named", String.class) .setLabel("Type Name").setRequired(true) .setDescription("The type name"); named.addValidator((context) -> { if (!Types.isSimpleName(named.getValue())) context.addValidationError(named, "Invalid java type name."); }); asClient = inputFactory.createInput(ThorntailConfiguration.TEST_AS_CLIENT_FLAG_CONFIGURATION_ELEMENT, Boolean.class) .setLabel("As Client").setDescription("Sets test mode to as client."); archiveType = inputFactory.createSelectOne(ThorntailConfiguration.TEST_TYPE_CONFIGURATION_ELEMENT, String.class) .setLabel("Archive Type") .setDescription("Sets type of default archive") .setValueChoices(ARCHIVE_TYPES); builder.add(targetPackage) .add(named) .add(asClient) .add(archiveType); }
Example #18
Source File: AddFractionCommand.java From thorntail-addon with Eclipse Public License 1.0 | 5 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { InputComponentFactory factory = builder.getInputComponentFactory(); fractionElements = factory.createSelectMany("fractions", FractionDescriptor.class) .setLabel("Fraction List") .setDescription("Fraction list"); UIContext uiContext = builder.getUIContext(); if (uiContext.getProvider().isGUI()) { fractionElements.setItemLabelConverter(FractionDescriptor::getName); } else { fractionElements.setItemLabelConverter(FractionDescriptor::getArtifactId); } Project project = Projects.getSelectedProject(getProjectFactory(), uiContext); final Collection<FractionDescriptor> fractions; if (project != null && project.hasFacet(ThorntailFacet.class)) { fractions = project.getFacet(ThorntailFacet.class).getFractions(); } else { fractions = ThorntailFacet.getAllFractionDescriptors(); } final List<FractionDescriptor> nonInternalfractions = fractions.stream() .filter(f -> !f.isInternal()) .collect(Collectors.toList()); fractionElements.setValueChoices(nonInternalfractions); builder.add(fractionElements); }
Example #19
Source File: CamelProjectAddLanguageCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { Project project = getSelectedProject(builder); dtos = new CamelLanguagesCompleter(project, getCamelCatalog()).getValueChoices(); List<String> names = new ArrayList<>(); for (LanguageDto dto : dtos) { names.add(dto.getName()); } languageName.setValueChoices(names); builder.add(languageName); }
Example #20
Source File: CamelGetRoutesXmlCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { Project project = getSelectedProject(builder.getUIContext()); String currentFile = getSelectedFile(builder.getUIContext()); String selected = configureXml(project, xml, currentFile); builder.add(xml).add(format); }
Example #21
Source File: JSONRestResourceFromEntityCommand.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void initializeUI(UIBuilder builder) throws Exception { UIContext context = builder.getUIContext(); Project project = getSelectedProject(context); JPAFacet<PersistenceCommonDescriptor> persistenceFacet = project.getFacet(JPAFacet.class); JavaSourceFacet javaSourceFacet = project.getFacet(JavaSourceFacet.class); List<String> persistenceUnits = new ArrayList<>(); List<PersistenceUnitCommon> allUnits = persistenceFacet.getConfig().getAllPersistenceUnit(); for (PersistenceUnitCommon persistenceUnit : allUnits) { persistenceUnits.add(persistenceUnit.getName()); } if (!persistenceUnits.isEmpty()) { persistenceUnit.setValueChoices(persistenceUnits).setDefaultValue(persistenceUnits.get(0)); } // TODO: May detect where @Path resources are located packageName.setDefaultValue(javaSourceFacet.getBasePackage() + ".rest"); RestResourceGenerator defaultResourceGenerator = null; for (RestResourceGenerator generator : resourceGenerators) { if (generator.getName().equals(RestGenerationConstants.JPA_ENTITY)) { defaultResourceGenerator = generator; } } generator.setDefaultValue(defaultResourceGenerator); generator.setItemLabelConverter( context.getProvider().isGUI() ? RestResourceGenerator::getDescription : RestResourceGenerator::getName); builder.add(generator).add(packageName).add(persistenceUnit); }
Example #22
Source File: SetupCommand.java From thorntail-addon with Eclipse Public License 1.0 | 5 votes |
@Override public void initializeUI(UIBuilder builder) { InputComponentFactory inputFactory = builder.getInputComponentFactory(); httpPort = inputFactory.createInput("httpPort", Integer.class) .setLabel("HTTP Port").setDescription("HTTP Port Thorntail will listen to") .setDefaultValue(ThorntailConfiguration.HTTP_PORT_DEFAULT_VALUE); contextPath = inputFactory.createInput("contextPath", String.class) .setLabel("Context Path").setDescription("The context path of the web application") .setDefaultValue(ThorntailConfiguration.CONTEXT_PATH_DEFAULT_VALUE); portOffset = inputFactory.createInput("portOffset", Integer.class) .setLabel("HTTP Port Offset").setDescription("HTTP Port Offset") .setDefaultValue(ThorntailConfiguration.PORT_OFFSET_DEFAULT_VALUE); Project project = Projects.getSelectedProject(getProjectFactory(), builder.getUIContext()); if (project != null) { project.getFacetAsOptional(ThorntailFacet.class) .ifPresent((facet) -> { ThorntailConfiguration config = facet.getConfiguration(); httpPort.setDefaultValue(config.getHttpPort()); contextPath.setDefaultValue(config.getContextPath()); portOffset.setDefaultValue(config.getPortOffset()); }); } builder.add(httpPort).add(contextPath).add(portOffset); }
Example #23
Source File: CamelProjectAddComponentCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { final Project project = getSelectedProject(builder); filter.setValueChoices(CamelCommandsHelper.createComponentLabelValues(project, getCamelCatalog())); filter.setDefaultValue("<all>"); // we use the componentName in the next step so do not add it to this builder builder.add(filter); }
Example #24
Source File: CamelProjectAddDataFormatCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { Project project = getSelectedProject(builder); dtos = new CamelDataFormatsCompleter(project, getCamelCatalog()).getValueChoices(); List<String> names = new ArrayList<>(); for (DataFormatDto dto : dtos) { names.add(dto.getName()); } dataformatName.setValueChoices(names); builder.add(dataformatName); }
Example #25
Source File: ConfigureEipPropertiesStep.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void initializeUI(UIBuilder builder) throws Exception { if (inputs != null) { for (InputComponent input : inputs) { builder.add(input); } } }
Example #26
Source File: CamelDeleteNodeXmlCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { UIContext context = builder.getUIContext(); Project project = getSelectedProject(context); String currentFile = getSelectedFile(context); String selected = configureXml(project, xml, currentFile); nodes = configureXmlNodes(context, project, selected, xml, node); builder.add(xml).add(node); }
Example #27
Source File: AbstractPodCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { super.initializeUI(builder); // populate autocompletion options podId.setCompleter(new UICompleter<String>() { @Override public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) { List<String> list = new ArrayList<String>(); PodList pods = getKubernetes().pods().list(); if (pods != null) { List<Pod> items = pods.getItems(); if (items != null) { for (Pod item : items) { String id = KubernetesHelper.getName(item); list.add(id); } } } Collections.sort(list); System.out.println("Completion list is " + list); return list; } }); builder.add(podId); }
Example #28
Source File: CommandHelpers.java From fabric8-forge with Apache License 2.0 | 5 votes |
/** * A helper function to add the components to the builder and return a list of all the components */ public static List<InputComponent> addInputComponents(UIBuilder builder, InputComponent... components) { List<InputComponent> inputComponents = new ArrayList<>(); for (InputComponent component : components) { builder.add(component); inputComponents.add(component); } return inputComponents; }
Example #29
Source File: NamespaceSet.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { super.initializeUI(builder); // TODO load the list of namespaces... /* namespace.setCompleter(new UICompleter<String>() { @Override public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) { List<String> list = new ArrayList<String>(); PodList pods = getKubernetes().getPods(); if (pods != null) { List<Pod> items = pods.getItems(); if (items != null) { for (Pod item : items) { String id = getName(item); list.add(id); } } } Collections.sort(list); System.out.println("Completion list is " + list); return list; } }); */ builder.add(namespace); }
Example #30
Source File: ConfigureEndpointPropertiesStep.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void initializeUI(UIBuilder builder) throws Exception { if (inputs != null) { for (InputComponent input : inputs) { builder.add(input); } } }