/** * Insert a widget before the specified widget. If the widget is already a * child of this panel, this method behaves as though {@link #remove(Widget)} * had already been called. * * @param widget the widget to be added * @param before the widget before which to insert the new child, or <code>null</code> to append */ public void insert(Widget widget, Widget before) { assertIsChild(before); // Detach new child. widget.removeFromParent(); // Logical attach. WidgetCollection children = getChildren(); if (before == null) { children.add(widget); } else { int index = children.indexOf(before); children.insert(widget, index); } // Physical attach. Layer layer = layout.attachChild(widget.getElement(), (before != null) ? before.getElement() : null, widget); setWidgetVisible(widget, layer, false); widget.setLayoutData(layer); // Adopt. adopt(widget); // Update the layout. animate(0); }
public void onMouseUp(MouseUpEvent event) { dragging = false; DOM.releaseCapture(dragHandle.getElement()); } }
/** * 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()); }
Element getWidgetTd(Widget w) { if (w.getParent() != this) { return null; } return DOM.getParent(w.getElement()); } }
@Override public void claimElement(Element element) { if (renderable != null) { renderable.claimElement(element); setElement(widget.getElement()); } else { this.elementToWrap = element; } }
/** * Overrides {@link ComplexPanel#remove(Widget)} to change the removed * Widget's element back to static positioning.This is done so that any * positioning changes to the widget that were done by the panel are undone * when the widget is disowned from the panel. */ @Override public boolean remove(Widget w) { boolean removed = super.remove(w); if (removed) { changeToStaticPositioning(w.getElement()); } return removed; }
@Override public void initializeClaimedElement() { if (renderable != null) { renderable.initializeClaimedElement(); } else { elementToWrap.getParentNode().replaceChild(widget.getElement(), elementToWrap); } }
@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; }
@Override void replaceElement(com.google.gwt.dom.client.Element elem) { if (isAttached()) { // Remove old event listener to avoid leaking. onDetach will not do this // for us, because it is only called when the widget itself is detached // from the document. DOM.setEventListener(getElement(), null); } super.replaceElement(elem); if (isAttached()) { // Hook the event listener back up on the new element. onAttach will not // do this for us, because it is only called when the widget itself is // attached to the document. DOM.setEventListener(getElement(), this); } }
public void onBrowserEvent(Event event) { switch (DOM.eventGetType(event)) { case Event.ONMOUSEOVER: // Only fire the mouse over event if it's coming from outside this // widget. case Event.ONMOUSEOUT: // Only fire the mouse out event if it's leaving this // widget. Element related = event.getRelatedEventTarget().cast(); if (related != null && getElement().isOrHasChild(related)) { return; } break; } DomEvent.fireNativeEvent(event, this, this.getElement()); }
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); } } } }
@Override public boolean remove(Widget w) { // Validate. if (widget != w) { return false; } // Orphan. try { orphan(w); } finally { // Physical detach. getContainerElement().removeChild(w.getElement()); // Logical detach. widget = null; } return true; }
/** * Gets the position of the left outer border edge of the widget relative to * the left outer border edge of the panel. * * @param w the widget whose position is to be retrieved * @return the widget's left position */ public int getWidgetLeft(Widget w) { checkWidgetParent(w); return w.getElement().getAbsoluteLeft() - getElement().getAbsoluteLeft(); }
/** * Gets the position of the top outer border edge of the widget relative to * the top outer border edge of the panel. * * @param w the widget whose position is to be retrieved * @return the widget's top position */ public int getWidgetTop(Widget w) { checkWidgetParent(w); return w.getElement().getAbsoluteTop() - getElement().getAbsoluteTop(); }
/** * @deprecated Call and override {@link #add(Widget, Element)} instead. */ @Deprecated protected void add(Widget child, com.google.gwt.user.client.Element container) { // Detach new child. child.removeFromParent(); // Logical attach. getChildren().add(child); // Physical attach. DOM.appendChild(container, child.getElement()); // Adopt. adopt(child); }
public void onMouseDown(MouseDownEvent event) { dragging = true; DOM.setCapture(dragHandle.getElement()); dragStartX = event.getClientX(); dragStartY = event.getClientY(); DOM.eventGetCurrentEvent().preventDefault(); }
/** * Adds a child widget to the panel, replacing the HTML element. * * @param widget the widget to be added * @param toReplace the element to be replaced by the widget * @deprecated use {@link #addAndReplaceElement(Widget, Element)} */ @Deprecated public void addAndReplaceElement(Widget widget, com.google.gwt.user.client.Element toReplace) { // Logic pulled from super.add(), replacing the element rather than adding. widget.removeFromParent(); getChildren().add(widget); toReplace.getParentNode().replaceChild(widget.getElement(), toReplace); adopt(widget); }
@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; }
public void onScroll(ScrollEvent event) { Widget source = getSource(event); Element elem = source.getElement(); getListener().onScroll(getSource(event), elem.getScrollLeft(), elem.getScrollTop()); } }
protected void setWidgetPositionImpl(Widget w, int left, int top) { Element h = w.getElement(); if (left == -1 && top == -1) { changeToStaticPositioning(h); } else { h.getStyle().setProperty("position", "absolute"); h.getStyle().setProperty("left", left + "px"); h.getStyle().setProperty("top", top + "px"); } }