org.jboss.forge.addon.ui.hints.InputType Java Examples
The following examples show how to use
org.jboss.forge.addon.ui.hints.InputType.
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: 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 #2
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 #3
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 #4
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); }