List of usage examples for com.google.gwt.dom.client NodeList getLength
public int getLength()
From source file:ru.codeinside.gses.vaadin.client.VJsonFormIntegration.java
License:Mozilla Public License
private Frame createFrameWrap() { if (browserElement == null) { return null; }/*from w w w . ja va 2 s . c o m*/ Frame frameWrap = Frame.wrap(browserElement); frameWrap.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() { @Override public boolean execute() { IFrameElement formFrame = IFrameElement.as(browserElement); Document formDoc = formFrame.getContentDocument(); if (formDoc == null) { return true; } NodeList<com.google.gwt.dom.client.Element> elements; elements = formDoc.getElementsByTagName("input"); for (int i = 0; i < elements.getLength(); i++) { InputElement input = InputElement.as(elements.getItem(i)); if ("button".equalsIgnoreCase(input.getType())) { input.setDisabled(true); } else { input.setReadOnly(true); } } elements = formDoc.getElementsByTagName("button"); for (int i = 0; i < elements.getLength(); i++) { ButtonElement button = ButtonElement.as(elements.getItem(i)); button.setDisabled(true); } elements = formDoc.getElementsByTagName("select"); for (int i = 0; i < elements.getLength(); i++) { SelectElement select = SelectElement.as(elements.getItem(i)); select.setDisabled(true); } elements = formDoc.getElementsByTagName("textarea"); for (int i = 0; i < elements.getLength(); i++) { TextAreaElement textArea = TextAreaElement.as(elements.getItem(i)); textArea.setReadOnly(true); } return false; } }, 99); } }); return frameWrap; }
From source file:sf.wicklet.gwt.client.util.GwtDomUtil.java
License:Apache License
public static boolean hasElementWithAttributeValue(final com.google.gwt.dom.client.Document d, final String tag, final String name, final String value) { final com.google.gwt.dom.client.NodeList<com.google.gwt.dom.client.Element> a = d.getElementsByTagName(tag); for (int i = 0, len = a.getLength(); i < len; ++i) { final com.google.gwt.dom.client.Element elm = a.getItem(i); if (GwtTextUtil.equals(value, elm.getAttribute(name))) { return true; }//from w ww . j av a 2 s . c o m } return false; }
From source file:strat.mining.multipool.stats.client.component.TwitterTimelineWidget.java
License:Open Source License
public void setSize(int width, int height) { NodeList<Element> iframeNodes = container.getElement().getElementsByTagName("iframe"); if (iframeNodes != null && iframeNodes.getLength() > 0) { int iFrameHeight = height - 30; iFrameHeight = iFrameHeight > 0 ? iFrameHeight : 0; iframeNodes.getItem(0).setAttribute("width", width + "px"); iframeNodes.getItem(0).setAttribute("height", iFrameHeight + "px"); int streamHeight = iFrameHeight - 87; streamHeight = streamHeight > 0 ? streamHeight : 0; setHeight(streamHeight);/*from w w w .j av a2 s.c o m*/ } }
From source file:stroom.cell.valuespinner.client.ValueSpinnerCell.java
License:Apache License
@Override public void onBrowserEvent(final Context context, final Element parent, final Number value, final NativeEvent event, final ValueUpdater<Number> valueUpdater) { super.onBrowserEvent(context, parent, value, event, valueUpdater); // Get the target element. final Element target = event.getEventTarget().cast(); final String eventType = event.getType(); if ("focus".equals(eventType)) { // Ignore change events that don't target the input. final InputElement input = getInputElement(parent); if (input == null || !input.isOrHasChild(target)) { return; }/*from ww w. ja v a2 s .c o m*/ focusedKey = context.getKey(); } else if ("blur".equals(eventType)) { // Ignore change events that don't target the input. final InputElement input = getInputElement(parent); if (input == null || !input.isOrHasChild(target)) { return; } focusedKey = null; } else if ("change".equals(eventType)) { // Ignore change events that don't target the input. final InputElement input = getInputElement(parent); if (input == null || !input.isOrHasChild(target)) { return; } // The input has changed so finish editing. finishEditing(parent, value, context.getKey(), valueUpdater); } else if ("keyup".equals(eventType)) { // Ignore key up events that don't target the input. final InputElement input = getInputElement(parent); if (input == null || !input.isOrHasChild(target)) { return; } // Record keys as they are typed. final Object key = context.getKey(); ViewData vd = getViewData(key); if (vd == null) { vd = new ViewData(String.valueOf(value)); setViewData(key, vd); } vd.setCurrentValue(input.getValue()); } else { final NodeList<Element> nodes = parent.getElementsByTagName("img"); ImagePrototypeElement upArrow = null; ImagePrototypeElement downArrow = null; if (nodes != null && nodes.getLength() > 1) { upArrow = nodes.getItem(0).cast(); downArrow = nodes.getItem(1).cast(); if (upArrow.isOrHasChild(target)) { if ("mouseover".equals(eventType)) { arrowUpHover.applyTo(upArrow); } else if ("mouseout".equals(eventType)) { arrowUp.applyTo(upArrow); stopSpinning(context, parent, value, valueUpdater); } else if ("mouseup".equals(eventType)) { arrowUpHover.applyTo(upArrow); stopSpinning(context, parent, value, valueUpdater); } else if ("mousedown".equals(eventType)) { arrowUpPressed.applyTo(upArrow); ensureSpinner(); // Get the object that we are going to use to apply // value constraints. HasSpinnerConstraints constraints = this; if (value instanceof HasSpinnerConstraints) { constraints = (HasSpinnerConstraints) value; } final InputElement input = getInputElement(parent); if (input == null) { spinner.start(constraints, true, 0, input); } else { final String constrainedValue = constrainValue(constraints, input.getValue()); spinner.start(constraints, true, Long.valueOf(constrainedValue), input); } } } else if (downArrow.isOrHasChild(target)) { if ("mouseover".equals(eventType)) { arrowDownHover.applyTo(downArrow); } else if ("mouseout".equals(eventType)) { arrowDown.applyTo(downArrow); stopSpinning(context, parent, value, valueUpdater); } else if ("mouseup".equals(eventType)) { arrowDownHover.applyTo(downArrow); stopSpinning(context, parent, value, valueUpdater); } else if ("mousedown".equals(eventType)) { arrowDownPressed.applyTo(downArrow); ensureSpinner(); // Get the object that we are going to use to apply // value constraints. HasSpinnerConstraints constraints = this; if (value instanceof HasSpinnerConstraints) { constraints = (HasSpinnerConstraints) value; } final InputElement input = getInputElement(parent); final String constrainedValue = constrainValue(constraints, input.getValue()); spinner.start(constraints, false, Long.valueOf(constrainedValue), input); } } } } }
From source file:stroom.cell.valuespinner.client.ValueSpinnerCell.java
License:Apache License
private InputElement getInputElement(final Element parent) { Element vsDiv = null;/*from w w w.j a v a 2 s . co m*/ if (parent.hasTagName("div") && parent.hasClassName("valueSpinner")) { vsDiv = parent; } else { final NodeList<Element> divs = parent.getElementsByTagName("div"); for (int i = 0; i < divs.getLength(); i++) { final Element div = divs.getItem(i); if (div.hasClassName("valueSpinner")) { vsDiv = div; break; } } } if (vsDiv != null) { final Element inputElement = vsDiv.getFirstChildElement(); if (inputElement != null) { return inputElement.cast(); } } return null; }
From source file:stroom.svg.client.SvgImage.java
License:Apache License
private Element getSvg(final Element parent) { final NodeList<Element> nodes = parent.getElementsByTagName("svg"); if (nodes != null && nodes.getLength() > 0) { return nodes.getItem(0); }//from w ww. ja v a2 s. c o m return null; }
From source file:stroom.widget.button.client.ImageButton.java
License:Apache License
public void hide(final boolean hide) { final NodeList<Element> images = getElement().getElementsByTagName("img"); if (images.getLength() > 0) { final Element img = images.getItem(0); if (hide) { img.getStyle().setVisibility(Visibility.HIDDEN); } else {// www. j a v a 2 s.c o m img.getStyle().setVisibility(Visibility.VISIBLE); } } }
From source file:stroom.xmleditor.client.view.XMLArea.java
License:Apache License
public void scrollHighlightIntoView() { try {/*ww w .j a v a 2 s.c o m*/ if (container != null) { final NodeList<com.google.gwt.dom.client.Element> domElem = container.getElementsByTagName("hl"); if (domElem != null && domElem.getLength() > 0) { // Get the highlight rect. int left = Integer.MAX_VALUE; int right = 0; int top = Integer.MAX_VALUE; int bottom = 0; // Establish a bounding rect for the highlight area. for (int i = 0; i < domElem.getLength(); i++) { final Element element = domElem.getItem(i).cast(); if (element.getOffsetLeft() < left) { left = element.getOffsetLeft(); } if (element.getOffsetLeft() + element.getOffsetWidth() > right) { right = element.getOffsetLeft() + element.getOffsetWidth(); } if (element.getOffsetTop() < top) { top = element.getOffsetTop(); } if (element.getOffsetTop() + element.getOffsetHeight() > bottom) { bottom = element.getOffsetTop() + element.getOffsetHeight(); } } // Get the body rect. final int bodyLeft = container.getScrollLeft(); final int bodyRight = bodyLeft + container.getClientWidth(); final int bodyTop = container.getScrollTop(); final int bodyBottom = bodyTop + container.getClientHeight(); // Position the body scroll so that as much of the highlight // is shown as possible. if (bodyLeft > left) { container.setScrollLeft(left); } else if (bodyRight < right) { final int width = right - left; final int bodyWidth = bodyRight - bodyLeft; if (width > bodyWidth) { // The highlight section is too big to fit so show // the leftmost part. container.setScrollLeft(left); } else { // It will fit so show the rightmost part. container.setScrollLeft(right - bodyWidth); } } if (bodyTop > top) { container.setScrollTop(top); } else if (bodyBottom < bottom) { final int height = bottom - top; final int bodyHeight = bodyBottom - bodyTop; if (height > bodyHeight) { // The highlight section is too big to fit so show // the topmost part. container.setScrollTop(top); } else { // It will fit so show the bottommost part. container.setScrollTop(bottom - bodyHeight); } } } } } catch (final Exception e) { // Fails when source is not visible. This is not important so do // nothing. } }
From source file:virtuozo.infra.Elements.java
License:Apache License
public static Element byTagName(Element parent, String tagName) { NodeList<Element> nodeList = parent.getElementsByTagName(tagName); if (nodeList.getLength() > 0) { return nodeList.getItem(0); }/*from ww w .j a v a 2 s. c om*/ return null; }