List of usage examples for com.google.gwt.dom.client NodeList getLength
public int getLength()
From source file:com.arcbees.chosen.client.SelectParser.java
License:Apache License
public List<SelectItem> parse(SelectElement select) { NodeList<Node> children = select.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node n = children.getItem(i); addNode(n);//from w w w. jav a2 s. c o m } return parsed; }
From source file:com.arcbees.chosen.client.SelectParser.java
License:Apache License
private void addGroup(OptGroupElement group) { int position = parsed.size(); GroupItem item = new GroupItem(); item.arrayIndex = position;/*from w w w.j av a2 s . c o m*/ 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.arcbees.facebook.client.JavaScriptFacebook.java
License:Apache License
@Override public void injectFacebookApi(final FacebookCallback facebookCallback) { String locale = "en_US"; // get the correct locale from meta tag gwt:property facebooklocale final NodeList<Element> metas = Document.get().getElementsByTagName("meta"); for (int i = 0; i < metas.getLength(); i++) { final MetaElement m = MetaElement.as(metas.getItem(i)); if ("gwt:property".equals(m.getName())) { String content = m.getContent(); if (content.contains("facebooklocale")) { locale = content.replaceFirst(".*\\=", "").trim(); }//from w w w .j a v a 2 s . co m } } Element firstElement = Document.get().getBody().getFirstChildElement(); Element fbRoot = Document.get().createDivElement(); fbRoot.setId(FB_ROOT); firstElement.getParentNode().insertBefore(fbRoot, firstElement); ScriptElement fbScript = Document.get().createScriptElement(); fbScript.setSrc(FB_SCRIPT_SRC1 + locale + FB_SCRIPT_SRC2); fbScript.setType(FB_SCRIPT_TYPE); fbRoot.getParentNode().insertAfter(fbScript, fbRoot); Timer ensureFbIsLoaded = new Timer() { @Override public void run() { if (isLoaded()) { facebookCallback.onSuccess(); cancel(); } } }; ensureFbIsLoaded.scheduleRepeating(100); }
From source file:com.arcbees.seo.TagsInjector.java
License:Apache License
private Map<String, MetaElement> getMetaTags() { HeadElement head = document.getHead(); NodeList<Element> metaElements = head.getElementsByTagName("meta"); Map<String, MetaElement> metaElementsMap = new HashMap<>(); for (int i = 0; i < metaElements.getLength(); i++) { MetaElement metaElement = (MetaElement) metaElements.getItem(i); String name = getPropertyOrName(metaElement); metaElementsMap.put(name, metaElement); }//from w ww . j a va 2s . c o m return metaElementsMap; }
From source file:com.bearsoft.gwt.ui.widgets.grid.GridSection.java
@Override public void removeColumn(int index) { if (columnsRemover != null) { columnsRemover.removeColumn(index); } else {/*from w ww.jav a2 s.c om*/ Column<T, ?> col = getColumn(index); hiddenColumns.remove(col); super.removeColumn(index); NodeList<Element> colGroups = getElement().getElementsByTagName("colgroup"); if (colGroups != null && colGroups.getLength() == 1) { TableColElement colGroup = colGroups.getItem(0).cast(); if (getColumnCount() < colGroup.getChildCount()) { // It seems, that GWT's bug is still here. if (index >= 0 && index < colGroup.getChildCount()) { colGroup.removeChild(colGroup.getChild(index)); } } } } }
From source file:com.bearsoft.gwt.ui.widgets.grid.GridSection.java
public TableCellElement getCell(int aRow, int aCol) { NodeList<TableRowElement> rows = getTableBodyElement().getRows(); if (aRow >= 0 && aRow < rows.getLength()) { TableRowElement row = rows.getItem(aRow); NodeList<TableCellElement> cells = row.getCells(); if (aCol >= 0 && aCol < cells.getLength()) { return cells.getItem(aCol); }// www. j av a 2s.c o m } return null; }
From source file:com.bearsoft.gwt.ui.widgets.grid.GridSection.java
public <C> void redrawAllRowsInColumn(int aIndex, ListDataProvider<T> aDataProvider) { if (aIndex >= 0 && aIndex < getColumnCount()) { int start = getVisibleRange().getStart(); Column<T, C> column = (Column<T, C>) getColumn(aIndex); Cell<C> cell = column.getCell(); List<T> data = aDataProvider.getList(); ProvidesKey<T> keys = getKeyProvider(); NodeList<TableRowElement> rows = getTableBodyElement().getRows(); for (int i = 0; i < rows.getLength(); i++) { TableRowElement row = rows.getItem(i); NodeList<TableCellElement> cells = row.getCells(); if (aIndex >= 0 && aIndex < cells.getLength()) { TableCellElement toRerender = cells.getItem(aIndex); if (toRerender != null) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); int dataIdx = start + i; if (dataIdx >= 0 && dataIdx < data.size()) { T object = data.get(dataIdx); Cell.Context cx = new Cell.Context(start + i, aIndex, keys.getKey(object)); cell.render(cx, column.getValue(object), sb); // Take into account, that cell builder supports // some // maps // to cells' divs // and generates them. So we have to work with first // <div> // in <td>. toRerender.getFirstChildElement().setInnerSafeHtml(sb.toSafeHtml()); }//from w w w . j ava2s . co m } } } } }
From source file:com.bearsoft.gwt.ui.XElement.java
protected static void iterate(Element aRoot, Observer aTask) { if (aRoot != null) { aTask.observe(aRoot);//from ww w . j a v a2s . c o m NodeList<Node> nl = aRoot.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node n = nl.getItem(i); if (n instanceof Element) { iterate((Element) n, aTask); } } } }
From source file:com.bearsoft.gwt.ui.XElement.java
/** * Removes a mask over this element to disable user interaction. * // ww w . j a v a 2s .com */ public final void unmask() { NodeList<Node> nl = getChildNodes(); for (int i = nl.getLength() - 1; i >= 0; i--) { Node n = nl.getItem(i); if (Element.is(n) && Element.as(n).getClassName() != null && Element.as(n).hasClassName("p-mask")) { n.removeFromParent(); } } }
From source file:com.bearsoft.gwt.ui.XElement.java
public final int getChildIndex(Element aChild) { NodeList<Node> nl = getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { if (nl.getItem(i) == aChild) { return i; }// ww w .jav a 2 s . c o m } return -1; }