Example usage for com.google.gwt.dom.client NodeList getItem

List of usage examples for com.google.gwt.dom.client NodeList getItem

Introduction

In this page you can find the example usage for com.google.gwt.dom.client NodeList getItem.

Prototype

public T getItem(int index) 

Source Link

Usage

From source file:com.vaadin.terminal.gwt.client.ui.VLabel.java

License:Open Source License

private void sinkOnloadsForContainedImgs() {
    NodeList<Element> images = getElement().getElementsByTagName("img");
    for (int i = 0; i < images.getLength(); i++) {
        Element img = images.getItem(i);
        DOM.sinkEvents((com.google.gwt.user.client.Element) img, Event.ONLOAD);
    }/*ww w. ja v a2s.c o  m*/

}

From source file:com.vaadin.terminal.gwt.client.ui.VTabsheetPanel.java

License:Open Source License

/**
 * Creates an empty tabsheet panel.//from  ww w  . j  av  a  2 s  .com
 */
public VTabsheetPanel() {
    setElement(DOM.createDiv());
    sinkEvents(Event.TOUCHEVENTS);
    addDomHandler(new TouchStartHandler() {
        public void onTouchStart(TouchStartEvent event) {
            /*
             * All container elements needs to be scrollable by one finger.
             * Update the scrollable element list of touch delegate on each
             * touch start.
             */
            NodeList<Node> childNodes = getElement().getChildNodes();
            Element[] elements = new Element[childNodes.getLength()];
            for (int i = 0; i < elements.length; i++) {
                elements[i] = (Element) childNodes.getItem(i);
            }
            getTouchScrollDelegate().setElements(elements);
            getTouchScrollDelegate().onTouchStart(event);
        }
    }, TouchStartEvent.getType());
}

From source file:com.vaadin.terminal.gwt.client.Util.java

License:Open Source License

public static void sinkOnloadForImages(Element element) {
    NodeList<com.google.gwt.dom.client.Element> imgElements = element.getElementsByTagName("img");
    for (int i = 0; i < imgElements.getLength(); i++) {
        DOM.sinkEvents((Element) imgElements.getItem(i), Event.ONLOAD);
    }/* w  ww .j  a va 2s . c o  m*/

}

From source file:com.watopi.chosen.client.ChosenImpl.java

License:Open Source License

private void setDefaultValues() {
    clickTestAction = new Function() {
        @Override/*from w  w w  .  j  ava2  s  . c  om*/
        public boolean f(Event e) {
            return testActiveClick(e);
        }
    };

    activateAction = new Function() {
        @Override
        public boolean f(Event e) {
            return activateField(e);
        }
    };

    activeField = false;
    mouseOnContainer = false;
    resultsShowing = false;

    NodeList<OptionElement> optionsList = selectElement.getOptions();
    allowSingleDeselect = options.isAllowSingleDeselect() && optionsList.getLength() > 0
            && "".equals(optionsList.getItem(0).getText());

    choices = 0;

    if (options.getResources() != null) {
        css = options.getResources().css();
    } else {
        css = GWT.<Resources>create(Resources.class).css();
    }

    // Force the injection the first time only 
    // If you want to use different css file for different GwtChosen component
    // please register your css files (css.ensureInject()) before the first call of the plugin
    if (!cssInjected) {
        StyleInjector.inject(css.getText(), true);
        cssInjected = true;
    }

}

From source file:com.watopi.chosen.client.SelectParser.java

License:Open Source License

public JsObjectArray<SelectItem> parse(SelectElement select) {

    NodeList<Node> children = select.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node n = children.getItem(i);
        addNode(n);//  w w  w .  j  av a  2  s .  co  m
    }

    return parsed;
}

From source file:com.watopi.chosen.client.SelectParser.java

License:Open Source License

