Examples of UIComponentTagAttribute


Examples of org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute

    return elementExtension;
  }

  protected void addAttribute(MethodDeclaration d, Class uiComponentClass, List properties, List attributes,
      Namespace namespace) {
    UIComponentTagAttribute componentAttribute = d.getAnnotation(UIComponentTagAttribute.class);
    if (componentAttribute != null) {
      String simpleName = d.getSimpleName();
      if (simpleName.startsWith("set")) {
        String attributeStr = simpleName.substring(3, 4).toLowerCase(Locale.ENGLISH) + simpleName.substring(4);
        String methodStr;
        if (componentAttribute.type().length == 1
            && (componentAttribute.type()[0].equals(Boolean.class.getName())
            || componentAttribute.type()[0].equals("boolean"))) {
          methodStr = "is" + simpleName.substring(3);
        } else {
          methodStr = "get" + simpleName.substring(3);
        }
        try {
          uiComponentClass.getMethod(methodStr, new Class[0]);
          Element property = new Element(PROPERTY, namespace);
          Element propertyName = new Element(PROPERTY_NAME, namespace);
          Element propertyClass = new Element(PROPERTY_CLASS, namespace);

          propertyName.setText(attributeStr);
          addClass(componentAttribute, propertyClass);

          addDescription(d, property, namespace);

          property.addContent(propertyName);
          property.addContent(propertyClass);
          if (componentAttribute.defaultValue().length() > 0) {
            Element defaultValue = new Element(DEFAULT_VALUE, namespace);
            defaultValue.setText(componentAttribute.defaultValue());
            property.addContent(defaultValue);
          }

          property.addContent(createPropertyOrAttributeExtension(PROPERTY_EXTENSION, d, componentAttribute, namespace));
          properties.add(property);
        } catch (NoSuchMethodException e) {
          // if property not found should be attribute
          Element attribute = new Element(ATTRIBUTE, namespace);
          Element attributeName = new Element(ATTRIBUTE_NAME, namespace);
          Element attributeClass = new Element(ATTRIBUTE_CLASS, namespace);

          attributeName.setText(attributeStr);
          addClass(componentAttribute, attributeClass);

          addDescription(d, attribute, namespace);

          attribute.addContent(attributeName);
          attribute.addContent(attributeClass);
          if (componentAttribute.defaultValue().length() > 0) {
            Element defaultValue = new Element(DEFAULT_VALUE, namespace);
            defaultValue.setText(componentAttribute.defaultValue());
            attribute.addContent(defaultValue);
          }

          attribute.addContent(createPropertyOrAttributeExtension(ATTRIBUTE_EXTENSION, d,
              componentAttribute, namespace));
View Full Code Here

Examples of org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute

    }
    UIComponentTag componentTag = decl.getAnnotation(UIComponentTag.class);
    if (componentTag != null) {
      description.append(createDescription(componentTag));
    }
    UIComponentTagAttribute attributeTag = decl.getAnnotation(UIComponentTagAttribute.class);
    if (attributeTag != null) {
      if (null != attributeTag.type() && attributeTag.type().length > 0) {
        description.append("<br />Type: <code>")
            .append(attributeTag.type().length == 1 ? attributeTag.type()[0] : Arrays.toString(attributeTag.type()))
            .append("</code>");
      }
      if (StringUtils.isNotEmpty(attributeTag.defaultValue())) {
        description.append("<br />Default: <code>")
            .append(attributeTag.defaultValue())
            .append("</code>");
      }
      if (attributeTag.allowedValues().length > 0) {
        description.append("<br />Allowed Values: <code>")
            .append(Arrays.toString(attributeTag.allowedValues()))
            .append("</code>");
      }
    }
    ExtensionTag extensionTag = decl.getAnnotation(ExtensionTag.class);
    if (extensionTag != null) {
View Full Code Here

Examples of org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute

        checkAttributeDuplicates(attributeStr);
        addDescription(d, attribute, document, false);
        addLeafTextElement(attributeStr, "name", attribute, document);

        addLeafTextElement(Boolean.toString(tagAttribute.required()), "required", attribute, document);
        UIComponentTagAttribute componentTagAttribute = d.getAnnotation(UIComponentTagAttribute.class);
        if (isMinium12() && !tagAttribute.rtexprvalue()) {
          if (componentTagAttribute != null) {
            if (componentTagAttribute.expression().isMethodExpression()) {
              Element deferredMethod = document.createElement("deferred-method");
              StringBuilder signature = new StringBuilder();
              signature.append(componentTagAttribute.methodReturnType());
              signature.append(" ");
              signature.append(attributeStr);
              signature.append("(");
              signature.append(StringUtils.join(componentTagAttribute.methodSignature(), ", "));
              signature.append(")");
              addLeafTextElement(signature.toString(), "method-signature", deferredMethod, document);
              attribute.appendChild(deferredMethod);
            } else if (componentTagAttribute != null && componentTagAttribute.expression().isValueExpression()) {
              Element deferredValue = document.createElement("deferred-value");
              String type = "java.lang.Object";
              if (componentTagAttribute.expression().isValueExpression()) {
                if (componentTagAttribute.type().length == 1
                    // XXX fix me hack
                    && !"org.apache.myfaces.tobago.layout.Measure".equals(componentTagAttribute.type()[0])) {
                  type = componentTagAttribute.type()[0];
                }
              } else {
                type = componentTagAttribute.type()[0];
              }
              addLeafTextElement(type, "type", deferredValue, document);
              attribute.appendChild(deferredValue);
            }
          } else {
View Full Code Here

Examples of org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute

    }
    UIComponentTag componentTag = typeElement.getAnnotation(UIComponentTag.class);
    if (componentTag != null) {
      description.append(createDescription(componentTag));
    }
    UIComponentTagAttribute attributeTag = typeElement.getAnnotation(UIComponentTagAttribute.class);
    if (attributeTag != null) {
      if (null != attributeTag.type() && attributeTag.type().length > 0) {
        description.append("<br />Type: <code>")
            .append(attributeTag.type().length == 1 ? attributeTag.type()[0] : Arrays.toString(attributeTag.type()))
            .append("</code>");
      }
      if (StringUtils.isNotEmpty(attributeTag.defaultValue())) {
        description.append("<br />Default: <code>")
            .append(attributeTag.defaultValue())
            .append("</code>");
      }
      if (attributeTag.allowedValues().length > 0) {
        description.append("<br />Allowed Values: <code>")
            .append(Arrays.toString(attributeTag.allowedValues()))
            .append("</code>");
      }
    }
    ExtensionTag extensionTag = typeElement.getAnnotation(ExtensionTag.class);
    if (extensionTag != null) {
View Full Code Here

Examples of org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute

        checkAttributeDuplicates(attributeName);
        addDescription(element, attribute, document, false);
        addLeafTextElement(attributeName, "name", attribute, document);

        addLeafTextElement(Boolean.toString(tagAttribute.required()), "required", attribute, document);
        UIComponentTagAttribute componentTagAttribute = element.getAnnotation(UIComponentTagAttribute.class);
        type.addAttributeType(attribute, tagAttribute, componentTagAttribute, document, attributeName);
        tagElement.appendChild(attribute);
      } else {
        throw new IllegalArgumentException("Only setter allowed found: " + simpleName);
      }
View Full Code Here

Examples of org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute

    }
  }

  protected void addProperty(ExecutableElement declaration, Map<String, PropertyInfo> properties) {
    TagAttribute tagAttribute = declaration.getAnnotation(TagAttribute.class);
    UIComponentTagAttribute uiComponentTagAttribute = declaration.getAnnotation(UIComponentTagAttribute.class);
    if (uiComponentTagAttribute != null) {
      String simpleName = declaration.getSimpleName().toString();
      if (simpleName.startsWith("set") || simpleName.startsWith("get")) {
        String name = simpleName.substring(3, 4).toLowerCase(Locale.ENGLISH) + simpleName.substring(4);
        if (ignoredProperties.contains(name)) {
          return;
        }
        PropertyInfo propertyInfo = new PropertyInfo(name);
        propertyInfo.setAllowedValues(uiComponentTagAttribute.allowedValues());
        if (tagAttribute != null) {
          propertyInfo.setBodyContent(tagAttribute.bodyContent());
          propertyInfo.setTagAttribute(true);
        }
        final String type;
        if (uiComponentTagAttribute.expression().isMethodExpression()) {
          propertyInfo.setMethodExpressionRequired(true);
          type = "javax.el.MethodExpression";
        } else {
          if (uiComponentTagAttribute.expression() == DynamicExpression.VALUE_EXPRESSION_REQUIRED) {
            propertyInfo.setValueExpressionRequired(true);
          } else if (uiComponentTagAttribute.expression() == DynamicExpression.PROHIBITED) {
            propertyInfo.setLiteralOnly(true);
          }

          if (uiComponentTagAttribute.type().length > 1) {
            type = "java.lang.Object";
          } else {
            type = uiComponentTagAttribute.type()[0];
          }
        }
        propertyInfo.setType(type);
        propertyInfo.setDefaultValue(
            uiComponentTagAttribute.defaultValue().length() > 0 ? uiComponentTagAttribute.defaultValue() : null);
        propertyInfo.setDefaultCode(
            uiComponentTagAttribute.defaultCode().length() > 0 ? uiComponentTagAttribute.defaultCode() : null);
        propertyInfo.setMethodSignature(uiComponentTagAttribute.methodSignature());
        propertyInfo.setDeprecated(declaration.getAnnotation(Deprecated.class) != null);
        propertyInfo.setDescription(getDescription(declaration));
        propertyInfo.setTransient(uiComponentTagAttribute.isTransient());
        propertyInfo.setGenerate(uiComponentTagAttribute.generate());
        if (properties.containsKey(name)) {
          warn("Redefinition of attribute '" + name + "'.");
        }
        properties.put(name, propertyInfo);
      }
View Full Code Here

Examples of org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute

  }

  protected void addAttribute(
      ExecutableElement executableElement, List<org.jdom.Element> attributes, List<org.jdom.Element> properties,
      Namespace namespace) {
    UIComponentTagAttribute componentAttribute = executableElement.getAnnotation(UIComponentTagAttribute.class);
    if (componentAttribute != null) {
      String simpleName = executableElement.getSimpleName().toString();
      if (simpleName.startsWith("set")) {
        String name = simpleName.substring(3, 4).toLowerCase(Locale.ENGLISH) + simpleName.substring(4);
        if (IGNORED_PROPERTIES.contains(name)) {
          org.jdom.Element attribute = new org.jdom.Element(ATTRIBUTE, namespace);
          org.jdom.Element attributeName = new org.jdom.Element(ATTRIBUTE_NAME, namespace);
          org.jdom.Element attributeClass = new org.jdom.Element(ATTRIBUTE_CLASS, namespace);

          attributeName.setText(name);
          addClass(componentAttribute, attributeClass);

          addDescription(executableElement, attribute, namespace);

          attribute.addContent(attributeName);
          attribute.addContent(attributeClass);
          if (componentAttribute.defaultValue().length() > 0) {
            org.jdom.Element defaultValue = new org.jdom.Element(DEFAULT_VALUE, namespace);
            defaultValue.setText(componentAttribute.defaultValue());
            attribute.addContent(defaultValue);
          }

          attribute.addContent(createPropertyOrAttributeExtension(ATTRIBUTE_EXTENSION, executableElement,
              componentAttribute, namespace));

          attributes.add(attribute);
        } else {
          org.jdom.Element property = new org.jdom.Element(PROPERTY, namespace);
          org.jdom.Element propertyName = new org.jdom.Element(PROPERTY_NAME, namespace);
          org.jdom.Element propertyClass = new org.jdom.Element(PROPERTY_CLASS, namespace);

          propertyName.setText(name);
          addClass(componentAttribute, propertyClass);

          addDescription(executableElement, property, namespace);

          property.addContent(propertyName);
          property.addContent(propertyClass);
          if (componentAttribute.defaultValue().length() > 0) {
            org.jdom.Element defaultValue = new org.jdom.Element(DEFAULT_VALUE, namespace);
            defaultValue.setText(componentAttribute.defaultValue());
            property.addContent(defaultValue);
          }

          property.addContent(
              createPropertyOrAttributeExtension(PROPERTY_EXTENSION, executableElement, componentAttribute, namespace));
View Full Code Here

Examples of org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute

    }
    UIComponentTag componentTag = decl.getAnnotation(UIComponentTag.class);
    if (componentTag != null) {
      description.append(createDescription(componentTag));
    }
    UIComponentTagAttribute attributeTag = decl.getAnnotation(UIComponentTagAttribute.class);
    if (attributeTag != null) {
      if (null != attributeTag.type() && attributeTag.type().length > 0) {
        description.append("<br />Type: <code>")
            .append(attributeTag.type().length == 1 ? attributeTag.type()[0] : Arrays.toString(attributeTag.type()))
            .append("</code>");
      }
      if (StringUtils.isNotEmpty(attributeTag.defaultValue())) {
        description.append("<br />Default: <code>")
            .append(attributeTag.defaultValue())
            .append("</code>");
      }
      if (attributeTag.allowedValues().length > 0) {
        description.append("<br />Allowed Values: <code>")
            .append(Arrays.toString(attributeTag.allowedValues()))
            .append("</code>");
      }
    }
    ExtensionTag extensionTag = decl.getAnnotation(ExtensionTag.class);
    if (extensionTag != null) {
View Full Code Here

Examples of org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute

        }
        checkAttributeDuplicates(attributeStr);
        addLeafTextElement(attributeStr, "name", attribute, document);

        addLeafTextElement(Boolean.toString(tagAttribute.required()), "required", attribute, document);
        UIComponentTagAttribute componentTagAttribute = d.getAnnotation(UIComponentTagAttribute.class);
        if (isMinium12() && !tagAttribute.rtexprvalue()) {
          if (componentTagAttribute != null) {
            if (componentTagAttribute.expression().isMethodExpression()) {
              Element deferredMethod = document.createElement("deferred-method");
              StringBuilder signature = new StringBuilder();
              signature.append(componentTagAttribute.methodReturnType());
              signature.append(" ");
              signature.append(attributeStr);
              signature.append("(");
              signature.append(StringUtils.join(componentTagAttribute.methodSignature(), ", "));
              signature.append(")");
              addLeafTextElement(signature.toString(), "method-signature", deferredMethod, document);
              attribute.appendChild(deferredMethod);
            } else if (componentTagAttribute != null && componentTagAttribute.expression().isValueExpression()) {
              Element deferredValue = document.createElement("deferred-value");
              String type = "java.lang.Object";
              if (componentTagAttribute.expression().isValueExpression()) {
                if (componentTagAttribute.type().length == 1
                    // XXX fix me hack
                    && !"org.apache.myfaces.tobago.layout.Measure".equals(componentTagAttribute.type()[0])) {
                  type = componentTagAttribute.type()[0];
                }
              } else {
                type = componentTagAttribute.type()[0];
              }
              addLeafTextElement(type, "type", deferredValue, document);
              attribute.appendChild(deferredValue);
            }
          } else {
View Full Code Here

Examples of org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute

    }
  }

  protected void addProperty(MethodDeclaration declaration, Map<String, PropertyInfo> properties) {
    TagAttribute tagAttribute = declaration.getAnnotation(TagAttribute.class);
    UIComponentTagAttribute uiComponentTagAttribute = declaration.getAnnotation(UIComponentTagAttribute.class);
    if (uiComponentTagAttribute != null) {
      String simpleName = declaration.getSimpleName();
      if (simpleName.startsWith("set") || simpleName.startsWith("get")) {
        String name = simpleName.substring(3, 4).toLowerCase(Locale.ENGLISH) + simpleName.substring(4);
        if (ignoredProperties.contains(name)) {
          return;
        }
        PropertyInfo propertyInfo = new PropertyInfo(name);
        propertyInfo.setAllowedValues(uiComponentTagAttribute.allowedValues());
        if (tagAttribute != null) {
          propertyInfo.setBodyContent(tagAttribute.bodyContent());
          propertyInfo.setTagAttribute(true);
        }
        final String type;
        if (uiComponentTagAttribute.expression().isMethodExpression()) {
          propertyInfo.setMethodExpressionRequired(true);
          type = "javax.faces.el.MethodBinding";
        } else {
          if (uiComponentTagAttribute.expression() == DynamicExpression.VALUE_BINDING_REQUIRED) {
            propertyInfo.setValueExpressionRequired(true);
          } else if (uiComponentTagAttribute.expression() == DynamicExpression.PROHIBITED) {
            propertyInfo.setLiteralOnly(true);
          }

          if (uiComponentTagAttribute.type().length > 1) {
            type = "java.lang.Object";
          } else {
            type = uiComponentTagAttribute.type()[0];
          }
        }
        propertyInfo.setType(type);
        propertyInfo.setDefaultValue(
            uiComponentTagAttribute.defaultValue().length() > 0 ? uiComponentTagAttribute.defaultValue() : null);
        propertyInfo.setDefaultCode(
            uiComponentTagAttribute.defaultCode().length() > 0 ? uiComponentTagAttribute.defaultCode() : null);
        propertyInfo.setMethodSignature(uiComponentTagAttribute.methodSignature());
        propertyInfo.setDeprecated(declaration.getAnnotation(Deprecated.class) != null);
        propertyInfo.setDescription(getDescription(declaration));
        propertyInfo.setTransient(uiComponentTagAttribute.isTransient());
        if (properties.containsKey(name)) {
          getEnv().getMessager().printWarning("Redefinition of attribute '" + name + "'.");
        }
        properties.put(name, propertyInfo);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.