private void setCheckBoxStyle(CheckBox box) { Element input = box.getElement().getFirstChildElement(); input.getStyle().setVerticalAlign(VerticalAlign.MIDDLE); Element label = input.getNextSiblingElement(); label.getStyle().setVerticalAlign(VerticalAlign.MIDDLE); label.getStyle().setPaddingLeft(5, Unit.PX); label.getStyle().setFontSize(13, Unit.PX); }
@Override protected Element getCellParent(Element item) { return item.getFirstChildElement().getNextSiblingElement(); }
@Override public void setValue(Context context, Element parent, C object) { Element curChild = getContainerElement(parent).getFirstChildElement(); for (HasCell<C, ?> hasCell : hasCells) { setValueImpl(context, curChild, object, hasCell); curChild = curChild.getNextSiblingElement(); } }
@Override public boolean isEditing(Context context, Element parent, C value) { Element curChild = getContainerElement(parent).getFirstChildElement(); for (HasCell<C, ?> hasCell : hasCells) { if (isEditingImpl(context, curChild, value, hasCell)) { return true; } curChild = curChild.getNextSiblingElement(); } return false; }
@Override public boolean resetFocus(Context context, Element parent, C value) { Element curChild = getContainerElement(parent).getFirstChildElement(); for (HasCell<C, ?> hasCell : hasCells) { // The first child that takes focus wins. Only one child should ever be in // edit mode, so this is safe. if (resetFocusImpl(context, curChild, value, hasCell)) { return true; } curChild = curChild.getNextSiblingElement(); } return false; }
/** * This method is used for legacy AbstractCellTable that's not a * {@link TableSectionChangeHandler}. */ protected void replaceAllRowsImplLegacy(AbstractCellTable<?> table, TableSectionElement section, SafeHtml html) { // Remove all children. Element child = section.getFirstChildElement(); while (child != null) { Element next = child.getNextSiblingElement(); section.removeChild(child); child = next; } // Add new child elements. TableSectionElement newSection = convertToSectionElement(table, section.getTagName(), html); child = newSection.getFirstChildElement(); while (child != null) { Element next = child.getNextSiblingElement(); section.appendChild(child); child = next; } }
/** * Attaches the element to the dom temporarily. Keeps track of where it is * attached so that things can be put back latter. * * @return attachment record which can be used for reverting back to previous * DOM state */ public static TempAttachment attachToDom(Element element) { // TODO(rjrjr) This is copied from HTMLPanel. Reconcile ensureHiddenDiv(); // Hang on to the panel's original parent and sibling elements so that it // can be replaced. Element origParent = element.getParentElement(); Element origSibling = element.getNextSiblingElement(); // Attach the panel's element to the hidden div. hiddenDiv.appendChild(element); return new TempAttachment(origParent, origSibling, element); }
@Override public void onBrowserEvent(Context context, Element parent, C value, NativeEvent event, ValueUpdater<C> valueUpdater) { int index = 0; EventTarget eventTarget = event.getEventTarget(); if (Element.is(eventTarget)) { Element target = eventTarget.cast(); Element container = getContainerElement(parent); Element wrapper = container.getFirstChildElement(); while (wrapper != null) { if (wrapper.isOrHasChild(target)) { onBrowserEventImpl(context, wrapper, value, event, valueUpdater, hasCells.get(index)); } index++; wrapper = wrapper.getNextSiblingElement(); } } }
/** * Check whether or not an event occurred within the wrapper around the image * element. * * @param event the event * @param parent the parent element * @return true if the event targets the image */ private boolean eventOccurredOnImage(NativeEvent event, Element parent) { EventTarget eventTarget = event.getEventTarget(); if (!Element.is(eventTarget)) { return false; } Element target = eventTarget.cast(); // Make sure the target occurred within the div around the image. Element imgWrapper = parent.getFirstChildElement().getNextSiblingElement(); return imgWrapper.isOrHasChild(target); } }
Element nextSibling = toReplace.getNextSiblingElement(); childContainer.replaceChild(newChildren.getChild(0), toReplace); toReplace = nextSibling;
/** * Redraw the widget. */ public void redraw() { SafeHtmlBuilder sb = new SafeHtmlBuilder(); cell.render(createContext(), value, sb); getElement().setInnerSafeHtml(sb.toSafeHtml()); /* * The rendered Cell should fill the root element so height and width styles * applied to the widget also apply to the Cell. If there is exactly one * child element, the height and width are set to 100% to fill the parent. */ Element child = getElement().getFirstChildElement(); if (child != null && child.getNextSiblingElement() == null) { child.getStyle().setHeight(100, Unit.PCT); child.getStyle().setWidth(100, Unit.PCT); } }
private com.google.gwt.dom.client.Element findBodyTr(final int i) { int j = 0; Element tr = body.getFirstChildElement(); while (tr != null && j < i) { tr = tr.getNextSiblingElement(); j++; } return tr; }
@Override protected Element getCellParent(Element item) { return item.getFirstChildElement().getNextSiblingElement(); }
private static Element firstNonMetaElement(final Element parserDiv) { Element displayable = parserDiv.getFirstChildElement(); while (displayable != null && displayable.getTagName().equalsIgnoreCase("meta")) { displayable = displayable.getNextSiblingElement(); } return displayable; }
private Element getToolBar(String role) { Element element = getElement().getFirstChildElement(); while (element != null) { if (role.equals(element.getAttribute("data-role"))) { return element; } element = element.getNextSiblingElement(); } return null; }
@Override public void setValue(Context context, Element parent, C object) { Element curChild = getContainerElement(parent).getFirstChildElement(); for (HasCell<C, ?> hasCell : hasCells) { setValueImpl(context, curChild, object, hasCell); curChild = curChild.getNextSiblingElement(); } }
Element newChild = newSection.getFirstChildElement(); while (newChild != null) { Element next = newChild.getNextSiblingElement(); section.insertBefore(newChild, insertBefore); newChild = next;
private static <T> VisitContext<T> depthFirst(VisitContextImpl<T> context, Element root, Visitor<T> visitor) { Element current = root; // If visit returns false, stop visiting down (but keep visiting) if (visitor.visit(context, current)) { current = current.getFirstChildElement(); while (current != null && !context.isVisitComplete()) { depthFirst(context, current, visitor); current = current.getNextSiblingElement(); } } return context; }
/** * Get all following siblings of each element in the set of matched elements, filtered by a * selector. */ public GQuery nextAll(String filter) { JsNodeArray result = JsNodeArray.create(); for (Element e : elements) { allNextSiblingElements(e.getNextSiblingElement(), result, null, null, filter); } return pushStack(unique(result), "nextAll", getSelector()); }
/** * Get all following siblings of each element up to but not including the element matched by the * GQuery object, filtered by a selector. * * @return */ public GQuery nextUntil(GQuery until, String filter) { JsNodeArray result = JsNodeArray.create(); for (Element e : elements) { allNextSiblingElements(e.getNextSiblingElement(), result, null, until, filter); } return pushStack(unique(result), "nextUntil", getSelector()); }