Search in sources :

Example 1 with ExtensionDefinition

use of com.aire.ux.ExtensionDefinition 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();
        }
    };
}
Also used : lombok.val(lombok.val) ExtensionDefinition(com.aire.ux.ExtensionDefinition) ElementResolver(com.aire.ux.test.ElementResolver) DefaultComponentExtension(com.aire.ux.DefaultComponentExtension)

Example 2 with ExtensionDefinition

use of com.aire.ux.ExtensionDefinition in project aire-components by aire-ux.

the class SpringExtensionRegistry method decorate.

@Override
@SuppressWarnings("unchecked")
public void decorate(Class<?> type, HasElement component) {
    synchronized (lock) {
        resolve(type).ifPresent(ext -> {
            val selection = ext.getSelection();
            val opt = selection.select(component, getUserInterface(), ext.getExtension());
            opt.ifPresent(extDef -> {
                val definition = (ExtensionDefinition<?>) extDef;
                if (inclusionManager.decide(definition)) {
                    ext.decorate(definition.getValue());
                }
            });
        });
    }
}
Also used : lombok.val(lombok.val) ExtensionDefinition(com.aire.ux.ExtensionDefinition)

Aggregations

ExtensionDefinition (com.aire.ux.ExtensionDefinition)2 lombok.val (lombok.val)2 DefaultComponentExtension (com.aire.ux.DefaultComponentExtension)1 ElementResolver (com.aire.ux.test.ElementResolver)1