/** * Gets an element's next sibling element. * * @param elem the element whose sibling is to be retrieved * @return the sibling element */ public static com.google.gwt.user.client.Element getNextSibling(Element elem) { return elem.getNextSibling().cast(); }
/** * Get the input element in edit mode. */ private InputElement getInputElement(Element parent) { return parent.getFirstChild().<InputElement> cast(); }
/** * Clones an element. * * @param elem the element to be cloned * @param deep should children be cloned as well? */ public static com.google.gwt.user.client.Element clone(Element elem, boolean deep) { return elem.cloneNode(deep).cast(); }
/** * Get the parent element of the decorated cell. * * @param parent the parent of this cell * @return the decorated cell's parent */ private Element getCellParent(Element parent) { return parent.getFirstChildElement().getChild(1).cast(); } }
/** * Returns the element that parents the cell contents of the node. * * @param nodeElem the element that represents the node * @return the cell parent within the node */ private static Element getCellParent(Element nodeElem) { return getSelectionElement(nodeElem).getFirstChildElement().getChild(1).cast(); }
/** * Get the element that represents the specified index. * * @param index the index of the row value * @return the child element, or null if it does not exist */ protected Element getChildElement(int index) { Element childContainer = getChildContainer(); int childCount = childContainer.getChildCount(); return (index < childCount) ? childContainer.getChild(index).<Element> cast() : null; }
@Override protected Element getKeyboardSelectedElement() { // Do not use getRowElement() because that will flush the presenter. int rowIndex = getKeyboardSelectedRow(); if (rowIndex >= 0 && childContainer.getChildCount() > rowIndex) { return childContainer.getChild(rowIndex).cast(); } return null; }
private static Element getFirstAncestorWithListener(Event evt) { Element curElem = evt.getCurrentEventTarget().cast(); while (curElem != null && getEventListener(curElem) == null) { curElem = curElem.getParentNode().cast(); } return curElem; }
private Element ensureColumn(int col) { prepareColumn(col); prepareColumnGroup(); resizeColumnGroup(col + 1, true); return columnGroup.getChild(col).cast(); }
/** * Creates an HTML IFRAME element with a name. * * @param name the name of the frame, which must contain at least one * non-whitespace character and must not contain reserved HTML markup * characters such as '<code><</code>', '<code>></code>', * or '<code>&</code>' * @return the newly-created element * @throws IllegalArgumentException if the supplied name is not allowed */ private static IFrameElement createIFrame(String name) { if (name == null || !isValidName(name.trim())) { throw new IllegalArgumentException( "expecting one or more non-whitespace chars with no '<', '>', or '&'"); } // Use innerHTML to implicitly create the <iframe>. This is necessary // because most browsers will not respect a dynamically-set iframe name. Element div = DOM.createDiv(); div.setInnerSafeHtml(IFrameTemplate.INSTANCE.get(name)); return div.getFirstChild().cast(); }
@Override public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) { super.onBrowserEvent(context, parent, value, event, valueUpdater); String type = event.getType(); if (BrowserEvents.CHANGE.equals(type)) { Object key = context.getKey(); SelectElement select = parent.getFirstChild().cast(); String newValue = options.get(select.getSelectedIndex()); setViewData(key, newValue); finishEditing(parent, newValue, key, valueUpdater); if (valueUpdater != null) { valueUpdater.update(newValue); } } }
/** * Get the {@link TableColElement} at the specified index, creating it if * necessary. * * @param index the column index * @return the {@link TableColElement} */ public TableColElement ensureTableColElement(int index) { // Ensure that we have enough columns. for (int i = colgroup.getChildCount(); i <= index; i++) { colgroup.appendChild(Document.get().createColElement()); } return colgroup.getChild(index).cast(); }
/** * Get the {@link TableColElement} at the specified index, creating it if * necessary. * * @param index the column index * @return the {@link TableColElement} */ private TableColElement ensureTableColElement(int index) { // Ensure that we have enough columns. for (int i = colgroup.getChildCount(); i <= index; i++) { colgroup.appendChild(Document.get().createColElement()); } return colgroup.getChild(index).cast(); } }
/** * Get the {@link Element} for the specified index. If the element has not * been created, null is returned. * * @param indexOnPage the index on the page * @return the element, or null if it doesn't exists * @throws IndexOutOfBoundsException if the index is outside of the current * page */ public Element getRowElement(int indexOnPage) { getPresenter().flush(); checkRowBounds(indexOnPage); if (childContainer.getChildCount() > indexOnPage) { return childContainer.getChild(indexOnPage).cast(); } return null; }
private void updateVisibility(Element container) { // If this element has an associated layer, re-run layout for it. Layer layer = getLayer(container); if (layer != null) { layout(layer); } // Walk all children, looking for elements with a '__layer' property. If one // exists, call layout() for that element. This is not cheap, but it's the // only way to correctly ensure that layout units get translated correctly. NodeList<Node> nodes = container.getChildNodes(); for (int i = 0; i < nodes.getLength(); ++i) { Node node = nodes.getItem(i); if (node.getNodeType() == Node.ELEMENT_NODE) { updateVisibility(node.<Element>cast()); } } } }
/** * Returns the wrapped {@link com.google.gwt.dom.client.Document} * @return the wrapped {@link com.google.gwt.dom.client.Document} */ public Document getDocument() { return ot.cast(); }
@Override public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) { // The loading indicator can fire its own load or error event, so we check // that the event actually occurred on the main image. String type = event.getType(); if (BrowserEvents.LOAD.equals(type) && eventOccurredOnImage(event, parent)) { // Remove the loading indicator. parent.getFirstChildElement().getStyle().setDisplay(Display.NONE); // Show the image. Element imgWrapper = parent.getChild(1).cast(); imgWrapper.getStyle().setProperty("height", "auto"); imgWrapper.getStyle().setProperty("width", "auto"); imgWrapper.getStyle().setProperty("overflow", "auto"); } else if (BrowserEvents.ERROR.equals(type) && eventOccurredOnImage(event, parent)) { // Replace the loading indicator with an error message. parent.getFirstChildElement().setInnerSafeHtml(errorRenderer.render(value)); } }
&& event.getKeyCode() == KeyCodes.KEY_ENTER; if (BrowserEvents.CHANGE.equals(type) || enterPressed) { InputElement input = parent.getFirstChild().cast(); Boolean isChecked = input.isChecked();
Element toReplace = null; if (start < childCount) { toReplace = childContainer.getChild(start).cast();
/** * Returns the elements previous sibling. * * @return the previous sibling */ public Element previousSibling() { return dom.getPreviousSibling().cast(); }