Java源码示例:org.jboss.forge.addon.ui.hints.InputType
示例1
@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);
}
示例2
@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);
}
示例3
@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);
}
示例4
@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);
}