com.google.gwt.dom.client.Element.getElementsByTagName()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(272)

本文整理了Java中com.google.gwt.dom.client.Element.getElementsByTagName()方法的一些代码示例,展示了Element.getElementsByTagName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getElementsByTagName()方法的具体详情如下:
包路径:com.google.gwt.dom.client.Element
类名称:Element
方法名:getElementsByTagName

Element.getElementsByTagName介绍

[英]Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.
[中]返回具有给定标记名的所有子代元素的节点列表,按照在该元素树的前序遍历中遇到它们的顺序。

代码示例

代码示例来源:origin: org.vectomatic/lib-gwt-svg

  1. /**
  2. * Returns a <code>OMNodeList</code> of all descendant <code>OMElements</code>
  3. * with a given tag name, in document order.
  4. * @param name The name of the tag to match on. The special value "*"
  5. * matches all tags.
  6. * @return A list of matching <code>OMElement</code> nodes.
  7. */
  8. public final <T extends OMElement> OMNodeList<T> getElementsByTagName(String name) {
  9. return new OMNodeList<T>(((Element) ot).getElementsByTagName(name));
  10. }

代码示例来源:origin: laaglu/lib-gwt-svg

  1. /**
  2. * Returns a <code>OMNodeList</code> of all descendant <code>OMElements</code>
  3. * with a given tag name, in document order.
  4. * @param name The name of the tag to match on. The special value "*"
  5. * matches all tags.
  6. * @return A list of matching <code>OMElement</code> nodes.
  7. */
  8. public final <T extends OMElement> OMNodeList<T> getElementsByTagName(String name) {
  9. return new OMNodeList<T>(((Element) ot).getElementsByTagName(name));
  10. }

代码示例来源:origin: gwt-test-utils/gwt-test-utils

  1. private JsArray<Element> getCells(Element row) {
  2. return toArray(row.getElementsByTagName("td"));
  3. }

代码示例来源:origin: gwt-test-utils/gwt-test-utils

  1. private JsArray<Element> getRows(Element tbody) {
  2. return toArray(tbody.getElementsByTagName("tr"));
  3. }

代码示例来源:origin: com.googlecode.gwt-test-utils/gwt-test-utils

  1. private JsArray<Element> getCells(Element row) {
  2. return toArray(row.getElementsByTagName("td"));
  3. }

代码示例来源:origin: com.googlecode.gwt-test-utils/gwt-test-utils

  1. private JsArray<Element> getRows(Element tbody) {
  2. return toArray(tbody.getElementsByTagName("tr"));
  3. }

代码示例来源:origin: com.googlecode.gwtquery/gwtquery

  1. private static NodeList<Element> getElementsByTagName(String tag, Node ctx) {
  2. if (ctx == null) {
  3. return JavaScriptObject.createArray().cast();
  4. }
  5. return ((Element) ctx).getElementsByTagName(tag);
  6. }

代码示例来源:origin: gwt-test-utils/gwt-test-utils

  1. private void handleTabLayoutPanelSpecifics(TabLayoutPanel wrapped, Element element,
  2. List<IsWidget> childWidgets) {
  3. if ("tab".equals(element.getTagName())) {
  4. NodeList<Element> headers = element.getElementsByTagName("header");
  5. if (headers.getLength() == 1 && childWidgets.size() == 1) {
  6. // case of "header"
  7. String header = headers.getItem(0).getInnerHTML();
  8. wrapped.add(childWidgets.get(0), header);
  9. } else {
  10. NodeList<Element> customHeaders = element.getElementsByTagName("customHeader");
  11. if (customHeaders.getLength() == 1 && childWidgets.size() == 1) {
  12. // case of "customHeader"
  13. List<IsWidget> customHeaderChilds = UiBinderXmlUtils.getChildWidgets(customHeaders.getItem(0));
  14. if (customHeaderChilds.size() == 1) {
  15. wrapped.add(childWidgets.get(0), customHeaderChilds.get(0));
  16. }
  17. }
  18. }
  19. }
  20. }

代码示例来源:origin: com.googlecode.gwt-test-utils/gwt-test-utils

  1. private void handleTabLayoutPanelSpecifics(TabLayoutPanel wrapped, Element element,
  2. List<IsWidget> childWidgets) {
  3. if ("tab".equals(element.getTagName())) {
  4. NodeList<Element> headers = element.getElementsByTagName("header");
  5. if (headers.getLength() == 1 && childWidgets.size() == 1) {
  6. // case of "header"
  7. String header = headers.getItem(0).getInnerHTML();
  8. wrapped.add(childWidgets.get(0), header);
  9. } else {
  10. NodeList<Element> customHeaders = element.getElementsByTagName("customHeader");
  11. if (customHeaders.getLength() == 1 && childWidgets.size() == 1) {
  12. // case of "customHeader"
  13. List<IsWidget> customHeaderChilds = UiBinderXmlUtils.getChildWidgets(customHeaders.getItem(0));
  14. if (customHeaderChilds.size() == 1) {
  15. wrapped.add(childWidgets.get(0), customHeaderChilds.get(0));
  16. }
  17. }
  18. }
  19. }
  20. }

