Search in sources :

Example 1 with Table

use of org.jboss.hal.processor.mbui.ElementType.Table in project console by hal.

the class MbuiViewProcessor method processMbuiElements.

// ------------------------------------------------------ process @MbuiElement
@SuppressWarnings("HardCodedStringLiteral")
private void processMbuiElements(TypeElement type, Document document, MbuiViewContext context) {
    ElementFilter.fieldsIn(type.getEnclosedElements()).stream().filter(field -> MoreElements.isAnnotationPresent(field, MbuiElement.class)).forEach(field -> {
        // verify the field
        if (field.getModifiers().contains(Modifier.PRIVATE)) {
            error(field, "@%s member must not be private", MbuiElement.class.getSimpleName());
        }
        if (field.getModifiers().contains(Modifier.STATIC)) {
            error(field, "@%s member must not be static", MbuiElement.class.getSimpleName());
        }
        // verify the selector
        String selector = getSelector(field);
        org.jdom2.Element element = verifySelector(selector, field, document);
        // delegate to specific processors based on element type
        ElementType elementType = getMbuiElementType(field.asType());
        if (elementType == null) {
            error(field, "Unsupported type %s. Please choose one of %s", field.asType(), EnumSet.allOf(ElementType.class));
        } else {
            MbuiElementProcessor elementProcessor = null;
            switch(elementType) {
                case VerticalNavigation:
                    elementProcessor = new VerticalNavigationProcessor(this, elementUtils, xPathFactory);
                    break;
                case Table:
                    elementProcessor = new DataTableProcessor(this, elementUtils, xPathFactory);
                    break;
                case Form:
                    elementProcessor = new FormProcessor(this, elementUtils, xPathFactory);
                    break;
                default:
                    break;
            }
            elementProcessor.process(field, element, selector, context);
        }
    });
}
Also used : Modifier(javax.lang.model.element.Modifier) XPathFactory(org.jdom2.xpath.XPathFactory) Form(org.jboss.hal.processor.mbui.ElementType.Form) TypeElement(javax.lang.model.element.TypeElement) MbuiViewImpl(org.jboss.hal.core.mbui.MbuiViewImpl) SupportedAnnotationTypes(javax.annotation.processing.SupportedAnnotationTypes) TemplateNames(org.jboss.hal.processor.TemplateNames) FileObject(javax.tools.FileObject) Document(org.jdom2.Document) Introspector(java.beans.Introspector) AbstractProcessor(org.jboss.auto.AbstractProcessor) Strings(com.google.common.base.Strings) JDOMException(org.jdom2.JDOMException) MbuiElement(org.jboss.hal.spi.MbuiElement) Map(java.util.Map) VerticalNavigation(org.jboss.hal.processor.mbui.ElementType.VerticalNavigation) ElementFilter(javax.lang.model.util.ElementFilter) XmlHelper.xmlAsString(org.jboss.hal.processor.mbui.XmlHelper.xmlAsString) EnumSet(java.util.EnumSet) TypeSimplifier(org.jboss.hal.processor.TypeSimplifier) StandardLocation(javax.tools.StandardLocation) SAXBuilder(org.jdom2.input.SAXBuilder) MoreElements(com.google.auto.common.MoreElements) ElementKind(javax.lang.model.element.ElementKind) ImmutableMap(com.google.common.collect.ImmutableMap) Table(org.jboss.hal.ballroom.table.Table) ExecutableElement(javax.lang.model.element.ExecutableElement) Set(java.util.Set) IOException(java.io.IOException) Element(javax.lang.model.element.Element) Processor(javax.annotation.processing.Processor) Table(org.jboss.hal.processor.mbui.ElementType.Table) AnnotationMirror(javax.lang.model.element.AnnotationMirror) XPathExpression(org.jdom2.xpath.XPathExpression) TypeKind(javax.lang.model.type.TypeKind) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) List(java.util.List) TypeMirror(javax.lang.model.type.TypeMirror) RoundEnvironment(javax.annotation.processing.RoundEnvironment) AutoService(com.google.auto.service.AutoService) Annotation(java.lang.annotation.Annotation) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) MbuiView(org.jboss.hal.spi.MbuiView) AnnotationValue(javax.lang.model.element.AnnotationValue) Filters(org.jdom2.filter.Filters) Form(org.jboss.hal.ballroom.form.Form) MbuiElement(org.jboss.hal.spi.MbuiElement) XmlHelper.xmlAsString(org.jboss.hal.processor.mbui.XmlHelper.xmlAsString)

Aggregations

MoreElements (com.google.auto.common.MoreElements)1 AutoService (com.google.auto.service.AutoService)1 Strings (com.google.common.base.Strings)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Introspector (java.beans.Introspector)1 IOException (java.io.IOException)1 Annotation (java.lang.annotation.Annotation)1 EnumSet (java.util.EnumSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 PostConstruct (javax.annotation.PostConstruct)1 Processor (javax.annotation.processing.Processor)1 RoundEnvironment (javax.annotation.processing.RoundEnvironment)1 SupportedAnnotationTypes (javax.annotation.processing.SupportedAnnotationTypes)1 AnnotationMirror (javax.lang.model.element.AnnotationMirror)1 AnnotationValue (javax.lang.model.element.AnnotationValue)1 Element (javax.lang.model.element.Element)1 ElementKind (javax.lang.model.element.ElementKind)1