Examples of UIComponentTag


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

    }
  }

  protected void addElement(ClassDeclaration decl, List<Element> components, List<Element> renderer,
      Namespace namespace) throws IOException {
    UIComponentTag componentTag = decl.getAnnotation(UIComponentTag.class);
    if (componentTag != null) {
      try {
        Class<?> uiComponentClass = Class.forName(componentTag.uiComponent());
        if (!componentTag.isComponentAlreadyDefined()) {
          Element element = createComponentElement(decl, componentTag, uiComponentClass, namespace);
          if (element != null) {
            if (!containsElement(components, element)) {
              addFacets(componentTag, namespace, element);
              List attributes = new ArrayList();
View Full Code Here

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

    }
  }

  protected void addElement(InterfaceDeclaration decl, List<Element> components, List<Element> renderer,
      final Namespace namespace) throws IOException {
    UIComponentTag componentTag = decl.getAnnotation(UIComponentTag.class);
    if (componentTag != null) {
      try {
        Class<?> uiComponentClass = Class.forName(componentTag.uiComponent());
        if (!componentTag.isComponentAlreadyDefined()) {
          Element element = createComponentElement(decl, componentTag, uiComponentClass, namespace);
          if (element != null) {
            if (!containsElement(components, element)) {
              addFacets(componentTag, namespace, element);
              List attributes = new ArrayList();
View Full Code Here

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

        //description.append("<p>");
        description.append(comment);
        //description.append("</p>");
      }
    }
    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) {
      String baseName = extensionTag.baseClassName();
      description.append("<p><b>Extended tag: </b>");
      description.append(baseName);
      description.append("</p>");

      InterfaceDeclaration declaration = getInterfaceDeclaration(baseName + "Declaration");
      if (declaration != null) {
        UIComponentTag baseComponentTag = declaration.getAnnotation(UIComponentTag.class);
        if (baseComponentTag != null) {
          description.append(createDescription(baseComponentTag));
        }
      }
    }
View Full Code Here

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

        //description.append("<p>");
        description.append(comment);
        //description.append("</p>");
      }
    }
    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) {
      String baseName = extensionTag.baseClassName();
      description.append("<p><b>Extended tag: </b>");
      description.append(baseName);
      description.append("</p>");

      TypeElement declaration = getInterfaceDeclaration(baseName + "Declaration");
      if (declaration != null) {
        UIComponentTag baseComponentTag = declaration.getAnnotation(UIComponentTag.class);
        if (baseComponentTag != null) {
          description.append(createDescription(baseComponentTag));
        }
      }
    }
View Full Code Here

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

    tagInfo.addImport("org.slf4j.LoggerFactory");
    writeFile(tagInfo, stringTemplate);
  }

  private void createTagOrComponent(TypeElement declaration) throws IOException, ClassNotFoundException {
    UIComponentTag componentTag = declaration.getAnnotation(UIComponentTag.class);
    Tag tag = declaration.getAnnotation(Tag.class);
    Map<String, PropertyInfo> properties = new HashMap<String, PropertyInfo>();
    addProperties(declaration, properties);
    if (tag != null) {
      String className = "org.apache.myfaces.tobago.internal.taglib." + StringUtils.capitalize(tag.name()) + "Tag";
      TagInfo tagInfo = new TagInfo(declaration.getQualifiedName().toString(), className, componentTag.rendererType());
      for (PropertyInfo property : properties.values()) {
        if (property.isTagAttribute()) {
          tagInfo.getProperties().add(property);
        }
      }
      tagInfo.setSuperClass("org.apache.myfaces.tobago.internal.taglib.TobagoELTag");
      tagInfo.setComponentClassName(componentTag.uiComponent());
      tagInfo.addImport("org.apache.commons.lang.StringUtils");
      tagInfo.addImport("org.slf4j.Logger");
      tagInfo.addImport("org.slf4j.LoggerFactory");
      tagInfo.addImport("javax.faces.application.Application");
      tagInfo.addImport("javax.faces.component.UIComponent");
      tagInfo.addImport("javax.faces.context.FacesContext");

      StringTemplate stringTemplate = tagStringTemplateGroup.getInstanceOf("tag");
      stringTemplate.setAttribute("tagInfo", tagInfo);
      writeFile(tagInfo, stringTemplate);
    }

    if (componentTag.generate()) {
      StringTemplate componentStringTemplate = componentStringTemplateGroup.getInstanceOf("component");
      ComponentInfo componentInfo = new ComponentInfo(declaration, componentTag);
      componentInfo.setSuperClass(componentTag.uiComponentBaseClass());
      componentInfo.setDescription(getDescription(declaration));
      componentInfo.setDeprecated(declaration.getAnnotation(Deprecated.class) != null);
      for (String interfaces : componentTag.interfaces()) {
        componentInfo.addInterface(interfaces);
      }

      Class<? extends UIComponent> facesClass
          = Class.forName(componentTag.uiComponentFacesClass()).asSubclass(UIComponent.class);

      for (PropertyInfo info : properties.values()) {
        final String infoType = info.getType();
        String methodName
            = ((infoType.equals("java.lang.Boolean") || infoType.equals("boolean")) ? "is" : "get")
View Full Code Here

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

    return componentPropertyInfo;
  }

  private void createRenderer(TypeElement declaration) throws IOException {

    final UIComponentTag componentTag = declaration.getAnnotation(UIComponentTag.class);
    final String rendererType = componentTag.rendererType();

    if (rendererType != null && rendererType.length() > 0) {
      final String className = "org.apache.myfaces.tobago.renderkit." + rendererType + "Renderer";
      if (renderer.contains(className)) {
        // already created
        return;
      }
      renderer.add(className);
      RendererInfo info = new RendererInfo(declaration.getQualifiedName().toString(), className, rendererType);
      if (componentTag.isLayout()) {
        info.setSuperClass("org.apache.myfaces.tobago.renderkit.AbstractLayoutRendererWrapper");
      } else if (componentTag.isTransparentForLayout()) {
        info.setSuperClass("org.apache.myfaces.tobago.renderkit.AbstractRendererBaseWrapper");
      } else {
        info.setSuperClass("org.apache.myfaces.tobago.renderkit.AbstractLayoutableRendererBaseWrapper");
      }
      StringTemplate stringTemplate = rendererStringTemplateGroup.getInstanceOf("renderer");
View Full Code Here

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

  }

  protected void addElement(
      TypeElement typeElement, List<org.jdom.Element> components, List<org.jdom.Element> renderer,
      final Namespace namespace) throws Exception {
    UIComponentTag componentTag = typeElement.getAnnotation(UIComponentTag.class);
    if (componentTag != null) {
      ComponentInfo componentInfo = new ComponentInfo(typeElement, componentTag);
      if (!componentTag.isComponentAlreadyDefined()) {
        org.jdom.Element element = createComponentElement(componentInfo, componentTag, namespace);
        if (element != null) {
          if (!containsElement(components, element)) {
            addFacets(componentTag, namespace, element);
            List<org.jdom.Element> attributes = new ArrayList<org.jdom.Element>();
View Full Code Here

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

    }
  }

  protected void createTag(JConstructor constructor, InterfaceDeclaration decl, Tag annotationTag) {
    UIComponentTag componentTag = decl.getAnnotation(UIComponentTag.class);
    if (componentTag == null) {
      return;
    }
    try {
      ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
      Thread.currentThread().setContextClassLoader(UIComponent.class.getClassLoader());
      Class uiComponentClass = Class.forName(componentTag.uiComponent());

      StringBuilder addComponent = new StringBuilder("addTobagoComponent(\"");
      addComponent.append(annotationTag.name());

      Field componentField = uiComponentClass.getField("COMPONENT_TYPE");
      String componentType = (String) componentField.get(null);
      Thread.currentThread().setContextClassLoader(currentClassLoader);

      addComponent.append("\", \"");
      addComponent.append(componentType);
      addComponent.append("\", ");
      String rendererType = componentTag.rendererType();
      if (rendererType != null && rendererType.length() > 0) {
        addComponent.append("\"");
        addComponent.append(rendererType);
        addComponent.append("\", ");
      } else {
View Full Code Here

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

        //description.append("<p>");
        description.append(comment);
        //description.append("</p>");
      }
    }
    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) {
      String baseName = extensionTag.baseClassName();
      description.append("<p><b>Extended tag: </b>");
      description.append(baseName);
      description.append("</p>");

      InterfaceDeclaration declaration = getInterfaceDeclaration(baseName + "Declaration");
      if (declaration != null) {
        UIComponentTag baseComponentTag = declaration.getAnnotation(UIComponentTag.class);
        if (baseComponentTag != null) {
          description.append(createDescription(baseComponentTag));
        }
      }
    }
View Full Code Here

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

    tagInfo.addImport("org.slf4j.LoggerFactory");
    writeFile(tagInfo, stringTemplate);
  }

  private void createTagOrComponent(InterfaceDeclaration declaration) {
    UIComponentTag componentTag = declaration.getAnnotation(UIComponentTag.class);
    Tag tag = declaration.getAnnotation(Tag.class);
    Map<String, PropertyInfo> properties = new HashMap<String, PropertyInfo>();
    addProperties(declaration, properties);
    if (tag != null) {
      String className = "org.apache.myfaces.tobago.internal.taglib." + StringUtils.capitalize(tag.name()) + "Tag";
      TagInfo tagInfo = new TagInfo(declaration.getQualifiedName(), className, componentTag.rendererType());
      for (PropertyInfo property : properties.values()) {
        if (property.isTagAttribute()) {
          tagInfo.getProperties().add(property);
        }
      }
      if (isUnifiedEL()) {
        tagInfo.setSuperClass("org.apache.myfaces.tobago.internal.taglib.TobagoELTag");
      } else {
        if (tagInfo.getBodyContent() != null) {
          tagInfo.setSuperClass("org.apache.myfaces.tobago.internal.taglib.TobagoBodyTag");
        } else {
          tagInfo.setSuperClass("org.apache.myfaces.tobago.internal.taglib.TobagoTag");
        }
      }
      tagInfo.setComponentClassName(componentTag.uiComponent());
      tagInfo.addImport("org.apache.commons.lang.StringUtils");
      tagInfo.addImport("org.slf4j.Logger");
      tagInfo.addImport("org.slf4j.LoggerFactory");
      tagInfo.addImport("javax.faces.application.Application");
      tagInfo.addImport("javax.faces.component.UIComponent");
      tagInfo.addImport("javax.faces.context.FacesContext");

      StringTemplate stringTemplate = tagStringTemplateGroup.getInstanceOf("tag");
      stringTemplate.setAttribute("tagInfo", tagInfo);
      writeFile(tagInfo, stringTemplate);
    }

    if (componentTag.generate()) {
      StringTemplate componentStringTemplate = componentStringTemplateGroup.getInstanceOf("component");
      ComponentInfo componentInfo
          = new ComponentInfo(declaration.getQualifiedName(), componentTag.uiComponent(), componentTag.rendererType());
     
/*
      String p = componentTag.uiComponentBaseClass();
      String c = componentTag.uiComponent();
      String m = c.substring(0, 36) + "Abstract" + c.substring(36);
      if (p.equals(m)) {
        getEnv().getMessager().printNotice("*********** ok   " + c);
      } else {
        getEnv().getMessager().printNotice("*********** diff " + c + " " + p);
      }
*/
     
      componentInfo.setSuperClass(componentTag.uiComponentBaseClass());
      componentInfo.setComponentFamily(componentTag.componentFamily());
      componentInfo.setDescription(getDescription(declaration));
      componentInfo.setDeprecated(declaration.getAnnotation(Deprecated.class) != null);
      List<String> elMethods = Collections.emptyList();
      if (isUnifiedEL()) {
        elMethods = checkForElMethods(componentInfo, componentTag.interfaces());
      }
      for (String interfaces : componentTag.interfaces()) {
        componentInfo.addInterface(interfaces);
      }
      if (componentTag.componentType().length() > 0) {
        componentInfo.setComponentType(componentTag.componentType());
      } else {
        componentInfo.setComponentType(componentTag.uiComponent().replace(".component.UI", "."));
      }
      try {
        Class componentBaseClass = Class.forName(componentTag.uiComponentBaseClass());
        for (PropertyInfo info : properties.values()) {
          String methodName
              = (info.getType().equals("java.lang.Boolean") ? "is" : "get") + info.getUpperCamelCaseName();

          try {
            Method method = componentBaseClass.getMethod(methodName);
            if (Modifier.isAbstract(method.getModifiers())) {
              addPropertyToComponent(componentInfo, info, elMethods, false);
            }
          } catch (NoSuchMethodException e) {
            addPropertyToComponent(componentInfo, info, elMethods, false);
          }
        }
        boolean found = false;
        for (Method method : componentBaseClass.getMethods()) {
          if ("invokeOnComponent".equals(method.getName())) {
            found = true;
          }
        }
        if (!found) {
          componentInfo.setInvokeOnComponent(true);
          componentInfo.addImport("javax.faces.context.FacesContext");
          componentInfo.addImport("javax.faces.FacesException");
          componentInfo.addImport("javax.faces.component.ContextCallback");
          componentInfo.addImport("org.apache.myfaces.tobago.compat.FacesUtils");
          componentInfo.addInterface("org.apache.myfaces.tobago.compat.InvokeOnComponent");
        }

      } catch (ClassNotFoundException e) {
        Map<String, PropertyInfo> baseClassProperties = getBaseClassProperties(componentTag.uiComponentBaseClass());
        for (PropertyInfo info : properties.values()) {
          if (!baseClassProperties.containsValue(info)) {
            addPropertyToComponent(componentInfo, info, elMethods, false);
          }
        }
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.