org.jboss.forge.addon.ui.input.UIInput Java Examples

The following examples show how to use org.jboss.forge.addon.ui.input.UIInput. 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: SpringBootConfigurationFileCompleter.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
/**
 * Validates that the given selected directory and fileName are valid and that the file doesn't already exist
 */
public void validateFileDoesNotExist(UIInput<String> directory, UIInput<String> fileName, UIValidationContext validator) {
    String resourcePath = CamelXmlHelper.createFileName(directory, fileName);
    if (files.contains(resourcePath)) {
        validator.addValidationError(fileName, "A file with that name already exists!");
    }
}
 
Example #2
Source File: CamelComponentsCompleter.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public CamelComponentsCompleter(Project project, CamelCatalog camelCatalog, UIInput<String> filter,
                                boolean excludeComponentsOnClasspath, boolean includeCatalogComponents,
                                boolean consumerOnly, boolean producerOnly, boolean mustHasOptions) {
    this.project = project;
    this.camelCatalog = camelCatalog;
    this.filter = filter;
    this.excludeComponentsOnClasspath = excludeComponentsOnClasspath;
    this.includeCatalogComponents = includeCatalogComponents;
    this.consumerOnly = consumerOnly;
    this.producerOnly = producerOnly;
    this.mustHaveOptions = mustHasOptions;

    // need to find camel-core so we known the camel version
    core = CamelProjectHelper.findCamelCoreDependency(project);
}
 
Example #3
Source File: XmlFileCompleter.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
/**
 * Validates that the given selected directory and fileName are valid and that the file doesn't already exist
 */
public void validateFileDoesNotExist(UIInput<String> directory, UIInput<String> fileName, UIValidationContext validator) {
    String resourcePath = CamelXmlHelper.createFileName(directory, fileName);
    if (files.contains(resourcePath)) {
        validator.addValidationError(fileName, "A file with that name already exists!");
    }
}
 
Example #4
Source File: CommandHelpers.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
/**
 * If the initial value is not blank lets set the value on the underlying component
 */
public static <T> void setInitialComponentValue(UIInput<T> inputComponent, T value) {
    if (value != null) {
        inputComponent.setValue(value);
    }
}
 
Example #5
Source File: CamelGetComponentsCommand.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
protected static boolean isValueTrue(UIInput<Boolean> value) {
    Boolean verboseValue = value.getValue();
    return verboseValue != null && verboseValue;
}
 
Example #6
Source File: CamelXmlHelper.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
public static String createFileName(UIInput<String> directory, UIInput<String> name) {
    return directory.getValue() != null ? directory.getValue() + File.separator + name.getValue() : name.getValue();
}
 
Example #7
Source File: RouteCompleter.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
public RouteCompleter(JolokiaCamelController controller, UIInput<String> name) {
    this.controller = controller;
    this.name = name;
}
 
Example #8
Source File: WindupCommand.java    From windup with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private void initializeConfigurationOptionComponents(UIBuilder builder)
{
    for (final ConfigurationOption option : WindupConfiguration.getWindupConfigurationOptions())
    {
        InputComponent<?, ?> inputComponent = null;
        switch (option.getUIType())
        {
        case SINGLE:
        {
            UIInput<?> inputSingle = componentFactory.createInput(option.getName(), option.getType());
            inputSingle.setDefaultValue(new DefaultValueAdapter(option));
            inputComponent = inputSingle;
            break;
        }
        case MANY:
        {
            // forge can't handle "Path", so use File
            Class<?> optionType = option.getType() == Path.class ? File.class : option.getType();

            UIInputMany<?> inputMany = componentFactory.createInputMany(option.getName(), optionType);
            inputMany.setDefaultValue(new DefaultValueAdapter(option, Iterable.class));
            inputComponent = inputMany;
            break;
        }
        case SELECT_MANY:
        {
            UISelectMany<?> selectMany = componentFactory.createSelectMany(option.getName(), option.getType());
            selectMany.setValueChoices((Iterable) option.getAvailableValues());
            selectMany.setDefaultValue(new DefaultValueAdapter(option, Iterable.class));
            inputComponent = selectMany;
            break;
        }
        case SELECT_ONE:
        {
            UISelectOne<?> selectOne = componentFactory.createSelectOne(option.getName(), option.getType());
            selectOne.setValueChoices((Iterable) option.getAvailableValues());
            selectOne.setDefaultValue(new DefaultValueAdapter(option));
            inputComponent = selectOne;
            break;
        }
        case DIRECTORY:
        {
            UIInput<DirectoryResource> directoryInput = componentFactory.createInput(option.getName(),
                        DirectoryResource.class);
            directoryInput.setDefaultValue(new DefaultValueAdapter(option, DirectoryResource.class));
            inputComponent = directoryInput;
            break;
        }
        case FILE:
        {
            UIInput<?> fileInput = componentFactory.createInput(option.getName(), FileResource.class);
            fileInput.setDefaultValue(new DefaultValueAdapter(option, FileResource.class));
            inputComponent = fileInput;
            break;
        }
        case FILE_OR_DIRECTORY:
        {
            UIInput<?> fileOrDirInput = componentFactory.createInput(option.getName(), FileResource.class);
            fileOrDirInput.setDefaultValue(new DefaultValueAdapter(option, FileResource.class));
            inputComponent = fileOrDirInput;
            break;
        }
        }
        if (inputComponent == null)
        {
            throw new IllegalArgumentException("Could not build input component for: " + option);
        }
        inputComponent.setLabel(option.getLabel());
        inputComponent.setRequired(option.isRequired());
        inputComponent.setDescription(option.getDescription());
        builder.add(inputComponent);
        inputOptions.put(option, inputComponent);
    }
}