use of com.aire.ux.DefaultComponentExtension in project aire-components by aire-ux.
the class ApplicationLayoutTest method ensureRegisteringSimpleComponentWorks.
@ViewTest
@DirtiesContext
void ensureRegisteringSimpleComponentWorks(@Autowired UserInterface ui, @Context TestContext $) {
val extension = new DefaultComponentExtension<>(":management-menu", (NavigationBar parent) -> {
val button = spy(new Button("Hello"));
parent.add(button);
});
var button = $.selectFirst("vaadin-button[text~=Hello]", Button.class);
assertFalse(button.isPresent());
val registration = ui.register(Selection.path(":main:navigation"), extension);
$.flush();
val menu = ui.selectFirst(Selection.path(":main:navigation:management-menu"));
assertNotNull(menu);
button = $.selectFirst("vaadin-button[text~=Hello]", Button.class);
assertTrue(button.isPresent());
registration.close();
$.flush(true);
assertEquals(0, ui.getExtensionRegistry().getExtensionCount());
button = $.selectFirst("vaadin-button[text~=Hello]", Button.class);
assertFalse(button.isPresent());
}
use of com.aire.ux.DefaultComponentExtension in project aire-components by aire-ux.
the class PathRegistryParameterResolver method create.
@Override
public ElementResolver create(AnnotatedElement element) {
return new ElementResolver() {
@Override
@SuppressWarnings("unchecked")
public <T> T resolve() {
val selector = element.getAnnotation(Select.class);
val value = Utilities.firstNonDefault(selector.value(), selector.selector());
return (T) Selection.path(value).select(Aire.getUserInterface(), UI::getCurrent, new DefaultComponentExtension<>(value, c -> {
})).map(ExtensionDefinition::getValue).get();
}
};
}
Aggregations