/** * Instantiates a new ImageTextButton. */ public ImageTextButton(ImageResource imageResource, String text, ClickHandler clickHandler) { super(); if (clickHandler != null) { addClickHandler(clickHandler); } String definedStyles = getElement().getAttribute("style"); getElement().setAttribute("style", definedStyles + "; vertical-align:middle;"); this.text = text; Element span = DOM.createElement("span"); span.setInnerText(text); DOM.insertChild(getElement(), span, 0); Element imageSpan = DOM.createElement("span"); int spacing; if (this.text == null || this.text.trim().equals("")) { spacing = 0; } else { spacing = 16; } if (imageResource != null) { updateImageElementFromImageResource(imageSpan, imageResource, spacing); } DOM.insertBefore(getElement(), imageSpan, DOM.getFirstChild(getElement())); }
/** * Get the element that {@link PopupImpl} uses. PopupImpl creates an element * that goes inside of the outer element, so all methods in PopupImpl are * relative to the first child of the outer element, not the outer element * itself. * * @return the Element that {@link PopupImpl} creates and expects */ private com.google.gwt.user.client.Element getPopupImplElement() { return DOM.getFirstChild(super.getContainerElement()); }
@Override Element getHeaderTextElem(Element headerElem) { Element tbody = DOM.getFirstChild(headerElem); Element tr = DOM.getChild(tbody, 1); Element td = DOM.getChild(tr, 1); return DOM.getFirstChild(td); } }
Element getImageElement() { return DOM.getFirstChild(getImageHolderElement()); }
/** * Gets the Widget associated with the given cell. * * @param row the cell's row * @param column the cell's column * @return the widget */ private Widget getWidgetImpl(int row, int column) { Element e = cellFormatter.getRawElement(row, column); Element child = DOM.getFirstChild(e); if (child == null) { return null; } else { return widgetMap.get(child); } } }
void convertToFullNode(TreeItem item) { if (item.imageHolder == null) { // Extract the Elements from the object Element itemTable = DOM.clone(BASE_INTERNAL_ELEM, true); DOM.appendChild(item.getElement(), itemTable); Element tr = DOM.getFirstChild(DOM.getFirstChild(itemTable)); Element tdImg = DOM.getFirstChild(tr); Element tdContent = DOM.getNextSibling(tdImg); // Undoes padding from table element. item.getElement().getStyle().setProperty("padding", "0px"); DOM.appendChild(tdContent, item.contentElem); item.imageHolder = tdImg; } }
/** * Get a specific Element from the panel. * * @param row the row index * @param cell the cell index * @return the Element at the given row and cell */ protected com.google.gwt.user.client.Element getCellElement(int row, int cell) { Element tr = DOM.getChild(tbody, row); Element td = DOM.getChild(tr, cell); return DOM.asOld(DOM.getFirstChild(td)); }
private void setStackVisible(int index, boolean visible) { // Get the first table row containing the widget's selector item. Element tr = DOM.getChild(body, (index * 2)); if (tr == null) { return; } // Style the stack selector item. Element td = DOM.getFirstChild(tr); setStyleName(td, DEFAULT_ITEM_STYLENAME + "-selected", visible); // Show/hide the contained widget. setStackContentVisible(index, visible); // Set the style of the next header Element trNext = DOM.getChild(body, ((index + 1) * 2)); if (trNext != null) { Element tdNext = DOM.getFirstChild(trNext); setStyleName(tdNext, DEFAULT_ITEM_STYLENAME + "-below-selected", visible); } }
/** * @deprecated Call and override {@link internalClearCell(Element, boolean)} instead. */ @Deprecated protected boolean internalClearCell(com.google.gwt.user.client.Element td, boolean clearInnerHTML) { Element maybeChild = DOM.getFirstChild(td); Widget widget = null; if (maybeChild != null) { widget = widgetMap.get(maybeChild); } if (widget != null) { // If there is a widget, remove it. remove(widget); return true; } else { // Otherwise, simply clear whatever text and/or HTML may be there. if (clearInnerHTML) { td.setInnerHTML(""); } return false; } }
/** * <b>Affected Elements:</b> * <ul> * <li>-text# = The element around the header at the specified index.</li> * <li>-text-wrapper# = The element around the header at the specified index.</li> * <li>-content# = The element around the body at the specified index.</li> * </ul> * * @see UIObject#onEnsureDebugId(String) */ @Override protected void onEnsureDebugId(String baseID) { super.onEnsureDebugId(baseID); int numHeaders = DOM.getChildCount(body) >> 1; for (int i = 0; i < numHeaders; i++) { Element tdWrapper = DOM.getFirstChild(DOM.getChild(body, 2 * i)); Element headerElem = DOM.getFirstChild(tdWrapper); Element bodyElem = DOM.getFirstChild(DOM.getChild(body, 2 * i + 1)); ensureDebugId(tdWrapper, baseID, "text-wrapper" + i); ensureDebugId(bodyElem, baseID, "content" + i); ensureDebugId(getHeaderTextElem(headerElem), baseID, "text" + i); } }
private void updateIndicesFrom(int beforeIndex) { for (int i = beforeIndex, c = getWidgetCount(); i < c; ++i) { Element childTR = DOM.getChild(body, i * 2); Element childTD = DOM.getFirstChild(childTR); childTD.setPropertyInt("__index", i); // Update the special style on the first element if (beforeIndex == 0) { setStyleName(childTD, DEFAULT_ITEM_STYLENAME + "-first", true); } else { setStyleName(childTD, DEFAULT_ITEM_STYLENAME + "-first", false); } } }
private void showImage(TreeItem treeItem, AbstractImagePrototype proto) { Element holder = treeItem.getImageHolderElement(); Element child = DOM.getFirstChild(holder); if (child == null) { // If no image element has been created yet, create one from the // prototype. DOM.appendChild(holder, proto.createElement().<Element> cast()); } else { // Otherwise, simply apply the prototype to the existing element. proto.applyTo(child.<ImagePrototypeElement> cast()); } }
/** * Creates an empty tree item. * * @param isRoot true if this item is the root of a tree */ TreeItem(boolean isRoot) { this.isRoot = isRoot; Element elem = DOM.clone(BASE_BARE_ELEM, true); setElement(elem); contentElem = DOM.getFirstChild(elem); contentElem.setAttribute("id", DOM.createUniqueId()); // The root item always has children. if (isRoot) { initChildren(); } }
/** * Sets the text associated with a child by its index. * * @param index the index of the child whose text is to be set * @param text the text to be associated with it * @param asHTML <code>true</code> to treat the specified text as HTML */ public void setStackText(int index, @IsSafeHtml String text, boolean asHTML) { if (index >= getWidgetCount()) { return; } Element tdWrapper = DOM.getChild(DOM.getChild(body, index * 2), 0); Element headerElem = DOM.getFirstChild(tdWrapper); if (asHTML) { getHeaderTextElem(headerElem).setInnerHTML(text); } else { getHeaderTextElem(headerElem).setInnerText(text); } }
/** * Creates a new panel using the specified style names to apply to each row. * Each row will contain three cells (Left, Center, and Right). The Center * cell in the containerIndex row will contain the {@link Widget}. * * @param rowStyles an array of style names to apply to each row * @param containerIndex the index of the container row */ DecoratorPanel(String[] rowStyles, int containerIndex) { super(DOM.createTable()); // Add a tbody Element table = getElement(); tbody = DOM.createTBody(); DOM.appendChild(table, tbody); table.setPropertyInt("cellSpacing", 0); table.setPropertyInt("cellPadding", 0); // Add each row for (int i = 0; i < rowStyles.length; i++) { Element row = createTR(rowStyles[i]); DOM.appendChild(tbody, row); if (i == containerIndex) { containerElem = DOM.getFirstChild(DOM.getChild(row, 1)); } } // Set the overall style name setStyleName(DEFAULT_STYLENAME); }
/** * Returns the element's first child. * * @return the first child */ public El firstChild() { Element firstChild = DOM.getFirstChild(dom); return firstChild == null ? null : new El(firstChild); }
private void createFrame() { Element dummy = DOM.createDiv(); DOM.setInnerHTML(dummy, "<iframe id=\"" + XDOM.getUniqueId() + "\"" + ((GXT.isIE && GXT.isSecure) ? (" src=\"" + GXT.SSL_SECURE_URL + "\"") : "") + " name='" + frameName + "' style='position:absolute;width:0;height:0;border:0'>"); iframe = DOM.getFirstChild(dummy); }
private void showImage(TreeItem treeItem, AbstractImagePrototype proto) { Element holder = treeItem.getImageHolderElement(); Element child = DOM.getFirstChild(holder); if (child == null) { // If no image element has been created yet, create one from the // prototype. DOM.appendChild(holder, proto.createElement().<Element> cast()); } else { // Otherwise, simply apply the prototype to the existing element. proto.applyTo(child.<ImagePrototypeElement> cast()); } }
protected void renderRows(String rawHTMLTable) { DOM.setInnerHTML(getWrapperDiv(), rawHTMLTable); Element tableElement = DOM.getFirstChild(getWrapperDiv()); Element newBody = replaceBodyElement(table.getElement(), tableElement); setBodyElement(table, newBody); }
public void setImage(final ImageResource image) { Image img = new Image(image); String definedStyles = img.getElement().getAttribute("style"); img.getElement().setAttribute("style", definedStyles + "; vertical-align:middle;"); DOM.insertBefore(getElement(), img.getElement(), DOM.getFirstChild(getElement())); }