Package com.google.gwt.query.client

Examples of com.google.gwt.query.client.Selector


    return generatedPkgName + "." + generatedClassName;
  }

  public void generateMethod(SourceWriter sw, JMethod method, TreeLogger logger)
      throws UnableToCompleteException {
    Selector selectorAnnotation = method.getAnnotation(Selector.class);
    if (selectorAnnotation == null) {
      return;
    }

    JParameter[] params = method.getParameters();

    String retType = method.getReturnType()
        .getParameterizedQualifiedSourceName();
    sw.print("public final " + retType + " " + method.getName());
    boolean hasContext = false;
    if (params.length == 0) {
      sw.print("()");
    } else if (params.length == 1) {
      JClassType type = params[0].getType().isClassOrInterface();
      if (type != null && type.isAssignableTo(nodeType)) {
        sw.print("(Node root)");
        hasContext = true;
      }
    }
    sw.println(" {");
    sw.indent();
    Selector sel = method.getAnnotation(Selector.class);

    if (sel != null && sel.value().matches("^#\\w+$")) {
      // short circuit #foo
      sw.println("return "
          + wrap(method, "JsNodeArray.create(((Document)root).getElementById(\""
              + sel.value().substring(1) + "\"))") + ";");
    } else if (sel != null && sel.value().matches("^\\w+$")) {
      // short circuit FOO
      sw.println("return "
          + wrap(method,
              "JsNodeArray.create(((Element)root).getElementsByTagName(\""
                  + sel.value() + "\"))") + ";");
    } else if (sel != null && sel.value().matches("^\\.\\w+$")
        && hasGetElementsByClassName()) {
      // short circuit .foo for browsers with native getElementsByClassName
      sw.println("return "
          + wrap(method, "JsNodeArray.create(getElementsByClassName(\""
              + sel.value().substring(1) + "\", root))") + ";");
    } else {
      generateMethodBody(sw, method, logger, hasContext);
    }
    sw.outdent();
    sw.println("}");
View Full Code Here


      TreeLogger treeLogger) {
    sw.println("public DeferredSelector[] getAllSelectors() {return ds;}");
    sw.println("private final DeferredSelector[] ds = new DeferredSelector[] {");
    sw.indent();
    for (JMethod m : methods) {
      Selector selectorAnnotation = m.getAnnotation(Selector.class);
      if (selectorAnnotation == null) {
        continue;
      }
      String selector = selectorAnnotation.value();

      sw.println("new DeferredSelector() {");
      sw.indent();
      sw
          .println("public String getSelector() { return \"" + selector
View Full Code Here

TOP

Related Classes of com.google.gwt.query.client.Selector

Copyright © 2018 www.massapicom. 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.