panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); element.appendChild(panel.getElement()); root = panel;
panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); element.appendChild(panel.getElement()); root = panel;
/** * Appends one element to another's list of children. * <p> * If the child element is a {@link com.google.gwt.user.client.ui.PotentialElement}, it is first * resolved. * </p> * * @param parent the parent element * @param child its new child * @see com.google.gwt.user.client.ui.PotentialElement#resolve(Element) */ public static void appendChild(Element parent, Element child) { assert !isPotential(parent) : "Cannot append to a PotentialElement"; // If child isn't a PotentialElement, resolve() returns // the Element itself. parent.appendChild(resolve(child)); }
public void initParent(Element parent) { parent.getStyle().setPosition(Position.RELATIVE); parent.appendChild(relativeRuler = createRuler(EM, EX)); }
/** * Creates an empty scroll panel. */ public ScrollPanel() { this.scrollableElem = getElement(); this.containerElem = Document.get().createDivElement(); scrollableElem.appendChild(containerElem); initialize(); }
void addCells(Element tbody, int row, int num) { com.google.gwt.dom.client.Element rowElem = impl.getRows(tbody).get(row); for (int i = 0; i < num; i++) { TableCellElement tdElement = Document.get().createTDElement(); rowElem.appendChild(tdElement); } }
/** * Start a child element. * * @param element the element to start * @param builder the builder used to builder the new element */ private void start(Element element, ElementBuilderBase<?> builder) { onStart(element.getTagName(), builder); // Set the root element. if (rootElement == null) { // This is the new root element. rootElement = element; } else { // Appending to the current element. getCurrentElement().appendChild(element); } // Add the element to the stack. currentElement = element; }
/** * 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); }
/** * Resize the column group element. * * @param columns the number of columns * @param growOnly true to only grow, false to shrink if needed */ void resizeColumnGroup(int columns, boolean growOnly) { // The colgroup should always have at least one element. See // prepareColumnGroup() for more details. columns = Math.max(columns, 1); int num = columnGroup.getChildCount(); if (num < columns) { for (int i = num; i < columns; i++) { columnGroup.appendChild(Document.get().createColElement()); } } else if (!growOnly && num > columns) { for (int i = num; i > columns; i--) { columnGroup.removeChild(columnGroup.getLastChild()); } } }
/** * Add a widget to the panel in the specified container. Note that this method * does not do the logical attach. * * @param w the widget to add * @param toReplace the widget to replace * @param container the container in which to place the widget */ private void add(Widget w, Widget toReplace, Element container) { // Validate. if (w == toReplace) { return; } // Detach new child. if (w != null) { w.removeFromParent(); } // Remove old child. if (toReplace != null) { remove(toReplace); } if (w != null) { // Physical attach. container.appendChild(w.getElement()); container.getStyle().clearDisplay(); adopt(w); } }
/** * Ensure that the content container exists and return it. * * @return the content container */ Element ensureContentContainer() { if (contentContainer == null) { contentContainer = Document.get().createDivElement(); ensureAnimationFrame().appendChild(contentContainer); emptyMessageElem = Document.get().createDivElement(); emptyMessageElem.setInnerText(messages.emptyTree()); setStyleName(emptyMessageElem, tree.getStyle().cellTreeEmptyMessage(), true); showOrHide(emptyMessageElem, false); contentContainer.appendChild(emptyMessageElem); showMoreElem = Document.get().createAnchorElement(); // CellTree prevents strict-CSP violation by cancelling event default action. showMoreElem.setHref("javascript:;"); showMoreElem.setInnerText(messages.showMore()); setStyleName(showMoreElem, tree.getStyle().cellTreeShowMoreButton(), true); showOrHide(showMoreElem, false); contentContainer.appendChild(showMoreElem); } return contentContainer; }
childContainer.appendChild(item.getElement()); } else { Element beforeElem = getChild(beforeIndex).getElement();
public HeaderPanel() { // Create the outer element Element elem = Document.get().createDivElement().cast(); elem.getStyle().setPosition(Position.RELATIVE); elem.getStyle().setOverflow(Overflow.HIDDEN); setElement(elem); // Create a delegate to handle resize from the header and footer. ResizeLayoutPanel.Impl.Delegate resizeDelegate = new ResizeLayoutPanel.Impl.Delegate() { public void onResize() { scheduledLayout(); } }; // Create the header container. headerContainer = createContainer(); headerContainer.getStyle().setTop(0.0, Unit.PX); headerImpl.init(headerContainer, resizeDelegate); elem.appendChild(headerContainer); // Create the footer container. footerContainer = createContainer(); footerContainer.getStyle().setBottom(0.0, Unit.PX); footerImpl.init(footerContainer, resizeDelegate); elem.appendChild(footerContainer); // Create the content container. contentContainer = createContainer(); contentContainer.getStyle().setOverflow(Overflow.HIDDEN); contentContainer.getStyle().setTop(0.0, Unit.PX); contentContainer.getStyle().setHeight(0.0, Unit.PX); elem.appendChild(contentContainer); }
if (toReplace == null) { childContainer.appendChild(newChildren.getChild(0)); } else { Element nextSibling = toReplace.getNextSiblingElement();
hiddenDiv.appendChild(element); wrapInitializationCallback.execute(); element.getParentNode().removeChild(element);
expandable.getStyle().setOverflow(Overflow.SCROLL); expandable.getStyle().setZIndex(-1); elem.appendChild(expandable); expandableInner = Document.get().createDivElement().cast(); expandable.appendChild(expandableInner); DOM.sinkEvents(expandable, Event.ONSCROLL); collapsible.getStyle().setOverflow(Overflow.SCROLL); collapsible.getStyle().setZIndex(-1); elem.appendChild(collapsible); collapsibleInner = Document.get().createDivElement().cast(); collapsibleInner.getStyle().setWidth(200, Unit.PCT); collapsibleInner.getStyle().setHeight(200, Unit.PCT); collapsible.appendChild(collapsibleInner); DOM.sinkEvents(collapsible, Event.ONSCROLL);
hiddenDiv.appendChild(getElement());
scrollable.appendChild(containerElem); scrollableLayer = layout.attachChild(scrollable);
/** * Recalculate the height and width of a native scrollbar. */ private static void maybeRecalculateNativeScrollbarSize() { // Check if the size has already been calculated. if (nativeHeight > -1) { return; } // Create a scrollable element and attach it to the body. Element scrollable = Document.get().createDivElement(); scrollable.getStyle().setPosition(Position.ABSOLUTE); scrollable.getStyle().setTop(-1000.0, Unit.PX); scrollable.getStyle().setLeft(-1000.0, Unit.PX); scrollable.getStyle().setHeight(100.0, Unit.PX); scrollable.getStyle().setWidth(100.0, Unit.PX); scrollable.getStyle().setOverflow(Overflow.SCROLL); scrollable.getStyle().setProperty("direction", "rtl"); Document.get().getBody().appendChild(scrollable); // Add some content. Element content = Document.get().createDivElement(); content.setInnerText("content"); scrollable.appendChild(content); // Measure the height and width. nativeHeight = scrollable.getOffsetHeight() - scrollable.getClientHeight(); nativeWidth = scrollable.getOffsetWidth() - scrollable.getClientWidth(); nativeRtl = (content.getAbsoluteLeft() > scrollable.getAbsoluteLeft()); // Detach the scrollable element. scrollable.removeFromParent(); }
private void cloneAndAppendRow(VScrollTableRow row) { Element clonedTR = null; clonedTR = row.getElement().cloneNode(true).cast(); clonedTR.getStyle().setVisibility(Visibility.VISIBLE); cloneTable.appendChild(clonedTR); }