/** * 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 remove() { if (lastIndex < 0) { throw new IllegalStateException(); } Widget w = widgetList.get(lastIndex); assert (w.getParent() instanceof HTMLTable); w.removeFromParent(); lastIndex = -1; }
public void remove() { if (index < 0 || index >= widgetCount) { throw new IllegalStateException(); } IsWidget w = provider.get(index); if (w == null) { throw new IllegalStateException("Widget was already removed."); } w.asWidget().removeFromParent(); } }
/** * @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); }
/** * Inserts a child widget at the specified position before the specified * index. Setting a position of <code>(-1, -1)</code> will cause the child * widget to be positioned statically. If the widget is already a child of * this panel, it will be moved to the specified index. * * @param w the child widget to be inserted * @param left the widget's left position * @param top the widget's top position * @param beforeIndex the index before which it will be inserted * @throws IndexOutOfBoundsException if <code>beforeIndex</code> is out of * range */ public void insert(Widget w, int left, int top, int beforeIndex) { // In order to avoid the potential for a flicker effect, it is necessary // to set the position of the widget before adding it to the AbsolutePanel. // The Widget should be removed from its parent before any positional // changes are made to prevent flickering. w.removeFromParent(); setWidgetPositionImpl(w, left, top); insert(w, beforeIndex); verifyPositionNotStatic(w); }
/** * 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); }
/** * Adds a widget to the panel at the specified position. Setting a position of * <code>(-1, -1)</code> will cause the child widget to be positioned * statically. * * @param w the widget to be added * @param left the widget's left position * @param top the widget's top position */ public void add(Widget w, int left, int top) { // In order to avoid the potential for a flicker effect, it is necessary // to set the position of the widget before adding it to the AbsolutePanel. // The Widget should be removed from its parent before any positional // changes are made to prevent flickering. w.removeFromParent(); int beforeIndex = getWidgetCount(); setWidgetPositionImpl(w, left, top); insert(w, beforeIndex); verifyPositionNotStatic(w); }
/** * Sets this panel's widget. Any existing child widget will be removed. * * @param w the panel's new widget, or <code>null</code> to clear the panel */ public void setWidget(Widget w) { // Validate if (w == widget) { return; } // Detach new child. if (w != null) { w.removeFromParent(); } // Remove old child. if (widget != null) { remove(widget); } // Logical attach. widget = w; if (w != null) { // Physical attach. DOM.appendChild(getContainerElement(), widget.getElement()); adopt(w); } }
/** * @deprecated Call and override {@link insert(Widget, Element, int, boolean)} instead. */ @Deprecated protected void insert(Widget child, com.google.gwt.user.client.Element container, int beforeIndex, boolean domInsert) { // Validate index; adjust if the widget is already a child of this panel. beforeIndex = adjustIndex(child, beforeIndex); // Detach new child. child.removeFromParent(); // Logical attach. getChildren().insert(child, beforeIndex); // Physical attach. if (domInsert) { DOM.insertChild(container, child.getElement(), beforeIndex); } else { DOM.appendChild(container, child.getElement()); } // Adopt. adopt(child); }
public boolean remove(int index) { if ((index < 0) || (index >= getWidgetCount())) { return false; } Widget child = getWidget(index); tabBar.remove(index); deckPanel.removeProtected(child); child.removeStyleName(CONTENT_STYLE); Tab tab = tabs.remove(index); tab.getWidget().removeFromParent(); if (index == selectedIndex) { // If the selected tab is being removed, select the first tab (if there // is one). selectedIndex = -1; if (getWidgetCount() > 0) { selectTab(0); } } else if (index < selectedIndex) { // If the selectedIndex is greater than the one being removed, it needs // to be adjusted. --selectedIndex; } return true; }
/** * 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); } }
/** * Add a widget to the panel in the specified layer. Note that this method * does not do the logical attach. * * @param w the widget to add, or null to clear the widget * @param toReplace the widget to replace * @param layer the layer in which the existing widget is placed * @return the layer in which the new widget is placed, or null if no widget */ private Layer add(IsWidget w, IsWidget toReplace, Layer layer) { // Validate. if (w == toReplace) { return layer; } // Detach new child. if (w != null) { w.asWidget().removeFromParent(); } // Remove old child. if (toReplace != null) { remove(toReplace); } Layer toRet = null; if (w != null) { // Physical attach. toRet = layout.attachChild(w.asWidget().getElement()); adopt(w.asWidget()); } return toRet; }
@Override public void setWidget(Widget w) { // Validate if (w == widget) { return; } // Detach new child. if (w != null) { w.removeFromParent(); } // Remove old child. if (widget != null) { remove(widget); } // Logical attach. widget = w; if (w != null) { // Physical attach. layer = layout.attachChild(widget.getElement(), widget); layer.setTopHeight(0.0, Unit.PX, 100.0, Unit.PCT); layer.setLeftWidth(0.0, Unit.PX, 100.0, Unit.PCT); adopt(w); // Update the layout. layout.layout(); scheduleResize(); } }
@Override public void setWidget(Widget w) { // Validate if (w == widget) { return; } // Detach new child. if (w != null) { w.removeFromParent(); } // Remove old child. if (widget != null) { remove(widget); } // Logical attach. widget = w; if (w != null) { // Physical attach. layer = layout.attachChild(widget.getElement(), widget); layer.setTopHeight(0.0, Unit.PX, 100.0, Unit.PCT); layer.setLeftWidth(0.0, Unit.PX, 100.0, Unit.PCT); adopt(w); // Update the layout. layout.layout(); onResize(); } }
captionWidget.asWidget().removeFromParent(); caption = captionWidget;