private void addGroup(OptGroupElement group) {
    int position = parsed.length();

    GroupItem item = new GroupItem();
    item.arrayIndex = position;/*from   ww  w .  j av a2 s  .com*/
    item.label = group.getLabel();
    item.children = 0;
    item.disabled = group.isDisabled();

    parsed.add(item);

    NodeList<Node> children = group.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node n = children.getItem(i);
        if ("OPTION".equalsIgnoreCase(n.getNodeName())) {
            addOption(OptionElement.as((Element) n), position, group.isDisabled());
        }
    }

}

From source file:com.xemantic.tadedon.gwt.user.client.ui.TablePanel.java

License:Apache License

public void addRow(IsWidget rowWidget) {
    if (!(rowWidget.asWidget().getElement().cast() instanceof TableRowElement)) {
        throw new IllegalArgumentException("rowWidget's root element must be instance of TableRowElement");
    }/*w  ww .j  av  a 2 s . co m*/

    TableElement table = getElement().cast();
    NodeList<TableSectionElement> tBodies = table.getTBodies();
    if ((tBodies != null) && (tBodies.getLength() > 0)) {
        TableSectionElement tbody = tBodies.getItem(0);
        add(rowWidget.asWidget(), tbody);
    } else {
        add(rowWidget.asWidget(), getElement());
    }
}

From source file:com.xpn.xwiki.wysiwyg.client.widget.RadioButton.java

License:Open Source License

/**
 * Sets the value attribute of this radio button.
 * //from w w  w  . j ava2  s.c o  m
 * @param value the value to set for this radio button.
 */
public void setValue(String value) {
    NodeList<Element> innerInputList = this.getElement().getElementsByTagName(INPUT_TAG_NAME);
    if (innerInputList.getLength() > 0) {
        Element wrappedInput = innerInputList.getItem(0);
        wrappedInput.setAttribute(VALUE_ATTR_NAME, value);
    }
}

From source file:com.xpn.xwiki.wysiwyg.client.widget.RadioButton.java

License:Open Source License

/**
 * @return the value attribute of this radio button.
 *///www .j  a  v a 2  s  .c om
public String getValue() {
    NodeList<Element> innerInputList = this.getElement().getElementsByTagName(INPUT_TAG_NAME);
    if (innerInputList.getLength() > 0) {
        Element wrappedInput = innerInputList.getItem(0);
        return wrappedInput.getAttribute(VALUE_ATTR_NAME);
    }
    return "";
}

From source file:cz.cas.lib.proarc.webapp.client.ClientUtils.java

License:Open Source License

/**
 * Dumps Element content and traverse its children.
 * <p/><b>WARNING:</b> it is com.google.gwt.dom.client.Element not com.google.gwt.xml.client.Element!!!
 * //from  w ww  . j av  a 2  s  .  c o  m
 * @param elm an element to dump
 * @param indent row indentation for current level
 * @param indentIncrement increment for next level
 * @param sb dumped content
 * @return dumped content
 */
public static StringBuilder dump(Element elm, String indent, String indentIncrement, StringBuilder sb) {
    int childCount = elm.getChildCount();
    String innerText = elm.getInnerText();
    String lang = elm.getLang();
    String nodeName = elm.getNodeName();
    short nodeType = elm.getNodeType();
    String getString = elm.getString();
    String tagNameWithNS = elm.getTagName();
    String xmlLang = elm.getAttribute("xml:lang");

    sb.append(ClientUtils.format(
            "%sElement {nodeName: %s, nodeType: %s, tagNameWithNS: %s, lang: %s,"
                    + " childCount: %s, getString: %s, xmlLang: %s}\n",
            indent, nodeName, nodeType, tagNameWithNS, lang, childCount, getString, xmlLang));
    NodeList<Node> childNodes = elm.getChildNodes();
    indent += indentIncrement;
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node child = childNodes.getItem(i);
        if (Element.is(child)) {
            dump(Element.as(child), indent, indentIncrement, sb);
        } else {
            sb.append(ClientUtils.format("%sNode: nodeType: %s, nodeName: %s, childCount: %s, nodeValue: %s\n",
                    indent, child.getNodeType(), child.getNodeName(), child.getChildCount(),
                    child.getNodeValue()));
        }
    }
    return sb;
}