/** * Collects parents going up the element tree, terminated at the tree root. */ private void collectElementChain(ArrayList<Element> chain, Element hRoot, Element hElem) { if ((hElem == null) || (hElem == hRoot)) { return; } collectElementChain(chain, hRoot, DOM.getParent(hElem)); chain.add(hElem); }
/** * The container {@link Element} around a {@link Widget}. * * @param w the {@link Widget} * @return the container {@link Element} */ private static Element getContainer(Widget w) { return DOM.getParent(w.getElement()); }
/** * Determines the TD associated with the specified event. * * @param event the event to be queried * @return the TD associated with the event, or <code>null</code> if none is * found. */ protected com.google.gwt.user.client.Element getEventTargetCell(Event event) { Element td = DOM.eventGetTarget(event); for (; td != null; td = DOM.getParent(td)) { // If it's a TD, it might be the one we're looking for. if (td.getPropertyString("tagName").equalsIgnoreCase("td")) { // Make sure it's directly a part of this table before returning // it. Element tr = DOM.getParent(td); Element body = DOM.getParent(tr); if (body == bodyElem) { return DOM.asOld(td); } } // If we run into this table's body, we're out of options. if (td == bodyElem) { return null; } } return null; }
Element getWidgetTd(Widget w) { if (w.getParent() != this) { return null; } return DOM.getParent(w.getElement()); } }
@Override public boolean remove(Widget w) { /* * Get the TR to be removed before calling super.remove() because * super.remove() will detach the child widget's element from its parent. */ Element td = DOM.getParent(w.getElement()); boolean removed = super.remove(w); if (removed) { getBody().removeChild(DOM.getParent(td)); } return removed; }
private int findDividerIndex(Element elem) { while (elem != null && elem != getElement()) { String expando = elem.getPropertyString("__index"); if (expando != null) { // Make sure it belongs to me! int ownerHash = elem.getPropertyInt("__owner"); if (ownerHash == hashCode()) { // Yes, it's mine. return Integer.parseInt(expando); } else { // It must belong to some nested StackPanel. return -1; } } elem = DOM.getParent(elem); } return -1; }
@Override public boolean remove(Widget w) { // Get the TD to be removed, before calling super.remove(), because // super.remove() will detach the child widget's element from its parent. Element td = DOM.getParent(w.getElement()); boolean removed = super.remove(w); if (removed) { tableRow.removeChild(td); } return removed; }
private void setSelectionStyle(Widget item, boolean selected) { if (item != null) { if (selected) { item.addStyleName("gwt-TabBarItem-selected"); setStyleName(DOM.getParent(item.getElement()), "gwt-TabBarItem-wrapper-selected", true); } else { item.removeStyleName("gwt-TabBarItem-selected"); setStyleName(DOM.getParent(item.getElement()), "gwt-TabBarItem-wrapper-selected", false); } } } }
int count = countObj == null ? 1 : countObj.intValue(); String debugID = generateDebugId(dir, count); ensureDebugId(DOM.getParent(child.getElement()), baseID, debugID);
/** * Remove the specified widget from the table. * * @param widget widget to remove * @return was the widget removed from the table. */ @Override public boolean remove(Widget widget) { // Validate. if (widget.getParent() != this) { return false; } // Orphan. try { orphan(widget); } finally { // Physical detach. Element elem = widget.getElement(); DOM.getParent(elem).removeChild(elem); // Logical detach. widgetMap.removeByElement(elem); } return true; }
@Override public boolean remove(Widget w) { // Validate. if (w.getParent() != this) { return false; } // Orphan. try { orphan(w); } finally { // Physical detach. Element elem = w.getElement(); DOM.getParent(elem).removeChild(elem); // Logical detach. getChildren().remove(w); } return true; }
/** * <b>Affected Elements:</b> * <ul> * <li>-tab# = The element containing the contents of the tab.</li> * <li>-tab-wrapper# = The cell containing the tab at the index.</li> * </ul> * * @see UIObject#onEnsureDebugId(String) */ @Override protected void onEnsureDebugId(String baseID) { super.onEnsureDebugId(baseID); int numTabs = getTabCount(); for (int i = 0; i < numTabs; i++) { ClickDelegatePanel delPanel = (ClickDelegatePanel) panel.getWidget(i + 1); SimplePanel focusablePanel = delPanel.getFocusablePanel(); ensureDebugId(focusablePanel.getContainerElement(), baseID, "tab" + i); ensureDebugId(DOM.getParent(delPanel.getElement()), baseID, "tab-wrapper" + i); } }
/** * Inserts a new tab at the specified index. * * @param widget widget to be used in the new tab * @param beforeIndex the index before which this tab will be inserted */ protected void insertTabWidget(Widget widget, int beforeIndex) { checkInsertBeforeTabIndex(beforeIndex); ClickDelegatePanel delWidget = new ClickDelegatePanel(widget); delWidget.setStyleName(STYLENAME_DEFAULT); // Add a11y role "tab" SimplePanel focusablePanel = delWidget.getFocusablePanel(); Roles.getTabRole().set(focusablePanel.getElement()); panel.insert(delWidget, beforeIndex + 1); setStyleName(DOM.getParent(delWidget.getElement()), STYLENAME_DEFAULT + "-wrapper", true); }
/** * Returns the element's parent. * * @return the parent */ public El getParent() { Element e = DOM.getParent(dom); return e == null ? null : new El(e); }
Element getWidgetTd(Widget w) { if (w.getParent() != this) { return null; } return DOM.getParent(w.getElement()); } }
@Override public boolean remove(Widget w) { // Get the TD to be removed, before calling super.remove(), because // super.remove() will detach the child widget's element from its parent. Element td = DOM.getParent(w.getElement()); boolean removed = super.remove(w); if (removed) { tableRow.removeChild(td); } return removed; }
public int getHeaderForEvent( NativeEvent event ) { Element th = getEventTargetHeader( Event.as( event ) ); if( th == null ) return -1; return DOM.getChildIndex( DOM.getParent( th ), th ); }
/** * Sets header height property to the specified value.<p/> * This method is rather rarely used. Typically you don't have to invoke it. * * @param height is a value of the property. */ public void setHeaderHeight(String height) { DOM.setStyleAttribute(DOM.getParent(getHeaderTable().getElement()), "height", height); }