代码示例来源:origin: gwt-test-utils/gwt-test-utils

  1. private void handleStackLayoutPanelSpecifics(StackLayoutPanel wrapped, Element element,
  2. List<IsWidget> childWidgets) {
  3. if ("stack".equals(element.getTagName())) {
  4. NodeList<Element> headers = element.getElementsByTagName("header");
  5. if (headers.getLength() == 1 && childWidgets.size() == 1) {
  6. // case of "header"
  7. String header = headers.getItem(0).getInnerHTML();
  8. String headerSize = headers.getItem(0).getAttribute("size");
  9. wrapped.add(childWidgets.get(0).asWidget(), header, Double.valueOf(headerSize));
  10. } else {
  11. NodeList<Element> customHeaders = element.getElementsByTagName("customHeader");
  12. if (customHeaders.getLength() == 1 && childWidgets.size() == 1) {
  13. // case of "customHeader"
  14. List<IsWidget> customHeaderChilds = UiBinderXmlUtils.getChildWidgets(customHeaders.getItem(0));
  15. if (customHeaderChilds.size() == 1) {
  16. String customHeaderSize = customHeaders.getItem(0).getAttribute("size");
  17. wrapped.add(childWidgets.get(0), customHeaderChilds.get(0),
  18. Double.valueOf(customHeaderSize));
  19. }
  20. }
  21. }
  22. }
  23. }

代码示例来源:origin: com.googlecode.gwt-test-utils/gwt-test-utils

  1. private void handleStackLayoutPanelSpecifics(StackLayoutPanel wrapped, Element element,
  2. List<IsWidget> childWidgets) {
  3. if ("stack".equals(element.getTagName())) {
  4. NodeList<Element> headers = element.getElementsByTagName("header");
  5. if (headers.getLength() == 1 && childWidgets.size() == 1) {
  6. // case of "header"
  7. String header = headers.getItem(0).getInnerHTML();
  8. String headerSize = headers.getItem(0).getAttribute("size");
  9. wrapped.add(childWidgets.get(0).asWidget(), header, Double.valueOf(headerSize));
  10. } else {
  11. NodeList<Element> customHeaders = element.getElementsByTagName("customHeader");
  12. if (customHeaders.getLength() == 1 && childWidgets.size() == 1) {
  13. // case of "customHeader"
  14. List<IsWidget> customHeaderChilds = UiBinderXmlUtils.getChildWidgets(customHeaders.getItem(0));
  15. if (customHeaderChilds.size() == 1) {
  16. String customHeaderSize = customHeaders.getItem(0).getAttribute("size");
  17. wrapped.add(childWidgets.get(0), customHeaderChilds.get(0),
  18. Double.valueOf(customHeaderSize));
  19. }
  20. }
  21. }
  22. }
  23. }

代码示例来源:origin: org.eclipse.che.core/che-core-ide-ui

  1. Element item = nodeContainer.getElementsByTagName("span").getItem(0);
  2. String name = node.getName();
  3. String innerText = item.getInnerText();
  4. item = nodeContainer.getElementsByTagName("div").getItem(0).getFirstChildElement();
  5. innerText = item.getInnerText();

代码示例来源:origin: bedatadriven/activityinfo

  1. private void makeItBootstrapish(boolean allowRecursiveCall) {
  2. NodeList<Element> linkList = getElement().getParentElement().getElementsByTagName("a");
  3. Element link = linkList.getItem(0);
  4. link.setClassName("form-control");
  5. makeWidthIsNotCorrupted(link, allowRecursiveCall);
  6. }

代码示例来源:origin: gwt-test-utils/gwt-test-utils

  1. @PatchMethod
  2. static JavaScriptObject getElementsByTagNameImpl(XMLParserImpl xmlParserImpl,
  3. JavaScriptObject o, String tagName) {
  4. Node node = o.cast();
  5. NodeList<Element> nodeList;
  6. switch (node.getNodeType()) {
  7. case Node.DOCUMENT_NODE:
  8. Document document = node.cast();
  9. nodeList = document.getElementsByTagName(tagName);
  10. break;
  11. case Node.ELEMENT_NODE:
  12. Element element = node.cast();
  13. nodeList = element.getElementsByTagName(tagName);
  14. break;
  15. default:
  16. nodeList = JsoUtils.newNodeList();
  17. break;
  18. }
  19. return nodeList;
  20. }

代码示例来源:origin: com.googlecode.gwt-test-utils/gwt-test-utils

  1. @PatchMethod
  2. static JavaScriptObject getElementsByTagNameImpl(XMLParserImpl xmlParserImpl,
  3. JavaScriptObject o, String tagName) {
  4. Node node = o.cast();
  5. NodeList<Element> nodeList;
  6. switch (node.getNodeType()) {
  7. case Node.DOCUMENT_NODE:
  8. Document document = node.cast();
  9. nodeList = document.getElementsByTagName(tagName);
  10. break;
  11. case Node.ELEMENT_NODE:
  12. Element element = node.cast();
  13. nodeList = element.getElementsByTagName(tagName);
  14. break;
  15. default:
  16. nodeList = JsoUtils.newNodeList();
  17. break;
  18. }
  19. return nodeList;
  20. }

