Skip to content

Commit

Permalink
FORGE-2427: InputComponentFactory now pre-populates UISelect components
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Aug 7, 2015
1 parent aa9bb8a commit b5c0387
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.jboss.forge.furnace.services.Imported;

/**
* Produces UIInput objects
* Produces {@link InputComponent} objects
*
* @author <a href="mailto:ggastald@redhat.com">George Gastaldi</a>
*
Expand Down Expand Up @@ -83,7 +83,6 @@ public <T> UISelectOne<T> produceSelectOne(InjectionPoint injectionPoint)
: withAttributes.name();
char shortName = (withAttributes == null) ? InputComponents.DEFAULT_SHORT_NAME : withAttributes.shortName();
UISelectOne<T> input = createSelectOne(paramName, shortName, valueType);
setupSelectComponent(input);
preconfigureInput(input, withAttributes);
for (InputComponentInjectionEnricher enricher : enrichers)
{
Expand Down Expand Up @@ -116,7 +115,6 @@ public <T> UISelectMany<T> produceSelectMany(InjectionPoint injectionPoint)
: withAttributes.name();
char shortName = (withAttributes == null) ? InputComponents.DEFAULT_SHORT_NAME : withAttributes.shortName();
UISelectMany<T> input = createSelectMany(paramName, shortName, valueType);
setupSelectComponent(input);
preconfigureInput(input, withAttributes);
for (InputComponentInjectionEnricher enricher : enrichers)
{
Expand Down Expand Up @@ -220,6 +218,7 @@ public <T> UIInputMany<T> createInputMany(String name, char shortName, Class<T>
public <T> UISelectOne<T> createSelectOne(String name, char shortName, Class<T> valueType)
{
UISelectOneImpl<T> input = new UISelectOneImpl<>(name, shortName, valueType);
setupSelectComponent(input);
configureRequiredFacets(input);
return input;
}
Expand All @@ -228,6 +227,7 @@ public <T> UISelectOne<T> createSelectOne(String name, char shortName, Class<T>
public <T> UISelectMany<T> createSelectMany(String name, char shortName, Class<T> valueType)
{
UISelectManyImpl<T> input = new UISelectManyImpl<>(name, shortName, valueType);
setupSelectComponent(input);
configureRequiredFacets(input);
return input;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

package org.jboss.forge.addon.ui.impl;

import static org.hamcrest.CoreMatchers.hasItems;

import java.lang.annotation.ElementType;

import javax.inject.Inject;

import org.jboss.arquillian.container.test.api.Deployment;
Expand Down Expand Up @@ -170,4 +174,12 @@ public void testCreateUISelectOneDefaultValue() throws Exception
Assert.assertFalse(input.hasDefaultValue());
}

@Test
public void testCreateUISelectOneWithValueChoicesByDefault() throws Exception
{
UISelectOne<ElementType> input = factory.createSelectOne("foo", 'f', ElementType.class);
Assert.assertNotNull(input);
Assert.assertThat(input.getValueChoices(), hasItems(ElementType.values()));
}

}

0 comments on commit b5c0387

Please sign in to comment.