@PatchMethod
 static void deleteCaption(TableElement e) {
   TableCaptionElement caption = JavaScriptObjects.getObject(e, TCAPTION);
   if (caption != null) {
     JavaScriptObjects.remove(e, TCAPTION);
     e.removeChild(caption);
   }
 }
 @PatchMethod
 static void deleteTHead(TableElement e) {
   TableSectionElement thead = JavaScriptObjects.getObject(e, THEAD);
   if (thead != null) {
     JavaScriptObjects.remove(e, THEAD);
     e.removeChild(thead);
   }
 }
 @PatchMethod
 static void deleteTFoot(TableElement e) {
   TableSectionElement tfoot = JavaScriptObjects.getObject(e, TFOOT);
   if (tfoot != null) {
     JavaScriptObjects.remove(e, TFOOT);
     e.removeChild(tfoot);
   }
 }
 @PatchMethod
 static TableCaptionElement createCaption(TableElement e) {
   TableCaptionElement caption = JavaScriptObjects.getObject(e, TCAPTION);
   if (caption == null) {
     caption = Document.get().createCaptionElement();
     JavaScriptObjects.setProperty(e, TCAPTION, caption);
     e.insertFirst(caption);
   }
   return caption;
 }
  @PatchMethod
  static void setTHead(TableElement e, TableSectionElement tHead) {
    TableSectionElement old = JavaScriptObjects.getObject(e, THEAD);

    if (old != null && tHead != null) {
      e.replaceChild(tHead, old);
    } else if (tHead != null) {
      e.appendChild(tHead);
    } else {
      e.removeChild(old);
    }

    JavaScriptObjects.setProperty(e, THEAD, tHead);
  }
  @PatchMethod
  static void setTFoot(TableElement e, TableSectionElement tFoot) {
    TableSectionElement old = JavaScriptObjects.getObject(e, TFOOT);

    if (old != null && tFoot != null) {
      e.replaceChild(tFoot, old);
    } else if (tFoot != null) {
      e.appendChild(tFoot);
    } else {
      e.removeChild(old);
    }

    JavaScriptObjects.setProperty(e, TFOOT, tFoot);
  }
  @PatchMethod
  static TableSectionElement createTHead(TableElement e) {
    TableSectionElement thead = JavaScriptObjects.getObject(e, THEAD);
    if (thead == null) {
      thead = Document.get().createTHeadElement();
      TableCaptionElement caption = e.getCaption();
      if (caption == null) {
        e.insertFirst(thead);
      } else {
        e.insertAfter(thead, caption);
      }
      JavaScriptObjects.setProperty(e, THEAD, thead);
    }

    return thead;
  }
  @PatchMethod
  static TableSectionElement createTFoot(TableElement e) {
    TableSectionElement tfoot = JavaScriptObjects.getObject(e, TFOOT);
    if (tfoot == null) {
      tfoot = Document.get().createTFootElement();

      TableSectionElement thead = e.getTHead();
      if (thead != null) {
        e.insertAfter(tfoot, thead);
      } else {
        TableCaptionElement caption = e.getCaption();
        if (caption == null) {
          e.insertFirst(tfoot);
        } else {
          e.insertAfter(tfoot, caption);
        }
      }
      JavaScriptObjects.setProperty(e, TFOOT, tfoot);
    }

    return tfoot;
  }
  /**
   * Specific function which does not inspect deep.
   *
   * @param tag
   * @return
   */
  private static NodeList<Element> getElementByTagName(TableElement e, String tagName) {

    NodeList<Node> childs = e.getChildNodes();
    List<Element> list = new ArrayList<Element>();

    for (int i = 0; i < childs.getLength(); i++) {
      Node n = childs.getItem(i);
      if (Element.is(n)) {
        Element childElement = n.cast();
        if (tagName.equalsIgnoreCase(childElement.getTagName())) {
          list.add(childElement);
        }
      }
    }

    return JavaScriptObjects.newNodeList(list);
  }
Exemplo n.º 10
0
 @PatchMethod
 static TableSectionElement getTHead(TableElement e) {
   return JavaScriptObjects.getObject(e, THEAD);
 }
Exemplo n.º 11
0
 @PatchMethod
 static TableSectionElement getTFoot(TableElement e) {
   return JavaScriptObjects.getObject(e, TFOOT);
 }
Exemplo n.º 12
0
 @PatchMethod
 static TableCaptionElement getCaption(TableElement e) {
   return JavaScriptObjects.getObject(e, TCAPTION);
 }