代码示例来源:origin: org.kuali.student.core/ks-common-ui

  1. /**
  2. * Shows the uiObject content in a printable form in a new window
  3. * @param uiObject
  4. */
  5. public static void print(UIObject uiObject){
  6. String headTag = "";
  7. String styleTags = "";
  8. NodeList<com.google.gwt.dom.client.Element> head = Document.get().getElementsByTagName("head");
  9. if(head.getItem(0) != null){
  10. com.google.gwt.dom.client.Element e = head.getItem(0);
  11. NodeList<com.google.gwt.dom.client.Element> styles = e.getElementsByTagName("style");
  12. for(int i = 0; i < styles.getLength(); i++){
  13. styleTags = styleTags + styles.getItem(i).getString();
  14. }
  15. }
  16. headTag = "<HEAD><TITLE>Print - " + Window.getTitle() + "</TITLE>" + styleTags + "</HEAD>";
  17. openPrintWindow(uiObject.getElement().getString(), headTag, num);
  18. num++;
  19. }

代码示例来源:origin: bedatadriven/activityinfo

  1. private void makeWidthIsNotCorrupted(Element link, boolean allowRecursiveCall) {
  2. if (link.getOffsetWidth() > 1000) {
  3. if (allowRecursiveCall) {
  4. forceRedrawLater(false);
  5. } else { // fallback, in 99% should not happen
  6. link.getParentElement().getStyle().setWidth(DEFAULT_WIDTH + 2, Style.Unit.PX);
  7. link.getStyle().setWidth(DEFAULT_WIDTH, Style.Unit.PX);
  8. link.getNextSiblingElement().getStyle().setWidth(DEFAULT_WIDTH, Style.Unit.PX);
  9. Element input = link.getNextSiblingElement().getElementsByTagName("input").getItem(0);
  10. input.getStyle().setWidth(DEFAULT_WIDTH - 15, Style.Unit.PX);
  11. }
  12. }
  13. }
  14. }

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-git-ext-git

  1. @Override
  2. public Element render(
  3. final Node node, final String domID, final Tree.Joint joint, final int depth) {
  4. // Initialize HTML elements.
  5. final Element rootContainer = super.render(node, domID, joint, depth);
  6. final Element nodeContainer = rootContainer.getFirstChildElement();
  7. final Element checkBoxElement = new CheckBox().getElement();
  8. final InputElement checkBoxInputElement =
  9. (InputElement) checkBoxElement.getElementsByTagName("input").getItem(0);
  10. final Path nodePath =
  11. node instanceof ChangedFileNode
  12. ? Path.valueOf(node.getName())
  13. : ((ChangedFolderNode) node).getPath();
  14. setCheckBoxState(nodePath, checkBoxInputElement);
  15. setCheckBoxClickHandler(nodePath, checkBoxElement, checkBoxInputElement.isChecked());
  16. // Paste check-box element to node container.
  17. nodeContainer.insertAfter(checkBoxElement, nodeContainer.getFirstChild());
  18. return rootContainer;
  19. }

代码示例来源:origin: oVirt/ovirt-engine

  1. protected void styleItem(TreeItem item, boolean enabled) {
  2. Element tableElm = DOM.getFirstChild(item.getElement());
  3. tableElm.setAttribute("width", "100%"); //$NON-NLS-1$ //$NON-NLS-2$
  4. Element col = tableElm.getElementsByTagName("td").getItem(0); //$NON-NLS-1$
  5. col.setAttribute("width", "20px"); //$NON-NLS-1$ //$NON-NLS-2$
  6. NodeList<Element> inputs = item.getElement().getElementsByTagName("input"); //$NON-NLS-1$
  7. for (int i = 0; i < inputs.getLength(); i++) {
  8. if (!enabled) {
  9. disableElement(inputs.getItem(i));
  10. } else {
  11. ElementTooltipUtils.destroyTooltip(inputs.getItem(i));
  12. }
  13. }
  14. NodeList<Element> spans = item.getElement().getElementsByTagName("span"); //$NON-NLS-1$
  15. for (int i = 0; i < spans.getLength(); i++) {
  16. if (!enabled) {
  17. disableElement(spans.getItem(i));
  18. } else {
  19. ElementTooltipUtils.destroyTooltip(spans.getItem(i));
  20. }
  21. }
  22. boolean isLeafEmpty = item.getUserObject() != null && item.getUserObject().equals(true);
  23. if (isLeafEmpty) {
  24. item.getElement().getElementsByTagName("td").getItem(0).getStyle().setVisibility(Visibility.HIDDEN); //$NON-NLS-1$
  25. }
  26. }

相关文章

Element类方法